@backstage/plugin-auth-backend-module-auth0-provider 0.3.2-next.1 → 0.4.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,34 @@
1
1
  # @backstage/plugin-auth-backend-module-auth0-provider
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9244b70: Sign-out now redirects the browser to Auth0's `/v2/logout` endpoint, clearing the Auth0 session cookie so that the next sign-in creates a new Auth0 session. Previously, only the Backstage session was cleared, allowing users to sign back in without going through Auth0 logout first.
8
+
9
+ Set `federatedLogout: true` in the Auth0 provider config to additionally clear the upstream IdP session (e.g. Okta, Google). This is what guarantees a full re-login across the entire SSO chain and may require users to re-enter credentials.
10
+
11
+ ### Patch Changes
12
+
13
+ - b3bbd42: Added `createAuth0Authenticator` factory function that accepts a `CacheService` to cache Auth0 profile API responses for 1 minute during token refreshes. This avoids hitting Auth0 rate limits on repeated page refreshes. The module now uses the cached variant by default. The existing `auth0Authenticator` export remains available for use without caching.
14
+ - Updated dependencies
15
+ - @backstage/backend-plugin-api@1.9.0
16
+ - @backstage/errors@1.3.0
17
+ - @backstage/plugin-auth-node@0.7.0
18
+
19
+ ## 0.4.0-next.2
20
+
21
+ ### Minor Changes
22
+
23
+ - 9244b70: Added federated logout support. Set `federatedLogout: true` in the Auth0 provider config to clear both the Auth0 session and any upstream IdP session on sign-out. The authenticator returns a logout URL that redirects the browser to Auth0's `/v2/logout?federated` endpoint, ensuring users must fully re-authenticate after signing out.
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies
28
+ - @backstage/errors@1.3.0-next.0
29
+ - @backstage/plugin-auth-node@0.7.0-next.2
30
+ - @backstage/backend-plugin-api@1.9.0-next.2
31
+
3
32
  ## 0.3.2-next.1
4
33
 
5
34
  ### Patch Changes
package/config.d.ts CHANGED
@@ -33,6 +33,11 @@ export interface Config {
33
33
  connection?: string;
34
34
  connectionScope?: string;
35
35
  organization?: string;
36
+ /**
37
+ * Whether to perform federated logout, clearing both the Auth0
38
+ * session and any upstream IdP session. Defaults to false.
39
+ */
40
+ federatedLogout?: boolean;
36
41
  sessionDuration?: HumanDuration | string;
37
42
  };
38
43
  };
@@ -1,29 +1,33 @@
1
1
  'use strict';
2
2
 
3
+ var jose = require('jose');
3
4
  var pluginAuthNode = require('@backstage/plugin-auth-node');
4
5
  var strategy = require('./strategy.cjs.js');
5
6
 
6
- const auth0Authenticator = pluginAuthNode.createOAuthAuthenticator({
7
- defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
8
- initialize({ callbackUrl, config }) {
9
- const clientID = config.getString("clientId");
10
- const clientSecret = config.getString("clientSecret");
11
- const domain = config.getString("domain");
12
- const audience = config.getOptionalString("audience");
13
- const connection = config.getOptionalString("connection");
14
- const connectionScope = config.getOptionalString("connectionScope");
15
- const callbackURL = config.getOptionalString("callbackUrl") ?? callbackUrl;
16
- const organization = config.getOptionalString("organization");
17
- const store = {
18
- store(_req, cb) {
19
- cb(null, null);
20
- },
21
- verify(_req, _state, cb) {
22
- cb(null, true);
23
- }
24
- };
25
- const helper = pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
26
- new strategy.Auth0Strategy(
7
+ function createAuth0Authenticator(options) {
8
+ const profileCache = options?.cache?.withOptions({
9
+ defaultTtl: { minutes: 1 }
10
+ });
11
+ return pluginAuthNode.createOAuthAuthenticator({
12
+ defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
13
+ initialize({ callbackUrl, config }) {
14
+ const clientID = config.getString("clientId");
15
+ const clientSecret = config.getString("clientSecret");
16
+ const domain = config.getString("domain");
17
+ const audience = config.getOptionalString("audience");
18
+ const connection = config.getOptionalString("connection");
19
+ const connectionScope = config.getOptionalString("connectionScope");
20
+ const callbackURL = config.getOptionalString("callbackUrl") ?? callbackUrl;
21
+ const organization = config.getOptionalString("organization");
22
+ const store = {
23
+ store(_req, cb) {
24
+ cb(null, null);
25
+ },
26
+ verify(_req, _state, cb) {
27
+ cb(null, true);
28
+ }
29
+ };
30
+ const strategy$1 = new strategy.Auth0Strategy(
27
31
  {
28
32
  clientID,
29
33
  clientSecret,
@@ -48,30 +52,82 @@ const auth0Authenticator = pluginAuthNode.createOAuthAuthenticator({
48
52
  }
49
53
  );
50
54
  }
51
- )
52
- );
53
- return { helper, audience, connection, connectionScope };
54
- },
55
- async start(input, { helper, audience, connection, connectionScope: connection_scope }) {
56
- return helper.start(input, {
57
- accessType: "offline",
58
- prompt: "consent",
59
- ...audience ? { audience } : {},
60
- ...connection ? { connection } : {},
61
- ...connection_scope ? { connection_scope } : {}
62
- });
63
- },
64
- async authenticate(input, { helper, audience, connection, connectionScope: connection_scope }) {
65
- return helper.authenticate(input, {
66
- ...audience ? { audience } : {},
67
- ...connection ? { connection } : {},
68
- ...connection_scope ? { connection_scope } : {}
69
- });
70
- },
71
- async refresh(input, { helper }) {
72
- return helper.refresh(input);
73
- }
74
- });
55
+ );
56
+ const helper = pluginAuthNode.PassportOAuthAuthenticatorHelper.from(strategy$1);
57
+ const federated = config.getOptionalBoolean("federatedLogout") ?? false;
58
+ return {
59
+ helper,
60
+ strategy: strategy$1,
61
+ audience,
62
+ connection,
63
+ connectionScope,
64
+ domain,
65
+ clientID,
66
+ federated
67
+ };
68
+ },
69
+ async start(input, { helper, audience, connection, connectionScope: connection_scope }) {
70
+ return helper.start(input, {
71
+ accessType: "offline",
72
+ prompt: "consent",
73
+ ...audience ? { audience } : {},
74
+ ...connection ? { connection } : {},
75
+ ...connection_scope ? { connection_scope } : {}
76
+ });
77
+ },
78
+ async authenticate(input, { helper, audience, connection, connectionScope: connection_scope }) {
79
+ return helper.authenticate(input, {
80
+ ...audience ? { audience } : {},
81
+ ...connection ? { connection } : {},
82
+ ...connection_scope ? { connection_scope } : {}
83
+ });
84
+ },
85
+ async refresh(input, { helper, strategy }) {
86
+ const result = await pluginAuthNode.PassportHelpers.executeRefreshTokenStrategy(
87
+ strategy,
88
+ input.refreshToken,
89
+ input.scope
90
+ );
91
+ const { sub } = jose.decodeJwt(result.params.id_token);
92
+ const cacheKey = sub ? `auth0-profile:${sub}` : void 0;
93
+ let fullProfile = cacheKey ? await profileCache?.get(cacheKey) : void 0;
94
+ if (!fullProfile) {
95
+ fullProfile = await helper.fetchProfile(result.accessToken);
96
+ if (cacheKey) {
97
+ await profileCache?.set(
98
+ cacheKey,
99
+ JSON.parse(JSON.stringify(fullProfile))
100
+ );
101
+ }
102
+ }
103
+ return {
104
+ fullProfile,
105
+ session: {
106
+ accessToken: result.accessToken,
107
+ tokenType: result.params.token_type ?? "bearer",
108
+ scope: result.params.scope,
109
+ expiresInSeconds: result.params.expires_in,
110
+ idToken: result.params.id_token,
111
+ refreshToken: result.refreshToken
112
+ }
113
+ };
114
+ },
115
+ async logout(input, { domain, clientID, federated }) {
116
+ const logoutUrl = new URL(`https://${domain}/v2/logout`);
117
+ if (federated) {
118
+ logoutUrl.searchParams.set("federated", "");
119
+ }
120
+ logoutUrl.searchParams.set("client_id", clientID);
121
+ const origin = input.req.get("origin");
122
+ if (origin) {
123
+ logoutUrl.searchParams.set("returnTo", origin);
124
+ }
125
+ return { logoutUrl: logoutUrl.toString() };
126
+ }
127
+ });
128
+ }
129
+ const auth0Authenticator = createAuth0Authenticator();
75
130
 
76
131
  exports.auth0Authenticator = auth0Authenticator;
132
+ exports.createAuth0Authenticator = createAuth0Authenticator;
77
133
  //# sourceMappingURL=authenticator.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authenticator.cjs.js","sources":["../src/authenticator.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport express from 'express';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { Auth0Strategy } from './strategy';\n\n/** @public */\nexport const auth0Authenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientID = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const domain = config.getString('domain');\n const audience = config.getOptionalString('audience');\n const connection = config.getOptionalString('connection');\n const connectionScope = config.getOptionalString('connectionScope');\n const callbackURL = config.getOptionalString('callbackUrl') ?? callbackUrl;\n const organization = config.getOptionalString('organization');\n // Due to passport-auth0 forcing options.state = true,\n // passport-oauth2 requires express-session to be installed\n // so that the 'state' parameter of the oauth2 flow can be stored.\n // This implementation of StateStore matches the NullStore found within\n // passport-oauth2, which is the StateStore implementation used when options.state = false,\n // allowing us to avoid using express-session in order to integrate with auth0.\n const store = {\n store(_req: express.Request, cb: any) {\n cb(null, null);\n },\n verify(_req: express.Request, _state: string, cb: any) {\n cb(null, true);\n },\n };\n\n const helper = PassportOAuthAuthenticatorHelper.from(\n new Auth0Strategy(\n {\n clientID,\n clientSecret,\n callbackURL,\n domain,\n store,\n organization,\n // We need passReqToCallback set to false to get params, but there's\n // no matching type signature for that, so instead behold this beauty\n passReqToCallback: false as true,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(\n undefined,\n {\n fullProfile,\n accessToken,\n params,\n },\n {\n refreshToken,\n },\n );\n },\n ),\n );\n return { helper, audience, connection, connectionScope };\n },\n\n async start(\n input,\n { helper, audience, connection, connectionScope: connection_scope },\n ) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n ...(audience ? { audience } : {}),\n ...(connection ? { connection } : {}),\n ...(connection_scope ? { connection_scope } : {}),\n });\n },\n\n async authenticate(\n input,\n { helper, audience, connection, connectionScope: connection_scope },\n ) {\n return helper.authenticate(input, {\n ...(audience ? { audience } : {}),\n ...(connection ? { connection } : {}),\n ...(connection_scope ? { connection_scope } : {}),\n });\n },\n\n async refresh(input, { helper }) {\n return helper.refresh(input);\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","Auth0Strategy"],"mappings":";;;;;AA0BO,MAAM,qBAAqBA,uCAAA,CAAyB;AAAA,EACzD,yBACEC,+CAAA,CAAiC,uBAAA;AAAA,EACnC,UAAA,CAAW,EAAE,WAAA,EAAa,MAAA,EAAO,EAAG;AAClC,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,SAAA,CAAU,UAAU,CAAA;AAC5C,IAAA,MAAM,YAAA,GAAe,MAAA,CAAO,SAAA,CAAU,cAAc,CAAA;AACpD,IAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,QAAQ,CAAA;AACxC,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU,CAAA;AACpD,IAAA,MAAM,UAAA,GAAa,MAAA,CAAO,iBAAA,CAAkB,YAAY,CAAA;AACxD,IAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,iBAAA,CAAkB,iBAAiB,CAAA;AAClE,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,iBAAA,CAAkB,aAAa,CAAA,IAAK,WAAA;AAC/D,IAAA,MAAM,YAAA,GAAe,MAAA,CAAO,iBAAA,CAAkB,cAAc,CAAA;AAO5D,IAAA,MAAM,KAAA,GAAQ;AAAA,MACZ,KAAA,CAAM,MAAuB,EAAA,EAAS;AACpC,QAAA,EAAA,CAAG,MAAM,IAAI,CAAA;AAAA,MACf,CAAA;AAAA,MACA,MAAA,CAAO,IAAA,EAAuB,MAAA,EAAgB,EAAA,EAA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AAC;AAAA,MAC/B,GAAI,UAAA,GAAa,EAAE,UAAA,KAAe,EAAC;AAAA,MACnC,GAAI,gBAAA,GAAmB,EAAE,gBAAA,KAAqB;AAAC,KAChD,CAAA;AAAA,EACH,CAAA;AAAA,EAEA,MAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,QAAO,EAAG;AAC/B,IAAA,OAAO,MAAA,CAAO,QAAQ,KAAK,CAAA;AAAA,EAC7B;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"authenticator.cjs.js","sources":["../src/authenticator.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CacheService } from '@backstage/backend-plugin-api';\nimport express from 'express';\nimport { decodeJwt } from 'jose';\nimport { Strategy } from 'passport';\nimport {\n createOAuthAuthenticator,\n PassportHelpers,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { Auth0Strategy } from './strategy';\n\n/** @public */\nexport function createAuth0Authenticator(options?: { cache?: CacheService }) {\n const profileCache = options?.cache?.withOptions({\n defaultTtl: { minutes: 1 },\n });\n\n return createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientID = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const domain = config.getString('domain');\n const audience = config.getOptionalString('audience');\n const connection = config.getOptionalString('connection');\n const connectionScope = config.getOptionalString('connectionScope');\n const callbackURL =\n config.getOptionalString('callbackUrl') ?? callbackUrl;\n const organization = config.getOptionalString('organization');\n // Due to passport-auth0 forcing options.state = true,\n // passport-oauth2 requires express-session to be installed\n // so that the 'state' parameter of the oauth2 flow can be stored.\n // This implementation of StateStore matches the NullStore found within\n // passport-oauth2, which is the StateStore implementation used when options.state = false,\n // allowing us to avoid using express-session in order to integrate with auth0.\n const store = {\n store(_req: express.Request, cb: any) {\n cb(null, null);\n },\n verify(_req: express.Request, _state: string, cb: any) {\n cb(null, true);\n },\n };\n\n const strategy = new Auth0Strategy(\n {\n clientID,\n clientSecret,\n callbackURL,\n domain,\n store,\n organization,\n // We need passReqToCallback set to false to get params, but there's\n // no matching type signature for that, so instead behold this beauty\n passReqToCallback: false as true,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(\n undefined,\n {\n fullProfile,\n accessToken,\n params,\n },\n {\n refreshToken,\n },\n );\n },\n );\n\n const helper = PassportOAuthAuthenticatorHelper.from(strategy);\n const federated = config.getOptionalBoolean('federatedLogout') ?? false;\n return {\n helper,\n strategy: strategy as Strategy,\n audience,\n connection,\n connectionScope,\n domain,\n clientID,\n federated,\n };\n },\n\n async start(\n input,\n { helper, audience, connection, connectionScope: connection_scope },\n ) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n ...(audience ? { audience } : {}),\n ...(connection ? { connection } : {}),\n ...(connection_scope ? { connection_scope } : {}),\n });\n },\n\n async authenticate(\n input,\n { helper, audience, connection, connectionScope: connection_scope },\n ) {\n return helper.authenticate(input, {\n ...(audience ? { audience } : {}),\n ...(connection ? { connection } : {}),\n ...(connection_scope ? { connection_scope } : {}),\n });\n },\n\n async refresh(input, { helper, strategy }) {\n const result = await PassportHelpers.executeRefreshTokenStrategy(\n strategy,\n input.refreshToken,\n input.scope,\n );\n\n const { sub } = decodeJwt(result.params.id_token);\n const cacheKey = sub ? `auth0-profile:${sub}` : undefined;\n\n let fullProfile = cacheKey\n ? ((await profileCache?.get(cacheKey)) as PassportProfile | undefined)\n : undefined;\n\n if (!fullProfile) {\n fullProfile = await helper.fetchProfile(result.accessToken);\n if (cacheKey) {\n await profileCache?.set(\n cacheKey,\n JSON.parse(JSON.stringify(fullProfile)),\n );\n }\n }\n\n return {\n fullProfile,\n session: {\n accessToken: result.accessToken,\n tokenType: result.params.token_type ?? 'bearer',\n scope: result.params.scope,\n expiresInSeconds: result.params.expires_in,\n idToken: result.params.id_token,\n refreshToken: result.refreshToken,\n },\n };\n },\n\n async logout(input, { domain, clientID, federated }) {\n const logoutUrl = new URL(`https://${domain}/v2/logout`);\n if (federated) {\n logoutUrl.searchParams.set('federated', '');\n }\n logoutUrl.searchParams.set('client_id', clientID);\n const origin = input.req.get('origin');\n if (origin) {\n logoutUrl.searchParams.set('returnTo', origin);\n }\n return { logoutUrl: logoutUrl.toString() };\n },\n });\n}\n\n/** @public */\nexport const auth0Authenticator = createAuth0Authenticator();\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","strategy","Auth0Strategy","PassportHelpers","decodeJwt"],"mappings":";;;;;;AA8BO,SAAS,yBAAyB,OAAA,EAAoC;AAC3E,EAAA,MAAM,YAAA,GAAe,OAAA,EAAS,KAAA,EAAO,WAAA,CAAY;AAAA,IAC/C,UAAA,EAAY,EAAE,OAAA,EAAS,CAAA;AAAE,GAC1B,CAAA;AAED,EAAA,OAAOA,uCAAA,CAAyB;AAAA,IAC9B,yBACEC,+CAAA,CAAiC,uBAAA;AAAA,IACnC,UAAA,CAAW,EAAE,WAAA,EAAa,MAAA,EAAO,EAAG;AAClC,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,SAAA,CAAU,UAAU,CAAA;AAC5C,MAAA,MAAM,YAAA,GAAe,MAAA,CAAO,SAAA,CAAU,cAAc,CAAA;AACpD,MAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,QAAQ,CAAA;AACxC,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,iBAAA,CAAkB,UAAU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AAI,MAAA,EAAQ;AACV,QAAA,SAAA,CAAU,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,MAAM,CAAA;AAAA,MAC/C;AACA,MAAA,OAAO,EAAE,SAAA,EAAW,SAAA,CAAU,QAAA,EAAS,EAAE;AAAA,IAC3C;AAAA,GACD,CAAA;AACH;AAGO,MAAM,qBAAqB,wBAAA;;;;;"}
package/dist/index.cjs.js CHANGED
@@ -8,5 +8,6 @@ var module$1 = require('./module.cjs.js');
8
8
 
9
9
 
10
10
  exports.auth0Authenticator = authenticator.auth0Authenticator;
11
+ exports.createAuth0Authenticator = authenticator.createAuth0Authenticator;
11
12
  exports.default = module$1.authModuleAuth0Provider;
12
13
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,16 +1,35 @@
1
1
  import * as _backstage_plugin_auth_node from '@backstage/plugin-auth-node';
2
2
  import { PassportOAuthAuthenticatorHelper, PassportProfile } from '@backstage/plugin-auth-node';
3
3
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
4
+ import { CacheService } from '@backstage/backend-plugin-api';
5
+ import { Strategy } from 'passport';
4
6
 
7
+ /** @public */
8
+ declare function createAuth0Authenticator(options?: {
9
+ cache?: CacheService;
10
+ }): _backstage_plugin_auth_node.OAuthAuthenticator<{
11
+ helper: PassportOAuthAuthenticatorHelper;
12
+ strategy: Strategy;
13
+ audience: string | undefined;
14
+ connection: string | undefined;
15
+ connectionScope: string | undefined;
16
+ domain: string;
17
+ clientID: string;
18
+ federated: boolean;
19
+ }, PassportProfile>;
5
20
  /** @public */
6
21
  declare const auth0Authenticator: _backstage_plugin_auth_node.OAuthAuthenticator<{
7
22
  helper: PassportOAuthAuthenticatorHelper;
23
+ strategy: Strategy;
8
24
  audience: string | undefined;
9
25
  connection: string | undefined;
10
26
  connectionScope: string | undefined;
27
+ domain: string;
28
+ clientID: string;
29
+ federated: boolean;
11
30
  }, PassportProfile>;
12
31
 
13
32
  /** @public */
14
33
  declare const authModuleAuth0Provider: _backstage_backend_plugin_api.BackendFeature;
15
34
 
16
- export { auth0Authenticator, authModuleAuth0Provider as default };
35
+ export { auth0Authenticator, createAuth0Authenticator, authModuleAuth0Provider as default };
@@ -10,13 +10,14 @@ const authModuleAuth0Provider = backendPluginApi.createBackendModule({
10
10
  register(reg) {
11
11
  reg.registerInit({
12
12
  deps: {
13
- providers: pluginAuthNode.authProvidersExtensionPoint
13
+ providers: pluginAuthNode.authProvidersExtensionPoint,
14
+ cache: backendPluginApi.coreServices.cache
14
15
  },
15
- async init({ providers }) {
16
+ async init({ providers, cache }) {
16
17
  providers.registerProvider({
17
18
  providerId: "auth0",
18
19
  factory: pluginAuthNode.createOAuthProviderFactory({
19
- authenticator: authenticator.auth0Authenticator,
20
+ authenticator: authenticator.createAuth0Authenticator({ cache }),
20
21
  signInResolverFactories: {
21
22
  ...pluginAuthNode.commonSignInResolvers
22
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { auth0Authenticator } from './authenticator';\n\n/** @public */\nexport const authModuleAuth0Provider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'auth0-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'auth0',\n factory: createOAuthProviderFactory({\n authenticator: auth0Authenticator,\n signInResolverFactories: {\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","auth0Authenticator","commonSignInResolvers"],"mappings":";;;;;;AAyBO,MAAM,0BAA0BA,oCAAA,CAAoB;AAAA,EACzD,QAAA,EAAU,MAAA;AAAA,EACV,QAAA,EAAU,gBAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,SAAA,EAAWC;AAAA,OACb;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAU,EAAG;AACxB,QAAA,SAAA,CAAU,gBAAA,CAAiB;AAAA,UACzB,UAAA,EAAY,OAAA;AAAA,UACZ,SAASC,yCAAA,CAA2B;AAAA,YAClC,aAAA,EAAeC,gCAAA;AAAA,YACf,uBAAA,EAAyB;AAAA,cACvB,GAAGC;AAAA;AACL,WACD;AAAA,SACF,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { createAuth0Authenticator } from './authenticator';\n\n/** @public */\nexport const authModuleAuth0Provider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'auth0-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n cache: coreServices.cache,\n },\n async init({ providers, cache }) {\n providers.registerProvider({\n providerId: 'auth0',\n factory: createOAuthProviderFactory({\n authenticator: createAuth0Authenticator({ cache }),\n signInResolverFactories: {\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","coreServices","createOAuthProviderFactory","createAuth0Authenticator","commonSignInResolvers"],"mappings":";;;;;;AA4BO,MAAM,0BAA0BA,oCAAA,CAAoB;AAAA,EACzD,QAAA,EAAU,MAAA;AAAA,EACV,QAAA,EAAU,gBAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,SAAA,EAAWC,0CAAA;AAAA,QACX,OAAOC,6BAAA,CAAa;AAAA,OACtB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAW,OAAM,EAAG;AAC/B,QAAA,SAAA,CAAU,gBAAA,CAAiB;AAAA,UACzB,UAAA,EAAY,OAAA;AAAA,UACZ,SAASC,yCAAA,CAA2B;AAAA,YAClC,aAAA,EAAeC,sCAAA,CAAyB,EAAE,KAAA,EAAO,CAAA;AAAA,YACjD,uBAAA,EAAyB;AAAA,cACvB,GAAGC;AAAA;AACL,WACD;AAAA,SACF,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-auth-backend-module-auth0-provider",
3
- "version": "0.3.2-next.1",
3
+ "version": "0.4.0",
4
4
  "description": "The auth0-provider backend module for the auth plugin.",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -37,21 +37,22 @@
37
37
  "test": "backstage-cli package test"
38
38
  },
39
39
  "dependencies": {
40
- "@backstage/backend-plugin-api": "1.9.0-next.1",
41
- "@backstage/errors": "1.2.7",
42
- "@backstage/plugin-auth-node": "0.7.0-next.1",
40
+ "@backstage/backend-plugin-api": "^1.9.0",
41
+ "@backstage/errors": "^1.3.0",
42
+ "@backstage/plugin-auth-node": "^0.7.0",
43
+ "@types/passport": "^1.0.3",
43
44
  "express": "^4.22.0",
45
+ "jose": "^5.0.0",
44
46
  "passport": "^0.7.0",
45
47
  "passport-auth0": "^1.4.3",
46
48
  "passport-oauth2": "^1.6.1"
47
49
  },
48
50
  "devDependencies": {
49
- "@backstage/backend-defaults": "0.16.1-next.1",
50
- "@backstage/backend-test-utils": "1.11.2-next.1",
51
- "@backstage/cli": "0.36.1-next.1",
52
- "@backstage/plugin-auth-backend": "0.28.0-next.1",
53
- "@backstage/types": "1.2.2",
54
- "@types/passport": "^1.0.3",
51
+ "@backstage/backend-defaults": "^0.17.0",
52
+ "@backstage/backend-test-utils": "^1.11.2",
53
+ "@backstage/cli": "^0.36.1",
54
+ "@backstage/plugin-auth-backend": "^0.28.0",
55
+ "@backstage/types": "^1.2.2",
55
56
  "@types/passport-auth0": "^1.0.5",
56
57
  "@types/passport-oauth2": "^1.4.15",
57
58
  "supertest": "^7.0.0"