@backstage/plugin-auth-backend 0.20.1-next.0 → 0.20.1-next.2

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 CHANGED
@@ -1,5 +1,55 @@
1
1
  # @backstage/plugin-auth-backend
2
2
 
3
+ ## 0.20.1-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 783797a: fix static token issuer not being able to initialize
8
+ - a62764b: Updated dependency `passport` to `^0.7.0`.
9
+ - Updated dependencies
10
+ - @backstage/plugin-auth-backend-module-oauth2-proxy-provider@0.1.0-next.1
11
+ - @backstage/plugin-catalog-node@1.6.0-next.2
12
+ - @backstage/backend-common@0.20.0-next.2
13
+ - @backstage/plugin-auth-backend-module-atlassian-provider@0.1.0-next.2
14
+ - @backstage/plugin-auth-backend-module-gitlab-provider@0.1.5-next.2
15
+ - @backstage/plugin-auth-backend-module-oauth2-provider@0.1.5-next.2
16
+ - @backstage/plugin-auth-backend-module-okta-provider@0.0.1-next.2
17
+ - @backstage/plugin-auth-node@0.4.2-next.2
18
+ - @backstage/catalog-client@1.5.0-next.1
19
+ - @backstage/plugin-auth-backend-module-gcp-iap-provider@0.2.2-next.2
20
+ - @backstage/plugin-auth-backend-module-google-provider@0.1.5-next.2
21
+ - @backstage/backend-plugin-api@0.6.8-next.2
22
+ - @backstage/catalog-model@1.4.3
23
+ - @backstage/config@1.1.1
24
+ - @backstage/errors@1.2.3
25
+ - @backstage/types@1.1.1
26
+ - @backstage/plugin-auth-backend-module-github-provider@0.1.5-next.2
27
+
28
+ ## 0.20.1-next.1
29
+
30
+ ### Patch Changes
31
+
32
+ - 7ac25759a5: `oauth2-proxy` auth implementation has been moved to `@backstage/plugin-auth-backend-module-oauth2-proxy-provider`
33
+ - bcbbf8e042: Updated dependency `@google-cloud/firestore` to `^7.0.0`.
34
+ - Updated dependencies
35
+ - @backstage/plugin-auth-backend-module-oauth2-proxy-provider@0.1.0-next.0
36
+ - @backstage/catalog-client@1.5.0-next.0
37
+ - @backstage/backend-common@0.20.0-next.1
38
+ - @backstage/plugin-auth-backend-module-atlassian-provider@0.1.0-next.1
39
+ - @backstage/plugin-auth-backend-module-github-provider@0.1.5-next.1
40
+ - @backstage/plugin-auth-backend-module-gitlab-provider@0.1.5-next.1
41
+ - @backstage/plugin-auth-backend-module-google-provider@0.1.5-next.1
42
+ - @backstage/plugin-auth-backend-module-oauth2-provider@0.1.5-next.1
43
+ - @backstage/plugin-auth-backend-module-okta-provider@0.0.1-next.1
44
+ - @backstage/backend-plugin-api@0.6.8-next.1
45
+ - @backstage/catalog-model@1.4.3
46
+ - @backstage/config@1.1.1
47
+ - @backstage/errors@1.2.3
48
+ - @backstage/types@1.1.1
49
+ - @backstage/plugin-auth-backend-module-gcp-iap-provider@0.2.2-next.1
50
+ - @backstage/plugin-auth-node@0.4.2-next.1
51
+ - @backstage/plugin-catalog-node@1.5.1-next.1
52
+
3
53
  ## 0.20.1-next.0
4
54
 
5
55
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -24,6 +24,7 @@ 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
29
  var pluginAuthBackendModuleOktaProvider = require('@backstage/plugin-auth-backend-module-okta-provider');
29
30
  var passportOneloginOauth = require('passport-onelogin-oauth');
@@ -239,10 +240,10 @@ const ensuresXRequestedWith = (req) => {
239
240
 
240
241
  const prepareBackstageIdentityResponse = pluginAuthNode.prepareBackstageIdentityResponse;
241
242
 
242
- var __defProp$g = Object.defineProperty;
243
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
244
- var __publicField$g = (obj, key, value) => {
245
- __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
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);
246
247
  return value;
247
248
  };
248
249
  const THOUSAND_DAYS_MS = 1e3 * 24 * 60 * 60 * 1e3;
@@ -251,8 +252,8 @@ class OAuthAdapter {
251
252
  constructor(handlers, options) {
252
253
  this.handlers = handlers;
253
254
  this.options = options;
254
- __publicField$g(this, "baseCookieOptions");
255
- __publicField$g(this, "setNonceCookie", (res, nonce, cookieConfig) => {
255
+ __publicField$f(this, "baseCookieOptions");
256
+ __publicField$f(this, "setNonceCookie", (res, nonce, cookieConfig) => {
256
257
  res.cookie(`${this.options.providerId}-nonce`, nonce, {
257
258
  maxAge: TEN_MINUTES_MS,
258
259
  ...this.baseCookieOptions,
@@ -260,34 +261,34 @@ class OAuthAdapter {
260
261
  path: `${cookieConfig.path}/handler`
261
262
  });
262
263
  });
263
- __publicField$g(this, "setGrantedScopeCookie", (res, scope, cookieConfig) => {
264
+ __publicField$f(this, "setGrantedScopeCookie", (res, scope, cookieConfig) => {
264
265
  res.cookie(`${this.options.providerId}-granted-scope`, scope, {
265
266
  maxAge: THOUSAND_DAYS_MS,
266
267
  ...this.baseCookieOptions,
267
268
  ...cookieConfig
268
269
  });
269
270
  });
270
- __publicField$g(this, "getRefreshTokenFromCookie", (req) => {
271
+ __publicField$f(this, "getRefreshTokenFromCookie", (req) => {
271
272
  return req.cookies[`${this.options.providerId}-refresh-token`];
272
273
  });
273
- __publicField$g(this, "getGrantedScopeFromCookie", (req) => {
274
+ __publicField$f(this, "getGrantedScopeFromCookie", (req) => {
274
275
  return req.cookies[`${this.options.providerId}-granted-scope`];
275
276
  });
276
- __publicField$g(this, "setRefreshTokenCookie", (res, refreshToken, cookieConfig) => {
277
+ __publicField$f(this, "setRefreshTokenCookie", (res, refreshToken, cookieConfig) => {
277
278
  res.cookie(`${this.options.providerId}-refresh-token`, refreshToken, {
278
279
  maxAge: THOUSAND_DAYS_MS,
279
280
  ...this.baseCookieOptions,
280
281
  ...cookieConfig
281
282
  });
282
283
  });
283
- __publicField$g(this, "removeRefreshTokenCookie", (res, cookieConfig) => {
284
+ __publicField$f(this, "removeRefreshTokenCookie", (res, cookieConfig) => {
284
285
  res.cookie(`${this.options.providerId}-refresh-token`, "", {
285
286
  maxAge: 0,
286
287
  ...this.baseCookieOptions,
287
288
  ...cookieConfig
288
289
  });
289
290
  });
290
- __publicField$g(this, "getCookieConfig", (origin) => {
291
+ __publicField$f(this, "getCookieConfig", (origin) => {
291
292
  return this.options.cookieConfigurer({
292
293
  providerId: this.options.providerId,
293
294
  baseUrl: this.options.baseUrl,
@@ -585,21 +586,21 @@ const executeFetchUserProfileStrategy = async (providerStrategy, accessToken) =>
585
586
  });
586
587
  };
587
588
 
588
- var __defProp$f = Object.defineProperty;
589
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
590
- var __publicField$f = (obj, key, value) => {
591
- __defNormalProp$f(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);
592
593
  return value;
593
594
  };
594
595
  class Auth0AuthProvider {
595
596
  constructor(options) {
596
- __publicField$f(this, "_strategy");
597
- __publicField$f(this, "signInResolver");
598
- __publicField$f(this, "authHandler");
599
- __publicField$f(this, "resolverContext");
600
- __publicField$f(this, "audience");
601
- __publicField$f(this, "connection");
602
- __publicField$f(this, "connectionScope");
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");
603
604
  /**
604
605
  * Due to passport-auth0 forcing options.state = true,
605
606
  * passport-oauth2 requires express-session to be installed
@@ -608,7 +609,7 @@ class Auth0AuthProvider {
608
609
  * passport-oauth2, which is the StateStore implementation used when options.state = false,
609
610
  * allowing us to avoid using express-session in order to integrate with auth0.
610
611
  */
611
- __publicField$f(this, "store", {
612
+ __publicField$e(this, "store", {
612
613
  store(_req, cb) {
613
614
  cb(null, null);
614
615
  },
@@ -749,23 +750,23 @@ const auth0 = createAuthProviderIntegration({
749
750
  }
750
751
  });
751
752
 
752
- var __defProp$e = Object.defineProperty;
753
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
754
- var __publicField$e = (obj, key, value) => {
755
- __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
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);
756
757
  return value;
757
758
  };
758
759
  const ALB_JWT_HEADER = "x-amzn-oidc-data";
759
760
  const ALB_ACCESS_TOKEN_HEADER = "x-amzn-oidc-accesstoken";
760
761
  class AwsAlbAuthProvider {
761
762
  constructor(options) {
762
- __publicField$e(this, "region");
763
- __publicField$e(this, "issuer");
764
- __publicField$e(this, "resolverContext");
765
- __publicField$e(this, "keyCache");
766
- __publicField$e(this, "authHandler");
767
- __publicField$e(this, "signInResolver");
768
- __publicField$e(this, "getKey", async (header) => {
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) => {
769
770
  if (!header.kid) {
770
771
  throw new errors.AuthenticationError("No key id was specified in header");
771
772
  }
@@ -893,18 +894,18 @@ const awsAlb = createAuthProviderIntegration({
893
894
  }
894
895
  });
895
896
 
896
- var __defProp$d = Object.defineProperty;
897
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
898
- var __publicField$d = (obj, key, value) => {
899
- __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
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);
900
901
  return value;
901
902
  };
902
903
  class BitbucketAuthProvider {
903
904
  constructor(options) {
904
- __publicField$d(this, "_strategy");
905
- __publicField$d(this, "signInResolver");
906
- __publicField$d(this, "authHandler");
907
- __publicField$d(this, "resolverContext");
905
+ __publicField$c(this, "_strategy");
906
+ __publicField$c(this, "signInResolver");
907
+ __publicField$c(this, "authHandler");
908
+ __publicField$c(this, "resolverContext");
908
909
  this.signInResolver = options.signInResolver;
909
910
  this.authHandler = options.authHandler;
910
911
  this.resolverContext = options.resolverContext;
@@ -1072,10 +1073,10 @@ const commonByEmailResolver = async (info, ctx) => {
1072
1073
  });
1073
1074
  };
1074
1075
 
1075
- var __defProp$c = Object.defineProperty;
1076
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1077
- var __publicField$c = (obj, key, value) => {
1078
- __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
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);
1079
1080
  return value;
1080
1081
  };
1081
1082
  const CF_JWT_HEADER = "cf-access-jwt-assertion";
@@ -1083,12 +1084,12 @@ const COOKIE_AUTH_NAME = "CF_Authorization";
1083
1084
  const CACHE_PREFIX = "providers/cloudflare-access/profile-v1";
1084
1085
  class CloudflareAccessAuthProvider {
1085
1086
  constructor(options) {
1086
- __publicField$c(this, "teamName");
1087
- __publicField$c(this, "resolverContext");
1088
- __publicField$c(this, "authHandler");
1089
- __publicField$c(this, "signInResolver");
1090
- __publicField$c(this, "jwtKeySet");
1091
- __publicField$c(this, "cache");
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");
1092
1093
  this.teamName = options.teamName;
1093
1094
  this.authHandler = options.authHandler;
1094
1095
  this.signInResolver = options.signInResolver;
@@ -1320,20 +1321,20 @@ const google = createAuthProviderIntegration({
1320
1321
 
1321
1322
  const BACKSTAGE_SESSION_EXPIRATION = 3600;
1322
1323
 
1323
- var __defProp$b = Object.defineProperty;
1324
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1325
- var __publicField$b = (obj, key, value) => {
1326
- __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
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);
1327
1328
  return value;
1328
1329
  };
1329
1330
  class MicrosoftAuthProvider {
1330
1331
  constructor(options) {
1331
- __publicField$b(this, "_strategy");
1332
- __publicField$b(this, "signInResolver");
1333
- __publicField$b(this, "authHandler");
1334
- __publicField$b(this, "logger");
1335
- __publicField$b(this, "resolverContext");
1336
- __publicField$b(this, "skipUserProfile", (accessToken) => {
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) => {
1337
1338
  const { aud, scp } = jose.decodeJwt(accessToken);
1338
1339
  const hasGraphReadScope = aud === "00000003-0000-0000-c000-000000000000" && scp.split(" ").map((s) => s.toLowerCase()).includes("user.read");
1339
1340
  return !hasGraphReadScope;
@@ -1509,89 +1510,14 @@ const oauth2 = createAuthProviderIntegration({
1509
1510
  }
1510
1511
  });
1511
1512
 
1512
- var __defProp$a = Object.defineProperty;
1513
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1514
- var __publicField$a = (obj, key, value) => {
1515
- __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
1516
- return value;
1517
- };
1518
- const OAUTH2_PROXY_JWT_HEADER = "X-OAUTH2-PROXY-ID-TOKEN";
1519
- class Oauth2ProxyAuthProvider {
1520
- constructor(options) {
1521
- __publicField$a(this, "resolverContext");
1522
- __publicField$a(this, "signInResolver");
1523
- __publicField$a(this, "authHandler");
1524
- this.resolverContext = options.resolverContext;
1525
- this.signInResolver = options.signInResolver;
1526
- this.authHandler = options.authHandler;
1527
- }
1528
- frameHandler() {
1529
- return Promise.resolve(void 0);
1530
- }
1531
- async refresh(req, res) {
1532
- try {
1533
- const authHeader = req.header(OAUTH2_PROXY_JWT_HEADER);
1534
- const jwt = pluginAuthNode.getBearerTokenFromAuthorizationHeader(authHeader);
1535
- const decodedJWT = jwt && jose.decodeJwt(jwt);
1536
- const result = {
1537
- fullProfile: decodedJWT || {},
1538
- accessToken: jwt || "",
1539
- headers: req.headers,
1540
- getHeader(name) {
1541
- if (name.toLocaleLowerCase("en-US") === "set-cookie") {
1542
- throw new Error("Access Set-Cookie via the headers object instead");
1543
- }
1544
- return req.get(name);
1545
- }
1546
- };
1547
- const response = await this.handleResult(result);
1548
- res.json(response);
1549
- } catch (e) {
1550
- throw new errors.AuthenticationError("Refresh failed", e);
1551
- }
1552
- }
1553
- start() {
1554
- return Promise.resolve(void 0);
1555
- }
1556
- async handleResult(result) {
1557
- const { profile } = await this.authHandler(result, this.resolverContext);
1558
- const backstageSignInResult = await this.signInResolver(
1559
- {
1560
- result,
1561
- profile
1562
- },
1563
- this.resolverContext
1564
- );
1565
- return {
1566
- providerInfo: {
1567
- accessToken: result.accessToken
1568
- },
1569
- backstageIdentity: prepareBackstageIdentityResponse(
1570
- backstageSignInResult
1571
- ),
1572
- profile
1573
- };
1574
- }
1575
- }
1576
- async function defaultAuthHandler(result) {
1577
- return {
1578
- profile: {
1579
- email: result.getHeader("x-forwarded-email"),
1580
- displayName: result.getHeader("x-forwarded-preferred-username") || result.getHeader("x-forwarded-user")
1581
- }
1582
- };
1583
- }
1584
1513
  const oauth2Proxy = createAuthProviderIntegration({
1585
1514
  create(options) {
1586
- return ({ resolverContext }) => {
1587
- const signInResolver = options.signIn.resolver;
1588
- const authHandler = options.authHandler;
1589
- return new Oauth2ProxyAuthProvider({
1590
- resolverContext,
1591
- signInResolver,
1592
- authHandler: authHandler != null ? authHandler : defaultAuthHandler
1593
- });
1594
- };
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
+ });
1595
1521
  }
1596
1522
  });
1597
1523
 
@@ -2764,7 +2690,7 @@ class KeyStores {
2764
2690
  return keyStore;
2765
2691
  }
2766
2692
  if (provider === "static") {
2767
- await StaticKeyStore.fromConfig(config);
2693
+ return await StaticKeyStore.fromConfig(config);
2768
2694
  }
2769
2695
  throw new Error(`Unknown KeyStore provider: ${provider}`);
2770
2696
  }