@backstage/plugin-auth-backend-module-auth0-provider 0.3.0-next.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/strategy.cjs.js +19 -5
- package/dist/strategy.cjs.js.map +1 -1
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-auth0-provider
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 36804fe: feat: Added organization option to authorization params of the strategy
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 867c905: Add support for organizational invites in auth0 strategy
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/backend-plugin-api@1.7.0
|
|
14
|
+
- @backstage/plugin-auth-node@0.6.13
|
|
15
|
+
|
|
16
|
+
## 0.3.0-next.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 867c905: Add support for organizational invites in auth0 strategy
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/backend-plugin-api@1.7.0-next.1
|
|
23
|
+
- @backstage/plugin-auth-node@0.6.13-next.1
|
|
24
|
+
|
|
3
25
|
## 0.3.0-next.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/dist/strategy.cjs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Auth0InternalStrategy = require('passport-auth0');
|
|
4
|
+
var errors = require('@backstage/errors');
|
|
4
5
|
|
|
5
6
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
6
7
|
|
|
@@ -19,13 +20,26 @@ class Auth0Strategy extends Auth0InternalStrategy__default.default {
|
|
|
19
20
|
super(optionsWithURLs, verify);
|
|
20
21
|
this.organization = options.organization;
|
|
21
22
|
}
|
|
23
|
+
authenticate(req, options) {
|
|
24
|
+
const { organization, invitation } = req.query;
|
|
25
|
+
if (organization && this.organization && organization !== this.organization) {
|
|
26
|
+
throw new errors.InputError(
|
|
27
|
+
"Organization mismatch. The organization provided in the request does not match the organization configured in the strategy."
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
super.authenticate(req, {
|
|
31
|
+
...options,
|
|
32
|
+
...organization ? { organization } : {},
|
|
33
|
+
...invitation ? { invitation } : {}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
22
36
|
authorizationParams(options) {
|
|
23
37
|
const params = super.authorizationParams(options);
|
|
24
|
-
if (this.organization) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
if (options.organization || this.organization) {
|
|
39
|
+
params.organization = options.organization || this.organization;
|
|
40
|
+
}
|
|
41
|
+
if (options.invitation) {
|
|
42
|
+
params.invitation = options.invitation;
|
|
29
43
|
}
|
|
30
44
|
return params;
|
|
31
45
|
}
|
package/dist/strategy.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.cjs.js","sources":["../src/strategy.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Auth0InternalStrategy from 'passport-auth0';\nimport type { StateStore } from 'passport-oauth2';\n\n/** @public */\nexport interface Auth0StrategyOptionsWithRequest {\n clientID: string;\n clientSecret: string;\n callbackURL: string;\n domain: string;\n passReqToCallback: true;\n store: StateStore;\n organization?: string;\n}\n\n/** @public */\nexport class Auth0Strategy extends Auth0InternalStrategy {\n private organization: string | undefined;\n\n constructor(\n options: Auth0StrategyOptionsWithRequest,\n verify: Auth0InternalStrategy.VerifyFunction,\n ) {\n const optionsWithURLs = {\n ...options,\n authorizationURL: `https://${options.domain}/authorize`,\n tokenURL: `https://${options.domain}/oauth/token`,\n userInfoURL: `https://${options.domain}/userinfo`,\n apiUrl: `https://${options.domain}/api`,\n };\n super(optionsWithURLs, verify);\n this.organization = options.organization;\n }\n\n authorizationParams(options: Record<string, any>): Record<string, any> {\n const params = super.authorizationParams(options);\n\n if (this.organization) {\n
|
|
1
|
+
{"version":3,"file":"strategy.cjs.js","sources":["../src/strategy.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Auth0InternalStrategy from 'passport-auth0';\nimport type { StateStore } from 'passport-oauth2';\nimport type express from 'express';\nimport { InputError } from '@backstage/errors';\n\n/** @public */\nexport interface Auth0StrategyOptionsWithRequest {\n clientID: string;\n clientSecret: string;\n callbackURL: string;\n domain: string;\n passReqToCallback: true;\n store: StateStore;\n organization?: string;\n}\n\n/** @public */\nexport class Auth0Strategy extends Auth0InternalStrategy {\n private organization: string | undefined;\n\n constructor(\n options: Auth0StrategyOptionsWithRequest,\n verify: Auth0InternalStrategy.VerifyFunction,\n ) {\n const optionsWithURLs = {\n ...options,\n authorizationURL: `https://${options.domain}/authorize`,\n tokenURL: `https://${options.domain}/oauth/token`,\n userInfoURL: `https://${options.domain}/userinfo`,\n apiUrl: `https://${options.domain}/api`,\n };\n super(optionsWithURLs, verify);\n this.organization = options.organization;\n }\n\n authenticate(req: express.Request, options: Record<string, any>): void {\n const { organization, invitation } = req.query;\n\n // Throw an error if the organization in the request does not match the organization configured in the strategy\n if (\n organization &&\n this.organization &&\n organization !== this.organization\n ) {\n throw new InputError(\n 'Organization mismatch. The organization provided in the request does not match the organization configured in the strategy.',\n );\n }\n\n super.authenticate(req, {\n ...options,\n ...(organization ? { organization } : {}),\n ...(invitation ? { invitation } : {}),\n });\n }\n\n authorizationParams(options: Record<string, any>): Record<string, any> {\n const params = super.authorizationParams(options);\n\n if (options.organization || this.organization) {\n params.organization = options.organization || this.organization;\n }\n\n if (options.invitation) {\n params.invitation = options.invitation;\n }\n\n return params;\n }\n}\n"],"names":["Auth0InternalStrategy","InputError"],"mappings":";;;;;;;;;AAiCO,MAAM,sBAAsBA,sCAAA,CAAsB;AAAA,EAC/C,YAAA;AAAA,EAER,WAAA,CACE,SACA,MAAA,EACA;AACA,IAAA,MAAM,eAAA,GAAkB;AAAA,MACtB,GAAG,OAAA;AAAA,MACH,gBAAA,EAAkB,CAAA,QAAA,EAAW,OAAA,CAAQ,MAAM,CAAA,UAAA,CAAA;AAAA,MAC3C,QAAA,EAAU,CAAA,QAAA,EAAW,OAAA,CAAQ,MAAM,CAAA,YAAA,CAAA;AAAA,MACnC,WAAA,EAAa,CAAA,QAAA,EAAW,OAAA,CAAQ,MAAM,CAAA,SAAA,CAAA;AAAA,MACtC,MAAA,EAAQ,CAAA,QAAA,EAAW,OAAA,CAAQ,MAAM,CAAA,IAAA;AAAA,KACnC;AACA,IAAA,KAAA,CAAM,iBAAiB,MAAM,CAAA;AAC7B,IAAA,IAAA,CAAK,eAAe,OAAA,CAAQ,YAAA;AAAA,EAC9B;AAAA,EAEA,YAAA,CAAa,KAAsB,OAAA,EAAoC;AACrE,IAAA,MAAM,EAAE,YAAA,EAAc,UAAA,EAAW,GAAI,GAAA,CAAI,KAAA;AAGzC,IAAA,IACE,YAAA,IACA,IAAA,CAAK,YAAA,IACL,YAAA,KAAiB,KAAK,YAAA,EACtB;AACA,MAAA,MAAM,IAAIC,iBAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAEA,IAAA,KAAA,CAAM,aAAa,GAAA,EAAK;AAAA,MACtB,GAAG,OAAA;AAAA,MACH,GAAI,YAAA,GAAe,EAAE,YAAA,KAAiB,EAAC;AAAA,MACvC,GAAI,UAAA,GAAa,EAAE,UAAA,KAAe;AAAC,KACpC,CAAA;AAAA,EACH;AAAA,EAEA,oBAAoB,OAAA,EAAmD;AACrE,IAAA,MAAM,MAAA,GAAS,KAAA,CAAM,mBAAA,CAAoB,OAAO,CAAA;AAEhD,IAAA,IAAI,OAAA,CAAQ,YAAA,IAAgB,IAAA,CAAK,YAAA,EAAc;AAC7C,MAAA,MAAA,CAAO,YAAA,GAAe,OAAA,CAAQ,YAAA,IAAgB,IAAA,CAAK,YAAA;AAAA,IACrD;AAEA,IAAA,IAAI,QAAQ,UAAA,EAAY;AACtB,MAAA,MAAA,CAAO,aAAa,OAAA,CAAQ,UAAA;AAAA,IAC9B;AAEA,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-backend-module-auth0-provider",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The auth0-provider backend module for the auth plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -37,19 +37,20 @@
|
|
|
37
37
|
"test": "backstage-cli package test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/backend-plugin-api": "1.7.0
|
|
41
|
-
"@backstage/
|
|
40
|
+
"@backstage/backend-plugin-api": "^1.7.0",
|
|
41
|
+
"@backstage/errors": "^1.2.7",
|
|
42
|
+
"@backstage/plugin-auth-node": "^0.6.13",
|
|
42
43
|
"express": "^4.22.0",
|
|
43
44
|
"passport": "^0.7.0",
|
|
44
45
|
"passport-auth0": "^1.4.3",
|
|
45
46
|
"passport-oauth2": "^1.6.1"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@backstage/backend-defaults": "0.15.
|
|
49
|
-
"@backstage/backend-test-utils": "1.
|
|
50
|
-
"@backstage/cli": "0.35.
|
|
51
|
-
"@backstage/plugin-auth-backend": "0.
|
|
52
|
-
"@backstage/types": "1.2.2",
|
|
49
|
+
"@backstage/backend-defaults": "^0.15.2",
|
|
50
|
+
"@backstage/backend-test-utils": "^1.11.0",
|
|
51
|
+
"@backstage/cli": "^0.35.4",
|
|
52
|
+
"@backstage/plugin-auth-backend": "^0.27.0",
|
|
53
|
+
"@backstage/types": "^1.2.2",
|
|
53
54
|
"@types/passport": "^1.0.3",
|
|
54
55
|
"@types/passport-auth0": "^1.0.5",
|
|
55
56
|
"@types/passport-oauth2": "^1.4.15",
|