@backstage/plugin-auth-backend 0.18.9-next.1 → 0.19.0-next.3
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 +57 -0
- package/dist/index.cjs.js +83 -222
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +18 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend
|
|
2
2
|
|
|
3
|
+
## 0.19.0-next.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 71114ac50e02: **BREAKING**: The export for the new backend system has been moved to be the `default` export.
|
|
8
|
+
|
|
9
|
+
For example, if you are currently importing the plugin using the following pattern:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { examplePlugin } from '@backstage/plugin-example-backend';
|
|
13
|
+
|
|
14
|
+
backend.add(examplePlugin);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
It should be migrated to this:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
backend.add(import('@backstage/plugin-example-backend'));
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/plugin-auth-backend-module-gcp-iap-provider@0.1.0-next.3
|
|
27
|
+
- @backstage/plugin-auth-backend-module-github-provider@0.1.0-next.3
|
|
28
|
+
- @backstage/plugin-auth-backend-module-gitlab-provider@0.1.0-next.2
|
|
29
|
+
- @backstage/plugin-auth-backend-module-google-provider@0.1.0-next.3
|
|
30
|
+
- @backstage/plugin-auth-backend-module-oauth2-provider@0.1.0-next.0
|
|
31
|
+
- @backstage/catalog-client@1.4.4-next.2
|
|
32
|
+
- @backstage/catalog-model@1.4.2-next.2
|
|
33
|
+
- @backstage/config@1.1.0-next.2
|
|
34
|
+
- @backstage/errors@1.2.2-next.0
|
|
35
|
+
- @backstage/types@1.1.1-next.0
|
|
36
|
+
- @backstage/backend-plugin-api@0.6.3-next.3
|
|
37
|
+
- @backstage/backend-common@0.19.5-next.3
|
|
38
|
+
- @backstage/plugin-auth-node@0.3.0-next.3
|
|
39
|
+
- @backstage/plugin-catalog-node@1.4.4-next.3
|
|
40
|
+
|
|
41
|
+
## 0.18.9-next.2
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies
|
|
46
|
+
- @backstage/config@1.1.0-next.1
|
|
47
|
+
- @backstage/backend-common@0.19.5-next.2
|
|
48
|
+
- @backstage/plugin-auth-backend-module-gcp-iap-provider@0.1.0-next.2
|
|
49
|
+
- @backstage/plugin-auth-backend-module-github-provider@0.1.0-next.2
|
|
50
|
+
- @backstage/plugin-auth-backend-module-gitlab-provider@0.1.0-next.1
|
|
51
|
+
- @backstage/plugin-auth-backend-module-google-provider@0.1.0-next.2
|
|
52
|
+
- @backstage/plugin-auth-node@0.3.0-next.2
|
|
53
|
+
- @backstage/plugin-catalog-node@1.4.4-next.2
|
|
54
|
+
- @backstage/backend-plugin-api@0.6.3-next.2
|
|
55
|
+
- @backstage/catalog-model@1.4.2-next.1
|
|
56
|
+
- @backstage/catalog-client@1.4.4-next.1
|
|
57
|
+
- @backstage/errors@1.2.1
|
|
58
|
+
- @backstage/types@1.1.0
|
|
59
|
+
|
|
3
60
|
## 0.18.9-next.1
|
|
4
61
|
|
|
5
62
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -23,6 +23,7 @@ var pluginAuthBackendModuleGithubProvider = require('@backstage/plugin-auth-back
|
|
|
23
23
|
var pluginAuthBackendModuleGitlabProvider = require('@backstage/plugin-auth-backend-module-gitlab-provider');
|
|
24
24
|
var pluginAuthBackendModuleGoogleProvider = require('@backstage/plugin-auth-backend-module-google-provider');
|
|
25
25
|
var passportMicrosoft = require('passport-microsoft');
|
|
26
|
+
var pluginAuthBackendModuleOauth2Provider = require('@backstage/plugin-auth-backend-module-oauth2-provider');
|
|
26
27
|
var openidClient = require('openid-client');
|
|
27
28
|
var passportOktaOauth = require('@davidzemon/passport-okta-oauth');
|
|
28
29
|
var passportOneloginOauth = require('passport-onelogin-oauth');
|
|
@@ -74,10 +75,10 @@ var session__default = /*#__PURE__*/_interopDefaultLegacy(session);
|
|
|
74
75
|
var connectSessionKnex__default = /*#__PURE__*/_interopDefaultLegacy(connectSessionKnex);
|
|
75
76
|
var passport__default = /*#__PURE__*/_interopDefaultLegacy(passport);
|
|
76
77
|
|
|
77
|
-
var __defProp$
|
|
78
|
-
var __defNormalProp$
|
|
79
|
-
var __publicField$
|
|
80
|
-
__defNormalProp$
|
|
78
|
+
var __defProp$h = Object.defineProperty;
|
|
79
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
80
|
+
var __publicField$h = (obj, key, value) => {
|
|
81
|
+
__defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
81
82
|
return value;
|
|
82
83
|
};
|
|
83
84
|
const defaultScopes = ["offline_access", "read:me"];
|
|
@@ -94,7 +95,7 @@ class AtlassianStrategy extends OAuth2Strategy__default["default"] {
|
|
|
94
95
|
scope: Array.from(/* @__PURE__ */ new Set([...defaultScopes, ...scopes]))
|
|
95
96
|
};
|
|
96
97
|
super(optionsWithURLs, verify);
|
|
97
|
-
__publicField$
|
|
98
|
+
__publicField$h(this, "profileURL");
|
|
98
99
|
this.profileURL = "https://api.atlassian.com/me";
|
|
99
100
|
this.name = "atlassian";
|
|
100
101
|
this._oauth2.useAuthorizationHeaderforGET(true);
|
|
@@ -209,10 +210,10 @@ const ensuresXRequestedWith = (req) => {
|
|
|
209
210
|
|
|
210
211
|
const prepareBackstageIdentityResponse = pluginAuthNode.prepareBackstageIdentityResponse;
|
|
211
212
|
|
|
212
|
-
var __defProp$
|
|
213
|
-
var __defNormalProp$
|
|
214
|
-
var __publicField$
|
|
215
|
-
__defNormalProp$
|
|
213
|
+
var __defProp$g = Object.defineProperty;
|
|
214
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
215
|
+
var __publicField$g = (obj, key, value) => {
|
|
216
|
+
__defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
216
217
|
return value;
|
|
217
218
|
};
|
|
218
219
|
const THOUSAND_DAYS_MS = 1e3 * 24 * 60 * 60 * 1e3;
|
|
@@ -221,8 +222,8 @@ class OAuthAdapter {
|
|
|
221
222
|
constructor(handlers, options) {
|
|
222
223
|
this.handlers = handlers;
|
|
223
224
|
this.options = options;
|
|
224
|
-
__publicField$
|
|
225
|
-
__publicField$
|
|
225
|
+
__publicField$g(this, "baseCookieOptions");
|
|
226
|
+
__publicField$g(this, "setNonceCookie", (res, nonce, cookieConfig) => {
|
|
226
227
|
res.cookie(`${this.options.providerId}-nonce`, nonce, {
|
|
227
228
|
maxAge: TEN_MINUTES_MS,
|
|
228
229
|
...this.baseCookieOptions,
|
|
@@ -230,34 +231,34 @@ class OAuthAdapter {
|
|
|
230
231
|
path: `${cookieConfig.path}/handler`
|
|
231
232
|
});
|
|
232
233
|
});
|
|
233
|
-
__publicField$
|
|
234
|
+
__publicField$g(this, "setGrantedScopeCookie", (res, scope, cookieConfig) => {
|
|
234
235
|
res.cookie(`${this.options.providerId}-granted-scope`, scope, {
|
|
235
236
|
maxAge: THOUSAND_DAYS_MS,
|
|
236
237
|
...this.baseCookieOptions,
|
|
237
238
|
...cookieConfig
|
|
238
239
|
});
|
|
239
240
|
});
|
|
240
|
-
__publicField$
|
|
241
|
+
__publicField$g(this, "getRefreshTokenFromCookie", (req) => {
|
|
241
242
|
return req.cookies[`${this.options.providerId}-refresh-token`];
|
|
242
243
|
});
|
|
243
|
-
__publicField$
|
|
244
|
+
__publicField$g(this, "getGrantedScopeFromCookie", (req) => {
|
|
244
245
|
return req.cookies[`${this.options.providerId}-granted-scope`];
|
|
245
246
|
});
|
|
246
|
-
__publicField$
|
|
247
|
+
__publicField$g(this, "setRefreshTokenCookie", (res, refreshToken, cookieConfig) => {
|
|
247
248
|
res.cookie(`${this.options.providerId}-refresh-token`, refreshToken, {
|
|
248
249
|
maxAge: THOUSAND_DAYS_MS,
|
|
249
250
|
...this.baseCookieOptions,
|
|
250
251
|
...cookieConfig
|
|
251
252
|
});
|
|
252
253
|
});
|
|
253
|
-
__publicField$
|
|
254
|
+
__publicField$g(this, "removeRefreshTokenCookie", (res, cookieConfig) => {
|
|
254
255
|
res.cookie(`${this.options.providerId}-refresh-token`, "", {
|
|
255
256
|
maxAge: 0,
|
|
256
257
|
...this.baseCookieOptions,
|
|
257
258
|
...cookieConfig
|
|
258
259
|
});
|
|
259
260
|
});
|
|
260
|
-
__publicField$
|
|
261
|
+
__publicField$g(this, "getCookieConfig", (origin) => {
|
|
261
262
|
return this.options.cookieConfigurer({
|
|
262
263
|
providerId: this.options.providerId,
|
|
263
264
|
baseUrl: this.options.baseUrl,
|
|
@@ -563,10 +564,10 @@ function createAuthProviderIntegration(config) {
|
|
|
563
564
|
});
|
|
564
565
|
}
|
|
565
566
|
|
|
566
|
-
var __defProp$
|
|
567
|
-
var __defNormalProp$
|
|
568
|
-
var __publicField$
|
|
569
|
-
__defNormalProp$
|
|
567
|
+
var __defProp$f = Object.defineProperty;
|
|
568
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
569
|
+
var __publicField$f = (obj, key, value) => {
|
|
570
|
+
__defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
570
571
|
return value;
|
|
571
572
|
};
|
|
572
573
|
const atlassianDefaultAuthHandler = async ({
|
|
@@ -577,10 +578,10 @@ const atlassianDefaultAuthHandler = async ({
|
|
|
577
578
|
});
|
|
578
579
|
class AtlassianAuthProvider {
|
|
579
580
|
constructor(options) {
|
|
580
|
-
__publicField$
|
|
581
|
-
__publicField$
|
|
582
|
-
__publicField$
|
|
583
|
-
__publicField$
|
|
581
|
+
__publicField$f(this, "_strategy");
|
|
582
|
+
__publicField$f(this, "signInResolver");
|
|
583
|
+
__publicField$f(this, "authHandler");
|
|
584
|
+
__publicField$f(this, "resolverContext");
|
|
584
585
|
this.resolverContext = options.resolverContext;
|
|
585
586
|
this.authHandler = options.authHandler;
|
|
586
587
|
this.signInResolver = options.signInResolver;
|
|
@@ -698,21 +699,21 @@ class Auth0Strategy extends Auth0InternalStrategy__default["default"] {
|
|
|
698
699
|
}
|
|
699
700
|
}
|
|
700
701
|
|
|
701
|
-
var __defProp$
|
|
702
|
-
var __defNormalProp$
|
|
703
|
-
var __publicField$
|
|
704
|
-
__defNormalProp$
|
|
702
|
+
var __defProp$e = Object.defineProperty;
|
|
703
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
704
|
+
var __publicField$e = (obj, key, value) => {
|
|
705
|
+
__defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
705
706
|
return value;
|
|
706
707
|
};
|
|
707
708
|
class Auth0AuthProvider {
|
|
708
709
|
constructor(options) {
|
|
709
|
-
__publicField$
|
|
710
|
-
__publicField$
|
|
711
|
-
__publicField$
|
|
712
|
-
__publicField$
|
|
713
|
-
__publicField$
|
|
714
|
-
__publicField$
|
|
715
|
-
__publicField$
|
|
710
|
+
__publicField$e(this, "_strategy");
|
|
711
|
+
__publicField$e(this, "signInResolver");
|
|
712
|
+
__publicField$e(this, "authHandler");
|
|
713
|
+
__publicField$e(this, "resolverContext");
|
|
714
|
+
__publicField$e(this, "audience");
|
|
715
|
+
__publicField$e(this, "connection");
|
|
716
|
+
__publicField$e(this, "connectionScope");
|
|
716
717
|
/**
|
|
717
718
|
* Due to passport-auth0 forcing options.state = true,
|
|
718
719
|
* passport-oauth2 requires express-session to be installed
|
|
@@ -721,7 +722,7 @@ class Auth0AuthProvider {
|
|
|
721
722
|
* passport-oauth2, which is the StateStore implementation used when options.state = false,
|
|
722
723
|
* allowing us to avoid using express-session in order to integrate with auth0.
|
|
723
724
|
*/
|
|
724
|
-
__publicField$
|
|
725
|
+
__publicField$e(this, "store", {
|
|
725
726
|
store(_req, cb) {
|
|
726
727
|
cb(null, null);
|
|
727
728
|
},
|
|
@@ -862,23 +863,23 @@ const auth0 = createAuthProviderIntegration({
|
|
|
862
863
|
}
|
|
863
864
|
});
|
|
864
865
|
|
|
865
|
-
var __defProp$
|
|
866
|
-
var __defNormalProp$
|
|
867
|
-
var __publicField$
|
|
868
|
-
__defNormalProp$
|
|
866
|
+
var __defProp$d = Object.defineProperty;
|
|
867
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
868
|
+
var __publicField$d = (obj, key, value) => {
|
|
869
|
+
__defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
869
870
|
return value;
|
|
870
871
|
};
|
|
871
872
|
const ALB_JWT_HEADER = "x-amzn-oidc-data";
|
|
872
873
|
const ALB_ACCESS_TOKEN_HEADER = "x-amzn-oidc-accesstoken";
|
|
873
874
|
class AwsAlbAuthProvider {
|
|
874
875
|
constructor(options) {
|
|
875
|
-
__publicField$
|
|
876
|
-
__publicField$
|
|
877
|
-
__publicField$
|
|
878
|
-
__publicField$
|
|
879
|
-
__publicField$
|
|
880
|
-
__publicField$
|
|
881
|
-
__publicField$
|
|
876
|
+
__publicField$d(this, "region");
|
|
877
|
+
__publicField$d(this, "issuer");
|
|
878
|
+
__publicField$d(this, "resolverContext");
|
|
879
|
+
__publicField$d(this, "keyCache");
|
|
880
|
+
__publicField$d(this, "authHandler");
|
|
881
|
+
__publicField$d(this, "signInResolver");
|
|
882
|
+
__publicField$d(this, "getKey", async (header) => {
|
|
882
883
|
if (!header.kid) {
|
|
883
884
|
throw new errors.AuthenticationError("No key id was specified in header");
|
|
884
885
|
}
|
|
@@ -1006,18 +1007,18 @@ const awsAlb = createAuthProviderIntegration({
|
|
|
1006
1007
|
}
|
|
1007
1008
|
});
|
|
1008
1009
|
|
|
1009
|
-
var __defProp$
|
|
1010
|
-
var __defNormalProp$
|
|
1011
|
-
var __publicField$
|
|
1012
|
-
__defNormalProp$
|
|
1010
|
+
var __defProp$c = Object.defineProperty;
|
|
1011
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1012
|
+
var __publicField$c = (obj, key, value) => {
|
|
1013
|
+
__defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1013
1014
|
return value;
|
|
1014
1015
|
};
|
|
1015
1016
|
class BitbucketAuthProvider {
|
|
1016
1017
|
constructor(options) {
|
|
1017
|
-
__publicField$
|
|
1018
|
-
__publicField$
|
|
1019
|
-
__publicField$
|
|
1020
|
-
__publicField$
|
|
1018
|
+
__publicField$c(this, "_strategy");
|
|
1019
|
+
__publicField$c(this, "signInResolver");
|
|
1020
|
+
__publicField$c(this, "authHandler");
|
|
1021
|
+
__publicField$c(this, "resolverContext");
|
|
1021
1022
|
this.signInResolver = options.signInResolver;
|
|
1022
1023
|
this.authHandler = options.authHandler;
|
|
1023
1024
|
this.resolverContext = options.resolverContext;
|
|
@@ -1185,10 +1186,10 @@ const commonByEmailResolver = async (info, ctx) => {
|
|
|
1185
1186
|
});
|
|
1186
1187
|
};
|
|
1187
1188
|
|
|
1188
|
-
var __defProp$
|
|
1189
|
-
var __defNormalProp$
|
|
1190
|
-
var __publicField$
|
|
1191
|
-
__defNormalProp$
|
|
1189
|
+
var __defProp$b = Object.defineProperty;
|
|
1190
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1191
|
+
var __publicField$b = (obj, key, value) => {
|
|
1192
|
+
__defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1192
1193
|
return value;
|
|
1193
1194
|
};
|
|
1194
1195
|
const CF_JWT_HEADER = "cf-access-jwt-assertion";
|
|
@@ -1196,12 +1197,12 @@ const COOKIE_AUTH_NAME = "CF_Authorization";
|
|
|
1196
1197
|
const CACHE_PREFIX = "providers/cloudflare-access/profile-v1";
|
|
1197
1198
|
class CloudflareAccessAuthProvider {
|
|
1198
1199
|
constructor(options) {
|
|
1199
|
-
__publicField$
|
|
1200
|
-
__publicField$
|
|
1201
|
-
__publicField$
|
|
1202
|
-
__publicField$
|
|
1203
|
-
__publicField$
|
|
1204
|
-
__publicField$
|
|
1200
|
+
__publicField$b(this, "teamName");
|
|
1201
|
+
__publicField$b(this, "resolverContext");
|
|
1202
|
+
__publicField$b(this, "authHandler");
|
|
1203
|
+
__publicField$b(this, "signInResolver");
|
|
1204
|
+
__publicField$b(this, "jwtKeySet");
|
|
1205
|
+
__publicField$b(this, "cache");
|
|
1205
1206
|
this.teamName = options.teamName;
|
|
1206
1207
|
this.authHandler = options.authHandler;
|
|
1207
1208
|
this.signInResolver = options.signInResolver;
|
|
@@ -1497,20 +1498,20 @@ const google = createAuthProviderIntegration({
|
|
|
1497
1498
|
|
|
1498
1499
|
const BACKSTAGE_SESSION_EXPIRATION = 3600;
|
|
1499
1500
|
|
|
1500
|
-
var __defProp$
|
|
1501
|
-
var __defNormalProp$
|
|
1502
|
-
var __publicField$
|
|
1503
|
-
__defNormalProp$
|
|
1501
|
+
var __defProp$a = Object.defineProperty;
|
|
1502
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1503
|
+
var __publicField$a = (obj, key, value) => {
|
|
1504
|
+
__defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1504
1505
|
return value;
|
|
1505
1506
|
};
|
|
1506
1507
|
class MicrosoftAuthProvider {
|
|
1507
1508
|
constructor(options) {
|
|
1508
|
-
__publicField$
|
|
1509
|
-
__publicField$
|
|
1510
|
-
__publicField$
|
|
1511
|
-
__publicField$
|
|
1512
|
-
__publicField$
|
|
1513
|
-
__publicField$
|
|
1509
|
+
__publicField$a(this, "_strategy");
|
|
1510
|
+
__publicField$a(this, "signInResolver");
|
|
1511
|
+
__publicField$a(this, "authHandler");
|
|
1512
|
+
__publicField$a(this, "logger");
|
|
1513
|
+
__publicField$a(this, "resolverContext");
|
|
1514
|
+
__publicField$a(this, "skipUserProfile", (accessToken) => {
|
|
1514
1515
|
const { aud, scp } = jose.decodeJwt(accessToken);
|
|
1515
1516
|
const hasGraphReadScope = aud === "00000003-0000-0000-c000-000000000000" && scp.split(" ").map((s) => s.toLowerCase()).includes("user.read");
|
|
1516
1517
|
return !hasGraphReadScope;
|
|
@@ -1675,153 +1676,13 @@ const microsoft = createAuthProviderIntegration({
|
|
|
1675
1676
|
}
|
|
1676
1677
|
});
|
|
1677
1678
|
|
|
1678
|
-
var __defProp$a = Object.defineProperty;
|
|
1679
|
-
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1680
|
-
var __publicField$a = (obj, key, value) => {
|
|
1681
|
-
__defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1682
|
-
return value;
|
|
1683
|
-
};
|
|
1684
|
-
class OAuth2AuthProvider {
|
|
1685
|
-
constructor(options) {
|
|
1686
|
-
__publicField$a(this, "_strategy");
|
|
1687
|
-
__publicField$a(this, "signInResolver");
|
|
1688
|
-
__publicField$a(this, "authHandler");
|
|
1689
|
-
__publicField$a(this, "resolverContext");
|
|
1690
|
-
__publicField$a(this, "disableRefresh");
|
|
1691
|
-
var _a;
|
|
1692
|
-
this.signInResolver = options.signInResolver;
|
|
1693
|
-
this.authHandler = options.authHandler;
|
|
1694
|
-
this.resolverContext = options.resolverContext;
|
|
1695
|
-
this.disableRefresh = (_a = options.disableRefresh) != null ? _a : false;
|
|
1696
|
-
this._strategy = new OAuth2Strategy.Strategy(
|
|
1697
|
-
{
|
|
1698
|
-
clientID: options.clientId,
|
|
1699
|
-
clientSecret: options.clientSecret,
|
|
1700
|
-
callbackURL: options.callbackUrl,
|
|
1701
|
-
authorizationURL: options.authorizationUrl,
|
|
1702
|
-
tokenURL: options.tokenUrl,
|
|
1703
|
-
passReqToCallback: false,
|
|
1704
|
-
scope: options.scope,
|
|
1705
|
-
customHeaders: options.includeBasicAuth ? {
|
|
1706
|
-
Authorization: `Basic ${this.encodeClientCredentials(
|
|
1707
|
-
options.clientId,
|
|
1708
|
-
options.clientSecret
|
|
1709
|
-
)}`
|
|
1710
|
-
} : void 0
|
|
1711
|
-
},
|
|
1712
|
-
(accessToken, refreshToken, params, fullProfile, done) => {
|
|
1713
|
-
done(
|
|
1714
|
-
void 0,
|
|
1715
|
-
{
|
|
1716
|
-
fullProfile,
|
|
1717
|
-
accessToken,
|
|
1718
|
-
refreshToken,
|
|
1719
|
-
params
|
|
1720
|
-
},
|
|
1721
|
-
{
|
|
1722
|
-
refreshToken
|
|
1723
|
-
}
|
|
1724
|
-
);
|
|
1725
|
-
}
|
|
1726
|
-
);
|
|
1727
|
-
}
|
|
1728
|
-
async start(req) {
|
|
1729
|
-
return await executeRedirectStrategy(req, this._strategy, {
|
|
1730
|
-
accessType: "offline",
|
|
1731
|
-
prompt: "consent",
|
|
1732
|
-
scope: req.scope,
|
|
1733
|
-
state: encodeState(req.state)
|
|
1734
|
-
});
|
|
1735
|
-
}
|
|
1736
|
-
async handler(req) {
|
|
1737
|
-
const { result, privateInfo } = await executeFrameHandlerStrategy(req, this._strategy);
|
|
1738
|
-
return {
|
|
1739
|
-
response: await this.handleResult(result),
|
|
1740
|
-
refreshToken: privateInfo.refreshToken
|
|
1741
|
-
};
|
|
1742
|
-
}
|
|
1743
|
-
async refresh(req) {
|
|
1744
|
-
if (this.disableRefresh) {
|
|
1745
|
-
throw new errors.InputError("Session refreshes have been disabled");
|
|
1746
|
-
}
|
|
1747
|
-
const refreshTokenResponse = await executeRefreshTokenStrategy(
|
|
1748
|
-
this._strategy,
|
|
1749
|
-
req.refreshToken,
|
|
1750
|
-
req.scope
|
|
1751
|
-
);
|
|
1752
|
-
const { accessToken, params, refreshToken } = refreshTokenResponse;
|
|
1753
|
-
const fullProfile = await executeFetchUserProfileStrategy(
|
|
1754
|
-
this._strategy,
|
|
1755
|
-
accessToken
|
|
1756
|
-
);
|
|
1757
|
-
return {
|
|
1758
|
-
response: await this.handleResult({
|
|
1759
|
-
fullProfile,
|
|
1760
|
-
params,
|
|
1761
|
-
accessToken
|
|
1762
|
-
}),
|
|
1763
|
-
refreshToken
|
|
1764
|
-
};
|
|
1765
|
-
}
|
|
1766
|
-
async handleResult(result) {
|
|
1767
|
-
const { profile } = await this.authHandler(result, this.resolverContext);
|
|
1768
|
-
const response = {
|
|
1769
|
-
providerInfo: {
|
|
1770
|
-
idToken: result.params.id_token,
|
|
1771
|
-
accessToken: result.accessToken,
|
|
1772
|
-
scope: result.params.scope,
|
|
1773
|
-
expiresInSeconds: result.params.expires_in
|
|
1774
|
-
},
|
|
1775
|
-
profile
|
|
1776
|
-
};
|
|
1777
|
-
if (this.signInResolver) {
|
|
1778
|
-
response.backstageIdentity = await this.signInResolver(
|
|
1779
|
-
{
|
|
1780
|
-
result,
|
|
1781
|
-
profile
|
|
1782
|
-
},
|
|
1783
|
-
this.resolverContext
|
|
1784
|
-
);
|
|
1785
|
-
}
|
|
1786
|
-
return response;
|
|
1787
|
-
}
|
|
1788
|
-
encodeClientCredentials(clientID, clientSecret) {
|
|
1789
|
-
return Buffer.from(`${clientID}:${clientSecret}`).toString("base64");
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
1679
|
const oauth2 = createAuthProviderIntegration({
|
|
1793
1680
|
create(options) {
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
const callbackUrl = customCallbackUrl || `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
1800
|
-
const authorizationUrl = envConfig.getString("authorizationUrl");
|
|
1801
|
-
const tokenUrl = envConfig.getString("tokenUrl");
|
|
1802
|
-
const scope = envConfig.getOptionalString("scope");
|
|
1803
|
-
const includeBasicAuth = envConfig.getOptionalBoolean("includeBasicAuth");
|
|
1804
|
-
const disableRefresh = (_a = envConfig.getOptionalBoolean("disableRefresh")) != null ? _a : false;
|
|
1805
|
-
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
|
|
1806
|
-
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
1807
|
-
});
|
|
1808
|
-
const provider = new OAuth2AuthProvider({
|
|
1809
|
-
clientId,
|
|
1810
|
-
clientSecret,
|
|
1811
|
-
callbackUrl,
|
|
1812
|
-
signInResolver: (_b = options == null ? void 0 : options.signIn) == null ? void 0 : _b.resolver,
|
|
1813
|
-
authHandler,
|
|
1814
|
-
authorizationUrl,
|
|
1815
|
-
tokenUrl,
|
|
1816
|
-
scope,
|
|
1817
|
-
includeBasicAuth,
|
|
1818
|
-
resolverContext,
|
|
1819
|
-
disableRefresh
|
|
1820
|
-
});
|
|
1821
|
-
return OAuthAdapter.fromConfig(globalConfig, provider, {
|
|
1822
|
-
providerId,
|
|
1823
|
-
callbackUrl
|
|
1824
|
-
});
|
|
1681
|
+
var _a;
|
|
1682
|
+
return pluginAuthNode.createOAuthProviderFactory({
|
|
1683
|
+
authenticator: pluginAuthBackendModuleOauth2Provider.oauth2Authenticator,
|
|
1684
|
+
profileTransform: adaptLegacyOAuthHandler(options == null ? void 0 : options.authHandler),
|
|
1685
|
+
signInResolver: adaptLegacyOAuthSignInResolver((_a = options == null ? void 0 : options.signIn) == null ? void 0 : _a.resolver)
|
|
1825
1686
|
});
|
|
1826
1687
|
}
|
|
1827
1688
|
});
|
|
@@ -3573,10 +3434,10 @@ const authPlugin = backendPluginApi.createBackendPlugin({
|
|
|
3573
3434
|
exports.CatalogIdentityClient = CatalogIdentityClient;
|
|
3574
3435
|
exports.OAuthAdapter = OAuthAdapter;
|
|
3575
3436
|
exports.OAuthEnvironmentHandler = OAuthEnvironmentHandler;
|
|
3576
|
-
exports.authPlugin = authPlugin;
|
|
3577
3437
|
exports.createAuthProviderIntegration = createAuthProviderIntegration;
|
|
3578
3438
|
exports.createOriginFilter = createOriginFilter;
|
|
3579
3439
|
exports.createRouter = createRouter;
|
|
3440
|
+
exports["default"] = authPlugin;
|
|
3580
3441
|
exports.defaultAuthProviderFactories = defaultAuthProviderFactories;
|
|
3581
3442
|
exports.encodeState = encodeState;
|
|
3582
3443
|
exports.ensuresXRequestedWith = ensuresXRequestedWith;
|