@backstage/plugin-auth-backend 0.16.0-next.2 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # @backstage/plugin-auth-backend
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2fc41ebf07: Removed the previously deprecated class `AtlassianAuthProvider`. Please use `providers.atlassian.create(...)` instead.
8
+ - a291688bc5: Renamed the `RedirectInfo` type to `OAuthStartResponse`
9
+ - 8600855fbf: The auth0 integration is updated to use the `passport-auth0` library. The configuration under `auth.providers.auth0.\*` now supports an optional `audience` parameter; providing that allows you to connect to the correct API to get permissions, access tokens, and full profile information.
10
+
11
+ [What is an Audience](https://community.auth0.com/t/what-is-the-audience/71414)
12
+
13
+ ### Patch Changes
14
+
15
+ - 5b011fb2e6: Allow adding misc claims to JWT
16
+ - d669d89206: Minor API signatures cleanup
17
+ - 667d917488: Updated dependency `msw` to `^0.47.0`.
18
+ - 87ec2ba4d6: Updated dependency `msw` to `^0.46.0`.
19
+ - bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
20
+ - e1ebaeb332: Cloudflare Access Provider: Add JWT to CloudflareAccessResult
21
+ - Updated dependencies
22
+ - @backstage/backend-common@0.15.1
23
+ - @backstage/plugin-auth-node@0.2.5
24
+ - @backstage/catalog-client@1.1.0
25
+ - @backstage/catalog-model@1.1.1
26
+ - @backstage/config@1.0.2
27
+ - @backstage/errors@1.1.1
28
+
29
+ ## 0.16.0-next.3
30
+
31
+ ### Minor Changes
32
+
33
+ - 8600855fbf: The auth0 integration is updated to use the `passport-auth0` library. The configuration under `auth.providers.auth0.\*` now supports an optional `audience` parameter; providing that allows you to connect to the correct API to get permissions, access tokens, and full profile information.
34
+
35
+ [What is an Audience](https://community.auth0.com/t/what-is-the-audience/71414)
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies
40
+ - @backstage/catalog-client@1.1.0-next.2
41
+ - @backstage/catalog-model@1.1.1-next.0
42
+ - @backstage/config@1.0.2-next.0
43
+ - @backstage/errors@1.1.1-next.0
44
+ - @backstage/backend-common@0.15.1-next.3
45
+ - @backstage/plugin-auth-node@0.2.5-next.3
46
+
3
47
  ## 0.16.0-next.2
4
48
 
5
49
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -11,6 +11,7 @@ var pickBy = require('lodash/pickBy');
11
11
  var crypto = require('crypto');
12
12
  var url = require('url');
13
13
  var jwtDecoder = require('jwt-decode');
14
+ var Auth0InternalStrategy = require('passport-auth0');
14
15
  var fetch = require('node-fetch');
15
16
  var NodeCache = require('node-cache');
16
17
  var jose = require('jose');
@@ -64,6 +65,7 @@ var pickBy__default = /*#__PURE__*/_interopDefaultLegacy(pickBy);
64
65
  var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
65
66
  var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
66
67
  var jwtDecoder__default = /*#__PURE__*/_interopDefaultLegacy(jwtDecoder);
68
+ var Auth0InternalStrategy__default = /*#__PURE__*/_interopDefaultLegacy(Auth0InternalStrategy);
67
69
  var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
68
70
  var NodeCache__default = /*#__PURE__*/_interopDefaultLegacy(NodeCache);
69
71
  var session__default = /*#__PURE__*/_interopDefaultLegacy(session);
@@ -494,7 +496,7 @@ const executeRedirectStrategy = async (req, providerStrategy, options) => {
494
496
  strategy.authenticate(req, { ...options });
495
497
  });
496
498
  };
497
- const executeFrameHandlerStrategy = async (req, providerStrategy) => {
499
+ const executeFrameHandlerStrategy = async (req, providerStrategy, options) => {
498
500
  return new Promise(
499
501
  (resolve, reject) => {
500
502
  const strategy = Object.create(providerStrategy);
@@ -523,7 +525,7 @@ const executeFrameHandlerStrategy = async (req, providerStrategy) => {
523
525
  strategy.redirect = () => {
524
526
  reject(new Error("Unexpected redirect"));
525
527
  };
526
- strategy.authenticate(req, {});
528
+ strategy.authenticate(req, { ...options != null ? options : {} });
527
529
  }
528
530
  );
529
531
  };
@@ -701,7 +703,7 @@ const atlassian = createAuthProviderIntegration({
701
703
  }
702
704
  });
703
705
 
704
- class Auth0Strategy extends OAuth2Strategy__default["default"] {
706
+ class Auth0Strategy extends Auth0InternalStrategy__default["default"] {
705
707
  constructor(options, verify) {
706
708
  const optionsWithURLs = {
707
709
  ...options,
@@ -716,16 +718,26 @@ class Auth0Strategy extends OAuth2Strategy__default["default"] {
716
718
 
717
719
  class Auth0AuthProvider {
718
720
  constructor(options) {
721
+ this.store = {
722
+ store(_req, cb) {
723
+ cb(null, null);
724
+ },
725
+ verify(_req, _state, cb) {
726
+ cb(null, true);
727
+ }
728
+ };
719
729
  this.signInResolver = options.signInResolver;
720
730
  this.authHandler = options.authHandler;
721
731
  this.resolverContext = options.resolverContext;
732
+ this.audience = options.audience;
722
733
  this._strategy = new Auth0Strategy(
723
734
  {
724
735
  clientID: options.clientId,
725
736
  clientSecret: options.clientSecret,
726
737
  callbackURL: options.callbackUrl,
727
738
  domain: options.domain,
728
- passReqToCallback: false
739
+ passReqToCallback: false,
740
+ store: this.store
729
741
  },
730
742
  (accessToken, refreshToken, params, fullProfile, done) => {
731
743
  done(
@@ -748,11 +760,14 @@ class Auth0AuthProvider {
748
760
  accessType: "offline",
749
761
  prompt: "consent",
750
762
  scope: req.scope,
751
- state: encodeState(req.state)
763
+ state: encodeState(req.state),
764
+ ...this.audience ? { audience: this.audience } : {}
752
765
  });
753
766
  }
754
767
  async handler(req) {
755
- const { result, privateInfo } = await executeFrameHandlerStrategy(req, this._strategy);
768
+ const { result, privateInfo } = await executeFrameHandlerStrategy(req, this._strategy, {
769
+ ...this.audience ? { audience: this.audience } : {}
770
+ });
756
771
  return {
757
772
  response: await this.handleResult(result),
758
773
  refreshToken: privateInfo.refreshToken
@@ -808,6 +823,7 @@ const auth0 = createAuthProviderIntegration({
808
823
  const clientSecret = envConfig.getString("clientSecret");
809
824
  const domain = envConfig.getString("domain");
810
825
  const customCallbackUrl = envConfig.getOptionalString("callbackUrl");
826
+ const audience = envConfig.getOptionalString("audience");
811
827
  const callbackUrl = customCallbackUrl || `${globalConfig.baseUrl}/${providerId}/handler/frame`;
812
828
  const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
813
829
  profile: makeProfileInfo(fullProfile, params.id_token)
@@ -820,7 +836,8 @@ const auth0 = createAuthProviderIntegration({
820
836
  domain,
821
837
  authHandler,
822
838
  signInResolver,
823
- resolverContext
839
+ resolverContext,
840
+ audience
824
841
  });
825
842
  return OAuthAdapter.fromConfig(globalConfig, provider, {
826
843
  providerId,
@@ -2707,8 +2724,7 @@ class TokenFactory {
2707
2724
  async issueToken(params) {
2708
2725
  const key = await this.getKey();
2709
2726
  const iss = this.issuer;
2710
- const sub = params.claims.sub;
2711
- const ent = params.claims.ent;
2727
+ const { sub, ent, ...additionalClaims } = params.claims;
2712
2728
  const aud = "backstage";
2713
2729
  const iat = Math.floor(Date.now() / MS_IN_S);
2714
2730
  const exp = iat + this.keyDurationSeconds;
@@ -2723,7 +2739,7 @@ class TokenFactory {
2723
2739
  if (!key.alg) {
2724
2740
  throw new errors.AuthenticationError("No algorithm was provided in the key");
2725
2741
  }
2726
- return new jose.SignJWT({ iss, sub, ent, aud, iat, exp }).setProtectedHeader({ alg: key.alg, kid: key.kid }).setIssuer(iss).setAudience(aud).setSubject(sub).setIssuedAt(iat).setExpirationTime(exp).sign(await jose.importJWK(key));
2742
+ return new jose.SignJWT({ ...additionalClaims, iss, sub, ent, aud, iat, exp }).setProtectedHeader({ alg: key.alg, kid: key.kid }).setIssuer(iss).setAudience(aud).setSubject(sub).setIssuedAt(iat).setExpirationTime(exp).sign(await jose.importJWK(key));
2727
2743
  }
2728
2744
  async listPublicKeys() {
2729
2745
  const { items: keys } = await this.keyStore.listKeys();