@backstage/plugin-auth-backend 0.20.0 → 0.20.1-next.1
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 +49 -0
- package/config.d.ts +0 -15
- package/dist/index.cjs.js +179 -592
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -42
- package/package.json +18 -16
package/dist/index.cjs.js
CHANGED
|
@@ -8,12 +8,12 @@ var alpha = require('@backstage/plugin-catalog-node/alpha');
|
|
|
8
8
|
var express = require('express');
|
|
9
9
|
var Router = require('express-promise-router');
|
|
10
10
|
var cookieParser = require('cookie-parser');
|
|
11
|
-
var
|
|
11
|
+
var pluginAuthBackendModuleAtlassianProvider = require('@backstage/plugin-auth-backend-module-atlassian-provider');
|
|
12
|
+
var Auth0InternalStrategy = require('passport-auth0');
|
|
12
13
|
var crypto = require('crypto');
|
|
13
14
|
var url = require('url');
|
|
14
15
|
var errors = require('@backstage/errors');
|
|
15
16
|
var jwtDecoder = require('jwt-decode');
|
|
16
|
-
var Auth0InternalStrategy = require('passport-auth0');
|
|
17
17
|
var fetch = require('node-fetch');
|
|
18
18
|
var NodeCache = require('node-cache');
|
|
19
19
|
var jose = require('jose');
|
|
@@ -24,10 +24,12 @@ var pluginAuthBackendModuleGitlabProvider = require('@backstage/plugin-auth-back
|
|
|
24
24
|
var pluginAuthBackendModuleGoogleProvider = require('@backstage/plugin-auth-backend-module-google-provider');
|
|
25
25
|
var passportMicrosoft = require('passport-microsoft');
|
|
26
26
|
var pluginAuthBackendModuleOauth2Provider = require('@backstage/plugin-auth-backend-module-oauth2-provider');
|
|
27
|
+
var pluginAuthBackendModuleOauth2ProxyProvider = require('@backstage/plugin-auth-backend-module-oauth2-proxy-provider');
|
|
27
28
|
var openidClient = require('openid-client');
|
|
28
|
-
var
|
|
29
|
+
var pluginAuthBackendModuleOktaProvider = require('@backstage/plugin-auth-backend-module-okta-provider');
|
|
29
30
|
var passportOneloginOauth = require('passport-onelogin-oauth');
|
|
30
31
|
var passportSaml = require('passport-saml');
|
|
32
|
+
var passportOauth2 = require('passport-oauth2');
|
|
31
33
|
var catalogClient = require('@backstage/catalog-client');
|
|
32
34
|
var catalogModel = require('@backstage/catalog-model');
|
|
33
35
|
var luxon = require('luxon');
|
|
@@ -65,82 +67,109 @@ function _interopNamespace(e) {
|
|
|
65
67
|
var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
66
68
|
var Router__default = /*#__PURE__*/_interopDefaultLegacy(Router);
|
|
67
69
|
var cookieParser__default = /*#__PURE__*/_interopDefaultLegacy(cookieParser);
|
|
68
|
-
var
|
|
70
|
+
var Auth0InternalStrategy__default = /*#__PURE__*/_interopDefaultLegacy(Auth0InternalStrategy);
|
|
69
71
|
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
70
72
|
var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
|
|
71
73
|
var jwtDecoder__default = /*#__PURE__*/_interopDefaultLegacy(jwtDecoder);
|
|
72
|
-
var Auth0InternalStrategy__default = /*#__PURE__*/_interopDefaultLegacy(Auth0InternalStrategy);
|
|
73
74
|
var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
|
|
74
75
|
var NodeCache__default = /*#__PURE__*/_interopDefaultLegacy(NodeCache);
|
|
75
76
|
var session__default = /*#__PURE__*/_interopDefaultLegacy(session);
|
|
76
77
|
var connectSessionKnex__default = /*#__PURE__*/_interopDefaultLegacy(connectSessionKnex);
|
|
77
78
|
var passport__default = /*#__PURE__*/_interopDefaultLegacy(passport);
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
super(optionsWithURLs, verify);
|
|
99
|
-
__publicField$j(this, "profileURL");
|
|
100
|
-
this.profileURL = "https://api.atlassian.com/me";
|
|
101
|
-
this.name = "atlassian";
|
|
102
|
-
this._oauth2.useAuthorizationHeaderforGET(true);
|
|
103
|
-
}
|
|
104
|
-
authorizationParams() {
|
|
105
|
-
return {
|
|
106
|
-
audience: "api.atlassian.com",
|
|
107
|
-
prompt: "consent"
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
userProfile(accessToken, done) {
|
|
111
|
-
this._oauth2.get(this.profileURL, accessToken, (err, body) => {
|
|
112
|
-
if (err) {
|
|
113
|
-
return done(
|
|
114
|
-
new OAuth2Strategy.InternalOAuthError(
|
|
115
|
-
"Failed to fetch user profile",
|
|
116
|
-
err.statusCode
|
|
117
|
-
)
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
if (!body) {
|
|
121
|
-
return done(
|
|
122
|
-
new Error("Failed to fetch user profile, body cannot be empty")
|
|
123
|
-
);
|
|
80
|
+
function createAuthProviderIntegration(config) {
|
|
81
|
+
var _a;
|
|
82
|
+
return Object.freeze({
|
|
83
|
+
...config,
|
|
84
|
+
resolvers: Object.freeze((_a = config.resolvers) != null ? _a : {})
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function adaptLegacyOAuthHandler(authHandler) {
|
|
89
|
+
return authHandler && (async (result, ctx) => authHandler(
|
|
90
|
+
{
|
|
91
|
+
fullProfile: result.fullProfile,
|
|
92
|
+
accessToken: result.session.accessToken,
|
|
93
|
+
params: {
|
|
94
|
+
scope: result.session.scope,
|
|
95
|
+
id_token: result.session.idToken,
|
|
96
|
+
token_type: result.session.tokenType,
|
|
97
|
+
expires_in: result.session.expiresInSeconds
|
|
124
98
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
99
|
+
},
|
|
100
|
+
ctx
|
|
101
|
+
));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function adaptLegacyOAuthSignInResolver(signInResolver) {
|
|
105
|
+
return signInResolver && (async (input, ctx) => signInResolver(
|
|
106
|
+
{
|
|
107
|
+
profile: input.profile,
|
|
108
|
+
result: {
|
|
109
|
+
fullProfile: input.result.fullProfile,
|
|
110
|
+
accessToken: input.result.session.accessToken,
|
|
111
|
+
refreshToken: input.result.session.refreshToken,
|
|
112
|
+
params: {
|
|
113
|
+
scope: input.result.session.scope,
|
|
114
|
+
id_token: input.result.session.idToken,
|
|
115
|
+
token_type: input.result.session.tokenType,
|
|
116
|
+
expires_in: input.result.session.expiresInSeconds
|
|
117
|
+
}
|
|
131
118
|
}
|
|
119
|
+
},
|
|
120
|
+
ctx
|
|
121
|
+
));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function adaptOAuthSignInResolverToLegacy(resolvers) {
|
|
125
|
+
const legacyResolvers = {};
|
|
126
|
+
for (const name of Object.keys(resolvers)) {
|
|
127
|
+
const resolver = resolvers[name];
|
|
128
|
+
legacyResolvers[name] = () => async (input, ctx) => {
|
|
129
|
+
var _a;
|
|
130
|
+
return resolver(
|
|
131
|
+
{
|
|
132
|
+
profile: input.profile,
|
|
133
|
+
result: {
|
|
134
|
+
fullProfile: input.result.fullProfile,
|
|
135
|
+
session: {
|
|
136
|
+
accessToken: input.result.accessToken,
|
|
137
|
+
expiresInSeconds: input.result.params.expires_in,
|
|
138
|
+
scope: input.result.params.scope,
|
|
139
|
+
idToken: input.result.params.id_token,
|
|
140
|
+
tokenType: (_a = input.result.params.token_type) != null ? _a : "bearer",
|
|
141
|
+
refreshToken: input.result.refreshToken
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
ctx
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return legacyResolvers;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const atlassian = createAuthProviderIntegration({
|
|
153
|
+
create(options) {
|
|
154
|
+
var _a;
|
|
155
|
+
return pluginAuthNode.createOAuthProviderFactory({
|
|
156
|
+
authenticator: pluginAuthBackendModuleAtlassianProvider.atlassianAuthenticator,
|
|
157
|
+
profileTransform: adaptLegacyOAuthHandler(options == null ? void 0 : options.authHandler),
|
|
158
|
+
signInResolver: adaptLegacyOAuthSignInResolver((_a = options == null ? void 0 : options.signIn) == null ? void 0 : _a.resolver)
|
|
132
159
|
});
|
|
133
160
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
class Auth0Strategy extends Auth0InternalStrategy__default["default"] {
|
|
164
|
+
constructor(options, verify) {
|
|
165
|
+
const optionsWithURLs = {
|
|
166
|
+
...options,
|
|
167
|
+
authorizationURL: `https://${options.domain}/authorize`,
|
|
168
|
+
tokenURL: `https://${options.domain}/oauth/token`,
|
|
169
|
+
userInfoURL: `https://${options.domain}/userinfo`,
|
|
170
|
+
apiUrl: `https://${options.domain}/api`
|
|
143
171
|
};
|
|
172
|
+
super(optionsWithURLs, verify);
|
|
144
173
|
}
|
|
145
174
|
}
|
|
146
175
|
|
|
@@ -211,10 +240,10 @@ const ensuresXRequestedWith = (req) => {
|
|
|
211
240
|
|
|
212
241
|
const prepareBackstageIdentityResponse = pluginAuthNode.prepareBackstageIdentityResponse;
|
|
213
242
|
|
|
214
|
-
var __defProp$
|
|
215
|
-
var __defNormalProp$
|
|
216
|
-
var __publicField$
|
|
217
|
-
__defNormalProp$
|
|
243
|
+
var __defProp$f = Object.defineProperty;
|
|
244
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
245
|
+
var __publicField$f = (obj, key, value) => {
|
|
246
|
+
__defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
218
247
|
return value;
|
|
219
248
|
};
|
|
220
249
|
const THOUSAND_DAYS_MS = 1e3 * 24 * 60 * 60 * 1e3;
|
|
@@ -223,8 +252,8 @@ class OAuthAdapter {
|
|
|
223
252
|
constructor(handlers, options) {
|
|
224
253
|
this.handlers = handlers;
|
|
225
254
|
this.options = options;
|
|
226
|
-
__publicField$
|
|
227
|
-
__publicField$
|
|
255
|
+
__publicField$f(this, "baseCookieOptions");
|
|
256
|
+
__publicField$f(this, "setNonceCookie", (res, nonce, cookieConfig) => {
|
|
228
257
|
res.cookie(`${this.options.providerId}-nonce`, nonce, {
|
|
229
258
|
maxAge: TEN_MINUTES_MS,
|
|
230
259
|
...this.baseCookieOptions,
|
|
@@ -232,34 +261,34 @@ class OAuthAdapter {
|
|
|
232
261
|
path: `${cookieConfig.path}/handler`
|
|
233
262
|
});
|
|
234
263
|
});
|
|
235
|
-
__publicField$
|
|
264
|
+
__publicField$f(this, "setGrantedScopeCookie", (res, scope, cookieConfig) => {
|
|
236
265
|
res.cookie(`${this.options.providerId}-granted-scope`, scope, {
|
|
237
266
|
maxAge: THOUSAND_DAYS_MS,
|
|
238
267
|
...this.baseCookieOptions,
|
|
239
268
|
...cookieConfig
|
|
240
269
|
});
|
|
241
270
|
});
|
|
242
|
-
__publicField$
|
|
271
|
+
__publicField$f(this, "getRefreshTokenFromCookie", (req) => {
|
|
243
272
|
return req.cookies[`${this.options.providerId}-refresh-token`];
|
|
244
273
|
});
|
|
245
|
-
__publicField$
|
|
274
|
+
__publicField$f(this, "getGrantedScopeFromCookie", (req) => {
|
|
246
275
|
return req.cookies[`${this.options.providerId}-granted-scope`];
|
|
247
276
|
});
|
|
248
|
-
__publicField$
|
|
277
|
+
__publicField$f(this, "setRefreshTokenCookie", (res, refreshToken, cookieConfig) => {
|
|
249
278
|
res.cookie(`${this.options.providerId}-refresh-token`, refreshToken, {
|
|
250
279
|
maxAge: THOUSAND_DAYS_MS,
|
|
251
280
|
...this.baseCookieOptions,
|
|
252
281
|
...cookieConfig
|
|
253
282
|
});
|
|
254
283
|
});
|
|
255
|
-
__publicField$
|
|
284
|
+
__publicField$f(this, "removeRefreshTokenCookie", (res, cookieConfig) => {
|
|
256
285
|
res.cookie(`${this.options.providerId}-refresh-token`, "", {
|
|
257
286
|
maxAge: 0,
|
|
258
287
|
...this.baseCookieOptions,
|
|
259
288
|
...cookieConfig
|
|
260
289
|
});
|
|
261
290
|
});
|
|
262
|
-
__publicField$
|
|
291
|
+
__publicField$f(this, "getCookieConfig", (origin) => {
|
|
263
292
|
return this.options.cookieConfigurer({
|
|
264
293
|
providerId: this.options.providerId,
|
|
265
294
|
baseUrl: this.options.baseUrl,
|
|
@@ -557,164 +586,21 @@ const executeFetchUserProfileStrategy = async (providerStrategy, accessToken) =>
|
|
|
557
586
|
});
|
|
558
587
|
};
|
|
559
588
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
resolvers: Object.freeze((_a = config.resolvers) != null ? _a : {})
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
var __defProp$h = Object.defineProperty;
|
|
569
|
-
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
570
|
-
var __publicField$h = (obj, key, value) => {
|
|
571
|
-
__defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
572
|
-
return value;
|
|
573
|
-
};
|
|
574
|
-
const atlassianDefaultAuthHandler = async ({
|
|
575
|
-
fullProfile,
|
|
576
|
-
params
|
|
577
|
-
}) => ({
|
|
578
|
-
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
579
|
-
});
|
|
580
|
-
class AtlassianAuthProvider {
|
|
581
|
-
constructor(options) {
|
|
582
|
-
__publicField$h(this, "_strategy");
|
|
583
|
-
__publicField$h(this, "signInResolver");
|
|
584
|
-
__publicField$h(this, "authHandler");
|
|
585
|
-
__publicField$h(this, "resolverContext");
|
|
586
|
-
this.resolverContext = options.resolverContext;
|
|
587
|
-
this.authHandler = options.authHandler;
|
|
588
|
-
this.signInResolver = options.signInResolver;
|
|
589
|
-
this._strategy = new AtlassianStrategy(
|
|
590
|
-
{
|
|
591
|
-
clientID: options.clientId,
|
|
592
|
-
clientSecret: options.clientSecret,
|
|
593
|
-
callbackURL: options.callbackUrl,
|
|
594
|
-
scope: options.scopes
|
|
595
|
-
},
|
|
596
|
-
(accessToken, refreshToken, params, fullProfile, done) => {
|
|
597
|
-
done(void 0, {
|
|
598
|
-
fullProfile,
|
|
599
|
-
accessToken,
|
|
600
|
-
refreshToken,
|
|
601
|
-
params
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
);
|
|
605
|
-
}
|
|
606
|
-
async start(req) {
|
|
607
|
-
return await executeRedirectStrategy(req, this._strategy, {
|
|
608
|
-
state: encodeState(req.state)
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
async handler(req) {
|
|
612
|
-
const { result } = await executeFrameHandlerStrategy(
|
|
613
|
-
req,
|
|
614
|
-
this._strategy
|
|
615
|
-
);
|
|
616
|
-
return {
|
|
617
|
-
response: await this.handleResult(result),
|
|
618
|
-
refreshToken: result.refreshToken
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
async handleResult(result) {
|
|
622
|
-
const { profile } = await this.authHandler(result, this.resolverContext);
|
|
623
|
-
const response = {
|
|
624
|
-
providerInfo: {
|
|
625
|
-
idToken: result.params.id_token,
|
|
626
|
-
accessToken: result.accessToken,
|
|
627
|
-
scope: result.params.scope,
|
|
628
|
-
expiresInSeconds: result.params.expires_in
|
|
629
|
-
},
|
|
630
|
-
profile
|
|
631
|
-
};
|
|
632
|
-
if (this.signInResolver) {
|
|
633
|
-
response.backstageIdentity = await this.signInResolver(
|
|
634
|
-
{
|
|
635
|
-
result,
|
|
636
|
-
profile
|
|
637
|
-
},
|
|
638
|
-
this.resolverContext
|
|
639
|
-
);
|
|
640
|
-
}
|
|
641
|
-
return response;
|
|
642
|
-
}
|
|
643
|
-
async refresh(req) {
|
|
644
|
-
const { accessToken, params, refreshToken } = await executeRefreshTokenStrategy(
|
|
645
|
-
this._strategy,
|
|
646
|
-
req.refreshToken,
|
|
647
|
-
req.scope
|
|
648
|
-
);
|
|
649
|
-
const fullProfile = await executeFetchUserProfileStrategy(
|
|
650
|
-
this._strategy,
|
|
651
|
-
accessToken
|
|
652
|
-
);
|
|
653
|
-
return {
|
|
654
|
-
response: await this.handleResult({
|
|
655
|
-
fullProfile,
|
|
656
|
-
params,
|
|
657
|
-
accessToken
|
|
658
|
-
}),
|
|
659
|
-
refreshToken
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
const atlassian = createAuthProviderIntegration({
|
|
664
|
-
create(options) {
|
|
665
|
-
return ({ providerId, globalConfig, config, resolverContext }) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
666
|
-
var _a, _b;
|
|
667
|
-
const clientId = envConfig.getString("clientId");
|
|
668
|
-
const clientSecret = envConfig.getString("clientSecret");
|
|
669
|
-
const scopes = envConfig.getString("scopes");
|
|
670
|
-
const customCallbackUrl = envConfig.getOptionalString("callbackUrl");
|
|
671
|
-
const callbackUrl = customCallbackUrl || `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
672
|
-
const authHandler = (_a = options == null ? void 0 : options.authHandler) != null ? _a : atlassianDefaultAuthHandler;
|
|
673
|
-
const provider = new AtlassianAuthProvider({
|
|
674
|
-
clientId,
|
|
675
|
-
clientSecret,
|
|
676
|
-
scopes,
|
|
677
|
-
callbackUrl,
|
|
678
|
-
authHandler,
|
|
679
|
-
signInResolver: (_b = options == null ? void 0 : options.signIn) == null ? void 0 : _b.resolver,
|
|
680
|
-
resolverContext
|
|
681
|
-
});
|
|
682
|
-
return OAuthAdapter.fromConfig(globalConfig, provider, {
|
|
683
|
-
providerId,
|
|
684
|
-
callbackUrl
|
|
685
|
-
});
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
class Auth0Strategy extends Auth0InternalStrategy__default["default"] {
|
|
691
|
-
constructor(options, verify) {
|
|
692
|
-
const optionsWithURLs = {
|
|
693
|
-
...options,
|
|
694
|
-
authorizationURL: `https://${options.domain}/authorize`,
|
|
695
|
-
tokenURL: `https://${options.domain}/oauth/token`,
|
|
696
|
-
userInfoURL: `https://${options.domain}/userinfo`,
|
|
697
|
-
apiUrl: `https://${options.domain}/api`
|
|
698
|
-
};
|
|
699
|
-
super(optionsWithURLs, verify);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
var __defProp$g = Object.defineProperty;
|
|
704
|
-
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
705
|
-
var __publicField$g = (obj, key, value) => {
|
|
706
|
-
__defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
589
|
+
var __defProp$e = Object.defineProperty;
|
|
590
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
591
|
+
var __publicField$e = (obj, key, value) => {
|
|
592
|
+
__defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
707
593
|
return value;
|
|
708
594
|
};
|
|
709
595
|
class Auth0AuthProvider {
|
|
710
596
|
constructor(options) {
|
|
711
|
-
__publicField$
|
|
712
|
-
__publicField$
|
|
713
|
-
__publicField$
|
|
714
|
-
__publicField$
|
|
715
|
-
__publicField$
|
|
716
|
-
__publicField$
|
|
717
|
-
__publicField$
|
|
597
|
+
__publicField$e(this, "_strategy");
|
|
598
|
+
__publicField$e(this, "signInResolver");
|
|
599
|
+
__publicField$e(this, "authHandler");
|
|
600
|
+
__publicField$e(this, "resolverContext");
|
|
601
|
+
__publicField$e(this, "audience");
|
|
602
|
+
__publicField$e(this, "connection");
|
|
603
|
+
__publicField$e(this, "connectionScope");
|
|
718
604
|
/**
|
|
719
605
|
* Due to passport-auth0 forcing options.state = true,
|
|
720
606
|
* passport-oauth2 requires express-session to be installed
|
|
@@ -723,7 +609,7 @@ class Auth0AuthProvider {
|
|
|
723
609
|
* passport-oauth2, which is the StateStore implementation used when options.state = false,
|
|
724
610
|
* allowing us to avoid using express-session in order to integrate with auth0.
|
|
725
611
|
*/
|
|
726
|
-
__publicField$
|
|
612
|
+
__publicField$e(this, "store", {
|
|
727
613
|
store(_req, cb) {
|
|
728
614
|
cb(null, null);
|
|
729
615
|
},
|
|
@@ -864,23 +750,23 @@ const auth0 = createAuthProviderIntegration({
|
|
|
864
750
|
}
|
|
865
751
|
});
|
|
866
752
|
|
|
867
|
-
var __defProp$
|
|
868
|
-
var __defNormalProp$
|
|
869
|
-
var __publicField$
|
|
870
|
-
__defNormalProp$
|
|
753
|
+
var __defProp$d = Object.defineProperty;
|
|
754
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
755
|
+
var __publicField$d = (obj, key, value) => {
|
|
756
|
+
__defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
871
757
|
return value;
|
|
872
758
|
};
|
|
873
759
|
const ALB_JWT_HEADER = "x-amzn-oidc-data";
|
|
874
760
|
const ALB_ACCESS_TOKEN_HEADER = "x-amzn-oidc-accesstoken";
|
|
875
761
|
class AwsAlbAuthProvider {
|
|
876
762
|
constructor(options) {
|
|
877
|
-
__publicField$
|
|
878
|
-
__publicField$
|
|
879
|
-
__publicField$
|
|
880
|
-
__publicField$
|
|
881
|
-
__publicField$
|
|
882
|
-
__publicField$
|
|
883
|
-
__publicField$
|
|
763
|
+
__publicField$d(this, "region");
|
|
764
|
+
__publicField$d(this, "issuer");
|
|
765
|
+
__publicField$d(this, "resolverContext");
|
|
766
|
+
__publicField$d(this, "keyCache");
|
|
767
|
+
__publicField$d(this, "authHandler");
|
|
768
|
+
__publicField$d(this, "signInResolver");
|
|
769
|
+
__publicField$d(this, "getKey", async (header) => {
|
|
884
770
|
if (!header.kid) {
|
|
885
771
|
throw new errors.AuthenticationError("No key id was specified in header");
|
|
886
772
|
}
|
|
@@ -1008,18 +894,18 @@ const awsAlb = createAuthProviderIntegration({
|
|
|
1008
894
|
}
|
|
1009
895
|
});
|
|
1010
896
|
|
|
1011
|
-
var __defProp$
|
|
1012
|
-
var __defNormalProp$
|
|
1013
|
-
var __publicField$
|
|
1014
|
-
__defNormalProp$
|
|
897
|
+
var __defProp$c = Object.defineProperty;
|
|
898
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
899
|
+
var __publicField$c = (obj, key, value) => {
|
|
900
|
+
__defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1015
901
|
return value;
|
|
1016
902
|
};
|
|
1017
903
|
class BitbucketAuthProvider {
|
|
1018
904
|
constructor(options) {
|
|
1019
|
-
__publicField$
|
|
1020
|
-
__publicField$
|
|
1021
|
-
__publicField$
|
|
1022
|
-
__publicField$
|
|
905
|
+
__publicField$c(this, "_strategy");
|
|
906
|
+
__publicField$c(this, "signInResolver");
|
|
907
|
+
__publicField$c(this, "authHandler");
|
|
908
|
+
__publicField$c(this, "resolverContext");
|
|
1023
909
|
this.signInResolver = options.signInResolver;
|
|
1024
910
|
this.authHandler = options.authHandler;
|
|
1025
911
|
this.resolverContext = options.resolverContext;
|
|
@@ -1187,10 +1073,10 @@ const commonByEmailResolver = async (info, ctx) => {
|
|
|
1187
1073
|
});
|
|
1188
1074
|
};
|
|
1189
1075
|
|
|
1190
|
-
var __defProp$
|
|
1191
|
-
var __defNormalProp$
|
|
1192
|
-
var __publicField$
|
|
1193
|
-
__defNormalProp$
|
|
1076
|
+
var __defProp$b = Object.defineProperty;
|
|
1077
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1078
|
+
var __publicField$b = (obj, key, value) => {
|
|
1079
|
+
__defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1194
1080
|
return value;
|
|
1195
1081
|
};
|
|
1196
1082
|
const CF_JWT_HEADER = "cf-access-jwt-assertion";
|
|
@@ -1198,12 +1084,12 @@ const COOKIE_AUTH_NAME = "CF_Authorization";
|
|
|
1198
1084
|
const CACHE_PREFIX = "providers/cloudflare-access/profile-v1";
|
|
1199
1085
|
class CloudflareAccessAuthProvider {
|
|
1200
1086
|
constructor(options) {
|
|
1201
|
-
__publicField$
|
|
1202
|
-
__publicField$
|
|
1203
|
-
__publicField$
|
|
1204
|
-
__publicField$
|
|
1205
|
-
__publicField$
|
|
1206
|
-
__publicField$
|
|
1087
|
+
__publicField$b(this, "teamName");
|
|
1088
|
+
__publicField$b(this, "resolverContext");
|
|
1089
|
+
__publicField$b(this, "authHandler");
|
|
1090
|
+
__publicField$b(this, "signInResolver");
|
|
1091
|
+
__publicField$b(this, "jwtKeySet");
|
|
1092
|
+
__publicField$b(this, "cache");
|
|
1207
1093
|
this.teamName = options.teamName;
|
|
1208
1094
|
this.authHandler = options.authHandler;
|
|
1209
1095
|
this.signInResolver = options.signInResolver;
|
|
@@ -1406,70 +1292,6 @@ const github = createAuthProviderIntegration({
|
|
|
1406
1292
|
}
|
|
1407
1293
|
});
|
|
1408
1294
|
|
|
1409
|
-
function adaptLegacyOAuthHandler(authHandler) {
|
|
1410
|
-
return authHandler && (async (result, ctx) => authHandler(
|
|
1411
|
-
{
|
|
1412
|
-
fullProfile: result.fullProfile,
|
|
1413
|
-
accessToken: result.session.accessToken,
|
|
1414
|
-
params: {
|
|
1415
|
-
scope: result.session.scope,
|
|
1416
|
-
id_token: result.session.idToken,
|
|
1417
|
-
token_type: result.session.tokenType,
|
|
1418
|
-
expires_in: result.session.expiresInSeconds
|
|
1419
|
-
}
|
|
1420
|
-
},
|
|
1421
|
-
ctx
|
|
1422
|
-
));
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
function adaptLegacyOAuthSignInResolver(signInResolver) {
|
|
1426
|
-
return signInResolver && (async (input, ctx) => signInResolver(
|
|
1427
|
-
{
|
|
1428
|
-
profile: input.profile,
|
|
1429
|
-
result: {
|
|
1430
|
-
fullProfile: input.result.fullProfile,
|
|
1431
|
-
accessToken: input.result.session.accessToken,
|
|
1432
|
-
refreshToken: input.result.session.refreshToken,
|
|
1433
|
-
params: {
|
|
1434
|
-
scope: input.result.session.scope,
|
|
1435
|
-
id_token: input.result.session.idToken,
|
|
1436
|
-
token_type: input.result.session.tokenType,
|
|
1437
|
-
expires_in: input.result.session.expiresInSeconds
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
},
|
|
1441
|
-
ctx
|
|
1442
|
-
));
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
function adaptOAuthSignInResolverToLegacy(resolvers) {
|
|
1446
|
-
const legacyResolvers = {};
|
|
1447
|
-
for (const name of Object.keys(resolvers)) {
|
|
1448
|
-
const resolver = resolvers[name];
|
|
1449
|
-
legacyResolvers[name] = () => async (input, ctx) => {
|
|
1450
|
-
var _a;
|
|
1451
|
-
return resolver(
|
|
1452
|
-
{
|
|
1453
|
-
profile: input.profile,
|
|
1454
|
-
result: {
|
|
1455
|
-
fullProfile: input.result.fullProfile,
|
|
1456
|
-
session: {
|
|
1457
|
-
accessToken: input.result.accessToken,
|
|
1458
|
-
expiresInSeconds: input.result.params.expires_in,
|
|
1459
|
-
scope: input.result.params.scope,
|
|
1460
|
-
idToken: input.result.params.id_token,
|
|
1461
|
-
tokenType: (_a = input.result.params.token_type) != null ? _a : "bearer",
|
|
1462
|
-
refreshToken: input.result.refreshToken
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
},
|
|
1466
|
-
ctx
|
|
1467
|
-
);
|
|
1468
|
-
};
|
|
1469
|
-
}
|
|
1470
|
-
return legacyResolvers;
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
1295
|
const gitlab = createAuthProviderIntegration({
|
|
1474
1296
|
create(options) {
|
|
1475
1297
|
var _a;
|
|
@@ -1499,20 +1321,20 @@ const google = createAuthProviderIntegration({
|
|
|
1499
1321
|
|
|
1500
1322
|
const BACKSTAGE_SESSION_EXPIRATION = 3600;
|
|
1501
1323
|
|
|
1502
|
-
var __defProp$
|
|
1503
|
-
var __defNormalProp$
|
|
1504
|
-
var __publicField$
|
|
1505
|
-
__defNormalProp$
|
|
1324
|
+
var __defProp$a = Object.defineProperty;
|
|
1325
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1326
|
+
var __publicField$a = (obj, key, value) => {
|
|
1327
|
+
__defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1506
1328
|
return value;
|
|
1507
1329
|
};
|
|
1508
1330
|
class MicrosoftAuthProvider {
|
|
1509
1331
|
constructor(options) {
|
|
1510
|
-
__publicField$
|
|
1511
|
-
__publicField$
|
|
1512
|
-
__publicField$
|
|
1513
|
-
__publicField$
|
|
1514
|
-
__publicField$
|
|
1515
|
-
__publicField$
|
|
1332
|
+
__publicField$a(this, "_strategy");
|
|
1333
|
+
__publicField$a(this, "signInResolver");
|
|
1334
|
+
__publicField$a(this, "authHandler");
|
|
1335
|
+
__publicField$a(this, "logger");
|
|
1336
|
+
__publicField$a(this, "resolverContext");
|
|
1337
|
+
__publicField$a(this, "skipUserProfile", (accessToken) => {
|
|
1516
1338
|
const { aud, scp } = jose.decodeJwt(accessToken);
|
|
1517
1339
|
const hasGraphReadScope = aud === "00000003-0000-0000-c000-000000000000" && scp.split(" ").map((s) => s.toLowerCase()).includes("user.read");
|
|
1518
1340
|
return !hasGraphReadScope;
|
|
@@ -1688,106 +1510,31 @@ const oauth2 = createAuthProviderIntegration({
|
|
|
1688
1510
|
}
|
|
1689
1511
|
});
|
|
1690
1512
|
|
|
1691
|
-
var __defProp$b = Object.defineProperty;
|
|
1692
|
-
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1693
|
-
var __publicField$b = (obj, key, value) => {
|
|
1694
|
-
__defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1695
|
-
return value;
|
|
1696
|
-
};
|
|
1697
|
-
const OAUTH2_PROXY_JWT_HEADER = "X-OAUTH2-PROXY-ID-TOKEN";
|
|
1698
|
-
class Oauth2ProxyAuthProvider {
|
|
1699
|
-
constructor(options) {
|
|
1700
|
-
__publicField$b(this, "resolverContext");
|
|
1701
|
-
__publicField$b(this, "signInResolver");
|
|
1702
|
-
__publicField$b(this, "authHandler");
|
|
1703
|
-
this.resolverContext = options.resolverContext;
|
|
1704
|
-
this.signInResolver = options.signInResolver;
|
|
1705
|
-
this.authHandler = options.authHandler;
|
|
1706
|
-
}
|
|
1707
|
-
frameHandler() {
|
|
1708
|
-
return Promise.resolve(void 0);
|
|
1709
|
-
}
|
|
1710
|
-
async refresh(req, res) {
|
|
1711
|
-
try {
|
|
1712
|
-
const authHeader = req.header(OAUTH2_PROXY_JWT_HEADER);
|
|
1713
|
-
const jwt = pluginAuthNode.getBearerTokenFromAuthorizationHeader(authHeader);
|
|
1714
|
-
const decodedJWT = jwt && jose.decodeJwt(jwt);
|
|
1715
|
-
const result = {
|
|
1716
|
-
fullProfile: decodedJWT || {},
|
|
1717
|
-
accessToken: jwt || "",
|
|
1718
|
-
headers: req.headers,
|
|
1719
|
-
getHeader(name) {
|
|
1720
|
-
if (name.toLocaleLowerCase("en-US") === "set-cookie") {
|
|
1721
|
-
throw new Error("Access Set-Cookie via the headers object instead");
|
|
1722
|
-
}
|
|
1723
|
-
return req.get(name);
|
|
1724
|
-
}
|
|
1725
|
-
};
|
|
1726
|
-
const response = await this.handleResult(result);
|
|
1727
|
-
res.json(response);
|
|
1728
|
-
} catch (e) {
|
|
1729
|
-
throw new errors.AuthenticationError("Refresh failed", e);
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
start() {
|
|
1733
|
-
return Promise.resolve(void 0);
|
|
1734
|
-
}
|
|
1735
|
-
async handleResult(result) {
|
|
1736
|
-
const { profile } = await this.authHandler(result, this.resolverContext);
|
|
1737
|
-
const backstageSignInResult = await this.signInResolver(
|
|
1738
|
-
{
|
|
1739
|
-
result,
|
|
1740
|
-
profile
|
|
1741
|
-
},
|
|
1742
|
-
this.resolverContext
|
|
1743
|
-
);
|
|
1744
|
-
return {
|
|
1745
|
-
providerInfo: {
|
|
1746
|
-
accessToken: result.accessToken
|
|
1747
|
-
},
|
|
1748
|
-
backstageIdentity: prepareBackstageIdentityResponse(
|
|
1749
|
-
backstageSignInResult
|
|
1750
|
-
),
|
|
1751
|
-
profile
|
|
1752
|
-
};
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
async function defaultAuthHandler(result) {
|
|
1756
|
-
return {
|
|
1757
|
-
profile: {
|
|
1758
|
-
email: result.getHeader("x-forwarded-email"),
|
|
1759
|
-
displayName: result.getHeader("x-forwarded-preferred-username") || result.getHeader("x-forwarded-user")
|
|
1760
|
-
}
|
|
1761
|
-
};
|
|
1762
|
-
}
|
|
1763
1513
|
const oauth2Proxy = createAuthProviderIntegration({
|
|
1764
1514
|
create(options) {
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
authHandler: authHandler != null ? authHandler : defaultAuthHandler
|
|
1772
|
-
});
|
|
1773
|
-
};
|
|
1515
|
+
var _a;
|
|
1516
|
+
return pluginAuthNode.createProxyAuthProviderFactory({
|
|
1517
|
+
authenticator: pluginAuthBackendModuleOauth2ProxyProvider.oauth2ProxyAuthenticator,
|
|
1518
|
+
profileTransform: options == null ? void 0 : options.authHandler,
|
|
1519
|
+
signInResolver: (_a = options == null ? void 0 : options.signIn) == null ? void 0 : _a.resolver
|
|
1520
|
+
});
|
|
1774
1521
|
}
|
|
1775
1522
|
});
|
|
1776
1523
|
|
|
1777
|
-
var __defProp$
|
|
1778
|
-
var __defNormalProp$
|
|
1779
|
-
var __publicField$
|
|
1780
|
-
__defNormalProp$
|
|
1524
|
+
var __defProp$9 = Object.defineProperty;
|
|
1525
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1526
|
+
var __publicField$9 = (obj, key, value) => {
|
|
1527
|
+
__defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1781
1528
|
return value;
|
|
1782
1529
|
};
|
|
1783
1530
|
class OidcAuthProvider {
|
|
1784
1531
|
constructor(options) {
|
|
1785
|
-
__publicField$
|
|
1786
|
-
__publicField$
|
|
1787
|
-
__publicField$
|
|
1788
|
-
__publicField$
|
|
1789
|
-
__publicField$
|
|
1790
|
-
__publicField$
|
|
1532
|
+
__publicField$9(this, "implementation");
|
|
1533
|
+
__publicField$9(this, "scope");
|
|
1534
|
+
__publicField$9(this, "prompt");
|
|
1535
|
+
__publicField$9(this, "signInResolver");
|
|
1536
|
+
__publicField$9(this, "authHandler");
|
|
1537
|
+
__publicField$9(this, "resolverContext");
|
|
1791
1538
|
this.implementation = this.setupStrategy(options);
|
|
1792
1539
|
this.scope = options.scope;
|
|
1793
1540
|
this.prompt = options.prompt;
|
|
@@ -1948,176 +1695,16 @@ const oidc = createAuthProviderIntegration({
|
|
|
1948
1695
|
}
|
|
1949
1696
|
});
|
|
1950
1697
|
|
|
1951
|
-
var __defProp$9 = Object.defineProperty;
|
|
1952
|
-
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1953
|
-
var __publicField$9 = (obj, key, value) => {
|
|
1954
|
-
__defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1955
|
-
return value;
|
|
1956
|
-
};
|
|
1957
|
-
class OktaAuthProvider {
|
|
1958
|
-
constructor(options) {
|
|
1959
|
-
__publicField$9(this, "strategy");
|
|
1960
|
-
__publicField$9(this, "signInResolver");
|
|
1961
|
-
__publicField$9(this, "authHandler");
|
|
1962
|
-
__publicField$9(this, "resolverContext");
|
|
1963
|
-
__publicField$9(this, "additionalScopes");
|
|
1964
|
-
/**
|
|
1965
|
-
* Due to passport-okta-oauth forcing options.state = true,
|
|
1966
|
-
* passport-oauth2 requires express-session to be installed
|
|
1967
|
-
* so that the 'state' parameter of the oauth2 flow can be stored.
|
|
1968
|
-
* This implementation of StateStore matches the NullStore found within
|
|
1969
|
-
* passport-oauth2, which is the StateStore implementation used when options.state = false,
|
|
1970
|
-
* allowing us to avoid using express-session in order to integrate with Okta.
|
|
1971
|
-
*/
|
|
1972
|
-
__publicField$9(this, "store", {
|
|
1973
|
-
store(_req, cb) {
|
|
1974
|
-
cb(null, null);
|
|
1975
|
-
},
|
|
1976
|
-
verify(_req, _state, cb) {
|
|
1977
|
-
cb(null, true);
|
|
1978
|
-
}
|
|
1979
|
-
});
|
|
1980
|
-
this.signInResolver = options.signInResolver;
|
|
1981
|
-
this.authHandler = options.authHandler;
|
|
1982
|
-
this.resolverContext = options.resolverContext;
|
|
1983
|
-
this.additionalScopes = options.additionalScopes || "";
|
|
1984
|
-
this.strategy = new passportOktaOauth.Strategy(
|
|
1985
|
-
{
|
|
1986
|
-
clientID: options.clientId,
|
|
1987
|
-
clientSecret: options.clientSecret,
|
|
1988
|
-
callbackURL: options.callbackUrl,
|
|
1989
|
-
audience: options.audience,
|
|
1990
|
-
authServerID: options.authServerId,
|
|
1991
|
-
idp: options.idp,
|
|
1992
|
-
passReqToCallback: false,
|
|
1993
|
-
store: this.store,
|
|
1994
|
-
response_type: "code"
|
|
1995
|
-
},
|
|
1996
|
-
(accessToken, refreshToken, params, fullProfile, done) => {
|
|
1997
|
-
done(
|
|
1998
|
-
void 0,
|
|
1999
|
-
{
|
|
2000
|
-
accessToken,
|
|
2001
|
-
refreshToken,
|
|
2002
|
-
params,
|
|
2003
|
-
fullProfile
|
|
2004
|
-
},
|
|
2005
|
-
{
|
|
2006
|
-
refreshToken
|
|
2007
|
-
}
|
|
2008
|
-
);
|
|
2009
|
-
}
|
|
2010
|
-
);
|
|
2011
|
-
}
|
|
2012
|
-
combineScopeStrings(scopesA, scopesB) {
|
|
2013
|
-
const scopesAArray = scopesA.split(" ");
|
|
2014
|
-
const scopesBArray = scopesB.split(" ");
|
|
2015
|
-
const combinedScopes = /* @__PURE__ */ new Set([...scopesAArray, ...scopesBArray]);
|
|
2016
|
-
return Array.from(combinedScopes).join(" ");
|
|
2017
|
-
}
|
|
2018
|
-
async start(req) {
|
|
2019
|
-
const scope = this.combineScopeStrings(req.scope, this.additionalScopes);
|
|
2020
|
-
return await executeRedirectStrategy(req, this.strategy, {
|
|
2021
|
-
accessType: "offline",
|
|
2022
|
-
prompt: "consent",
|
|
2023
|
-
scope,
|
|
2024
|
-
state: encodeState(req.state)
|
|
2025
|
-
});
|
|
2026
|
-
}
|
|
2027
|
-
async handler(req) {
|
|
2028
|
-
const { result, privateInfo } = await executeFrameHandlerStrategy(req, this.strategy);
|
|
2029
|
-
return {
|
|
2030
|
-
response: await this.handleResult(result),
|
|
2031
|
-
refreshToken: privateInfo.refreshToken
|
|
2032
|
-
};
|
|
2033
|
-
}
|
|
2034
|
-
async refresh(req) {
|
|
2035
|
-
const scope = this.combineScopeStrings(req.scope, this.additionalScopes);
|
|
2036
|
-
const { accessToken, refreshToken, params } = await executeRefreshTokenStrategy(this.strategy, req.refreshToken, scope);
|
|
2037
|
-
const fullProfile = await executeFetchUserProfileStrategy(
|
|
2038
|
-
this.strategy,
|
|
2039
|
-
accessToken
|
|
2040
|
-
);
|
|
2041
|
-
return {
|
|
2042
|
-
response: await this.handleResult({
|
|
2043
|
-
fullProfile,
|
|
2044
|
-
params,
|
|
2045
|
-
accessToken
|
|
2046
|
-
}),
|
|
2047
|
-
refreshToken
|
|
2048
|
-
};
|
|
2049
|
-
}
|
|
2050
|
-
async handleResult(result) {
|
|
2051
|
-
const { profile } = await this.authHandler(result, this.resolverContext);
|
|
2052
|
-
const response = {
|
|
2053
|
-
providerInfo: {
|
|
2054
|
-
idToken: result.params.id_token,
|
|
2055
|
-
accessToken: result.accessToken,
|
|
2056
|
-
scope: result.params.scope,
|
|
2057
|
-
expiresInSeconds: result.params.expires_in
|
|
2058
|
-
},
|
|
2059
|
-
profile
|
|
2060
|
-
};
|
|
2061
|
-
if (this.signInResolver) {
|
|
2062
|
-
response.backstageIdentity = await this.signInResolver(
|
|
2063
|
-
{
|
|
2064
|
-
result,
|
|
2065
|
-
profile
|
|
2066
|
-
},
|
|
2067
|
-
this.resolverContext
|
|
2068
|
-
);
|
|
2069
|
-
}
|
|
2070
|
-
return response;
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
1698
|
const okta = createAuthProviderIntegration({
|
|
2074
1699
|
create(options) {
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
const authServerId = envConfig.getOptionalString("authServerId");
|
|
2081
|
-
const idp = envConfig.getOptionalString("idp");
|
|
2082
|
-
const customCallbackUrl = envConfig.getOptionalString("callbackUrl");
|
|
2083
|
-
const callbackUrl = customCallbackUrl || `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
2084
|
-
const additionalScopes = envConfig.getOptionalString("additionalScopes");
|
|
2085
|
-
if (!audience.startsWith("https://")) {
|
|
2086
|
-
throw new Error("URL for 'audience' must start with 'https://'.");
|
|
2087
|
-
}
|
|
2088
|
-
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
|
|
2089
|
-
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
2090
|
-
});
|
|
2091
|
-
const provider = new OktaAuthProvider({
|
|
2092
|
-
audience,
|
|
2093
|
-
authServerId,
|
|
2094
|
-
idp,
|
|
2095
|
-
clientId,
|
|
2096
|
-
clientSecret,
|
|
2097
|
-
callbackUrl,
|
|
2098
|
-
authHandler,
|
|
2099
|
-
signInResolver: (_a = options == null ? void 0 : options.signIn) == null ? void 0 : _a.resolver,
|
|
2100
|
-
resolverContext,
|
|
2101
|
-
additionalScopes
|
|
2102
|
-
});
|
|
2103
|
-
return OAuthAdapter.fromConfig(globalConfig, provider, {
|
|
2104
|
-
providerId,
|
|
2105
|
-
callbackUrl
|
|
2106
|
-
});
|
|
1700
|
+
var _a;
|
|
1701
|
+
return pluginAuthNode.createOAuthProviderFactory({
|
|
1702
|
+
authenticator: pluginAuthBackendModuleOktaProvider.oktaAuthenticator,
|
|
1703
|
+
profileTransform: adaptLegacyOAuthHandler(options == null ? void 0 : options.authHandler),
|
|
1704
|
+
signInResolver: adaptLegacyOAuthSignInResolver((_a = options == null ? void 0 : options.signIn) == null ? void 0 : _a.resolver)
|
|
2107
1705
|
});
|
|
2108
1706
|
},
|
|
2109
1707
|
resolvers: {
|
|
2110
|
-
/**
|
|
2111
|
-
* Looks up the user by matching their email local part to the entity name.
|
|
2112
|
-
*/
|
|
2113
|
-
emailLocalPartMatchingUserEntityName: () => commonByEmailLocalPartResolver,
|
|
2114
|
-
/**
|
|
2115
|
-
* Looks up the user by matching their email to the entity email.
|
|
2116
|
-
*/
|
|
2117
|
-
emailMatchingUserEntityProfileEmail: () => commonByEmailResolver,
|
|
2118
|
-
/**
|
|
2119
|
-
* Looks up the user by matching their email to the `okta.com/email` annotation.
|
|
2120
|
-
*/
|
|
2121
1708
|
emailMatchingUserEntityAnnotation() {
|
|
2122
1709
|
return async (info, ctx) => {
|
|
2123
1710
|
const { profile } = info;
|
|
@@ -2386,7 +1973,7 @@ class BitbucketServerAuthProvider {
|
|
|
2386
1973
|
this.signInResolver = options.signInResolver;
|
|
2387
1974
|
this.authHandler = options.authHandler;
|
|
2388
1975
|
this.resolverContext = options.resolverContext;
|
|
2389
|
-
this.strategy = new
|
|
1976
|
+
this.strategy = new passportOauth2.Strategy(
|
|
2390
1977
|
{
|
|
2391
1978
|
authorizationURL: options.authorizationUrl,
|
|
2392
1979
|
tokenURL: options.tokenUrl,
|