@backstage/plugin-auth-backend 0.24.5 → 0.25.0-next.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/config.d.ts +0 -58
  3. package/dist/authPlugin.cjs.js +4 -8
  4. package/dist/authPlugin.cjs.js.map +1 -1
  5. package/dist/database/AuthDatabase.cjs.js +0 -16
  6. package/dist/database/AuthDatabase.cjs.js.map +1 -1
  7. package/dist/index.cjs.js +0 -26
  8. package/dist/index.cjs.js.map +1 -1
  9. package/dist/index.d.ts +1 -850
  10. package/dist/lib/catalog/CatalogIdentityClient.cjs.js +11 -20
  11. package/dist/lib/catalog/CatalogIdentityClient.cjs.js.map +1 -1
  12. package/dist/lib/resolvers/CatalogAuthResolverContext.cjs.js +14 -17
  13. package/dist/lib/resolvers/CatalogAuthResolverContext.cjs.js.map +1 -1
  14. package/dist/providers/router.cjs.js +2 -9
  15. package/dist/providers/router.cjs.js.map +1 -1
  16. package/dist/service/router.cjs.js +5 -16
  17. package/dist/service/router.cjs.js.map +1 -1
  18. package/package.json +15 -58
  19. package/dist/lib/flow/authFlowHelpers.cjs.js +0 -43
  20. package/dist/lib/flow/authFlowHelpers.cjs.js.map +0 -1
  21. package/dist/lib/legacy/adaptLegacyOAuthHandler.cjs.js +0 -20
  22. package/dist/lib/legacy/adaptLegacyOAuthHandler.cjs.js.map +0 -1
  23. package/dist/lib/legacy/adaptLegacyOAuthSignInResolver.cjs.js +0 -24
  24. package/dist/lib/legacy/adaptLegacyOAuthSignInResolver.cjs.js.map +0 -1
  25. package/dist/lib/legacy/adaptOAuthSignInResolverToLegacy.cjs.js +0 -29
  26. package/dist/lib/legacy/adaptOAuthSignInResolverToLegacy.cjs.js.map +0 -1
  27. package/dist/lib/oauth/OAuthAdapter.cjs.js +0 -220
  28. package/dist/lib/oauth/OAuthAdapter.cjs.js.map +0 -1
  29. package/dist/lib/oauth/OAuthEnvironmentHandler.cjs.js +0 -8
  30. package/dist/lib/oauth/OAuthEnvironmentHandler.cjs.js.map +0 -1
  31. package/dist/lib/oauth/helpers.cjs.js +0 -40
  32. package/dist/lib/oauth/helpers.cjs.js.map +0 -1
  33. package/dist/lib/passport/PassportStrategyHelper.cjs.js +0 -49
  34. package/dist/lib/passport/PassportStrategyHelper.cjs.js.map +0 -1
  35. package/dist/providers/atlassian/provider.cjs.js +0 -20
  36. package/dist/providers/atlassian/provider.cjs.js.map +0 -1
  37. package/dist/providers/auth0/provider.cjs.js +0 -20
  38. package/dist/providers/auth0/provider.cjs.js.map +0 -1
  39. package/dist/providers/aws-alb/provider.cjs.js +0 -18
  40. package/dist/providers/aws-alb/provider.cjs.js.map +0 -1
  41. package/dist/providers/azure-easyauth/provider.cjs.js +0 -18
  42. package/dist/providers/azure-easyauth/provider.cjs.js.map +0 -1
  43. package/dist/providers/bitbucket/provider.cjs.js +0 -25
  44. package/dist/providers/bitbucket/provider.cjs.js.map +0 -1
  45. package/dist/providers/bitbucketServer/provider.cjs.js +0 -46
  46. package/dist/providers/bitbucketServer/provider.cjs.js.map +0 -1
  47. package/dist/providers/cloudflare-access/provider.cjs.js +0 -22
  48. package/dist/providers/cloudflare-access/provider.cjs.js.map +0 -1
  49. package/dist/providers/createAuthProviderIntegration.cjs.js +0 -11
  50. package/dist/providers/createAuthProviderIntegration.cjs.js.map +0 -1
  51. package/dist/providers/gcp-iap/provider.cjs.js +0 -18
  52. package/dist/providers/gcp-iap/provider.cjs.js.map +0 -1
  53. package/dist/providers/github/provider.cjs.js +0 -61
  54. package/dist/providers/github/provider.cjs.js.map +0 -1
  55. package/dist/providers/gitlab/provider.cjs.js +0 -20
  56. package/dist/providers/gitlab/provider.cjs.js.map +0 -1
  57. package/dist/providers/google/provider.cjs.js +0 -26
  58. package/dist/providers/google/provider.cjs.js.map +0 -1
  59. package/dist/providers/microsoft/provider.cjs.js +0 -27
  60. package/dist/providers/microsoft/provider.cjs.js.map +0 -1
  61. package/dist/providers/oauth2/provider.cjs.js +0 -20
  62. package/dist/providers/oauth2/provider.cjs.js.map +0 -1
  63. package/dist/providers/oauth2-proxy/provider.cjs.js +0 -18
  64. package/dist/providers/oauth2-proxy/provider.cjs.js.map +0 -1
  65. package/dist/providers/oidc/provider.cjs.js +0 -37
  66. package/dist/providers/oidc/provider.cjs.js.map +0 -1
  67. package/dist/providers/okta/provider.cjs.js +0 -47
  68. package/dist/providers/okta/provider.cjs.js.map +0 -1
  69. package/dist/providers/onelogin/provider.cjs.js +0 -20
  70. package/dist/providers/onelogin/provider.cjs.js.map +0 -1
  71. package/dist/providers/prepareBackstageIdentityResponse.cjs.js +0 -8
  72. package/dist/providers/prepareBackstageIdentityResponse.cjs.js.map +0 -1
  73. package/dist/providers/providers.cjs.js +0 -62
  74. package/dist/providers/providers.cjs.js.map +0 -1
  75. package/dist/providers/resolvers.cjs.js +0 -27
  76. package/dist/providers/resolvers.cjs.js.map +0 -1
  77. package/dist/providers/saml/provider.cjs.js +0 -121
  78. package/dist/providers/saml/provider.cjs.js.map +0 -1
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- function adaptLegacyOAuthSignInResolver(signInResolver) {
4
- return signInResolver && (async (input, ctx) => signInResolver(
5
- {
6
- profile: input.profile,
7
- result: {
8
- fullProfile: input.result.fullProfile,
9
- accessToken: input.result.session.accessToken,
10
- refreshToken: input.result.session.refreshToken,
11
- params: {
12
- scope: input.result.session.scope,
13
- id_token: input.result.session.idToken,
14
- token_type: input.result.session.tokenType,
15
- expires_in: input.result.session.expiresInSeconds
16
- }
17
- }
18
- },
19
- ctx
20
- ));
21
- }
22
-
23
- exports.adaptLegacyOAuthSignInResolver = adaptLegacyOAuthSignInResolver;
24
- //# sourceMappingURL=adaptLegacyOAuthSignInResolver.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adaptLegacyOAuthSignInResolver.cjs.js","sources":["../../../src/lib/legacy/adaptLegacyOAuthSignInResolver.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInResolver,\n} from '@backstage/plugin-auth-node';\nimport { OAuthResult } from '../oauth';\n\n/** @internal */\nexport function adaptLegacyOAuthSignInResolver(\n signInResolver?: SignInResolver<OAuthResult>,\n): SignInResolver<OAuthAuthenticatorResult<PassportProfile>> | undefined {\n return (\n signInResolver &&\n (async (input, ctx) =>\n signInResolver(\n {\n profile: input.profile,\n result: {\n fullProfile: input.result.fullProfile,\n accessToken: input.result.session.accessToken,\n refreshToken: input.result.session.refreshToken,\n params: {\n scope: input.result.session.scope,\n id_token: input.result.session.idToken,\n token_type: input.result.session.tokenType,\n expires_in: input.result.session.expiresInSeconds!,\n },\n },\n },\n ctx,\n ))\n );\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,+BACd,cACuE,EAAA;AACvE,EACE,OAAA,cAAA,KACC,OAAO,KAAA,EAAO,GACb,KAAA,cAAA;AAAA,IACE;AAAA,MACE,SAAS,KAAM,CAAA,OAAA;AAAA,MACf,MAAQ,EAAA;AAAA,QACN,WAAA,EAAa,MAAM,MAAO,CAAA,WAAA;AAAA,QAC1B,WAAA,EAAa,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA,WAAA;AAAA,QAClC,YAAA,EAAc,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA,YAAA;AAAA,QACnC,MAAQ,EAAA;AAAA,UACN,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA,KAAA;AAAA,UAC5B,QAAA,EAAU,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA,OAAA;AAAA,UAC/B,UAAA,EAAY,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA,SAAA;AAAA,UACjC,UAAA,EAAY,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA;AAAA;AACnC;AACF,KACF;AAAA,IACA;AAAA,GACF,CAAA;AAEN;;;;"}
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- function adaptOAuthSignInResolverToLegacy(resolvers) {
4
- const legacyResolvers = {};
5
- for (const name of Object.keys(resolvers)) {
6
- const resolver = resolvers[name];
7
- legacyResolvers[name] = () => async (input, ctx) => resolver(
8
- {
9
- profile: input.profile,
10
- result: {
11
- fullProfile: input.result.fullProfile,
12
- session: {
13
- accessToken: input.result.accessToken,
14
- expiresInSeconds: input.result.params.expires_in,
15
- scope: input.result.params.scope,
16
- idToken: input.result.params.id_token,
17
- tokenType: input.result.params.token_type ?? "bearer",
18
- refreshToken: input.result.refreshToken
19
- }
20
- }
21
- },
22
- ctx
23
- );
24
- }
25
- return legacyResolvers;
26
- }
27
-
28
- exports.adaptOAuthSignInResolverToLegacy = adaptOAuthSignInResolverToLegacy;
29
- //# sourceMappingURL=adaptOAuthSignInResolverToLegacy.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adaptOAuthSignInResolverToLegacy.cjs.js","sources":["../../../src/lib/legacy/adaptOAuthSignInResolverToLegacy.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInResolver,\n} from '@backstage/plugin-auth-node';\nimport { OAuthResult } from '../oauth';\n\n/** @internal */\nexport function adaptOAuthSignInResolverToLegacy<\n TKeys extends string,\n>(resolvers: {\n [key in TKeys]: SignInResolver<OAuthAuthenticatorResult<PassportProfile>>;\n}): { [key in TKeys]: () => SignInResolver<OAuthResult> } {\n const legacyResolvers = {} as {\n [key in TKeys]: () => SignInResolver<OAuthResult>;\n };\n for (const name of Object.keys(resolvers) as TKeys[]) {\n const resolver = resolvers[name];\n legacyResolvers[name] = () => async (input, ctx) =>\n resolver(\n {\n profile: input.profile,\n result: {\n fullProfile: input.result.fullProfile,\n session: {\n accessToken: input.result.accessToken,\n expiresInSeconds: input.result.params.expires_in,\n scope: input.result.params.scope,\n idToken: input.result.params.id_token,\n tokenType: input.result.params.token_type ?? 'bearer',\n refreshToken: input.result.refreshToken,\n },\n },\n },\n ctx,\n );\n }\n return legacyResolvers;\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,iCAEd,SAEwD,EAAA;AACxD,EAAA,MAAM,kBAAkB,EAAC;AAGzB,EAAA,KAAA,MAAW,IAAQ,IAAA,MAAA,CAAO,IAAK,CAAA,SAAS,CAAc,EAAA;AACpD,IAAM,MAAA,QAAA,GAAW,UAAU,IAAI,CAAA;AAC/B,IAAA,eAAA,CAAgB,IAAI,CAAA,GAAI,MAAM,OAAO,OAAO,GAC1C,KAAA,QAAA;AAAA,MACE;AAAA,QACE,SAAS,KAAM,CAAA,OAAA;AAAA,QACf,MAAQ,EAAA;AAAA,UACN,WAAA,EAAa,MAAM,MAAO,CAAA,WAAA;AAAA,UAC1B,OAAS,EAAA;AAAA,YACP,WAAA,EAAa,MAAM,MAAO,CAAA,WAAA;AAAA,YAC1B,gBAAA,EAAkB,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,UAAA;AAAA,YACtC,KAAA,EAAO,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,KAAA;AAAA,YAC3B,OAAA,EAAS,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,QAAA;AAAA,YAC7B,SAAW,EAAA,KAAA,CAAM,MAAO,CAAA,MAAA,CAAO,UAAc,IAAA,QAAA;AAAA,YAC7C,YAAA,EAAc,MAAM,MAAO,CAAA;AAAA;AAC7B;AACF,OACF;AAAA,MACA;AAAA,KACF;AAAA;AAEJ,EAAO,OAAA,eAAA;AACT;;;;"}
@@ -1,220 +0,0 @@
1
- 'use strict';
2
-
3
- var crypto = require('crypto');
4
- var url = require('url');
5
- var errors = require('@backstage/errors');
6
- var helpers = require('./helpers.cjs.js');
7
- var authFlowHelpers = require('../flow/authFlowHelpers.cjs.js');
8
- var prepareBackstageIdentityResponse = require('../../providers/prepareBackstageIdentityResponse.cjs.js');
9
-
10
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
-
12
- var crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
13
-
14
- const THOUSAND_DAYS_MS = 1e3 * 24 * 60 * 60 * 1e3;
15
- const TEN_MINUTES_MS = 600 * 1e3;
16
- class OAuthAdapter {
17
- constructor(handlers, options) {
18
- this.handlers = handlers;
19
- this.options = options;
20
- this.baseCookieOptions = {
21
- httpOnly: true,
22
- sameSite: "lax"
23
- };
24
- }
25
- static fromConfig(config, handlers, options) {
26
- const { appUrl, baseUrl, isOriginAllowed } = config;
27
- const { origin: appOrigin } = new url.URL(appUrl);
28
- const cookieConfigurer = config.cookieConfigurer ?? helpers.defaultCookieConfigurer;
29
- return new OAuthAdapter(handlers, {
30
- ...options,
31
- appOrigin,
32
- baseUrl,
33
- cookieConfigurer,
34
- isOriginAllowed
35
- });
36
- }
37
- baseCookieOptions;
38
- async start(req, res) {
39
- const scope = req.query.scope?.toString() ?? "";
40
- const env = req.query.env?.toString();
41
- const origin = req.query.origin?.toString();
42
- const redirectUrl = req.query.redirectUrl?.toString();
43
- const flow = req.query.flow?.toString();
44
- if (!env) {
45
- throw new errors.InputError("No env provided in request query parameters");
46
- }
47
- const cookieConfig = this.getCookieConfig(origin);
48
- const nonce = crypto__default.default.randomBytes(16).toString("base64");
49
- this.setNonceCookie(res, nonce, cookieConfig);
50
- const state = { nonce, env, origin, redirectUrl, flow };
51
- if (this.options.persistScopes) {
52
- state.scope = scope;
53
- }
54
- const forwardReq = Object.assign(req, { scope, state });
55
- const { url, status } = await this.handlers.start(
56
- forwardReq
57
- );
58
- res.statusCode = status || 302;
59
- res.setHeader("Location", url);
60
- res.setHeader("Content-Length", "0");
61
- res.end();
62
- }
63
- async frameHandler(req, res) {
64
- let appOrigin = this.options.appOrigin;
65
- try {
66
- const state = helpers.readState(req.query.state?.toString() ?? "");
67
- if (state.origin) {
68
- try {
69
- appOrigin = new url.URL(state.origin).origin;
70
- } catch {
71
- throw new errors.NotAllowedError("App origin is invalid, failed to parse");
72
- }
73
- if (!this.options.isOriginAllowed(appOrigin)) {
74
- throw new errors.NotAllowedError(`Origin '${appOrigin}' is not allowed`);
75
- }
76
- }
77
- helpers.verifyNonce(req, this.options.providerId);
78
- const { response, refreshToken } = await this.handlers.handler(req);
79
- const cookieConfig = this.getCookieConfig(appOrigin);
80
- if (this.options.persistScopes && state.scope) {
81
- this.setGrantedScopeCookie(res, state.scope, cookieConfig);
82
- response.providerInfo.scope = state.scope;
83
- }
84
- if (refreshToken) {
85
- this.setRefreshTokenCookie(res, refreshToken, cookieConfig);
86
- }
87
- const identity = await this.populateIdentity(response.backstageIdentity);
88
- const responseObj = {
89
- type: "authorization_response",
90
- response: { ...response, backstageIdentity: identity }
91
- };
92
- if (state.flow === "redirect") {
93
- if (!state.redirectUrl) {
94
- throw new errors.InputError(
95
- "No redirectUrl provided in request query parameters"
96
- );
97
- }
98
- res.redirect(state.redirectUrl);
99
- return void 0;
100
- }
101
- return authFlowHelpers.postMessageResponse(res, appOrigin, responseObj);
102
- } catch (error) {
103
- const { name, message } = errors.isError(error) ? error : new Error("Encountered invalid error");
104
- return authFlowHelpers.postMessageResponse(res, appOrigin, {
105
- type: "authorization_response",
106
- error: { name, message }
107
- });
108
- }
109
- }
110
- async logout(req, res) {
111
- if (!authFlowHelpers.ensuresXRequestedWith(req)) {
112
- throw new errors.AuthenticationError("Invalid X-Requested-With header");
113
- }
114
- if (this.handlers.logout) {
115
- const refreshToken = this.getRefreshTokenFromCookie(req);
116
- const revokeRequest = Object.assign(req, {
117
- refreshToken
118
- });
119
- await this.handlers.logout(revokeRequest);
120
- }
121
- const origin = req.get("origin");
122
- const cookieConfig = this.getCookieConfig(origin);
123
- this.removeRefreshTokenCookie(res, cookieConfig);
124
- res.status(200).end();
125
- }
126
- async refresh(req, res) {
127
- if (!authFlowHelpers.ensuresXRequestedWith(req)) {
128
- throw new errors.AuthenticationError("Invalid X-Requested-With header");
129
- }
130
- if (!this.handlers.refresh) {
131
- throw new errors.InputError(
132
- `Refresh token is not supported for provider ${this.options.providerId}`
133
- );
134
- }
135
- try {
136
- const refreshToken = this.getRefreshTokenFromCookie(req);
137
- if (!refreshToken) {
138
- throw new errors.InputError("Missing session cookie");
139
- }
140
- let scope = req.query.scope?.toString() ?? "";
141
- if (this.options.persistScopes) {
142
- scope = this.getGrantedScopeFromCookie(req);
143
- }
144
- const forwardReq = Object.assign(req, { scope, refreshToken });
145
- const { response, refreshToken: newRefreshToken } = await this.handlers.refresh(forwardReq);
146
- const backstageIdentity = await this.populateIdentity(
147
- response.backstageIdentity
148
- );
149
- if (newRefreshToken && newRefreshToken !== refreshToken) {
150
- const origin = req.get("origin");
151
- const cookieConfig = this.getCookieConfig(origin);
152
- this.setRefreshTokenCookie(res, newRefreshToken, cookieConfig);
153
- }
154
- res.status(200).json({ ...response, backstageIdentity });
155
- } catch (error) {
156
- throw new errors.AuthenticationError("Refresh failed", error);
157
- }
158
- }
159
- /**
160
- * If the response from the OAuth provider includes a Backstage identity, we
161
- * make sure it's populated with all the information we can derive from the user ID.
162
- */
163
- async populateIdentity(identity) {
164
- if (!identity) {
165
- return void 0;
166
- }
167
- if (!identity.token) {
168
- throw new errors.InputError(`Identity response must return a token`);
169
- }
170
- return prepareBackstageIdentityResponse.prepareBackstageIdentityResponse(identity);
171
- }
172
- setNonceCookie = (res, nonce, cookieConfig) => {
173
- res.cookie(`${this.options.providerId}-nonce`, nonce, {
174
- maxAge: TEN_MINUTES_MS,
175
- ...this.baseCookieOptions,
176
- ...cookieConfig,
177
- path: `${cookieConfig.path}/handler`
178
- });
179
- };
180
- setGrantedScopeCookie = (res, scope, cookieConfig) => {
181
- res.cookie(`${this.options.providerId}-granted-scope`, scope, {
182
- maxAge: THOUSAND_DAYS_MS,
183
- ...this.baseCookieOptions,
184
- ...cookieConfig
185
- });
186
- };
187
- getRefreshTokenFromCookie = (req) => {
188
- return req.cookies[`${this.options.providerId}-refresh-token`];
189
- };
190
- getGrantedScopeFromCookie = (req) => {
191
- return req.cookies[`${this.options.providerId}-granted-scope`];
192
- };
193
- setRefreshTokenCookie = (res, refreshToken, cookieConfig) => {
194
- res.cookie(`${this.options.providerId}-refresh-token`, refreshToken, {
195
- maxAge: THOUSAND_DAYS_MS,
196
- ...this.baseCookieOptions,
197
- ...cookieConfig
198
- });
199
- };
200
- removeRefreshTokenCookie = (res, cookieConfig) => {
201
- res.cookie(`${this.options.providerId}-refresh-token`, "", {
202
- maxAge: 0,
203
- ...this.baseCookieOptions,
204
- ...cookieConfig
205
- });
206
- };
207
- getCookieConfig = (origin) => {
208
- return this.options.cookieConfigurer({
209
- providerId: this.options.providerId,
210
- baseUrl: this.options.baseUrl,
211
- callbackUrl: this.options.callbackUrl,
212
- appOrigin: origin ?? this.options.appOrigin
213
- });
214
- };
215
- }
216
-
217
- exports.OAuthAdapter = OAuthAdapter;
218
- exports.TEN_MINUTES_MS = TEN_MINUTES_MS;
219
- exports.THOUSAND_DAYS_MS = THOUSAND_DAYS_MS;
220
- //# sourceMappingURL=OAuthAdapter.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OAuthAdapter.cjs.js","sources":["../../../src/lib/oauth/OAuthAdapter.ts"],"sourcesContent":["/*\n * Copyright 2020 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 express, { CookieOptions } from 'express';\nimport crypto from 'crypto';\nimport { URL } from 'url';\nimport {\n AuthProviderConfig,\n AuthProviderRouteHandlers,\n BackstageIdentityResponse,\n BackstageSignInResult,\n CookieConfigurer,\n OAuthState,\n} from '@backstage/plugin-auth-node';\nimport {\n AuthenticationError,\n InputError,\n isError,\n NotAllowedError,\n} from '@backstage/errors';\nimport { defaultCookieConfigurer, readState, verifyNonce } from './helpers';\nimport {\n postMessageResponse,\n ensuresXRequestedWith,\n WebMessageResponse,\n} from '../flow';\nimport {\n OAuthHandlers,\n OAuthStartRequest,\n OAuthRefreshRequest,\n OAuthLogoutRequest,\n} from './types';\nimport { prepareBackstageIdentityResponse } from '../../providers/prepareBackstageIdentityResponse';\n\nexport const THOUSAND_DAYS_MS = 1000 * 24 * 60 * 60 * 1000;\nexport const TEN_MINUTES_MS = 600 * 1000;\n\n/**\n * @public\n * @deprecated Use `createOAuthRouteHandlers` from `@backstage/plugin-auth-node` instead\n */\nexport type OAuthAdapterOptions = {\n providerId: string;\n persistScopes?: boolean;\n appOrigin: string;\n baseUrl: string;\n cookieConfigurer: CookieConfigurer;\n isOriginAllowed: (origin: string) => boolean;\n callbackUrl: string;\n};\n\n/**\n * @public\n * @deprecated Use `createOAuthRouteHandlers` from `@backstage/plugin-auth-node` instead\n */\nexport class OAuthAdapter implements AuthProviderRouteHandlers {\n static fromConfig(\n config: AuthProviderConfig,\n handlers: OAuthHandlers,\n options: Pick<\n OAuthAdapterOptions,\n 'providerId' | 'persistScopes' | 'callbackUrl'\n >,\n ): OAuthAdapter {\n const { appUrl, baseUrl, isOriginAllowed } = config;\n const { origin: appOrigin } = new URL(appUrl);\n\n const cookieConfigurer = config.cookieConfigurer ?? defaultCookieConfigurer;\n\n return new OAuthAdapter(handlers, {\n ...options,\n appOrigin,\n baseUrl,\n cookieConfigurer,\n isOriginAllowed,\n });\n }\n\n private readonly baseCookieOptions: CookieOptions;\n\n constructor(\n private readonly handlers: OAuthHandlers,\n private readonly options: OAuthAdapterOptions,\n ) {\n this.baseCookieOptions = {\n httpOnly: true,\n sameSite: 'lax',\n };\n }\n\n async start(req: express.Request, res: express.Response): Promise<void> {\n // retrieve scopes from request\n const scope = req.query.scope?.toString() ?? '';\n const env = req.query.env?.toString();\n const origin = req.query.origin?.toString();\n const redirectUrl = req.query.redirectUrl?.toString();\n const flow = req.query.flow?.toString();\n\n if (!env) {\n throw new InputError('No env provided in request query parameters');\n }\n\n const cookieConfig = this.getCookieConfig(origin);\n\n const nonce = crypto.randomBytes(16).toString('base64');\n // set a nonce cookie before redirecting to oauth provider\n this.setNonceCookie(res, nonce, cookieConfig);\n\n const state: OAuthState = { nonce, env, origin, redirectUrl, flow };\n\n // If scopes are persisted then we pass them through the state so that we\n // can set the cookie on successful auth\n if (this.options.persistScopes) {\n state.scope = scope;\n }\n const forwardReq = Object.assign(req, { scope, state });\n\n const { url, status } = await this.handlers.start(\n forwardReq as OAuthStartRequest,\n );\n\n res.statusCode = status || 302;\n res.setHeader('Location', url);\n res.setHeader('Content-Length', '0');\n res.end();\n }\n\n async frameHandler(\n req: express.Request,\n res: express.Response,\n ): Promise<void> {\n let appOrigin = this.options.appOrigin;\n\n try {\n const state: OAuthState = readState(req.query.state?.toString() ?? '');\n\n if (state.origin) {\n try {\n appOrigin = new URL(state.origin).origin;\n } catch {\n throw new NotAllowedError('App origin is invalid, failed to parse');\n }\n if (!this.options.isOriginAllowed(appOrigin)) {\n throw new NotAllowedError(`Origin '${appOrigin}' is not allowed`);\n }\n }\n\n // verify nonce cookie and state cookie on callback\n verifyNonce(req, this.options.providerId);\n\n const { response, refreshToken } = await this.handlers.handler(req);\n\n const cookieConfig = this.getCookieConfig(appOrigin);\n\n // Store the scope that we have been granted for this session. This is useful if\n // the provider does not return granted scopes on refresh or if they are normalized.\n if (this.options.persistScopes && state.scope) {\n this.setGrantedScopeCookie(res, state.scope, cookieConfig);\n response.providerInfo.scope = state.scope;\n }\n\n if (refreshToken) {\n // set new refresh token\n this.setRefreshTokenCookie(res, refreshToken, cookieConfig);\n }\n\n const identity = await this.populateIdentity(response.backstageIdentity);\n\n const responseObj: WebMessageResponse = {\n type: 'authorization_response',\n response: { ...response, backstageIdentity: identity },\n };\n\n if (state.flow === 'redirect') {\n if (!state.redirectUrl) {\n throw new InputError(\n 'No redirectUrl provided in request query parameters',\n );\n }\n res.redirect(state.redirectUrl);\n return undefined;\n }\n // post message back to popup if successful\n return postMessageResponse(res, appOrigin, responseObj);\n } catch (error) {\n const { name, message } = isError(error)\n ? error\n : new Error('Encountered invalid error'); // Being a bit safe and not forwarding the bad value\n // post error message back to popup if failure\n return postMessageResponse(res, appOrigin, {\n type: 'authorization_response',\n error: { name, message },\n });\n }\n }\n\n async logout(req: express.Request, res: express.Response): Promise<void> {\n if (!ensuresXRequestedWith(req)) {\n throw new AuthenticationError('Invalid X-Requested-With header');\n }\n\n if (this.handlers.logout) {\n const refreshToken = this.getRefreshTokenFromCookie(req);\n const revokeRequest: OAuthLogoutRequest = Object.assign(req, {\n refreshToken,\n });\n await this.handlers.logout(revokeRequest);\n }\n\n // remove refresh token cookie if it is set\n const origin = req.get('origin');\n const cookieConfig = this.getCookieConfig(origin);\n this.removeRefreshTokenCookie(res, cookieConfig);\n\n res.status(200).end();\n }\n\n async refresh(req: express.Request, res: express.Response): Promise<void> {\n if (!ensuresXRequestedWith(req)) {\n throw new AuthenticationError('Invalid X-Requested-With header');\n }\n\n if (!this.handlers.refresh) {\n throw new InputError(\n `Refresh token is not supported for provider ${this.options.providerId}`,\n );\n }\n\n try {\n const refreshToken = this.getRefreshTokenFromCookie(req);\n\n // throw error if refresh token is missing in the request\n if (!refreshToken) {\n throw new InputError('Missing session cookie');\n }\n\n let scope = req.query.scope?.toString() ?? '';\n if (this.options.persistScopes) {\n scope = this.getGrantedScopeFromCookie(req);\n }\n const forwardReq = Object.assign(req, { scope, refreshToken });\n\n // get new access_token\n const { response, refreshToken: newRefreshToken } =\n await this.handlers.refresh(forwardReq as OAuthRefreshRequest);\n\n const backstageIdentity = await this.populateIdentity(\n response.backstageIdentity,\n );\n\n if (newRefreshToken && newRefreshToken !== refreshToken) {\n const origin = req.get('origin');\n const cookieConfig = this.getCookieConfig(origin);\n this.setRefreshTokenCookie(res, newRefreshToken, cookieConfig);\n }\n\n res.status(200).json({ ...response, backstageIdentity });\n } catch (error) {\n throw new AuthenticationError('Refresh failed', error);\n }\n }\n\n /**\n * If the response from the OAuth provider includes a Backstage identity, we\n * make sure it's populated with all the information we can derive from the user ID.\n */\n private async populateIdentity(\n identity?: BackstageSignInResult,\n ): Promise<BackstageIdentityResponse | undefined> {\n if (!identity) {\n return undefined;\n }\n if (!identity.token) {\n throw new InputError(`Identity response must return a token`);\n }\n\n return prepareBackstageIdentityResponse(identity);\n }\n\n private setNonceCookie = (\n res: express.Response,\n nonce: string,\n cookieConfig: ReturnType<CookieConfigurer>,\n ) => {\n res.cookie(`${this.options.providerId}-nonce`, nonce, {\n maxAge: TEN_MINUTES_MS,\n ...this.baseCookieOptions,\n ...cookieConfig,\n path: `${cookieConfig.path}/handler`,\n });\n };\n\n private setGrantedScopeCookie = (\n res: express.Response,\n scope: string,\n cookieConfig: ReturnType<CookieConfigurer>,\n ) => {\n res.cookie(`${this.options.providerId}-granted-scope`, scope, {\n maxAge: THOUSAND_DAYS_MS,\n ...this.baseCookieOptions,\n ...cookieConfig,\n });\n };\n\n private getRefreshTokenFromCookie = (req: express.Request) => {\n return req.cookies[`${this.options.providerId}-refresh-token`];\n };\n\n private getGrantedScopeFromCookie = (req: express.Request) => {\n return req.cookies[`${this.options.providerId}-granted-scope`];\n };\n\n private setRefreshTokenCookie = (\n res: express.Response,\n refreshToken: string,\n cookieConfig: ReturnType<CookieConfigurer>,\n ) => {\n res.cookie(`${this.options.providerId}-refresh-token`, refreshToken, {\n maxAge: THOUSAND_DAYS_MS,\n ...this.baseCookieOptions,\n ...cookieConfig,\n });\n };\n\n private removeRefreshTokenCookie = (\n res: express.Response,\n cookieConfig: ReturnType<CookieConfigurer>,\n ) => {\n res.cookie(`${this.options.providerId}-refresh-token`, '', {\n maxAge: 0,\n ...this.baseCookieOptions,\n ...cookieConfig,\n });\n };\n\n private getCookieConfig = (origin?: string) => {\n return this.options.cookieConfigurer({\n providerId: this.options.providerId,\n baseUrl: this.options.baseUrl,\n callbackUrl: this.options.callbackUrl,\n appOrigin: origin ?? this.options.appOrigin,\n });\n };\n}\n"],"names":["URL","defaultCookieConfigurer","InputError","crypto","readState","NotAllowedError","verifyNonce","postMessageResponse","isError","ensuresXRequestedWith","AuthenticationError","prepareBackstageIdentityResponse"],"mappings":";;;;;;;;;;;;;AA+CO,MAAM,gBAAmB,GAAA,GAAA,GAAO,EAAK,GAAA,EAAA,GAAK,EAAK,GAAA;AAC/C,MAAM,iBAAiB,GAAM,GAAA;AAoB7B,MAAM,YAAkD,CAAA;AAAA,EAyB7D,WAAA,CACmB,UACA,OACjB,EAAA;AAFiB,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAEjB,IAAA,IAAA,CAAK,iBAAoB,GAAA;AAAA,MACvB,QAAU,EAAA,IAAA;AAAA,MACV,QAAU,EAAA;AAAA,KACZ;AAAA;AACF,EAhCA,OAAO,UAAA,CACL,MACA,EAAA,QAAA,EACA,OAIc,EAAA;AACd,IAAA,MAAM,EAAE,MAAA,EAAQ,OAAS,EAAA,eAAA,EAAoB,GAAA,MAAA;AAC7C,IAAA,MAAM,EAAE,MAAQ,EAAA,SAAA,E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AG;AAAA,KACJ,CAAA;AAAA,GACH;AAAA,EAEQ,wBAAA,GAA2B,CACjC,GAAA,EACA,YACG,KAAA;AACH,IAAA,GAAA,CAAI,OAAO,CAAG,EAAA,IAAA,CAAK,OAAQ,CAAA,UAAU,kBAAkB,EAAI,EAAA;AAAA,MACzD,MAAQ,EAAA,CAAA;AAAA,MACR,GAAG,IAAK,CAAA,iBAAA;AAAA,MACR,GAAG;AAAA,KACJ,CAAA;AAAA,GACH;AAAA,EAEQ,eAAA,GAAkB,CAAC,MAAoB,KAAA;AAC7C,IAAO,OAAA,IAAA,CAAK,QAAQ,gBAAiB,CAAA;AAAA,MACnC,UAAA,EAAY,KAAK,OAAQ,CAAA,UAAA;AAAA,MACzB,OAAA,EAAS,KAAK,OAAQ,CAAA,OAAA;AAAA,MACtB,WAAA,EAAa,KAAK,OAAQ,CAAA,WAAA;AAAA,MAC1B,SAAA,EAAW,MAAU,IAAA,IAAA,CAAK,OAAQ,CAAA;AAAA,KACnC,CAAA;AAAA,GACH;AACF;;;;;;"}
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var pluginAuthNode = require('@backstage/plugin-auth-node');
4
-
5
- const OAuthEnvironmentHandler = pluginAuthNode.OAuthEnvironmentHandler;
6
-
7
- exports.OAuthEnvironmentHandler = OAuthEnvironmentHandler;
8
- //# sourceMappingURL=OAuthEnvironmentHandler.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OAuthEnvironmentHandler.cjs.js","sources":["../../../src/lib/oauth/OAuthEnvironmentHandler.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { OAuthEnvironmentHandler as _OAuthEnvironmentHandler } from '@backstage/plugin-auth-node';\n\n/**\n * @public\n * @deprecated import from `@backstage/plugin-auth-node` instead\n */\nexport const OAuthEnvironmentHandler = _OAuthEnvironmentHandler;\n"],"names":["_OAuthEnvironmentHandler"],"mappings":";;;;AAsBO,MAAM,uBAA0B,GAAAA;;;;"}
@@ -1,40 +0,0 @@
1
- 'use strict';
2
-
3
- var pluginAuthNode = require('@backstage/plugin-auth-node');
4
-
5
- const readState = pluginAuthNode.decodeOAuthState;
6
- const encodeState = pluginAuthNode.encodeOAuthState;
7
- const verifyNonce = (req, providerId) => {
8
- const cookieNonce = req.cookies[`${providerId}-nonce`];
9
- const state = readState(req.query.state?.toString() ?? "");
10
- const stateNonce = state.nonce;
11
- if (!cookieNonce) {
12
- throw new Error("Auth response is missing cookie nonce");
13
- }
14
- if (stateNonce.length === 0) {
15
- throw new Error("Auth response is missing state nonce");
16
- }
17
- if (cookieNonce !== stateNonce) {
18
- throw new Error("Invalid nonce");
19
- }
20
- };
21
- const defaultCookieConfigurer = ({
22
- callbackUrl,
23
- providerId,
24
- appOrigin
25
- }) => {
26
- const { hostname: domain, pathname, protocol } = new URL(callbackUrl);
27
- const secure = protocol === "https:";
28
- let sameSite = "lax";
29
- if (new URL(appOrigin).hostname !== domain && secure) {
30
- sameSite = "none";
31
- }
32
- const path = pathname.endsWith(`${providerId}/handler/frame`) ? pathname.slice(0, -"/handler/frame".length) : `${pathname}/${providerId}`;
33
- return { domain, path, secure, sameSite };
34
- };
35
-
36
- exports.defaultCookieConfigurer = defaultCookieConfigurer;
37
- exports.encodeState = encodeState;
38
- exports.readState = readState;
39
- exports.verifyNonce = verifyNonce;
40
- //# sourceMappingURL=helpers.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.cjs.js","sources":["../../../src/lib/oauth/helpers.ts"],"sourcesContent":["/*\n * Copyright 2020 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 express from 'express';\nimport {\n CookieConfigurer,\n OAuthState,\n decodeOAuthState,\n encodeOAuthState,\n} from '@backstage/plugin-auth-node';\n\n/**\n * @public\n * @deprecated Use `decodeOAuthState` from `@backstage/plugin-auth-node` instead\n */\nexport const readState = decodeOAuthState;\n\n/**\n * @public\n * @deprecated Use `encodeOAuthState` from `@backstage/plugin-auth-node` instead\n */\nexport const encodeState = encodeOAuthState;\n\n/**\n * @public\n * @deprecated Use inline logic to make sure the session and state nonce matches instead.\n */\nexport const verifyNonce = (req: express.Request, providerId: string) => {\n const cookieNonce = req.cookies[`${providerId}-nonce`];\n const state: OAuthState = readState(req.query.state?.toString() ?? '');\n const stateNonce = state.nonce;\n\n if (!cookieNonce) {\n throw new Error('Auth response is missing cookie nonce');\n }\n if (stateNonce.length === 0) {\n throw new Error('Auth response is missing state nonce');\n }\n if (cookieNonce !== stateNonce) {\n throw new Error('Invalid nonce');\n }\n};\n\nexport const defaultCookieConfigurer: CookieConfigurer = ({\n callbackUrl,\n providerId,\n appOrigin,\n}) => {\n const { hostname: domain, pathname, protocol } = new URL(callbackUrl);\n const secure = protocol === 'https:';\n\n // For situations where the auth-backend is running on a\n // different domain than the app, we set the SameSite attribute\n // to 'none' to allow third-party access to the cookie, but\n // only if it's in a secure context (https).\n let sameSite: ReturnType<CookieConfigurer>['sameSite'] = 'lax';\n if (new URL(appOrigin).hostname !== domain && secure) {\n sameSite = 'none';\n }\n\n // If the provider supports callbackUrls, the pathname will\n // contain the complete path to the frame handler so we need\n // to slice off the trailing part of the path.\n const path = pathname.endsWith(`${providerId}/handler/frame`)\n ? pathname.slice(0, -'/handler/frame'.length)\n : `${pathname}/${providerId}`;\n\n return { domain, path, secure, sameSite };\n};\n"],"names":["decodeOAuthState","encodeOAuthState"],"mappings":";;;;AA4BO,MAAM,SAAY,GAAAA;AAMlB,MAAM,WAAc,GAAAC;AAMd,MAAA,WAAA,GAAc,CAAC,GAAA,EAAsB,UAAuB,KAAA;AACvE,EAAA,MAAM,WAAc,GAAA,GAAA,CAAI,OAAQ,CAAA,CAAA,EAAG,UAAU,CAAQ,MAAA,CAAA,CAAA;AACrD,EAAA,MAAM,QAAoB,SAAU,CAAA,GAAA,CAAI,MAAM,KAAO,EAAA,QAAA,MAAc,EAAE,CAAA;AACrE,EAAA,MAAM,aAAa,KAAM,CAAA,KAAA;AAEzB,EAAA,IAAI,CAAC,WAAa,EAAA;AAChB,IAAM,MAAA,IAAI,MAAM,uCAAuC,CAAA;AAAA;AAEzD,EAAI,IAAA,UAAA,CAAW,WAAW,CAAG,EAAA;AAC3B,IAAM,MAAA,IAAI,MAAM,sCAAsC,CAAA;AAAA;AAExD,EAAA,IAAI,gBAAgB,UAAY,EAAA;AAC9B,IAAM,MAAA,IAAI,MAAM,eAAe,CAAA;AAAA;AAEnC;AAEO,MAAM,0BAA4C,CAAC;AAAA,EACxD,WAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EAAM,MAAA,EAAE,UAAU,MAAQ,EAAA,QAAA,EAAU,UAAa,GAAA,IAAI,IAAI,WAAW,CAAA;AACpE,EAAA,MAAM,SAAS,QAAa,KAAA,QAAA;AAM5B,EAAA,IAAI,QAAqD,GAAA,KAAA;AACzD,EAAA,IAAI,IAAI,GAAI,CAAA,SAAS,CAAE,CAAA,QAAA,KAAa,UAAU,MAAQ,EAAA;AACpD,IAAW,QAAA,GAAA,MAAA;AAAA;AAMb,EAAA,MAAM,OAAO,QAAS,CAAA,QAAA,CAAS,CAAG,EAAA,UAAU,gBAAgB,CACxD,GAAA,QAAA,CAAS,KAAM,CAAA,CAAA,EAAG,CAAC,gBAAiB,CAAA,MAAM,IAC1C,CAAG,EAAA,QAAQ,IAAI,UAAU,CAAA,CAAA;AAE7B,EAAA,OAAO,EAAE,MAAA,EAAQ,IAAM,EAAA,MAAA,EAAQ,QAAS,EAAA;AAC1C;;;;;;;"}
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- require('jose');
4
- require('@backstage/errors');
5
-
6
- const executeRedirectStrategy = async (req, providerStrategy, options) => {
7
- return new Promise((resolve) => {
8
- const strategy = Object.create(providerStrategy);
9
- strategy.redirect = (url, status) => {
10
- resolve({ url, status: status ?? void 0 });
11
- };
12
- strategy.authenticate(req, { ...options });
13
- });
14
- };
15
- const executeFrameHandlerStrategy = async (req, providerStrategy, options) => {
16
- return new Promise(
17
- (resolve, reject) => {
18
- const strategy = Object.create(providerStrategy);
19
- strategy.success = (result, privateInfo) => {
20
- resolve({ result, privateInfo });
21
- };
22
- strategy.fail = (info) => {
23
- reject(new Error(`Authentication rejected, ${info.message ?? ""}`));
24
- };
25
- strategy.error = (error) => {
26
- let message = `Authentication failed, ${error.message}`;
27
- if (error.oauthError?.data) {
28
- try {
29
- const errorData = JSON.parse(error.oauthError.data);
30
- if (errorData.message) {
31
- message += ` - ${errorData.message}`;
32
- }
33
- } catch (parseError) {
34
- message += ` - ${error.oauthError}`;
35
- }
36
- }
37
- reject(new Error(message));
38
- };
39
- strategy.redirect = () => {
40
- reject(new Error("Unexpected redirect"));
41
- };
42
- strategy.authenticate(req, { ...{} });
43
- }
44
- );
45
- };
46
-
47
- exports.executeFrameHandlerStrategy = executeFrameHandlerStrategy;
48
- exports.executeRedirectStrategy = executeRedirectStrategy;
49
- //# sourceMappingURL=PassportStrategyHelper.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PassportStrategyHelper.cjs.js","sources":["../../../src/lib/passport/PassportStrategyHelper.ts"],"sourcesContent":["/*\n * Copyright 2020 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 express from 'express';\nimport passport from 'passport';\nimport { decodeJwt } from 'jose';\nimport { InternalOAuthError } from 'passport-oauth2';\nimport { ProfileInfo } from '@backstage/plugin-auth-node';\nimport { PassportProfile } from './types';\nimport { OAuthStartResponse } from '../../providers/types';\nimport { ForwardedError } from '@backstage/errors';\n\nexport type PassportDoneCallback<Res, Private = never> = (\n err?: Error,\n response?: Res,\n privateInfo?: Private,\n) => void;\n\nexport const makeProfileInfo = (\n profile: PassportProfile,\n idToken?: string,\n): ProfileInfo => {\n let email: string | undefined = undefined;\n if (profile.emails && profile.emails.length > 0) {\n const [firstEmail] = profile.emails;\n email = firstEmail.value;\n }\n\n let picture: string | undefined = undefined;\n if (profile.avatarUrl) {\n picture = profile.avatarUrl;\n } else if (profile.photos && profile.photos.length > 0) {\n const [firstPhoto] = profile.photos;\n picture = firstPhoto.value;\n }\n\n let displayName: string | undefined =\n profile.displayName ?? profile.username ?? profile.id;\n\n if ((!email || !picture || !displayName) && idToken) {\n try {\n const decoded = decodeJwt(idToken) as {\n email?: string;\n name?: string;\n picture?: string;\n };\n if (!email && decoded.email) {\n email = decoded.email;\n }\n if (!picture && decoded.picture) {\n picture = decoded.picture;\n }\n if (!displayName && decoded.name) {\n displayName = decoded.name;\n }\n } catch (e) {\n throw new ForwardedError(\n `Failed to parse id token and get profile info`,\n e,\n );\n }\n }\n\n return {\n email,\n picture,\n displayName,\n };\n};\n\nexport const executeRedirectStrategy = async (\n req: express.Request,\n providerStrategy: passport.Strategy,\n options: Record<string, string>,\n): Promise<OAuthStartResponse> => {\n return new Promise(resolve => {\n const strategy = Object.create(providerStrategy);\n strategy.redirect = (url: string, status?: number) => {\n resolve({ url, status: status ?? undefined });\n };\n\n strategy.authenticate(req, { ...options });\n });\n};\n\nexport const executeFrameHandlerStrategy = async <Result, PrivateInfo = never>(\n req: express.Request,\n providerStrategy: passport.Strategy,\n options?: Record<string, string>,\n) => {\n return new Promise<{ result: Result; privateInfo: PrivateInfo }>(\n (resolve, reject) => {\n const strategy = Object.create(providerStrategy);\n strategy.success = (result: any, privateInfo: any) => {\n resolve({ result, privateInfo });\n };\n strategy.fail = (\n info: { type: 'success' | 'error'; message?: string },\n // _status: number,\n ) => {\n reject(new Error(`Authentication rejected, ${info.message ?? ''}`));\n };\n strategy.error = (error: InternalOAuthError) => {\n let message = `Authentication failed, ${error.message}`;\n\n if (error.oauthError?.data) {\n try {\n const errorData = JSON.parse(error.oauthError.data);\n\n if (errorData.message) {\n message += ` - ${errorData.message}`;\n }\n } catch (parseError) {\n message += ` - ${error.oauthError}`;\n }\n }\n\n reject(new Error(message));\n };\n strategy.redirect = () => {\n reject(new Error('Unexpected redirect'));\n };\n strategy.authenticate(req, { ...(options ?? {}) });\n },\n );\n};\n\ntype RefreshTokenResponse = {\n /**\n * An access token issued for the signed in user.\n */\n accessToken: string;\n /**\n * Optionally, the server can issue a new Refresh Token for the user\n */\n refreshToken?: string;\n params: any;\n};\n\nexport const executeRefreshTokenStrategy = async (\n providerStrategy: passport.Strategy,\n refreshToken: string,\n scope: string,\n): Promise<RefreshTokenResponse> => {\n return new Promise((resolve, reject) => {\n const anyStrategy = providerStrategy as any;\n const OAuth2 = anyStrategy._oauth2.constructor;\n const oauth2 = new OAuth2(\n anyStrategy._oauth2._clientId,\n anyStrategy._oauth2._clientSecret,\n anyStrategy._oauth2._baseSite,\n anyStrategy._oauth2._authorizeUrl,\n anyStrategy._refreshURL || anyStrategy._oauth2._accessTokenUrl,\n anyStrategy._oauth2._customHeaders,\n );\n\n oauth2.getOAuthAccessToken(\n refreshToken,\n {\n scope,\n grant_type: 'refresh_token',\n },\n (\n err: Error | null,\n accessToken: string,\n newRefreshToken: string,\n params: any,\n ) => {\n if (err) {\n reject(new ForwardedError(`Failed to refresh access token`, err));\n }\n if (!accessToken) {\n reject(\n new Error(\n `Failed to refresh access token, no access token received`,\n ),\n );\n }\n\n resolve({\n accessToken,\n refreshToken: newRefreshToken,\n params,\n });\n },\n );\n });\n};\n\ntype ProviderStrategy = {\n userProfile(accessToken: string, callback: Function): void;\n};\n\nexport const executeFetchUserProfileStrategy = async (\n providerStrategy: passport.Strategy,\n accessToken: string,\n): Promise<PassportProfile> => {\n return new Promise((resolve, reject) => {\n const anyStrategy = providerStrategy as unknown as ProviderStrategy;\n anyStrategy.userProfile(\n accessToken,\n (error: Error, rawProfile: PassportProfile) => {\n if (error) {\n reject(error);\n } else {\n resolve(rawProfile);\n }\n },\n );\n });\n};\n"],"names":[],"mappings":";;;;;AAmFO,MAAM,uBAA0B,GAAA,OACrC,GACA,EAAA,gBAAA,EACA,OACgC,KAAA;AAChC,EAAO,OAAA,IAAI,QAAQ,CAAW,OAAA,KAAA;AAC5B,IAAM,MAAA,QAAA,GAAW,MAAO,CAAA,MAAA,CAAO,gBAAgB,CAAA;AAC/C,IAAS,QAAA,CAAA,QAAA,GAAW,CAAC,GAAA,EAAa,MAAoB,KAAA;AACpD,MAAA,OAAA,CAAQ,EAAE,GAAA,EAAK,MAAQ,EAAA,MAAA,IAAU,QAAW,CAAA;AAAA,KAC9C;AAEA,IAAA,QAAA,CAAS,YAAa,CAAA,GAAA,EAAK,EAAE,GAAG,SAAS,CAAA;AAAA,GAC1C,CAAA;AACH;AAEO,MAAM,2BAA8B,GAAA,OACzC,GACA,EAAA,gBAAA,EACA,OACG,KAAA;AACH,EAAA,OAAO,IAAI,OAAA;AAAA,IACT,CAAC,SAAS,MAAW,KAAA;AACnB,MAAM,MAAA,QAAA,GAAW,MAAO,CAAA,MAAA,CAAO,gBAAgB,CAAA;AAC/C,MAAS,QAAA,CAAA,OAAA,GAAU,CAAC,MAAA,EAAa,WAAqB,KAAA;AACpD,QAAQ,OAAA,CAAA,EAAE,MAAQ,EAAA,WAAA,EAAa,CAAA;AAAA,OACjC;AACA,MAAS,QAAA,CAAA,IAAA,GAAO,CACd,IAEG,KAAA;AACH,QAAA,MAAA,CAAO,IAAI,KAAM,CAAA,CAAA,yBAAA,EAA4B,KAAK,OAAW,IAAA,EAAE,EAAE,CAAC,CAAA;AAAA,OACpE;AACA,MAAS,QAAA,CAAA,KAAA,GAAQ,CAAC,KAA8B,KAAA;AAC9C,QAAI,IAAA,OAAA,GAAU,CAA0B,uBAAA,EAAA,KAAA,CAAM,OAAO,CAAA,CAAA;AAErD,QAAI,IAAA,KAAA,CAAM,YAAY,IAAM,EAAA;AAC1B,UAAI,IAAA;AACF,YAAA,MAAM,SAAY,GAAA,IAAA,CAAK,KAAM,CAAA,KAAA,CAAM,WAAW,IAAI,CAAA;AAElD,YAAA,IAAI,UAAU,OAAS,EAAA;AACrB,cAAW,OAAA,IAAA,CAAA,GAAA,EAAM,UAAU,OAAO,CAAA,CAAA;AAAA;AACpC,mBACO,UAAY,EAAA;AACnB,YAAW,OAAA,IAAA,CAAA,GAAA,EAAM,MAAM,UAAU,CAAA,CAAA;AAAA;AACnC;AAGF,QAAO,MAAA,CAAA,IAAI,KAAM,CAAA,OAAO,CAAC,CAAA;AAAA,OAC3B;AACA,MAAA,QAAA,CAAS,WAAW,MAAM;AACxB,QAAO,MAAA,CAAA,IAAI,KAAM,CAAA,qBAAqB,CAAC,CAAA;AAAA,OACzC;AACA,MAAA,QAAA,CAAS,aAAa,GAAK,EAAA,EAAE,GAAe,IAAK,CAAA;AAAA;AACnD,GACF;AACF;;;;;"}
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- var pluginAuthBackendModuleAtlassianProvider = require('@backstage/plugin-auth-backend-module-atlassian-provider');
4
- var pluginAuthNode = require('@backstage/plugin-auth-node');
5
- var adaptLegacyOAuthHandler = require('../../lib/legacy/adaptLegacyOAuthHandler.cjs.js');
6
- var adaptLegacyOAuthSignInResolver = require('../../lib/legacy/adaptLegacyOAuthSignInResolver.cjs.js');
7
- var createAuthProviderIntegration = require('../createAuthProviderIntegration.cjs.js');
8
-
9
- const atlassian = createAuthProviderIntegration.createAuthProviderIntegration({
10
- create(options) {
11
- return pluginAuthNode.createOAuthProviderFactory({
12
- authenticator: pluginAuthBackendModuleAtlassianProvider.atlassianAuthenticator,
13
- profileTransform: adaptLegacyOAuthHandler.adaptLegacyOAuthHandler(options?.authHandler),
14
- signInResolver: adaptLegacyOAuthSignInResolver.adaptLegacyOAuthSignInResolver(options?.signIn?.resolver)
15
- });
16
- }
17
- });
18
-
19
- exports.atlassian = atlassian;
20
- //# sourceMappingURL=provider.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.cjs.js","sources":["../../../src/providers/atlassian/provider.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { atlassianAuthenticator } from '@backstage/plugin-auth-backend-module-atlassian-provider';\nimport {\n SignInResolver,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport {\n adaptLegacyOAuthHandler,\n adaptLegacyOAuthSignInResolver,\n} from '../../lib/legacy';\nimport { OAuthResult } from '../../lib/oauth';\nimport { createAuthProviderIntegration } from '../createAuthProviderIntegration';\nimport { AuthHandler } from '../types';\n\n/**\n * Auth provider integration for Atlassian auth\n *\n * @public\n * @deprecated Migrate the auth plugin to the new backend system https://backstage.io/docs/backend-system/building-backends/migrating#the-auth-plugin\n */\nexport const atlassian = createAuthProviderIntegration({\n create(options?: {\n /**\n * The profile transformation function used to verify and convert the auth response\n * into the profile that will be presented to the user.\n */\n authHandler?: AuthHandler<OAuthResult>;\n\n /**\n * Configure sign-in for this provider, without it the provider can not be used to sign users in.\n */\n signIn?: {\n resolver: SignInResolver<OAuthResult>;\n };\n }) {\n return createOAuthProviderFactory({\n authenticator: atlassianAuthenticator,\n profileTransform: adaptLegacyOAuthHandler(options?.authHandler),\n signInResolver: adaptLegacyOAuthSignInResolver(options?.signIn?.resolver),\n });\n },\n});\n"],"names":["createAuthProviderIntegration","createOAuthProviderFactory","atlassianAuthenticator","adaptLegacyOAuthHandler","adaptLegacyOAuthSignInResolver"],"mappings":";;;;;;;;AAmCO,MAAM,YAAYA,2DAA8B,CAAA;AAAA,EACrD,OAAO,OAaJ,EAAA;AACD,IAAA,OAAOC,yCAA2B,CAAA;AAAA,MAChC,aAAe,EAAAC,+DAAA;AAAA,MACf,gBAAA,EAAkBC,+CAAwB,CAAA,OAAA,EAAS,WAAW,CAAA;AAAA,MAC9D,cAAgB,EAAAC,6DAAA,CAA+B,OAAS,EAAA,MAAA,EAAQ,QAAQ;AAAA,KACzE,CAAA;AAAA;AAEL,CAAC;;;;"}
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- var createAuthProviderIntegration = require('../createAuthProviderIntegration.cjs.js');
4
- var pluginAuthNode = require('@backstage/plugin-auth-node');
5
- var adaptLegacyOAuthHandler = require('../../lib/legacy/adaptLegacyOAuthHandler.cjs.js');
6
- var adaptLegacyOAuthSignInResolver = require('../../lib/legacy/adaptLegacyOAuthSignInResolver.cjs.js');
7
- var pluginAuthBackendModuleAuth0Provider = require('@backstage/plugin-auth-backend-module-auth0-provider');
8
-
9
- const auth0 = createAuthProviderIntegration.createAuthProviderIntegration({
10
- create(options) {
11
- return pluginAuthNode.createOAuthProviderFactory({
12
- authenticator: pluginAuthBackendModuleAuth0Provider.auth0Authenticator,
13
- profileTransform: adaptLegacyOAuthHandler.adaptLegacyOAuthHandler(options?.authHandler),
14
- signInResolver: adaptLegacyOAuthSignInResolver.adaptLegacyOAuthSignInResolver(options?.signIn?.resolver)
15
- });
16
- }
17
- });
18
-
19
- exports.auth0 = auth0;
20
- //# sourceMappingURL=provider.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.cjs.js","sources":["../../../src/providers/auth0/provider.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { OAuthProviderOptions, OAuthResult } from '../../lib/oauth';\n\nimport { AuthHandler } from '../types';\nimport { createAuthProviderIntegration } from '../createAuthProviderIntegration';\nimport {\n AuthResolverContext,\n createOAuthProviderFactory,\n SignInResolver,\n} from '@backstage/plugin-auth-node';\nimport {\n adaptLegacyOAuthHandler,\n adaptLegacyOAuthSignInResolver,\n} from '../../lib/legacy';\nimport { auth0Authenticator } from '@backstage/plugin-auth-backend-module-auth0-provider';\n\n/**\n * @public\n * @deprecated The Auth0 auth provider was extracted to `@backstage/plugin-auth-backend-module-auth0-provider`.\n */\nexport type Auth0AuthProviderOptions = OAuthProviderOptions & {\n domain: string;\n signInResolver?: SignInResolver<OAuthResult>;\n authHandler: AuthHandler<OAuthResult>;\n resolverContext: AuthResolverContext;\n audience?: string;\n connection?: string;\n connectionScope?: string;\n};\n\n/**\n * Auth provider integration for auth0 auth\n *\n * @public\n * @deprecated Migrate the auth plugin to the new backend system https://backstage.io/docs/backend-system/building-backends/migrating#the-auth-plugin\n */\nexport const auth0 = createAuthProviderIntegration({\n create(options?: {\n /**\n * The profile transformation function used to verify and convert the auth response\n * into the profile that will be presented to the user.\n */\n authHandler?: AuthHandler<OAuthResult>;\n\n /**\n * Configure sign-in for this provider, without it the provider can not be used to sign users in.\n */\n signIn?: {\n /**\n * Maps an auth result to a Backstage identity for the user.\n */\n resolver: SignInResolver<OAuthResult>;\n };\n }) {\n return createOAuthProviderFactory({\n authenticator: auth0Authenticator,\n profileTransform: adaptLegacyOAuthHandler(options?.authHandler),\n signInResolver: adaptLegacyOAuthSignInResolver(options?.signIn?.resolver),\n });\n },\n});\n"],"names":["createAuthProviderIntegration","createOAuthProviderFactory","auth0Authenticator","adaptLegacyOAuthHandler","adaptLegacyOAuthSignInResolver"],"mappings":";;;;;;;;AAmDO,MAAM,QAAQA,2DAA8B,CAAA;AAAA,EACjD,OAAO,OAgBJ,EAAA;AACD,IAAA,OAAOC,yCAA2B,CAAA;AAAA,MAChC,aAAe,EAAAC,uDAAA;AAAA,MACf,gBAAA,EAAkBC,+CAAwB,CAAA,OAAA,EAAS,WAAW,CAAA;AAAA,MAC9D,cAAgB,EAAAC,6DAAA,CAA+B,OAAS,EAAA,MAAA,EAAQ,QAAQ;AAAA,KACzE,CAAA;AAAA;AAEL,CAAC;;;;"}
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- var pluginAuthBackendModuleAwsAlbProvider = require('@backstage/plugin-auth-backend-module-aws-alb-provider');
4
- var pluginAuthNode = require('@backstage/plugin-auth-node');
5
- var createAuthProviderIntegration = require('../createAuthProviderIntegration.cjs.js');
6
-
7
- const awsAlb = createAuthProviderIntegration.createAuthProviderIntegration({
8
- create(options) {
9
- return pluginAuthNode.createProxyAuthProviderFactory({
10
- authenticator: pluginAuthBackendModuleAwsAlbProvider.awsAlbAuthenticator,
11
- profileTransform: options?.authHandler,
12
- signInResolver: options?.signIn?.resolver
13
- });
14
- }
15
- });
16
-
17
- exports.awsAlb = awsAlb;
18
- //# sourceMappingURL=provider.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.cjs.js","sources":["../../../src/providers/aws-alb/provider.ts"],"sourcesContent":["/*\n * Copyright 2021 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 {\n AwsAlbResult,\n awsAlbAuthenticator,\n} from '@backstage/plugin-auth-backend-module-aws-alb-provider';\nimport {\n SignInResolver,\n createProxyAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { AuthHandler } from '../types';\nimport { createAuthProviderIntegration } from '../createAuthProviderIntegration';\n\n/**\n * Auth provider integration for AWS ALB auth\n *\n * @public\n * @deprecated Migrate the auth plugin to the new backend system https://backstage.io/docs/backend-system/building-backends/migrating#the-auth-plugin\n */\nexport const awsAlb = createAuthProviderIntegration({\n create(options?: {\n /**\n * The profile transformation function used to verify and convert the auth\n * response into the profile that will be presented to the user. The default\n * implementation just provides the authenticated email that the IAP\n * presented.\n */\n authHandler?: AuthHandler<AwsAlbResult>;\n /**\n * Configures sign-in for this provider.\n */\n signIn: {\n /**\n * Maps an auth result to a Backstage identity for the user.\n */\n resolver: SignInResolver<AwsAlbResult>;\n };\n }) {\n return createProxyAuthProviderFactory({\n authenticator: awsAlbAuthenticator,\n profileTransform: options?.authHandler,\n signInResolver: options?.signIn?.resolver,\n });\n },\n});\n"],"names":["createAuthProviderIntegration","createProxyAuthProviderFactory","awsAlbAuthenticator"],"mappings":";;;;;;AAiCO,MAAM,SAASA,2DAA8B,CAAA;AAAA,EAClD,OAAO,OAiBJ,EAAA;AACD,IAAA,OAAOC,6CAA+B,CAAA;AAAA,MACpC,aAAe,EAAAC,yDAAA;AAAA,MACf,kBAAkB,OAAS,EAAA,WAAA;AAAA,MAC3B,cAAA,EAAgB,SAAS,MAAQ,EAAA;AAAA,KAClC,CAAA;AAAA;AAEL,CAAC;;;;"}
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- var pluginAuthNode = require('@backstage/plugin-auth-node');
4
- var createAuthProviderIntegration = require('../createAuthProviderIntegration.cjs.js');
5
- var pluginAuthBackendModuleAzureEasyauthProvider = require('@backstage/plugin-auth-backend-module-azure-easyauth-provider');
6
-
7
- const easyAuth = createAuthProviderIntegration.createAuthProviderIntegration({
8
- create(options) {
9
- return pluginAuthNode.createProxyAuthProviderFactory({
10
- authenticator: pluginAuthBackendModuleAzureEasyauthProvider.azureEasyAuthAuthenticator,
11
- profileTransform: options?.authHandler,
12
- signInResolver: options?.signIn?.resolver
13
- });
14
- }
15
- });
16
-
17
- exports.easyAuth = easyAuth;
18
- //# sourceMappingURL=provider.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.cjs.js","sources":["../../../src/providers/azure-easyauth/provider.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {\n SignInResolver,\n createProxyAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { AuthHandler } from '../types';\nimport { createAuthProviderIntegration } from '../createAuthProviderIntegration';\nimport {\n AzureEasyAuthResult,\n azureEasyAuthAuthenticator,\n} from '@backstage/plugin-auth-backend-module-azure-easyauth-provider';\n\n/**\n * Auth provider integration for Azure EasyAuth\n *\n * @public\n * @deprecated Migrate the auth plugin to the new backend system https://backstage.io/docs/backend-system/building-backends/migrating#the-auth-plugin\n */\nexport const easyAuth = createAuthProviderIntegration({\n create(options?: {\n /**\n * The profile transformation function used to verify and convert the auth response\n * into the profile that will be presented to the user.\n */\n authHandler?: AuthHandler<AzureEasyAuthResult>;\n\n /**\n * Configure sign-in for this provider, without it the provider can not be used to sign users in.\n */\n signIn: {\n /**\n * Maps an auth result to a Backstage identity for the user.\n */\n resolver: SignInResolver<AzureEasyAuthResult>;\n };\n }) {\n return createProxyAuthProviderFactory({\n authenticator: azureEasyAuthAuthenticator,\n profileTransform: options?.authHandler,\n signInResolver: options?.signIn?.resolver,\n });\n },\n});\n"],"names":["createAuthProviderIntegration","createProxyAuthProviderFactory","azureEasyAuthAuthenticator"],"mappings":";;;;;;AAiCO,MAAM,WAAWA,2DAA8B,CAAA;AAAA,EACpD,OAAO,OAgBJ,EAAA;AACD,IAAA,OAAOC,6CAA+B,CAAA;AAAA,MACpC,aAAe,EAAAC,uEAAA;AAAA,MACf,kBAAkB,OAAS,EAAA,WAAA;AAAA,MAC3B,cAAA,EAAgB,SAAS,MAAQ,EAAA;AAAA,KAClC,CAAA;AAAA;AAEL,CAAC;;;;"}
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- var pluginAuthBackendModuleBitbucketProvider = require('@backstage/plugin-auth-backend-module-bitbucket-provider');
4
- var pluginAuthNode = require('@backstage/plugin-auth-node');
5
- var adaptLegacyOAuthHandler = require('../../lib/legacy/adaptLegacyOAuthHandler.cjs.js');
6
- var adaptLegacyOAuthSignInResolver = require('../../lib/legacy/adaptLegacyOAuthSignInResolver.cjs.js');
7
- var adaptOAuthSignInResolverToLegacy = require('../../lib/legacy/adaptOAuthSignInResolverToLegacy.cjs.js');
8
- var createAuthProviderIntegration = require('../createAuthProviderIntegration.cjs.js');
9
-
10
- const bitbucket = createAuthProviderIntegration.createAuthProviderIntegration({
11
- create(options) {
12
- return pluginAuthNode.createOAuthProviderFactory({
13
- authenticator: pluginAuthBackendModuleBitbucketProvider.bitbucketAuthenticator,
14
- profileTransform: adaptLegacyOAuthHandler.adaptLegacyOAuthHandler(options?.authHandler),
15
- signInResolver: adaptLegacyOAuthSignInResolver.adaptLegacyOAuthSignInResolver(options?.signIn?.resolver)
16
- });
17
- },
18
- resolvers: adaptOAuthSignInResolverToLegacy.adaptOAuthSignInResolverToLegacy({
19
- userIdMatchingUserEntityAnnotation: pluginAuthBackendModuleBitbucketProvider.bitbucketSignInResolvers.userIdMatchingUserEntityAnnotation(),
20
- usernameMatchingUserEntityAnnotation: pluginAuthBackendModuleBitbucketProvider.bitbucketSignInResolvers.usernameMatchingUserEntityAnnotation()
21
- })
22
- });
23
-
24
- exports.bitbucket = bitbucket;
25
- //# sourceMappingURL=provider.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.cjs.js","sources":["../../../src/providers/bitbucket/provider.ts"],"sourcesContent":["/*\n * Copyright 2020 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 {\n bitbucketAuthenticator,\n bitbucketSignInResolvers,\n} from '@backstage/plugin-auth-backend-module-bitbucket-provider';\nimport {\n SignInResolver,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { Profile as PassportProfile } from 'passport';\nimport {\n adaptLegacyOAuthHandler,\n adaptLegacyOAuthSignInResolver,\n adaptOAuthSignInResolverToLegacy,\n} from '../../lib/legacy';\nimport { OAuthResult } from '../../lib/oauth';\nimport { createAuthProviderIntegration } from '../createAuthProviderIntegration';\nimport { AuthHandler } from '../types';\n\n/**\n * @public\n * @deprecated The Bitbucket auth provider was extracted to `@backstage/plugin-auth-backend-module-bitbucket-provider`.\n */\nexport type BitbucketOAuthResult = {\n fullProfile: BitbucketPassportProfile;\n params: {\n id_token?: string;\n scope: string;\n expires_in: number;\n };\n accessToken: string;\n refreshToken?: string;\n};\n\n/**\n * @public\n * @deprecated The Bitbucket auth provider was extracted to `@backstage/plugin-auth-backend-module-bitbucket-provider`.\n */\nexport type BitbucketPassportProfile = PassportProfile & {\n id?: string;\n displayName?: string;\n username?: string;\n avatarUrl?: string;\n _json?: {\n links?: {\n avatar?: {\n href?: string;\n };\n };\n };\n};\n\n/**\n * Auth provider integration for Bitbucket auth\n *\n * @public\n * @deprecated Migrate the auth plugin to the new backend system https://backstage.io/docs/backend-system/building-backends/migrating#the-auth-plugin\n */\nexport const bitbucket = createAuthProviderIntegration({\n create(options?: {\n /**\n * The profile transformation function used to verify and convert the auth response\n * into the profile that will be presented to the user.\n */\n authHandler?: AuthHandler<OAuthResult>;\n\n /**\n * Configure sign-in for this provider, without it the provider can not be used to sign users in.\n */\n signIn?: {\n resolver: SignInResolver<OAuthResult>;\n };\n }) {\n return createOAuthProviderFactory({\n authenticator: bitbucketAuthenticator,\n profileTransform: adaptLegacyOAuthHandler(options?.authHandler),\n signInResolver: adaptLegacyOAuthSignInResolver(options?.signIn?.resolver),\n });\n },\n resolvers: adaptOAuthSignInResolverToLegacy({\n userIdMatchingUserEntityAnnotation:\n bitbucketSignInResolvers.userIdMatchingUserEntityAnnotation(),\n usernameMatchingUserEntityAnnotation:\n bitbucketSignInResolvers.usernameMatchingUserEntityAnnotation(),\n }),\n});\n"],"names":["createAuthProviderIntegration","createOAuthProviderFactory","bitbucketAuthenticator","adaptLegacyOAuthHandler","adaptLegacyOAuthSignInResolver","adaptOAuthSignInResolverToLegacy","bitbucketSignInResolvers"],"mappings":";;;;;;;;;AAyEO,MAAM,YAAYA,2DAA8B,CAAA;AAAA,EACrD,OAAO,OAaJ,EAAA;AACD,IAAA,OAAOC,yCAA2B,CAAA;AAAA,MAChC,aAAe,EAAAC,+DAAA;AAAA,MACf,gBAAA,EAAkBC,+CAAwB,CAAA,OAAA,EAAS,WAAW,CAAA;AAAA,MAC9D,cAAgB,EAAAC,6DAAA,CAA+B,OAAS,EAAA,MAAA,EAAQ,QAAQ;AAAA,KACzE,CAAA;AAAA,GACH;AAAA,EACA,WAAWC,iEAAiC,CAAA;AAAA,IAC1C,kCAAA,EACEC,kEAAyB,kCAAmC,EAAA;AAAA,IAC9D,oCAAA,EACEA,kEAAyB,oCAAqC;AAAA,GACjE;AACH,CAAC;;;;"}