question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Client Credentials using OAuth 2.0 does not respect override scope-setting in API

See original GitHub issue

Bug description

Client Credentials using OAuth 2.0 in the interactive developer console does not respect if an API is configured to override scope (In the Azure Portal: API -> Settings -> Override scope). It seams that it is always using the default scope configured for the authorization server (In the Azure Portal: OAuth 2.0 - Default scope).

Reproduction steps

  1. Create authorization server that allows Client Credentials, and set default scope to for instance https://graph.microsoft.com/.default.
  2. Create API with override scope set to something else, for instance api://my-app/.default.
  3. Navigate to developer portal.
  4. Click “Try it” and chose “clientCredentials”.

This results in an Authorization header with a bearer token issued for https://graph.microsoft.com:

{
  "typ": "JWT",
  ...
}.{
  "aud": "https://graph.microsoft.com",
  "iss": "https://sts.windows.net/{tenantId}/",
  ...
  "appid": "id for client application, configured in APIM OAuth server.",
  ...
  "tenant_region_scope": "EU",
  ...
  "ver": "1.0",
  ...
}.[Signature]

Expected behavior

The authorization header should be set with a bearer token issued for my-app, for example:

{
  "typ": "JWT",
  ...
}.{
  "aud": "{id for resource application.}",
  "iss": "https://login.microsoftonline.com/{tenantId}/v2.0",
  ...
  "azp": "{id for client application, configured in APIM OAuth server.}",
  ...
  "roles": [
    "{role value configured for resource application and granted to client application."
  ],
  ...
  "ver": "2.0"
}.[Signature]

Is your portal managed or self-hosted?

Managed

Environment

  • Operating system: Windows
  • Browser: Edge
  • Version: 83.0.478.56

Additional context

It seams that oauthService.ts is only making the browser opening https://${location.hostname}/signin-oauth/credentials/${authorizationServer.id}. I cannot find anything that is passed along to .../signin-oauth/credentials/... (the backend that makes the actual request for getting the token) that can be used for picking up what API the token should be used for, and hence it cannot make use of any overridden scope that is defined in that API.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
azaslonovcommented, Sep 4, 2020

UPDATE: The fix is in the release pipeline and should land in every region in the next couple of weeks.

0reactions
azaslonovcommented, Sep 24, 2020

Backend deployed. Added respective changes to the client, which should be shipped by the end of this week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Call Your API Using the Client Credentials Flow - Auth0
This tutorial will help you call your API from a machine-to-machine (M2M) application using the Client Credentials Flow. To learn how the flow...
Read more >
Secure a Node API with OAuth 2.0 Client Credentials
In this article, I'll show you how you can use OAuth 2.0 outside the context of a user, in what is also known...
Read more >
Create an OAuth client - Genesys Cloud Resource Center
This procedure is for application providers who want their app to receive a token allowing it to make requests to the Genesys Cloud...
Read more >
The Client ID and Secret - OAuth 2.0 Simplified
This is the only way to ensure the developer won't accidentally include ... the developer what kind of app the credentials will be...
Read more >
RFC 6749: The OAuth 2.0 Authorization Framework
The OAuth 2.0 protocol is not backward compatible with OAuth 1.0. ... the implicit grant flow, the authorization server does not authenticate the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found