IdentityServer / IdentityServer3.AccessTokenValidation

OWIN Middleware to validate access tokens from IdentityServer3
Apache License 2.0
90 stars 149 forks source link

Add ability to specify custom ValidateIdentity #43

Closed billpratt closed 9 years ago

billpratt commented 9 years ago

We have a need to call User Info after an access token has been validated. This PR adds the ability to specify the IOAuthBearerAuthenticationProvider and use an override of ValidateIdentity.

dnfclas commented 9 years ago

Hi @billpratt, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. Real humans will now evaluate your PR.

TTYL, DNFBOT;

bschmidt commented 9 years ago

:+1:

leastprivilege commented 9 years ago

Hi,

a few comments

leastprivilege commented 9 years ago

..or maybe even a separate middleware to do claims transformation?

billpratt commented 9 years ago

I wanted to do something similar to how "UseOpenIdConnectAuthentication" handles it with Notifications but I wasnt sure how it would fit it. Are notifications currently being used anywhere or would I have to add that feature?

leastprivilege commented 9 years ago

..and why does it need to be a notifcation. Why not a separate middleware running after token validation?

billpratt commented 9 years ago

I liked notifications because it follows the same pattern to UseOpenIdConnectAuthentication to keep it consistent. I'm not opposed to middleware. If you want middleware, I'll do middleware. Its your party, I'm just attending :)

leastprivilege commented 9 years ago

I am trying to discuss this ;)

The whole middleware idea is about composing functionality. So I was wondering why not put your userinfo call into a claims transformation middleware.

billpratt commented 9 years ago

Understood. I like the middleware idea because its adding to the pipeline. Unlike the scopes required middleware where the code to run is hard coded in the class, would you allow the developer to specify what to run after the token has been validated?

billpratt commented 9 years ago

Should I be working out of "dev" or "master"

leastprivilege commented 9 years ago

In essence this middleware already exists - i might re-publish it with the new namespace etc

https://github.com/IdentityModel/Thinktecture.IdentityModel/tree/master/source/Owin.ClaimsTransformation

The only thing that is missing is, the token validation MW should have an option to preserve the access token as a claim so you can do whatever you want with it during transformation.

https://github.com/IdentityServer/IdentityServer3.AccessTokenValidation/issues/44

billpratt commented 9 years ago

Ah perfect. In order to use it here though you'll have to port it over or add a nuget dependency to IdentityModel? Or should this be added to the pipeline outside of this library?

billpratt commented 9 years ago

So once #44 gets released on nuget, I can use that change along with https://github.com/IdentityModel/Thinktecture.IdentityModel/tree/master/source/Owin.ClaimsTransformation to get what I need. I'll close this pull request.

CrescentFresh commented 8 years ago

This might be supported now (2.2.2), see https://github.com/IdentityServer/IdentityServer3.AccessTokenValidation/pull/52

leastprivilege commented 8 years ago

I still think that for transformation - as separate middleware is the better approach.