Requested Scope Not Present in Access Token scp Claim

%3CLINGO-SUB%20id%3D%22lingo-sub-2497910%22%20slang%3D%22en-US%22%3ERequested%20Scope%20Not%20Present%20in%20Access%20Token%20scp%20Claim%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2497910%22%20slang%3D%22en-US%22%3E%3CP%3ETL%2CDR%20version%3A%3C%2FP%3E%3CUL%3E%3CLI%3EI%20have%20an%20Azure%20AD%20app%20registration%20for%20a%20UI%20configured%20with%20permission%20to%20request%20an%20API%20scope%20from%20another%20app%20registration.%3C%2FLI%3E%3CLI%3EThe%20UI%20app%20is%20correctly%20requesting%20the%20API%20scope%20and%20the%20scope%20is%20present%20in%20the%20consent%20UI%20presented%20to%20the%20user.%3C%2FLI%3E%3CLI%3EThe%20scp%20claim%20does%20not%20contain%20the%20API%20scope%20even%20though%20it%20was%20authorized.%3C%2FLI%3E%3CLI%3EIs%20this%20expected%20behavior%3F%3C%2FLI%3E%3C%2FUL%3E%3CP%3EHello%20all.%20I%20have%20a%20pretty%20extensive%20background%20in%20leveraging%20OAuth%202.0%20and%20OIDC%20for%20authorization%20and%20authentication%20management.%20However%2C%20I'm%20just%20breaking%20into%20the%20Azure%20implementation%20of%20these%20concepts%2C%20and%20I'm%20finding%20myself%20a%20little%20confused%20by%20some%20of%20the%20specifics.%20My%20goal%20is%20to%20use%20Azure%20AD%20app%20registrations%20to%20secure%20the%20interaction%20between%20a%20UI%20and%20the%20API%20it%20consumes.%20Historically%2C%20I'm%20used%20to%20defining%20a%20scope%2C%20granting%20my%20UI%20client%20permission%20to%20request%20that%20scope%20from%20my%20IdP%2C%20and%20demanding%20on%20the%20API%20side%20that%20the%20scope%20claim%20be%20present%20in%20an%20access%20token%20to%20authorize%20access%20to%20that%20API.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20defined%20an%20app%20registration%20for%20my%20API%2C%20as%20well%20as%20defined%20an%20%22all%20access%22%20scope%20for%20it%20under%20the%20%3CSTRONG%3EExpose%20an%20API%3C%2FSTRONG%3E%20blade.%20I've%20also%20defined%20an%20app%20registration%20for%20my%20UI%20and%20requested%20that%20scope%20under%20the%20%3CSTRONG%3EAPI%20Permissions%3C%2FSTRONG%3E%20blade.%20I've%20created%20the%20UI%20client%20app%20and%20added%20the%20fully%20qualified%20scope%20name%20(something%20like%20api%3A%2F%2Fmy.api.name%2FMyApi.All)%20to%20the%20requested%20scopes%20for%20the%20authorize%20request%20to%20be%20made%20using%20the%20MSAL.%20When%20logging%20in%2C%20my%20user%20is%20presented%20with%20the%20consent%20UI%2C%20and%20the%20API%20scope%20and%20app%20are%20listed%20as%20part%20of%20the%20requested%20permissions.%20When%20monitoring%20the%20request%20in%20my%20browser%20network%20tab%2C%20the%20%3CSTRONG%3Escope%3C%2FSTRONG%3E%26nbsp%3Bform%20data%20element%20includes%20the%20expected%20value%2C%20something%20like%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markdown%22%3E%3CCODE%3Escope%3A%20api%3A%2F%2Fmy.api.name%2FMyApi.All%20User.Read%20openid%20profile%20offline_access%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20what%20I%20would%20expect%20if%20I%20wanted%20to%20request%20API%20scope%20access%2C%20MS%20Graph%20access%2C%20and%20user%20profile%20information%20from%20Azure%20AD%2C%20all%20appropriate%20for%20my%20goals.%20However%2C%20when%20checking%20the%20access%20token%20returned%20from%20the%20request%2C%20the%20%3CSTRONG%3Escp%3C%2FSTRONG%3E%20claim%20only%20includes%20the%20following%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20...%0A%20%20%22scp%22%3A%20%22openid%20profile%20User.Read%20email%22%0A%20%20...%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20a%20little%20confused%20by%20the%20results%20here%2C%20because%20if%20I'm%20requesting%20access%20to%20a%20resource%20scope%2C%20my%20expectation%20is%20that%20the%20resource%20should%20be%20able%20to%20verify%20the%20access%20token%20presented%20contains%20the%20required%20scope%20for%20access.%20Is%20there%20some%20reason%20the%20app%20registration's%20resource%20principal%20is%20cut%20out%20of%20the%20list%20here%3F%20Am%20I%20misunderstanding%20the%20access%20model%20intended%20with%20these%20app%20registrations%3F%20Or%20did%20I%20just%20mess%20up%20my%20configuration%20somewhere%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2497910%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Active%20Directory%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ECloud%20App%20Security%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Frequent Visitor

TL,DR version:

  • I have an Azure AD app registration for a UI configured with permission to request an API scope from another app registration.
  • The UI app is correctly requesting the API scope and the scope is present in the consent UI presented to the user.
  • The scp claim does not contain the API scope even though it was authorized.
  • Is this expected behavior?

Hello all. I have a pretty extensive background in leveraging OAuth 2.0 and OIDC for authorization and authentication management. However, I'm just breaking into the Azure implementation of these concepts, and I'm finding myself a little confused by some of the specifics. My goal is to use Azure AD app registrations to secure the interaction between a UI and the API it consumes. Historically, I'm used to defining a scope, granting my UI client permission to request that scope from my IdP, and demanding on the API side that the scope claim be present in an access token to authorize access to that API.

 

I've defined an app registration for my API, as well as defined an "all access" scope for it under the Expose an API blade. I've also defined an app registration for my UI and requested that scope under the API Permissions blade. I've created the UI client app and added the fully qualified scope name (something like api://my.api.name/MyApi.All) to the requested scopes for the authorize request to be made using the MSAL. When logging in, my user is presented with the consent UI, and the API scope and app are listed as part of the requested permissions. When monitoring the request in my browser network tab, the scope form data element includes the expected value, something like:

 

scope: User.Read api://my.api.name/MyApi.All openid profile offline_access

 

This is what I would expect if I wanted to request API scope access, MS Graph access, and user profile information from Azure AD, all appropriate for my goals. However, when checking the access token returned from the request, the scp claim only includes the following:

 

{
  ...
  "scp": "openid profile User.Read email"
  ...
}

 

I'm a little confused by the results here, because if I'm requesting access to a resource scope, my expectation is that the resource should be able to verify the access token presented contains the required scope for access. Is there some reason the app registration's resource principal is cut out of the list here? Am I misunderstanding the access model intended with these app registrations? Or did I just mess up my configuration somewhere?

EDIT:

It appears, after some testing, that the order in which I request scopes in MSAL determines the output of the access token. It would seem that I cannot request Microsoft Graph API scopes at the same time as one of my app registration API scopes, and the first requested scope defines what else is included in the token. Is my understanding correct, and is this expected? I can imagine some of the reasons why this is so, but could use validation.

0 Replies
www.000webhost.com