active-directory-angularjs-singlepageapp-dotnet-webapi icon indicating copy to clipboard operation
active-directory-angularjs-singlepageapp-dotnet-webapi copied to clipboard

Group claims are not in the jwt token

Open wvdd007 opened this issue 11 years ago • 13 comments

Hello. I was able to run this demo in no time thanks to the walkthrough. Is there something special being done with "group" claims for these kinds of applications ? For the same user and the application "webapp-groupclaims-dotnet" (another of your samples), I do get the group claim in the principal; while here I don't seem to receive it. Do you have any idea of what I am doing wrong ? (I altered the manifest files of bot the api and the app to have "groupMembershipClaims": "All".)

wvdd007 avatar Jul 19 '15 19:07 wvdd007

Hi @wvdd007.... Yes, there's some unique behavior around group claims in the SPA scenario. Group claims can quickly inflate the token, which in this case is returned in the fragement of the URL. Some browsers have URL length limits, so returning group claims in the token is not reasonable. Instead, you should query the Graph API to get the user's group membership.

dstrockis avatar Jul 30 '15 06:07 dstrockis

I was aware of that but I thought WAAD had a policy for that (max 200 claims in jWT token, max 150 in SAML2 with an overflow claim both cases).
However, the behavior I have is that for one application the group claims are in the token while for another they are not. On the azure side there is no difference in configuration for both so I would say that the server should expose the same behavior for both.
Unless somehow you call the server with different parameters ?

wvdd007 avatar Jul 30 '15 14:07 wvdd007

Are both of those applications single page apps?

Regardless, we do have a bug open right now on this topic. It affects architectures where a single web API accepts access tokens from both SPA's and other types of clients, and expects group claims (or the overage claim) to exist in the token. Is that what you're trying to accomplish?

dstrockis avatar Jul 30 '15 17:07 dstrockis

No, they are not both SPA's. But they use the same WAAD so I expect the same security tokens. I thought that the server provides the same tokens to each RP, regardless of what client type it is. That way scenario's like the one you talk about become possible : An App or a website or whatever gets a token and passes it to the API. Unless otherwise configured I expected these tokens to be the same.

Now I have one SPA and one other application using ADAL. The SPA app doesn't get security groups while the other does get them. I am just wondering where that difference comes from.

wvdd007 avatar Jul 30 '15 20:07 wvdd007

I think we're on the same page here.. . The difference comes from a bug we currently have. We're trying to work out the best way to support apps that depend on the existing behavior while updating to be in line with what you describe.

dstrockis avatar Jul 30 '15 20:07 dstrockis

Hi, so what is the recommended approach to secure and authorize Nodejs REST endpoints for a SPA? Does the passport-azure-adal in combination with the ADAL for JavaScript not enough to secure JavaScript rest endpoints based in AAD groups?

caligaris avatar Jun 02 '16 21:06 caligaris

Team, I have the same problem, Do you have any update on this topic? I need the Group Claim in The Id_token

iocampomx avatar May 05 '17 04:05 iocampomx

I'd also be interested in the solution. Diverging from the original issue a bit but I tried calling the getMemberGroups API on the backend side (as on-behalf-of flow) but that's returning "Authorization_RequestDenied .. Insufficient privileges". From documentation I understood that User.ReadBasic.All and Group.Read.All permissions would be enough for those but even then it fails. The token contains those: "scp": "Group.Read.All User.Read User.ReadBasic.All"

htuomola avatar Jun 20 '17 10:06 htuomola

Could we get groups or role of a single user from Angular Token? I have turn on "groupMembershipClaims": "All" but does not seem to work. No groups or role in token.

sonphnt avatar Sep 07 '17 14:09 sonphnt

It looks like the group claim limit is 5 groups. If your user is in 5 groups or more, the group attribute won't be send in the id_token

Gullfaxi171 avatar Sep 19 '17 19:09 Gullfaxi171

Hi Everyone,

I have a question about this. We have 2 App Registration in Azure in this example: ToDoApp and ToDoApi

When we assign roles or groups claims to users in ToDoApp. Do we need to apply the same things to ToDoApi? If yes then we have to manage roles/groups twice in 2 apps.

Is there any way in ToDoApi we authorize Roles/Groups of users based on ToDoApp not ToDoAPI?

Thanks

sonphnt avatar Feb 20 '18 16:02 sonphnt

What I learnt recently is that groupMembershipClaims values are only present in the id_token, not in the access token. Which means that if I want my WebAPI layer (the 'lowest layer' public interface) to perform checks for a given caller is part of an AD security group, then it is not possible.

sathiathirumal avatar Apr 06 '18 23:04 sathiathirumal

Closing this as we are archiving this sample. Please check out the new sample at ms-identity-javascript-angular-spa-aspnetcore-webapi.

derisen avatar Apr 23 '20 16:04 derisen