How to update claim identity received in asp.net core application

I have an asp.net core application…in which when user logged in we checked either this user have valid subscription or not …and according to this i need to update identity value from claim principle is it possible to update the Claim principle value in asp.net core application

Hi @sushama,

I am having a hard time getting a clear understanding of your requirements. Are you trying to update a specific claim in the token? Can you please give us an example?

hi,
We used auth0 as user identity manager.
I set the rule for getting custom claim like
context.idToken[“http://schemas.xmlsoap.org/ws/2005/05/identity/claims/issubscriptionvalid”] = false;

Application flow is as follows:

APPLICATION_1—user logged in with auth0 .
Getting Claim identity from auth0.
Now custom claim as mention above also getting in the claim identity.
In the application I need to update this claim against that user I want to update it as true.
this is possible to update this claim in asp.net application?
NOW…
User logged in to another application say APPLICATION_2—user logged in with auth0 .
Getting Claim identity from auth0.
Now custom claim as mention above also getting in the claim identity.
but at this time want to get updated claim.

Thanks for the update.

If I understand correctly, you are trying to do the following:

  • User logs in to application 1
  • A Rule adds the issubscriptionvalid = false custom claim to the token
  • a token is returned to application 1 with issubscriptionvalid
  • you update the user’s profile to issubscriptionvalid = true
  • the user logs in to application 2
  • a token is returned with issubscriptionvalid = true

If this is the desired flow, you will need to store the issubscriptionvalid flag in the user’s app_metadata. This allows you to store this flag in the user’s profile in Auth0, and you can later update this using the Auth0 Management API v2. You can then reference it in a rule, and add it as a custom claim to the token.

Does that make sense?

1 Like

but how this custom claim added to token ?
Can I have to set this custom claim in auth0 rule?

Or there is another way to add custom claim?

You can add custom claims to the token in an Actions Triggers: post-login.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.