aspnet-contrib / AspNet.Security.OpenIdConnect.Samples

ASP.NET Core samples demonstrating how to use the OpenID Connect server with MVC or JS apps
64 stars 31 forks source link

Signature Key Per Client #9

Closed RobinDavisNotts closed 8 years ago

RobinDavisNotts commented 8 years ago

Hello, Currently writing an Api which will use a jwt bearer token as an api key.

However we need to be able to sign each token with a different key, so that we can decrypt the incoming bearer token.

Is there a way of doing that in this library? I feel like possibly using the OnReceivingToken would allow for also retrieving the client id, so that we can retrieve their key.

Thanks for your help!

kevinchalet commented 8 years ago

Hey,

You could achieve what you want by using the OnSerializeAccessToken event and setting context.SigningCredentials with the signing credentials corresponding to the specific client application making the authorization/token request. ASOS would then use these credentials instead of the global ones defined in the main options.

That said, doing that is extremely unusual for at least 3 reasons:

RobinDavisNotts commented 8 years ago

So the client wouldnt be signing them, we would be providing them a bearer token, with this they call our api, we store a key per client, so that we can decrypt the bearer token they send, if we can't, then they are unauthorized.

kevinchalet commented 8 years ago

And when/where is the authorization server involved in this scenario?