diff --git a/.changeset/great-snails-lick.md b/.changeset/great-snails-lick.md new file mode 100644 index 0000000..35bde3a --- /dev/null +++ b/.changeset/great-snails-lick.md @@ -0,0 +1,5 @@ +--- +"druxt-auth": minor +--- + +feat(#35): added support for OAuth Scopes / Simple OAuth2 6.x diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..53d0020 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v16.20.1 diff --git a/README.md b/README.md index 5559558..9f6ebd5 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ module.exports = { ['druxt-auth', { clientId: '[DRUPAL_CONSUMER_UUID]', clientSecret: '[DRUPAL_CONSUMER_SECRET]', + scope: ['default'], }] ], druxt: { @@ -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. | diff --git a/src/index.js b/src/index.js index 146b48c..0b288f1 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,7 @@ const NuxtModule = function (moduleOptions = {}) { ...(this.options.druxt || {}).auth || {}, clientId: undefined, clientSecret: undefined, + scope: undefined, ...moduleOptions, } } @@ -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', }, diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index 64b5d54..6923626 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -18,6 +18,7 @@ Object { "grantType": "authorization_code", "responseType": "code", "scheme": "oauth2", + "scope": undefined, }, "drupal-password": Object { "endpoints": Object { @@ -75,6 +76,7 @@ Object { "grantType": "authorization_code", "responseType": "code", "scheme": "oauth2", + "scope": undefined, }, "drupal-password": Object { "endpoints": Object { @@ -132,6 +134,7 @@ Object { "grantType": "authorization_code", "responseType": "code", "scheme": "oauth2", + "scope": undefined, }, "drupal-password": Object { "endpoints": Object { @@ -189,6 +192,7 @@ Object { "grantType": "authorization_code", "responseType": "code", "scheme": "oauth2", + "scope": undefined, }, "drupal-password": Object { "endpoints": Object {