Permissions into Claims in Token
Quote from Shawn de Wet on February 20, 2018, 2:55 pmPlease can you point me to where the permissions that a user has are added to the Token as Claims? I can see where you add policies, and that those policies require the presence of certain permission claims. But I can't figure out where the permissions are added as claims to the token when a user logs in.
Please can you point me to where the permissions that a user has are added to the Token as Claims? I can see where you add policies, and that those policies require the presence of certain permission claims. But I can't figure out where the permissions are added as claims to the token when a user logs in.
Quote from Eben Monney on February 22, 2018, 6:26 amImplementing the IProfileService gives us a way of manually picking what is included in the Token as Claims.
This is a feature of IdentityServer: http://docs.identityserver.io/en/release/reference/profileservice.html
In QuickApp all these happens from the GetProfileDataAsync(ProfileDataRequestContext context) of the IProfileService implementation (ProfileService.cs).
From this method we first get all the claims belonging to the user through: var claims = principal.Claims.ToList();
principal.Claims is comprehensive and includes the permission claims as well as other claims we might not care about.
So we filter out only that which is allowed for the API: claims = claims.Where(claim => context.RequestedClaimTypes.Contains(claim.Type)).ToList();
(See IdentityServerConfig.GetApiResources() for the allowed resources for the API. Note that this includes ClaimConstants.Permission).After that we manually add whatever custom claims that might not be part of the User's original Principal.Claims.
Note that NOT implementing IProfileService will leave us with only the fundamental claims.
So to answer your question, when it comes to claims everything happens in this method ConstantsProfileService.GetProfileDataAsync
Implementing the IProfileService gives us a way of manually picking what is included in the Token as Claims.
This is a feature of IdentityServer: http://docs.identityserver.io/en/release/reference/profileservice.html
In QuickApp all these happens from the GetProfileDataAsync(ProfileDataRequestContext context) of the IProfileService implementation (ProfileService.cs).
From this method we first get all the claims belonging to the user through: var claims = principal.Claims.ToList();
principal.Claims is comprehensive and includes the permission claims as well as other claims we might not care about.
So we filter out only that which is allowed for the API: claims = claims.Where(claim => context.RequestedClaimTypes.Contains(claim.Type)).ToList();
(See IdentityServerConfig.GetApiResources() for the allowed resources for the API. Note that this includes ClaimConstants.Permission).
After that we manually add whatever custom claims that might not be part of the User's original Principal.Claims.
Note that NOT implementing IProfileService will leave us with only the fundamental claims.
So to answer your question, when it comes to claims everything happens in this method ConstantsProfileService.GetProfileDataAsync
Quote from jamse ales on February 20, 2021, 8:22 amGreat Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post. 먹튀검증사이트
Great Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post. 먹튀검증사이트
Quote from johnfavors557 on March 3, 2021, 8:31 amThank you for this interesting thread, much appreciated. While you’re taking a break from all the reading required, you and your friends might want to check out the plants vs. zombies game on your desktop for further appreciation of the second iteration of the game. Numerous streamers have been on this game for quite some time now as well. Also, the pubg became famous for its updates. Both of which are truly worth the time being spent playing! Try them for yourselves.
https://chrome.google.com/webstore/detail/pubg/pknkhcebclkaofaliggfhnieiahbbmnf
Thank you for this interesting thread, much appreciated. While you’re taking a break from all the reading required, you and your friends might want to check out the plants vs. zombies game on your desktop for further appreciation of the second iteration of the game. Numerous streamers have been on this game for quite some time now as well. Also, the pubg became famous for its updates. Both of which are truly worth the time being spent playing! Try them for yourselves.
https://chrome.google.com/webstore/detail/pubg/pknkhcebclkaofaliggfhnieiahbbmnf