@backstage/plugin-auth-backend 0.4.5 → 0.4.6

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,17 @@
1
1
  # @backstage/plugin-auth-backend
2
2
 
3
+ ## 0.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 3b767f19c9: Allow OAuth state to be encoded by a stateEncoder.
8
+ - Updated dependencies
9
+ - @backstage/test-utils@0.1.20
10
+ - @backstage/config@0.1.11
11
+ - @backstage/errors@0.1.4
12
+ - @backstage/backend-common@0.9.8
13
+ - @backstage/catalog-model@0.9.6
14
+
3
15
  ## 0.4.5
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -550,6 +550,7 @@ class GithubAuthProvider {
550
550
  constructor(options) {
551
551
  this.signInResolver = options.signInResolver;
552
552
  this.authHandler = options.authHandler;
553
+ this.stateEncoder = options.stateEncoder;
553
554
  this.tokenIssuer = options.tokenIssuer;
554
555
  this.catalogIdentityClient = options.catalogIdentityClient;
555
556
  this.logger = options.logger;
@@ -567,7 +568,7 @@ class GithubAuthProvider {
567
568
  async start(req) {
568
569
  return await executeRedirectStrategy(req, this._strategy, {
569
570
  scope: req.scope,
570
- state: encodeState(req.state)
571
+ state: (await this.stateEncoder(req)).encodedState
571
572
  });
572
573
  }
573
574
  async handler(req) {
@@ -633,7 +634,7 @@ const createGithubProvider = (options) => {
633
634
  catalogApi,
634
635
  logger
635
636
  }) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
636
- var _a, _b;
637
+ var _a, _b, _c;
637
638
  const clientId = envConfig.getString("clientId");
638
639
  const clientSecret = envConfig.getString("clientSecret");
639
640
  const enterpriseInstanceUrl = envConfig.getOptionalString("enterpriseInstanceUrl");
@@ -655,6 +656,9 @@ const createGithubProvider = (options) => {
655
656
  tokenIssuer,
656
657
  logger
657
658
  });
659
+ const stateEncoder = (_c = options == null ? void 0 : options.stateEncoder) != null ? _c : async (req) => {
660
+ return {encodedState: encodeState(req.state)};
661
+ };
658
662
  const provider = new GithubAuthProvider({
659
663
  clientId,
660
664
  clientSecret,
@@ -666,6 +670,7 @@ const createGithubProvider = (options) => {
666
670
  authHandler,
667
671
  tokenIssuer,
668
672
  catalogIdentityClient,
673
+ stateEncoder,
669
674
  logger
670
675
  });
671
676
  return OAuthAdapter.fromConfig(globalConfig, provider, {