@backstage/plugin-auth-backend 0.9.0 → 0.10.0-next.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,22 @@
1
1
  # @backstage/plugin-auth-backend
2
2
 
3
+ ## 0.10.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 08fcda13ef: The `callbackUrl` option of `OAuthAdapter` is now required.
8
+
9
+ ### Patch Changes
10
+
11
+ - 2441d1cf59: chore(deps): bump `knex` from 0.95.6 to 1.0.2
12
+
13
+ This also replaces `sqlite3` with `@vscode/sqlite3` 5.0.7
14
+
15
+ - 3396bc5973: Enabled refresh for the Atlassian provider.
16
+ - 08fcda13ef: Added a new `cookieConfigurer` option to `AuthProviderConfig` that makes it possible to override the default logic for configuring OAuth provider cookies.
17
+ - Updated dependencies
18
+ - @backstage/backend-common@0.10.7-next.0
19
+
3
20
  ## 0.9.0
4
21
 
5
22
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -149,15 +149,14 @@ const verifyNonce = (req, providerId) => {
149
149
  throw new Error("Invalid nonce");
150
150
  }
151
151
  };
152
- const getCookieConfig = (authUrl, providerId) => {
153
- const { hostname: cookieDomain, pathname, protocol } = authUrl;
152
+ const defaultCookieConfigurer = ({
153
+ callbackUrl,
154
+ providerId
155
+ }) => {
156
+ const { hostname: domain, pathname, protocol } = new URL(callbackUrl);
154
157
  const secure = protocol === "https:";
155
- const cookiePath = pathname.endsWith(`${providerId}/handler/frame`) ? pathname.slice(0, -"/handler/frame".length) : `${pathname}/${providerId}`;
156
- return {
157
- cookieDomain,
158
- cookiePath,
159
- secure
160
- };
158
+ const path = pathname.endsWith(`${providerId}/handler/frame`) ? pathname.slice(0, -"/handler/frame".length) : `${pathname}/${providerId}`;
159
+ return { domain, path, secure };
161
160
  };
162
161
 
163
162
  class OAuthEnvironmentHandler {
@@ -317,14 +316,18 @@ class OAuthAdapter {
317
316
  static fromConfig(config, handlers, options) {
318
317
  var _a;
319
318
  const { origin: appOrigin } = new url.URL(config.appUrl);
320
- const authUrl = new url.URL((_a = options.callbackUrl) != null ? _a : config.baseUrl);
321
- const { cookieDomain, cookiePath, secure } = getCookieConfig(authUrl, options.providerId);
319
+ const cookieConfigurer = (_a = config.cookieConfigurer) != null ? _a : defaultCookieConfigurer;
320
+ const cookieConfig = cookieConfigurer({
321
+ providerId: options.providerId,
322
+ baseUrl: config.baseUrl,
323
+ callbackUrl: options.callbackUrl
324
+ });
322
325
  return new OAuthAdapter(handlers, {
323
326
  ...options,
324
327
  appOrigin,
325
- cookieDomain,
326
- cookiePath,
327
- secure,
328
+ cookieDomain: cookieConfig.domain,
329
+ cookiePath: cookieConfig.path,
330
+ secure: cookieConfig.secure,
328
331
  isOriginAllowed: config.isOriginAllowed
329
332
  });
330
333
  }
@@ -732,7 +735,6 @@ const createAtlassianProvider = (options) => {
732
735
  tokenIssuer
733
736
  });
734
737
  return OAuthAdapter.fromConfig(globalConfig, provider, {
735
- disableRefresh: true,
736
738
  providerId,
737
739
  tokenIssuer,
738
740
  callbackUrl
@@ -3071,7 +3073,11 @@ async function createRouter(options) {
3071
3073
  try {
3072
3074
  const provider = providerFactory({
3073
3075
  providerId,
3074
- globalConfig: { baseUrl: authUrl, appUrl, isOriginAllowed },
3076
+ globalConfig: {
3077
+ baseUrl: authUrl,
3078
+ appUrl,
3079
+ isOriginAllowed
3080
+ },
3075
3081
  config: providersConfig.getConfig(providerId),
3076
3082
  logger,
3077
3083
  tokenManager,