auth0 / auth0-aspnet-owin

Auth0 ASP.NET 4.5 Owin/Katana Authentication Handler
MIT License
46 stars 50 forks source link

Edit Default claims #62

Closed fidenz-shehanF closed 6 years ago

fidenz-shehanF commented 6 years ago

Hi,

Is there a way that we can edit default claims ? like say, i need to change the Name field property that is coming from auth0 side using a local database value. currently Name field contains the email. i want to change that. is there a way? im currently trying to do this in the OnAuthenticated handler. Thanks

jerriep commented 6 years ago

I have not tried it, but I think the OnAuthenticated event is the correct one, as that is triggered before the AuthenticationTicket is created: https://github.com/auth0/auth0-aspnet-owin/blob/master/src/Auth0.Owin/Auth0AuthenticationHandler.cs#L130

Are you having problems with it?

fidenz-shehanF commented 6 years ago

Yeah it is. What i want to achieve is edit those claims that comes. currently for user's Name it gives me the email of that user. i want to change that to the user's name. i cant edit them since those claim properties are read only.

jerriep commented 6 years ago

I think you will have to remove the claim, and then add it back with the new value.

Please note however that we will retire this library in the next few weeks though. We want customers to start using the standard OWIN 4 OpenID Connect middleware

fidenz-shehanF commented 6 years ago

hmm yeah i got that confused. i replaced that claim with what the claim that i want thank you. Does that mean that Auth0 will not support applications that uses this library ?

jerriep commented 6 years ago

I cannot comment right now on that, as this needs to be finalised. I will keep you updated once we have everything in place with steps for migrating.

fidenz-shehanF commented 6 years ago

hmm we are currently building a web app using this library. Hope the change will not effect to the applications that already uses this library like ours. cause its kinda gonna be a hassle to migrate our code base as well yeah. Anyways thanks on quick response and the help.

jerriep commented 6 years ago

It may be best then, if you can, to switch to using the OWIN 4 OpenIdConnect middleware as soon as possible before you get to far along with this lib.

You can refer to this Startup class for how to configure it: https://github.com/auth0/auth0-aspnet-owin/blob/owin4/test/Auth0OwinTest/Startup.cs

You will need to install the Nuget package Microsoft.Owin.Security.OpenIdConnect version 4.0.0

fidenz-shehanF commented 6 years ago

Will check this out soon, thank you.