@backstage/plugin-auth-backend-module-atlassian-provider 0.3.1-next.0 → 0.3.1-next.1

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,14 @@
1
1
  # @backstage/plugin-auth-backend-module-atlassian-provider
2
2
 
3
+ ## 0.3.1-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 217458a: Updated configuration schema to include the new `allowedDomains` option for the `emailLocalPartMatchingUserEntityName` sign-in resolver.
8
+ - Updated dependencies
9
+ - @backstage/plugin-auth-node@0.5.3-next.1
10
+ - @backstage/backend-plugin-api@1.0.1-next.1
11
+
3
12
  ## 0.3.1-next.0
4
13
 
5
14
  ### Patch Changes
package/config.d.ts CHANGED
@@ -31,7 +31,10 @@ export interface Config {
31
31
  signIn?: {
32
32
  resolvers: Array<
33
33
  | { resolver: 'usernameMatchingUserEntityName' }
34
- | { resolver: 'emailLocalPartMatchingUserEntityName' }
34
+ | {
35
+ resolver: 'emailLocalPartMatchingUserEntityName';
36
+ allowedDomains?: string[];
37
+ }
35
38
  | { resolver: 'emailMatchingUserEntityProfileEmail' }
36
39
  >;
37
40
  };
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ var pluginAuthNode = require('@backstage/plugin-auth-node');
4
+ var AtlassianStrategy = require('passport-atlassian-oauth2');
5
+
6
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
+
8
+ var AtlassianStrategy__default = /*#__PURE__*/_interopDefaultCompat(AtlassianStrategy);
9
+
10
+ const atlassianAuthenticator = pluginAuthNode.createOAuthAuthenticator({
11
+ defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
12
+ scopes: {
13
+ required: ["offline_access", "read:me", "read:jira-work", "read:jira-user"]
14
+ },
15
+ initialize({ callbackUrl, config }) {
16
+ const clientId = config.getString("clientId");
17
+ const clientSecret = config.getString("clientSecret");
18
+ const baseUrl = "https://auth.atlassian.com";
19
+ if (config.has("scope") || config.has("scopes")) {
20
+ throw new Error(
21
+ 'The atlassian provider no longer supports the "scope" or "scopes" configuration options. Please use the "additionalScopes" option instead.'
22
+ );
23
+ }
24
+ return pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
25
+ new AtlassianStrategy__default.default(
26
+ {
27
+ clientID: clientId,
28
+ clientSecret,
29
+ callbackURL: callbackUrl,
30
+ baseURL: baseUrl,
31
+ authorizationURL: `${baseUrl}/authorize`,
32
+ tokenURL: `${baseUrl}/oauth/token`,
33
+ profileURL: "https://api.atlassian.com/me",
34
+ scope: []
35
+ // the Atlassian strategy requires a scope, but Backstage passes the right set of scopes when calling OAuth2Strategy.prototype.authenticate
36
+ },
37
+ (accessToken, refreshToken, params, fullProfile, done) => {
38
+ done(
39
+ void 0,
40
+ { fullProfile, params, accessToken },
41
+ { refreshToken }
42
+ );
43
+ }
44
+ )
45
+ );
46
+ },
47
+ async start(input, helper) {
48
+ return helper.start(input, {
49
+ accessType: "offline",
50
+ prompt: "consent"
51
+ });
52
+ },
53
+ async authenticate(input, helper) {
54
+ return helper.authenticate(input);
55
+ },
56
+ async refresh(input, helper) {
57
+ return helper.refresh(input);
58
+ }
59
+ });
60
+
61
+ exports.atlassianAuthenticator = atlassianAuthenticator;
62
+ //# sourceMappingURL=authenticator.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authenticator.cjs.js","sources":["../src/authenticator.ts"],"sourcesContent":["/*\n * Copyright 2023 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 createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport AtlassianStrategy from 'passport-atlassian-oauth2';\n\n/** @public */\nexport const atlassianAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n required: ['offline_access', 'read:me', 'read:jira-work', 'read:jira-user'],\n },\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const baseUrl = 'https://auth.atlassian.com';\n\n if (config.has('scope') || config.has('scopes')) {\n throw new Error(\n 'The atlassian provider no longer supports the \"scope\" or \"scopes\" configuration options. Please use the \"additionalScopes\" option instead.',\n );\n }\n\n return PassportOAuthAuthenticatorHelper.from(\n new AtlassianStrategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n baseURL: baseUrl,\n authorizationURL: `${baseUrl}/authorize`,\n tokenURL: `${baseUrl}/oauth/token`,\n profileURL: 'https://api.atlassian.com/me',\n scope: [], // the Atlassian strategy requires a scope, but Backstage passes the right set of scopes when calling OAuth2Strategy.prototype.authenticate\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(\n undefined,\n { fullProfile, params, accessToken },\n { refreshToken },\n );\n },\n ),\n );\n },\n\n async start(input, helper) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n });\n },\n\n async authenticate(input, helper) {\n return helper.authenticate(input);\n },\n\n async refresh(input, helper) {\n return helper.refresh(input);\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","AtlassianStrategy"],"mappings":";;;;;;;;;AAyBO,MAAM,yBAAyBA,uCAAyB,CAAA;AAAA,EAC7D,yBACEC,+CAAiC,CAAA,uBAAA;AAAA,EACnC,MAAQ,EAAA;AAAA,IACN,QA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AY,EAAA,SAAA;AAAA,MACZ,MAAQ,EAAA,SAAA;AAAA,KACT,CAAA,CAAA;AAAA,GACH;AAAA,EAEA,MAAM,YAAa,CAAA,KAAA,EAAO,MAAQ,EAAA;AAChC,IAAO,OAAA,MAAA,CAAO,aAAa,KAAK,CAAA,CAAA;AAAA,GAClC;AAAA,EAEA,MAAM,OAAQ,CAAA,KAAA,EAAO,MAAQ,EAAA;AAC3B,IAAO,OAAA,MAAA,CAAO,QAAQ,KAAK,CAAA,CAAA;AAAA,GAC7B;AACF,CAAC;;;;"}
package/dist/index.cjs.js CHANGED
@@ -2,105 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var pluginAuthNode = require('@backstage/plugin-auth-node');
6
- var AtlassianStrategy = require('passport-atlassian-oauth2');
7
- var backendPluginApi = require('@backstage/backend-plugin-api');
5
+ var authenticator = require('./authenticator.cjs.js');
6
+ var module$1 = require('./module.cjs.js');
7
+ var resolvers = require('./resolvers.cjs.js');
8
8
 
9
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
9
 
11
- var AtlassianStrategy__default = /*#__PURE__*/_interopDefaultCompat(AtlassianStrategy);
12
10
 
13
- const atlassianAuthenticator = pluginAuthNode.createOAuthAuthenticator({
14
- defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
15
- scopes: {
16
- required: ["offline_access", "read:me", "read:jira-work", "read:jira-user"]
17
- },
18
- initialize({ callbackUrl, config }) {
19
- const clientId = config.getString("clientId");
20
- const clientSecret = config.getString("clientSecret");
21
- const baseUrl = "https://auth.atlassian.com";
22
- if (config.has("scope") || config.has("scopes")) {
23
- throw new Error(
24
- 'The atlassian provider no longer supports the "scope" or "scopes" configuration options. Please use the "additionalScopes" option instead.'
25
- );
26
- }
27
- return pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
28
- new AtlassianStrategy__default.default(
29
- {
30
- clientID: clientId,
31
- clientSecret,
32
- callbackURL: callbackUrl,
33
- baseURL: baseUrl,
34
- authorizationURL: `${baseUrl}/authorize`,
35
- tokenURL: `${baseUrl}/oauth/token`,
36
- profileURL: "https://api.atlassian.com/me",
37
- scope: []
38
- // the Atlassian strategy requires a scope, but Backstage passes the right set of scopes when calling OAuth2Strategy.prototype.authenticate
39
- },
40
- (accessToken, refreshToken, params, fullProfile, done) => {
41
- done(
42
- void 0,
43
- { fullProfile, params, accessToken },
44
- { refreshToken }
45
- );
46
- }
47
- )
48
- );
49
- },
50
- async start(input, helper) {
51
- return helper.start(input, {
52
- accessType: "offline",
53
- prompt: "consent"
54
- });
55
- },
56
- async authenticate(input, helper) {
57
- return helper.authenticate(input);
58
- },
59
- async refresh(input, helper) {
60
- return helper.refresh(input);
61
- }
11
+ exports.atlassianAuthenticator = authenticator.atlassianAuthenticator;
12
+ exports.default = module$1.authModuleAtlassianProvider;
13
+ Object.defineProperty(exports, "atlassianSignInResolvers", {
14
+ enumerable: true,
15
+ get: function () { return resolvers.atlassianSignInResolvers; }
62
16
  });
63
-
64
- exports.atlassianSignInResolvers = void 0;
65
- ((atlassianSignInResolvers2) => {
66
- atlassianSignInResolvers2.usernameMatchingUserEntityName = pluginAuthNode.createSignInResolverFactory({
67
- create() {
68
- return async (info, ctx) => {
69
- const { result } = info;
70
- const id = result.fullProfile.username;
71
- if (!id) {
72
- throw new Error(`Atlassian user profile does not contain a username`);
73
- }
74
- return ctx.signInWithCatalogUser({ entityRef: { name: id } });
75
- };
76
- }
77
- });
78
- })(exports.atlassianSignInResolvers || (exports.atlassianSignInResolvers = {}));
79
-
80
- const authModuleAtlassianProvider = backendPluginApi.createBackendModule({
81
- pluginId: "auth",
82
- moduleId: "atlassian-provider",
83
- register(reg) {
84
- reg.registerInit({
85
- deps: {
86
- providers: pluginAuthNode.authProvidersExtensionPoint
87
- },
88
- async init({ providers }) {
89
- providers.registerProvider({
90
- providerId: "atlassian",
91
- factory: pluginAuthNode.createOAuthProviderFactory({
92
- authenticator: atlassianAuthenticator,
93
- signInResolverFactories: {
94
- ...exports.atlassianSignInResolvers,
95
- ...pluginAuthNode.commonSignInResolvers
96
- }
97
- })
98
- });
99
- }
100
- });
101
- }
102
- });
103
-
104
- exports.atlassianAuthenticator = atlassianAuthenticator;
105
- exports.default = authModuleAtlassianProvider;
106
17
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/authenticator.ts","../src/resolvers.ts","../src/module.ts"],"sourcesContent":["/*\n * Copyright 2023 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 createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport AtlassianStrategy from 'passport-atlassian-oauth2';\n\n/** @public */\nexport const atlassianAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n required: ['offline_access', 'read:me', 'read:jira-work', 'read:jira-user'],\n },\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const baseUrl = 'https://auth.atlassian.com';\n\n if (config.has('scope') || config.has('scopes')) {\n throw new Error(\n 'The atlassian provider no longer supports the \"scope\" or \"scopes\" configuration options. Please use the \"additionalScopes\" option instead.',\n );\n }\n\n return PassportOAuthAuthenticatorHelper.from(\n new AtlassianStrategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n baseURL: baseUrl,\n authorizationURL: `${baseUrl}/authorize`,\n tokenURL: `${baseUrl}/oauth/token`,\n profileURL: 'https://api.atlassian.com/me',\n scope: [], // the Atlassian strategy requires a scope, but Backstage passes the right set of scopes when calling OAuth2Strategy.prototype.authenticate\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(\n undefined,\n { fullProfile, params, accessToken },\n { refreshToken },\n );\n },\n ),\n );\n },\n\n async start(input, helper) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n });\n },\n\n async authenticate(input, helper) {\n return helper.authenticate(input);\n },\n\n async refresh(input, helper) {\n return helper.refresh(input);\n },\n});\n","/*\n * Copyright 2023 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 createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\n/**\n * Available sign-in resolvers for the Atlassian auth provider.\n *\n * @public\n */\nexport namespace atlassianSignInResolvers {\n /**\n * Looks up the user by matching their Atlassian username to the entity name.\n */\n export const usernameMatchingUserEntityName = createSignInResolverFactory({\n create() {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { result } = info;\n\n const id = result.fullProfile.username;\n if (!id) {\n throw new Error(`Atlassian user profile does not contain a username`);\n }\n\n return ctx.signInWithCatalogUser({ entityRef: { name: id } });\n };\n },\n });\n}\n","/*\n * Copyright 2023 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 */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { atlassianAuthenticator } from './authenticator';\nimport { atlassianSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleAtlassianProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'atlassian-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'atlassian',\n factory: createOAuthProviderFactory({\n authenticator: atlassianAuthenticator,\n signInResolverFactories: {\n ...atlassianSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","AtlassianStrategy","atlassianSignInResolvers","createSignInResolverFactory","createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","commonSignInResolvers"],"mappings":";;;;;;;;;;;;AAyBO,MAAM,yBAAyBA,uCAAyB,CAAA;AAAA,EAC7D,yBACEC,+CAAiC,CAAA,uBAAA;AAAA,EACnC,MAAQ,EAAA;AAAA,IACN,QAAU,EAAA,CAAC,gBAAkB,EAAA,SAAA,EAAW,kBAAkB,gBAAgB,CAAA;AAAA,GAC5E;AAAA,EACA,UAAW,CAAA,EAAE,WAAa,EAAA,MAAA,EAAU,EAAA;AAClC,IAAM,MAAA,QAAA,GAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA,CAAA;AAC5C,IAAM,MAAA,YAAA,GAAe,MAAO,CAAA,SAAA,CAAU,cAAc,CAAA,CAAA;AACpD,IAAA,M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ACF,CAAC;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var pluginAuthNode = require('@backstage/plugin-auth-node');
5
+ var authenticator = require('./authenticator.cjs.js');
6
+ var resolvers = require('./resolvers.cjs.js');
7
+
8
+ const authModuleAtlassianProvider = backendPluginApi.createBackendModule({
9
+ pluginId: "auth",
10
+ moduleId: "atlassian-provider",
11
+ register(reg) {
12
+ reg.registerInit({
13
+ deps: {
14
+ providers: pluginAuthNode.authProvidersExtensionPoint
15
+ },
16
+ async init({ providers }) {
17
+ providers.registerProvider({
18
+ providerId: "atlassian",
19
+ factory: pluginAuthNode.createOAuthProviderFactory({
20
+ authenticator: authenticator.atlassianAuthenticator,
21
+ signInResolverFactories: {
22
+ ...resolvers.atlassianSignInResolvers,
23
+ ...pluginAuthNode.commonSignInResolvers
24
+ }
25
+ })
26
+ });
27
+ }
28
+ });
29
+ }
30
+ });
31
+
32
+ exports.authModuleAtlassianProvider = authModuleAtlassianProvider;
33
+ //# sourceMappingURL=module.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { atlassianAuthenticator } from './authenticator';\nimport { atlassianSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleAtlassianProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'atlassian-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'atlassian',\n factory: createOAuthProviderFactory({\n authenticator: atlassianAuthenticator,\n signInResolverFactories: {\n ...atlassianSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","atlassianAuthenticator","atlassianSignInResolvers","commonSignInResolvers"],"mappings":";;;;;;;AAyBO,MAAM,8BAA8BA,oCAAoB,CAAA;AAAA,EAC7D,QAAU,EAAA,MAAA;AAAA,EACV,QAAU,EAAA,oBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,SAAW,EAAAC,0CAAA;AAAA,OACb;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAa,EAAA;AACxB,QAAA,SAAA,CAAU,gBAAiB,CAAA;AAAA,UACzB,UAAY,EAAA,WAAA;AAAA,UACZ,SAASC,yCAA2B,CAAA;AAAA,YAClC,aAAe,EAAAC,oCAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGC,kCAAA;AAAA,cACH,GAAGC,oCAAA;AAAA,aACL;AAAA,WACD,CAAA;AAAA,SACF,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var pluginAuthNode = require('@backstage/plugin-auth-node');
4
+
5
+ exports.atlassianSignInResolvers = void 0;
6
+ ((atlassianSignInResolvers2) => {
7
+ atlassianSignInResolvers2.usernameMatchingUserEntityName = pluginAuthNode.createSignInResolverFactory({
8
+ create() {
9
+ return async (info, ctx) => {
10
+ const { result } = info;
11
+ const id = result.fullProfile.username;
12
+ if (!id) {
13
+ throw new Error(`Atlassian user profile does not contain a username`);
14
+ }
15
+ return ctx.signInWithCatalogUser({ entityRef: { name: id } });
16
+ };
17
+ }
18
+ });
19
+ })(exports.atlassianSignInResolvers || (exports.atlassianSignInResolvers = {}));
20
+ //# sourceMappingURL=resolvers.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvers.cjs.js","sources":["../src/resolvers.ts"],"sourcesContent":["/*\n * Copyright 2023 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 createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\n/**\n * Available sign-in resolvers for the Atlassian auth provider.\n *\n * @public\n */\nexport namespace atlassianSignInResolvers {\n /**\n * Looks up the user by matching their Atlassian username to the entity name.\n */\n export const usernameMatchingUserEntityName = createSignInResolverFactory({\n create() {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { result } = info;\n\n const id = result.fullProfile.username;\n if (!id) {\n throw new Error(`Atlassian user profile does not contain a username`);\n }\n\n return ctx.signInWithCatalogUser({ entityRef: { name: id } });\n };\n },\n });\n}\n"],"names":["atlassianSignInResolvers","createSignInResolverFactory"],"mappings":";;;;AA4BiBA,0CAAA;AAAA,CAAV,CAAUA,yBAAV,KAAA;AAIE,EAAMA,yBAAAA,CAAA,iCAAiCC,0CAA4B,CAAA;AAAA,IACxE,MAAS,GAAA;AACP,MAAO,OAAA,OACL,MACA,GACG,KAAA;AACH,QAAM,MAAA,EAAE,QAAW,GAAA,IAAA,CAAA;AAEnB,QAAM,MAAA,EAAA,GAAK,OAAO,WAAY,CAAA,QAAA,CAAA;AAC9B,QAAA,IAAI,CAAC,EAAI,EAAA;AACP,UAAM,MAAA,IAAI,MAAM,CAAoD,kDAAA,CAAA,CAAA,CAAA;AAAA,SACtE;AAEA,QAAO,OAAA,GAAA,CAAI,sBAAsB,EAAE,SAAA,EAAW,EAAE,IAAM,EAAA,EAAA,IAAM,CAAA,CAAA;AAAA,OAC9D,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AAAA,CApBc,EAAAD,gCAAA,KAAAA,gCAAA,GAAA,EAAA,CAAA,CAAA;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-auth-backend-module-atlassian-provider",
3
- "version": "0.3.1-next.0",
3
+ "version": "0.3.1-next.1",
4
4
  "description": "The atlassian-provider backend module for the auth plugin.",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -34,17 +34,17 @@
34
34
  "test": "backstage-cli package test"
35
35
  },
36
36
  "dependencies": {
37
- "@backstage/backend-plugin-api": "^1.0.1-next.0",
38
- "@backstage/plugin-auth-node": "^0.5.3-next.0",
37
+ "@backstage/backend-plugin-api": "1.0.1-next.1",
38
+ "@backstage/plugin-auth-node": "0.5.3-next.1",
39
39
  "express": "^4.18.2",
40
40
  "passport": "^0.7.0",
41
41
  "passport-atlassian-oauth2": "^2.1.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@backstage/backend-defaults": "^0.5.1-next.0",
45
- "@backstage/backend-test-utils": "^1.0.1-next.0",
46
- "@backstage/cli": "^0.28.0-next.0",
47
- "@backstage/plugin-auth-backend": "^0.23.1-next.0",
44
+ "@backstage/backend-defaults": "0.5.1-next.2",
45
+ "@backstage/backend-test-utils": "1.0.1-next.2",
46
+ "@backstage/cli": "0.28.0-next.2",
47
+ "@backstage/plugin-auth-backend": "0.23.1-next.1",
48
48
  "supertest": "^7.0.0"
49
49
  },
50
50
  "configSchema": "config.d.ts"