@backstage/plugin-auth-backend 0.19.3 → 0.19.4

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,16 @@
1
1
  # @backstage/plugin-auth-backend
2
2
 
3
+ ## 0.19.4
4
+
5
+ ### Patch Changes
6
+
7
+ - bbbacb66f8e4: Reverted the Microsoft auth provider to the previous implementation.
8
+ - Updated dependencies
9
+ - @backstage/plugin-auth-backend-module-github-provider@0.1.3
10
+ - @backstage/plugin-auth-backend-module-gitlab-provider@0.1.3
11
+ - @backstage/plugin-auth-backend-module-google-provider@0.1.3
12
+ - @backstage/plugin-auth-backend-module-oauth2-provider@0.1.3
13
+
3
14
  ## 0.19.3
4
15
 
5
16
  ### Patch Changes
package/config.d.ts CHANGED
@@ -179,6 +179,18 @@ export interface Config {
179
179
  };
180
180
  };
181
181
  /** @visibility frontend */
182
+ microsoft?: {
183
+ [authEnv: string]: {
184
+ clientId: string;
185
+ /**
186
+ * @visibility secret
187
+ */
188
+ clientSecret: string;
189
+ tenantId: string;
190
+ callbackUrl?: string;
191
+ };
192
+ };
193
+ /** @visibility frontend */
182
194
  onelogin?: {
183
195
  [authEnv: string]: {
184
196
  clientId: string;
package/dist/index.cjs.js CHANGED
@@ -22,7 +22,7 @@ var pluginAuthBackendModuleGcpIapProvider = require('@backstage/plugin-auth-back
22
22
  var pluginAuthBackendModuleGithubProvider = require('@backstage/plugin-auth-backend-module-github-provider');
23
23
  var pluginAuthBackendModuleGitlabProvider = require('@backstage/plugin-auth-backend-module-gitlab-provider');
24
24
  var pluginAuthBackendModuleGoogleProvider = require('@backstage/plugin-auth-backend-module-google-provider');
25
- var pluginAuthBackendModuleMicrosoftProvider = require('@backstage/plugin-auth-backend-module-microsoft-provider');
25
+ var passportMicrosoft = require('passport-microsoft');
26
26
  var pluginAuthBackendModuleOauth2Provider = require('@backstage/plugin-auth-backend-module-oauth2-provider');
27
27
  var openidClient = require('openid-client');
28
28
  var passportOktaOauth = require('@davidzemon/passport-okta-oauth');
@@ -75,10 +75,10 @@ var session__default = /*#__PURE__*/_interopDefaultLegacy(session);
75
75
  var connectSessionKnex__default = /*#__PURE__*/_interopDefaultLegacy(connectSessionKnex);
76
76
  var passport__default = /*#__PURE__*/_interopDefaultLegacy(passport);
77
77
 
78
- var __defProp$g = Object.defineProperty;
79
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
80
- var __publicField$g = (obj, key, value) => {
81
- __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
78
+ var __defProp$h = Object.defineProperty;
79
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
80
+ var __publicField$h = (obj, key, value) => {
81
+ __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
82
82
  return value;
83
83
  };
84
84
  const defaultScopes = ["offline_access", "read:me"];
@@ -95,7 +95,7 @@ class AtlassianStrategy extends OAuth2Strategy__default["default"] {
95
95
  scope: Array.from(/* @__PURE__ */ new Set([...defaultScopes, ...scopes]))
96
96
  };
97
97
  super(optionsWithURLs, verify);
98
- __publicField$g(this, "profileURL");
98
+ __publicField$h(this, "profileURL");
99
99
  this.profileURL = "https://api.atlassian.com/me";
100
100
  this.name = "atlassian";
101
101
  this._oauth2.useAuthorizationHeaderforGET(true);
@@ -210,10 +210,10 @@ const ensuresXRequestedWith = (req) => {
210
210
 
211
211
  const prepareBackstageIdentityResponse = pluginAuthNode.prepareBackstageIdentityResponse;
212
212
 
213
- var __defProp$f = Object.defineProperty;
214
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
215
- var __publicField$f = (obj, key, value) => {
216
- __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
213
+ var __defProp$g = Object.defineProperty;
214
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
215
+ var __publicField$g = (obj, key, value) => {
216
+ __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
217
217
  return value;
218
218
  };
219
219
  const THOUSAND_DAYS_MS = 1e3 * 24 * 60 * 60 * 1e3;
@@ -222,8 +222,8 @@ class OAuthAdapter {
222
222
  constructor(handlers, options) {
223
223
  this.handlers = handlers;
224
224
  this.options = options;
225
- __publicField$f(this, "baseCookieOptions");
226
- __publicField$f(this, "setNonceCookie", (res, nonce, cookieConfig) => {
225
+ __publicField$g(this, "baseCookieOptions");
226
+ __publicField$g(this, "setNonceCookie", (res, nonce, cookieConfig) => {
227
227
  res.cookie(`${this.options.providerId}-nonce`, nonce, {
228
228
  maxAge: TEN_MINUTES_MS,
229
229
  ...this.baseCookieOptions,
@@ -231,34 +231,34 @@ class OAuthAdapter {
231
231
  path: `${cookieConfig.path}/handler`
232
232
  });
233
233
  });
234
- __publicField$f(this, "setGrantedScopeCookie", (res, scope, cookieConfig) => {
234
+ __publicField$g(this, "setGrantedScopeCookie", (res, scope, cookieConfig) => {
235
235
  res.cookie(`${this.options.providerId}-granted-scope`, scope, {
236
236
  maxAge: THOUSAND_DAYS_MS,
237
237
  ...this.baseCookieOptions,
238
238
  ...cookieConfig
239
239
  });
240
240
  });
241
- __publicField$f(this, "getRefreshTokenFromCookie", (req) => {
241
+ __publicField$g(this, "getRefreshTokenFromCookie", (req) => {
242
242
  return req.cookies[`${this.options.providerId}-refresh-token`];
243
243
  });
244
- __publicField$f(this, "getGrantedScopeFromCookie", (req) => {
244
+ __publicField$g(this, "getGrantedScopeFromCookie", (req) => {
245
245
  return req.cookies[`${this.options.providerId}-granted-scope`];
246
246
  });
247
- __publicField$f(this, "setRefreshTokenCookie", (res, refreshToken, cookieConfig) => {
247
+ __publicField$g(this, "setRefreshTokenCookie", (res, refreshToken, cookieConfig) => {
248
248
  res.cookie(`${this.options.providerId}-refresh-token`, refreshToken, {
249
249
  maxAge: THOUSAND_DAYS_MS,
250
250
  ...this.baseCookieOptions,
251
251
  ...cookieConfig
252
252
  });
253
253
  });
254
- __publicField$f(this, "removeRefreshTokenCookie", (res, cookieConfig) => {
254
+ __publicField$g(this, "removeRefreshTokenCookie", (res, cookieConfig) => {
255
255
  res.cookie(`${this.options.providerId}-refresh-token`, "", {
256
256
  maxAge: 0,
257
257
  ...this.baseCookieOptions,
258
258
  ...cookieConfig
259
259
  });
260
260
  });
261
- __publicField$f(this, "getCookieConfig", (origin) => {
261
+ __publicField$g(this, "getCookieConfig", (origin) => {
262
262
  return this.options.cookieConfigurer({
263
263
  providerId: this.options.providerId,
264
264
  baseUrl: this.options.baseUrl,
@@ -564,10 +564,10 @@ function createAuthProviderIntegration(config) {
564
564
  });
565
565
  }
566
566
 
567
- var __defProp$e = Object.defineProperty;
568
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
569
- var __publicField$e = (obj, key, value) => {
570
- __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
567
+ var __defProp$f = Object.defineProperty;
568
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
569
+ var __publicField$f = (obj, key, value) => {
570
+ __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
571
571
  return value;
572
572
  };
573
573
  const atlassianDefaultAuthHandler = async ({
@@ -578,10 +578,10 @@ const atlassianDefaultAuthHandler = async ({
578
578
  });
579
579
  class AtlassianAuthProvider {
580
580
  constructor(options) {
581
- __publicField$e(this, "_strategy");
582
- __publicField$e(this, "signInResolver");
583
- __publicField$e(this, "authHandler");
584
- __publicField$e(this, "resolverContext");
581
+ __publicField$f(this, "_strategy");
582
+ __publicField$f(this, "signInResolver");
583
+ __publicField$f(this, "authHandler");
584
+ __publicField$f(this, "resolverContext");
585
585
  this.resolverContext = options.resolverContext;
586
586
  this.authHandler = options.authHandler;
587
587
  this.signInResolver = options.signInResolver;
@@ -699,21 +699,21 @@ class Auth0Strategy extends Auth0InternalStrategy__default["default"] {
699
699
  }
700
700
  }
701
701
 
702
- var __defProp$d = Object.defineProperty;
703
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
704
- var __publicField$d = (obj, key, value) => {
705
- __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
702
+ var __defProp$e = Object.defineProperty;
703
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
704
+ var __publicField$e = (obj, key, value) => {
705
+ __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
706
706
  return value;
707
707
  };
708
708
  class Auth0AuthProvider {
709
709
  constructor(options) {
710
- __publicField$d(this, "_strategy");
711
- __publicField$d(this, "signInResolver");
712
- __publicField$d(this, "authHandler");
713
- __publicField$d(this, "resolverContext");
714
- __publicField$d(this, "audience");
715
- __publicField$d(this, "connection");
716
- __publicField$d(this, "connectionScope");
710
+ __publicField$e(this, "_strategy");
711
+ __publicField$e(this, "signInResolver");
712
+ __publicField$e(this, "authHandler");
713
+ __publicField$e(this, "resolverContext");
714
+ __publicField$e(this, "audience");
715
+ __publicField$e(this, "connection");
716
+ __publicField$e(this, "connectionScope");
717
717
  /**
718
718
  * Due to passport-auth0 forcing options.state = true,
719
719
  * passport-oauth2 requires express-session to be installed
@@ -722,7 +722,7 @@ class Auth0AuthProvider {
722
722
  * passport-oauth2, which is the StateStore implementation used when options.state = false,
723
723
  * allowing us to avoid using express-session in order to integrate with auth0.
724
724
  */
725
- __publicField$d(this, "store", {
725
+ __publicField$e(this, "store", {
726
726
  store(_req, cb) {
727
727
  cb(null, null);
728
728
  },
@@ -863,23 +863,23 @@ const auth0 = createAuthProviderIntegration({
863
863
  }
864
864
  });
865
865
 
866
- var __defProp$c = Object.defineProperty;
867
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
868
- var __publicField$c = (obj, key, value) => {
869
- __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
866
+ var __defProp$d = Object.defineProperty;
867
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
868
+ var __publicField$d = (obj, key, value) => {
869
+ __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
870
870
  return value;
871
871
  };
872
872
  const ALB_JWT_HEADER = "x-amzn-oidc-data";
873
873
  const ALB_ACCESS_TOKEN_HEADER = "x-amzn-oidc-accesstoken";
874
874
  class AwsAlbAuthProvider {
875
875
  constructor(options) {
876
- __publicField$c(this, "region");
877
- __publicField$c(this, "issuer");
878
- __publicField$c(this, "resolverContext");
879
- __publicField$c(this, "keyCache");
880
- __publicField$c(this, "authHandler");
881
- __publicField$c(this, "signInResolver");
882
- __publicField$c(this, "getKey", async (header) => {
876
+ __publicField$d(this, "region");
877
+ __publicField$d(this, "issuer");
878
+ __publicField$d(this, "resolverContext");
879
+ __publicField$d(this, "keyCache");
880
+ __publicField$d(this, "authHandler");
881
+ __publicField$d(this, "signInResolver");
882
+ __publicField$d(this, "getKey", async (header) => {
883
883
  if (!header.kid) {
884
884
  throw new errors.AuthenticationError("No key id was specified in header");
885
885
  }
@@ -1007,18 +1007,18 @@ const awsAlb = createAuthProviderIntegration({
1007
1007
  }
1008
1008
  });
1009
1009
 
1010
- var __defProp$b = Object.defineProperty;
1011
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1012
- var __publicField$b = (obj, key, value) => {
1013
- __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
1010
+ var __defProp$c = Object.defineProperty;
1011
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1012
+ var __publicField$c = (obj, key, value) => {
1013
+ __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
1014
1014
  return value;
1015
1015
  };
1016
1016
  class BitbucketAuthProvider {
1017
1017
  constructor(options) {
1018
- __publicField$b(this, "_strategy");
1019
- __publicField$b(this, "signInResolver");
1020
- __publicField$b(this, "authHandler");
1021
- __publicField$b(this, "resolverContext");
1018
+ __publicField$c(this, "_strategy");
1019
+ __publicField$c(this, "signInResolver");
1020
+ __publicField$c(this, "authHandler");
1021
+ __publicField$c(this, "resolverContext");
1022
1022
  this.signInResolver = options.signInResolver;
1023
1023
  this.authHandler = options.authHandler;
1024
1024
  this.resolverContext = options.resolverContext;
@@ -1186,10 +1186,10 @@ const commonByEmailResolver = async (info, ctx) => {
1186
1186
  });
1187
1187
  };
1188
1188
 
1189
- var __defProp$a = Object.defineProperty;
1190
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1191
- var __publicField$a = (obj, key, value) => {
1192
- __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
1189
+ var __defProp$b = Object.defineProperty;
1190
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1191
+ var __publicField$b = (obj, key, value) => {
1192
+ __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
1193
1193
  return value;
1194
1194
  };
1195
1195
  const CF_JWT_HEADER = "cf-access-jwt-assertion";
@@ -1197,12 +1197,12 @@ const COOKIE_AUTH_NAME = "CF_Authorization";
1197
1197
  const CACHE_PREFIX = "providers/cloudflare-access/profile-v1";
1198
1198
  class CloudflareAccessAuthProvider {
1199
1199
  constructor(options) {
1200
- __publicField$a(this, "teamName");
1201
- __publicField$a(this, "resolverContext");
1202
- __publicField$a(this, "authHandler");
1203
- __publicField$a(this, "signInResolver");
1204
- __publicField$a(this, "jwtKeySet");
1205
- __publicField$a(this, "cache");
1200
+ __publicField$b(this, "teamName");
1201
+ __publicField$b(this, "resolverContext");
1202
+ __publicField$b(this, "authHandler");
1203
+ __publicField$b(this, "signInResolver");
1204
+ __publicField$b(this, "jwtKeySet");
1205
+ __publicField$b(this, "cache");
1206
1206
  this.teamName = options.teamName;
1207
1207
  this.authHandler = options.authHandler;
1208
1208
  this.signInResolver = options.signInResolver;
@@ -1496,20 +1496,184 @@ const google = createAuthProviderIntegration({
1496
1496
  })
1497
1497
  });
1498
1498
 
1499
+ const BACKSTAGE_SESSION_EXPIRATION = 3600;
1500
+
1501
+ var __defProp$a = Object.defineProperty;
1502
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1503
+ var __publicField$a = (obj, key, value) => {
1504
+ __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
1505
+ return value;
1506
+ };
1507
+ class MicrosoftAuthProvider {
1508
+ constructor(options) {
1509
+ __publicField$a(this, "_strategy");
1510
+ __publicField$a(this, "signInResolver");
1511
+ __publicField$a(this, "authHandler");
1512
+ __publicField$a(this, "logger");
1513
+ __publicField$a(this, "resolverContext");
1514
+ __publicField$a(this, "skipUserProfile", (accessToken) => {
1515
+ const { aud, scp } = jose.decodeJwt(accessToken);
1516
+ const hasGraphReadScope = aud === "00000003-0000-0000-c000-000000000000" && scp.split(" ").map((s) => s.toLowerCase()).includes("user.read");
1517
+ return !hasGraphReadScope;
1518
+ });
1519
+ this.signInResolver = options.signInResolver;
1520
+ this.authHandler = options.authHandler;
1521
+ this.logger = options.logger;
1522
+ this.resolverContext = options.resolverContext;
1523
+ this._strategy = new passportMicrosoft.Strategy(
1524
+ {
1525
+ clientID: options.clientId,
1526
+ clientSecret: options.clientSecret,
1527
+ callbackURL: options.callbackUrl,
1528
+ authorizationURL: options.authorizationUrl,
1529
+ tokenURL: options.tokenUrl,
1530
+ passReqToCallback: false,
1531
+ skipUserProfile: (accessToken, done) => {
1532
+ done(null, this.skipUserProfile(accessToken));
1533
+ }
1534
+ },
1535
+ (accessToken, refreshToken, params, fullProfile, done) => {
1536
+ done(void 0, { fullProfile, accessToken, params }, { refreshToken });
1537
+ }
1538
+ );
1539
+ }
1540
+ async start(req) {
1541
+ return await executeRedirectStrategy(req, this._strategy, {
1542
+ scope: req.scope,
1543
+ state: encodeState(req.state)
1544
+ });
1545
+ }
1546
+ async handler(req) {
1547
+ const { result, privateInfo } = await executeFrameHandlerStrategy(req, this._strategy);
1548
+ return {
1549
+ response: await this.handleResult(result),
1550
+ refreshToken: privateInfo.refreshToken
1551
+ };
1552
+ }
1553
+ async refresh(req) {
1554
+ const { accessToken, refreshToken, params } = await executeRefreshTokenStrategy(
1555
+ this._strategy,
1556
+ req.refreshToken,
1557
+ req.scope
1558
+ );
1559
+ return {
1560
+ response: await this.handleResult({
1561
+ params,
1562
+ accessToken,
1563
+ ...!this.skipUserProfile(accessToken) && {
1564
+ fullProfile: await executeFetchUserProfileStrategy(
1565
+ this._strategy,
1566
+ accessToken
1567
+ )
1568
+ }
1569
+ }),
1570
+ refreshToken
1571
+ };
1572
+ }
1573
+ async handleResult(result) {
1574
+ let profile = {};
1575
+ if (result.fullProfile) {
1576
+ const photo = await this.getUserPhoto(result.accessToken);
1577
+ result.fullProfile.photos = photo ? [{ value: photo }] : void 0;
1578
+ ({ profile } = await this.authHandler(
1579
+ result,
1580
+ this.resolverContext
1581
+ ));
1582
+ }
1583
+ const expiresInSeconds = result.params.expires_in === void 0 ? BACKSTAGE_SESSION_EXPIRATION : Math.min(result.params.expires_in, BACKSTAGE_SESSION_EXPIRATION);
1584
+ return {
1585
+ providerInfo: {
1586
+ accessToken: result.accessToken,
1587
+ scope: result.params.scope,
1588
+ expiresInSeconds,
1589
+ ...{ idToken: result.params.id_token }
1590
+ },
1591
+ profile,
1592
+ ...result.fullProfile && this.signInResolver && {
1593
+ backstageIdentity: await this.signInResolver(
1594
+ { result, profile },
1595
+ this.resolverContext
1596
+ )
1597
+ }
1598
+ };
1599
+ }
1600
+ async getUserPhoto(accessToken) {
1601
+ try {
1602
+ const res = await fetch__default["default"](
1603
+ "https://graph.microsoft.com/v1.0/me/photos/48x48/$value",
1604
+ {
1605
+ headers: {
1606
+ Authorization: `Bearer ${accessToken}`
1607
+ }
1608
+ }
1609
+ );
1610
+ const data = await res.buffer();
1611
+ return `data:image/jpeg;base64,${data.toString("base64")}`;
1612
+ } catch (error) {
1613
+ this.logger.warn(
1614
+ `Could not retrieve user profile photo from Microsoft Graph API: ${error}`
1615
+ );
1616
+ return void 0;
1617
+ }
1618
+ }
1619
+ }
1499
1620
  const microsoft = createAuthProviderIntegration({
1500
1621
  create(options) {
1501
- var _a;
1502
- return pluginAuthNode.createOAuthProviderFactory({
1503
- authenticator: pluginAuthBackendModuleMicrosoftProvider.microsoftAuthenticator,
1504
- profileTransform: adaptLegacyOAuthHandler(options == null ? void 0 : options.authHandler),
1505
- signInResolver: adaptLegacyOAuthSignInResolver((_a = options == null ? void 0 : options.signIn) == null ? void 0 : _a.resolver)
1622
+ return ({ providerId, globalConfig, config, logger, resolverContext }) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
1623
+ var _a;
1624
+ const clientId = envConfig.getString("clientId");
1625
+ const clientSecret = envConfig.getString("clientSecret");
1626
+ const tenantId = envConfig.getString("tenantId");
1627
+ const customCallbackUrl = envConfig.getOptionalString("callbackUrl");
1628
+ const callbackUrl = customCallbackUrl || `${globalConfig.baseUrl}/${providerId}/handler/frame`;
1629
+ const authorizationUrl = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/authorize`;
1630
+ const tokenUrl = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`;
1631
+ const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
1632
+ profile: makeProfileInfo(fullProfile != null ? fullProfile : {}, params.id_token)
1633
+ });
1634
+ const provider = new MicrosoftAuthProvider({
1635
+ clientId,
1636
+ clientSecret,
1637
+ callbackUrl,
1638
+ authorizationUrl,
1639
+ tokenUrl,
1640
+ authHandler,
1641
+ signInResolver: (_a = options == null ? void 0 : options.signIn) == null ? void 0 : _a.resolver,
1642
+ logger,
1643
+ resolverContext
1644
+ });
1645
+ return OAuthAdapter.fromConfig(globalConfig, provider, {
1646
+ providerId,
1647
+ callbackUrl
1648
+ });
1506
1649
  });
1507
1650
  },
1508
- resolvers: adaptOAuthSignInResolverToLegacy({
1509
- emailLocalPartMatchingUserEntityName: pluginAuthNode.commonSignInResolvers.emailLocalPartMatchingUserEntityName(),
1510
- emailMatchingUserEntityProfileEmail: pluginAuthNode.commonSignInResolvers.emailMatchingUserEntityProfileEmail(),
1511
- emailMatchingUserEntityAnnotation: pluginAuthBackendModuleMicrosoftProvider.microsoftSignInResolvers.emailMatchingUserEntityAnnotation()
1512
- })
1651
+ resolvers: {
1652
+ /**
1653
+ * Looks up the user by matching their email local part to the entity name.
1654
+ */
1655
+ emailLocalPartMatchingUserEntityName: () => commonByEmailLocalPartResolver,
1656
+ /**
1657
+ * Looks up the user by matching their email to the entity email.
1658
+ */
1659
+ emailMatchingUserEntityProfileEmail: () => commonByEmailResolver,
1660
+ /**
1661
+ * Looks up the user by matching their email to the `microsoft.com/email` annotation.
1662
+ */
1663
+ emailMatchingUserEntityAnnotation() {
1664
+ return async (info, ctx) => {
1665
+ const { profile } = info;
1666
+ if (!profile.email) {
1667
+ throw new Error("Microsoft profile contained no email");
1668
+ }
1669
+ return ctx.signInWithCatalogUser({
1670
+ annotations: {
1671
+ "microsoft.com/email": profile.email
1672
+ }
1673
+ });
1674
+ };
1675
+ }
1676
+ }
1513
1677
  });
1514
1678
 
1515
1679
  const oauth2 = createAuthProviderIntegration({
@@ -1609,8 +1773,6 @@ const oauth2Proxy = createAuthProviderIntegration({
1609
1773
  }
1610
1774
  });
1611
1775
 
1612
- const BACKSTAGE_SESSION_EXPIRATION = 3600;
1613
-
1614
1776
  var __defProp$8 = Object.defineProperty;
1615
1777
  var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1616
1778
  var __publicField$8 = (obj, key, value) => {