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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @backstage/plugin-auth-backend
2
2
 
3
+ ## 0.16.0-next.3
4
+
5
+ ### Minor Changes
6
+
7
+ - 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.
8
+
9
+ [What is an Audience](https://community.auth0.com/t/what-is-the-audience/71414)
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+ - @backstage/catalog-client@1.1.0-next.2
15
+ - @backstage/catalog-model@1.1.1-next.0
16
+ - @backstage/config@1.0.2-next.0
17
+ - @backstage/errors@1.1.1-next.0
18
+ - @backstage/backend-common@0.15.1-next.3
19
+ - @backstage/plugin-auth-node@0.2.5-next.3
20
+
3
21
  ## 0.16.0-next.2
4
22
 
5
23
  ### 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,