Skip to content

Commit abfa084

Browse files
kazazespi0
authored andcommitted
fix: remove default auth0 audience (#239)
1 parent 398a515 commit abfa084

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

docs/providers/auth0.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ auth: {
1111
strategies: {
1212
auth0: {
1313
domain: 'domain.auth0.com',
14-
client_id: '....'
14+
client_id: '....',
15+
audience: 'https://my-api-domain.com/'
1516
}
1617
}
1718
}
@@ -30,8 +31,12 @@ User will be redirected to a page like this:
3031

3132
💁 This provider is based on [oauth2 scheme](../schemes/oauth2.md) and supports all scheme options.
3233

33-
### Obtaining `client_id` and **`domain`**
34+
### Obtaining `client_id`, `domain`, and `audience`
3435

35-
This options are **REQUIRED**. Your application needs some details about this client to communicate with Auth0. You can get these details from the Settings section for your client in the [Auth0 dashboard](https://manage.auth0.com).
36+
`client_id` and `domain` are **REQUIRED**. Your application needs some details about this client to communicate with Auth0.
37+
38+
`audience` is required _unless_ you've explicitly set a default audience [on your Auth0 tenent](https://manage.auth0.com/#/tenant).
39+
40+
You can get your `client_id` and `domain` the Settings section for your client in the [Auth0 API dashboard](https://manage.auth0.com/#/applications). Your audience is defined on your [client's API](https://manage.auth0.com/#/apis).
3641

3742
<img align="center" src="https://cdn2.auth0.com/docs/media/articles/dashboard/client_settings.png">

lib/providers/auth0.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ module.exports = function auth0 (strategy) {
66
authorization_endpoint: `https://${strategy.domain}/authorize`,
77
userinfo_endpoint: `https://${strategy.domain}/userinfo`,
88
scope: ['openid', 'profile', 'email'],
9-
audience: strategy.domain
10-
})
11-
}
9+
});
10+
};

lib/schemes/oauth2.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ export default class Oauth2Scheme {
7070
client_id: this.options.client_id,
7171
redirect_uri: this._redirectURI,
7272
scope: this._scope,
73-
audience: this.options.audience,
74-
state: randomString()
73+
state: randomString(),
74+
};
75+
76+
if (this.options.audience) {
77+
opts.audience = this.options.audience;
7578
}
7679

7780
this.$auth.$storage.setLocalStorage(this.name + '.state', opts.state)

0 commit comments

Comments
 (0)