Skip to content

Commit

Permalink
feat(#35): add scope parameter (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher authored Jul 28, 2023
1 parent 940533a commit b07c40b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-snails-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"druxt-auth": minor
---

feat(#35): added support for OAuth Scopes / Simple OAuth2 6.x
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.20.1
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
['druxt-auth', {
clientId: '[DRUPAL_CONSUMER_UUID]',
clientSecret: '[DRUPAL_CONSUMER_SECRET]',
scope: ['default'],
}]
],
druxt: {
Expand Down Expand Up @@ -86,3 +87,4 @@ It adds two auth strategies that can be used via the `$auth` plugin:
| --- | --- | --- | --- | --- |
| `clientId` | `string` | Yes | `undefined` | The Drupal Consumer UUID |
| `clientSecret` | `string` | No | `undefined` | The Drupal Consumer API secret. Required for Password grant. |
| `scope` | `array` | No | `undefined` | The OAuth Scopes to be used for the Drupal Consumer. |
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const NuxtModule = function (moduleOptions = {}) {
...(this.options.druxt || {}).auth || {},
clientId: undefined,
clientSecret: undefined,
scope: undefined,
...moduleOptions,
}
}
Expand Down Expand Up @@ -65,6 +66,7 @@ const NuxtModule = function (moduleOptions = {}) {
},
clientId: (options.auth || {}).clientId || process.env.DRUXT_AUTH_CLIENT_ID,
responseType: 'code',
scope: (options.auth || {}).scope,
grantType: 'authorization_code',
codeChallengeMethod: 'S256',
},
Expand Down
4 changes: 4 additions & 0 deletions test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Object {
"grantType": "authorization_code",
"responseType": "code",
"scheme": "oauth2",
"scope": undefined,
},
"drupal-password": Object {
"endpoints": Object {
Expand Down Expand Up @@ -75,6 +76,7 @@ Object {
"grantType": "authorization_code",
"responseType": "code",
"scheme": "oauth2",
"scope": undefined,
},
"drupal-password": Object {
"endpoints": Object {
Expand Down Expand Up @@ -132,6 +134,7 @@ Object {
"grantType": "authorization_code",
"responseType": "code",
"scheme": "oauth2",
"scope": undefined,
},
"drupal-password": Object {
"endpoints": Object {
Expand Down Expand Up @@ -189,6 +192,7 @@ Object {
"grantType": "authorization_code",
"responseType": "code",
"scheme": "oauth2",
"scope": undefined,
},
"drupal-password": Object {
"endpoints": Object {
Expand Down

0 comments on commit b07c40b

Please sign in to comment.