I am using Squidex Identity server to protect API calls so we need to pass JWT token on each API call. I have some custom script which run on content change and I want to pass JWT token of logged-in user in the API call.
I can see ctx.user.id, ctx.user.claims etc available. Is there a way to get hold of token which I can pass?
I am talking about below token which is currently being passed on /api, /schema calls. I am able to use same token to get Content also via API calls. I captured from network tab. I thought if somehow I can access this token in Scripting and pass it to outgoing API call in header.
Yes, you are right. Perhaps I can provide another solution and write an extension to create a token from a user id or something like that. But I am not sure which security implications it has.
Is there no other way? I am mean if the API is in the same network can you just not allow internal traffic?
You can use a second authorization and implement a simple API key. I have done this as well, takes only a few hours.
I am not sure if you use ASP.NET Core, you can add several authentication methods and then write a policy authorization schema which selects the actual schema based on header values and so on, e.g. use ApIKey if defined, or Bearer Token otherwise: