@backstage/plugin-auth-backend-module-bitbucket-provider 0.2.1-next.0 → 0.2.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,23 @@
1
1
  # @backstage/plugin-auth-backend-module-bitbucket-provider
2
2
 
3
+ ## 0.2.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
10
+ - @backstage/backend-plugin-api@1.0.1
11
+
12
+ ## 0.2.1-next.1
13
+
14
+ ### Patch Changes
15
+
16
+ - 217458a: Updated configuration schema to include the new `allowedDomains` option for the `emailLocalPartMatchingUserEntityName` sign-in resolver.
17
+ - Updated dependencies
18
+ - @backstage/plugin-auth-node@0.5.3-next.1
19
+ - @backstage/backend-plugin-api@1.0.1-next.1
20
+
3
21
  ## 0.2.1-next.0
4
22
 
5
23
  ### Patch Changes
package/config.d.ts CHANGED
@@ -29,7 +29,10 @@ export interface Config {
29
29
  signIn?: {
30
30
  resolvers: Array<
31
31
  | { resolver: 'userIdMatchingUserEntityAnnotation' }
32
- | { resolver: 'emailLocalPartMatchingUserEntityName' }
32
+ | {
33
+ resolver: 'emailLocalPartMatchingUserEntityName';
34
+ allowedDomains?: string[];
35
+ }
33
36
  | { resolver: 'emailMatchingUserEntityProfileEmail' }
34
37
  >;
35
38
  };
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var passportBitbucketOauth2 = require('passport-bitbucket-oauth2');
4
+ var pluginAuthNode = require('@backstage/plugin-auth-node');
5
+
6
+ const bitbucketAuthenticator = pluginAuthNode.createOAuthAuthenticator({
7
+ defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
8
+ scopes: {
9
+ required: ["account"]
10
+ },
11
+ initialize({ callbackUrl, config }) {
12
+ const clientID = config.getString("clientId");
13
+ const clientSecret = config.getString("clientSecret");
14
+ const baseURL = "https://bitbucket.org/site/oauth2";
15
+ return pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
16
+ new passportBitbucketOauth2.Strategy(
17
+ {
18
+ clientID,
19
+ clientSecret,
20
+ callbackURL: callbackUrl,
21
+ passReqToCallback: false,
22
+ baseURL,
23
+ authorizationURL: `${baseURL}/authorize`,
24
+ tokenURL: `${baseURL}/access_token`
25
+ },
26
+ (accessToken, refreshToken, params, fullProfile, done) => {
27
+ done(
28
+ void 0,
29
+ { fullProfile, params, accessToken },
30
+ { refreshToken }
31
+ );
32
+ }
33
+ )
34
+ );
35
+ },
36
+ async start(input, helper) {
37
+ return helper.start(input, {
38
+ accessType: "offline",
39
+ prompt: "consent"
40
+ });
41
+ },
42
+ async authenticate(input, helper) {
43
+ return helper.authenticate(input);
44
+ },
45
+ async refresh(input, helper) {
46
+ return helper.refresh(input);
47
+ }
48
+ });
49
+
50
+ exports.bitbucketAuthenticator = bitbucketAuthenticator;
51
+ //# sourceMappingURL=authenticator.cjs.js.map
@@ -0,0 +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 { Strategy as BitbucketStrategy } from 'passport-bitbucket-oauth2';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\n\n/** @public */\nexport const bitbucketAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n required: ['account'],\n },\n initialize({ callbackUrl, config }) {\n const clientID = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const baseURL = 'https://bitbucket.org/site/oauth2';\n\n return PassportOAuthAuthenticatorHelper.from(\n new BitbucketStrategy(\n {\n clientID,\n clientSecret,\n callbackURL: callbackUrl,\n passReqToCallback: false,\n baseURL,\n authorizationURL: `${baseURL}/authorize`,\n tokenURL: `${baseURL}/access_token`,\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","BitbucketStrategy"],"mappings":";;;;;AAyBO,MAAM,yBAAyBA,uCAAyB,CAAA;AAAA,EAC7D,yBACEC,+CAAiC,CAAA,uBAAA;AAAA,EACnC,MAAQ,EAAA;AAAA,IACN,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,GACtB;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,MAAM,OAAU,GAAA,mCAAA,CAAA;AAEhB,IAAA,OAAOA,+CAAiC,CAAA,IAAA;AAAA,MACtC,IAAIC,gCAAA;AAAA,QACF;AAAA,UACE,QAAA;AAAA,UACA,YAAA;AAAA,UACA,WAAa,EAAA,WAAA;AAAA,UACb,iBAAmB,EAAA,KAAA;AAAA,UACnB,OAAA;AAAA,UACA,gBAAA,EAAkB,GAAG,OAAO,CAAA,UAAA,CAAA;AAAA,UAC5B,QAAA,EAAU,GAAG,OAAO,CAAA,aAAA,CAAA;AAAA,SACtB;AAAA,QACA,CACE,WAAA,EACA,YACA,EAAA,MAAA,EACA,aACA,IACG,KAAA;AACH,UAAA,IAAA;AAAA,YACE,KAAA,CAAA;AAAA,YACA,EAAE,WAAa,EAAA,MAAA,EAAQ,WAAY,EAAA;AAAA,YACnC,EAAE,YAAa,EAAA;AAAA,WACjB,CAAA;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACF;AAAA,EAEA,MAAM,KAAM,CAAA,KAAA,EAAO,MAAQ,EAAA;AACzB,IAAO,OAAA,MAAA,CAAO,MAAM,KAAO,EAAA;AAAA,MACzB,UAAY,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,118 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var passportBitbucketOauth2 = require('passport-bitbucket-oauth2');
6
- var pluginAuthNode = require('@backstage/plugin-auth-node');
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
- const bitbucketAuthenticator = pluginAuthNode.createOAuthAuthenticator({
10
- defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
11
- scopes: {
12
- required: ["account"]
13
- },
14
- initialize({ callbackUrl, config }) {
15
- const clientID = config.getString("clientId");
16
- const clientSecret = config.getString("clientSecret");
17
- const baseURL = "https://bitbucket.org/site/oauth2";
18
- return pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
19
- new passportBitbucketOauth2.Strategy(
20
- {
21
- clientID,
22
- clientSecret,
23
- callbackURL: callbackUrl,
24
- passReqToCallback: false,
25
- baseURL,
26
- authorizationURL: `${baseURL}/authorize`,
27
- tokenURL: `${baseURL}/access_token`
28
- },
29
- (accessToken, refreshToken, params, fullProfile, done) => {
30
- done(
31
- void 0,
32
- { fullProfile, params, accessToken },
33
- { refreshToken }
34
- );
35
- }
36
- )
37
- );
38
- },
39
- async start(input, helper) {
40
- return helper.start(input, {
41
- accessType: "offline",
42
- prompt: "consent"
43
- });
44
- },
45
- async authenticate(input, helper) {
46
- return helper.authenticate(input);
47
- },
48
- async refresh(input, helper) {
49
- return helper.refresh(input);
50
- }
51
- });
52
9
 
53
- exports.bitbucketSignInResolvers = void 0;
54
- ((bitbucketSignInResolvers2) => {
55
- bitbucketSignInResolvers2.userIdMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory(
56
- {
57
- create() {
58
- return async (info, ctx) => {
59
- const { result } = info;
60
- const id = result.fullProfile.id;
61
- if (!id) {
62
- throw new Error("Bitbucket user profile does not contain an ID");
63
- }
64
- return ctx.signInWithCatalogUser({
65
- annotations: {
66
- "bitbucket.org/user-id": id
67
- }
68
- });
69
- };
70
- }
71
- }
72
- );
73
- bitbucketSignInResolvers2.usernameMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
74
- create() {
75
- return async (info, ctx) => {
76
- const { result } = info;
77
- const username = result.fullProfile.username;
78
- if (!username) {
79
- throw new Error(
80
- "Bitbucket user profile does not contain a Username"
81
- );
82
- }
83
- return ctx.signInWithCatalogUser({
84
- annotations: {
85
- "bitbucket.org/username": username
86
- }
87
- });
88
- };
89
- }
90
- });
91
- })(exports.bitbucketSignInResolvers || (exports.bitbucketSignInResolvers = {}));
92
10
 
93
- const authModuleBitbucketProvider = backendPluginApi.createBackendModule({
94
- pluginId: "auth",
95
- moduleId: "bitbucket-provider",
96
- register(reg) {
97
- reg.registerInit({
98
- deps: {
99
- providers: pluginAuthNode.authProvidersExtensionPoint
100
- },
101
- async init({ providers }) {
102
- providers.registerProvider({
103
- providerId: "bitbucket",
104
- factory: pluginAuthNode.createOAuthProviderFactory({
105
- authenticator: bitbucketAuthenticator,
106
- signInResolverFactories: {
107
- ...exports.bitbucketSignInResolvers,
108
- ...pluginAuthNode.commonSignInResolvers
109
- }
110
- })
111
- });
112
- }
113
- });
114
- }
11
+ exports.bitbucketAuthenticator = authenticator.bitbucketAuthenticator;
12
+ exports.default = module$1.authModuleBitbucketProvider;
13
+ Object.defineProperty(exports, "bitbucketSignInResolvers", {
14
+ enumerable: true,
15
+ get: function () { return resolvers.bitbucketSignInResolvers; }
115
16
  });
116
-
117
- exports.bitbucketAuthenticator = bitbucketAuthenticator;
118
- exports.default = authModuleBitbucketProvider;
119
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 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 { Strategy as BitbucketStrategy } from 'passport-bitbucket-oauth2';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\n\n/** @public */\nexport const bitbucketAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n required: ['account'],\n },\n initialize({ callbackUrl, config }) {\n const clientID = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const baseURL = 'https://bitbucket.org/site/oauth2';\n\n return PassportOAuthAuthenticatorHelper.from(\n new BitbucketStrategy(\n {\n clientID,\n clientSecret,\n callbackURL: callbackUrl,\n passReqToCallback: false,\n baseURL,\n authorizationURL: `${baseURL}/authorize`,\n tokenURL: `${baseURL}/access_token`,\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 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 createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\n/**\n * Available sign-in resolvers for the Bitbucket auth provider.\n *\n * @public\n */\nexport namespace bitbucketSignInResolvers {\n /**\n * Looks up the user by matching their Bitbucket user ID with the `bitbucket.org/user-id` annotation.\n */\n export const userIdMatchingUserEntityAnnotation = createSignInResolverFactory(\n {\n create() {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { result } = info;\n\n const id = result.fullProfile.id;\n if (!id) {\n throw new Error('Bitbucket user profile does not contain an ID');\n }\n\n return ctx.signInWithCatalogUser({\n annotations: {\n 'bitbucket.org/user-id': id,\n },\n });\n };\n },\n },\n );\n\n /**\n * Looks up the user by matching their Bitbucket username with the `bitbucket.org/username` annotation.\n */\n export const usernameMatchingUserEntityAnnotation =\n createSignInResolverFactory({\n create() {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { result } = info;\n\n const username = result.fullProfile.username;\n if (!username) {\n throw new Error(\n 'Bitbucket user profile does not contain a Username',\n );\n }\n\n return ctx.signInWithCatalogUser({\n annotations: {\n 'bitbucket.org/username': username,\n },\n });\n };\n },\n });\n}\n","/*\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 */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { bitbucketAuthenticator } from './authenticator';\nimport { bitbucketSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleBitbucketProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'bitbucket-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'bitbucket',\n factory: createOAuthProviderFactory({\n authenticator: bitbucketAuthenticator,\n signInResolverFactories: {\n ...bitbucketSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","BitbucketStrategy","bitbucketSignInResolvers","createSignInResolverFactory","createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","commonSignInResolvers"],"mappings":"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"}
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 authModuleBitbucketProvider = backendPluginApi.createBackendModule({
9
+ pluginId: "auth",
10
+ moduleId: "bitbucket-provider",
11
+ register(reg) {
12
+ reg.registerInit({
13
+ deps: {
14
+ providers: pluginAuthNode.authProvidersExtensionPoint
15
+ },
16
+ async init({ providers }) {
17
+ providers.registerProvider({
18
+ providerId: "bitbucket",
19
+ factory: pluginAuthNode.createOAuthProviderFactory({
20
+ authenticator: authenticator.bitbucketAuthenticator,
21
+ signInResolverFactories: {
22
+ ...resolvers.bitbucketSignInResolvers,
23
+ ...pluginAuthNode.commonSignInResolvers
24
+ }
25
+ })
26
+ });
27
+ }
28
+ });
29
+ }
30
+ });
31
+
32
+ exports.authModuleBitbucketProvider = authModuleBitbucketProvider;
33
+ //# sourceMappingURL=module.cjs.js.map
@@ -0,0 +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 */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { bitbucketAuthenticator } from './authenticator';\nimport { bitbucketSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleBitbucketProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'bitbucket-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'bitbucket',\n factory: createOAuthProviderFactory({\n authenticator: bitbucketAuthenticator,\n signInResolverFactories: {\n ...bitbucketSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","bitbucketAuthenticator","bitbucketSignInResolvers","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,44 @@
1
+ 'use strict';
2
+
3
+ var pluginAuthNode = require('@backstage/plugin-auth-node');
4
+
5
+ exports.bitbucketSignInResolvers = void 0;
6
+ ((bitbucketSignInResolvers2) => {
7
+ bitbucketSignInResolvers2.userIdMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory(
8
+ {
9
+ create() {
10
+ return async (info, ctx) => {
11
+ const { result } = info;
12
+ const id = result.fullProfile.id;
13
+ if (!id) {
14
+ throw new Error("Bitbucket user profile does not contain an ID");
15
+ }
16
+ return ctx.signInWithCatalogUser({
17
+ annotations: {
18
+ "bitbucket.org/user-id": id
19
+ }
20
+ });
21
+ };
22
+ }
23
+ }
24
+ );
25
+ bitbucketSignInResolvers2.usernameMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
26
+ create() {
27
+ return async (info, ctx) => {
28
+ const { result } = info;
29
+ const username = result.fullProfile.username;
30
+ if (!username) {
31
+ throw new Error(
32
+ "Bitbucket user profile does not contain a Username"
33
+ );
34
+ }
35
+ return ctx.signInWithCatalogUser({
36
+ annotations: {
37
+ "bitbucket.org/username": username
38
+ }
39
+ });
40
+ };
41
+ }
42
+ });
43
+ })(exports.bitbucketSignInResolvers || (exports.bitbucketSignInResolvers = {}));
44
+ //# sourceMappingURL=resolvers.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvers.cjs.js","sources":["../src/resolvers.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 createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\n/**\n * Available sign-in resolvers for the Bitbucket auth provider.\n *\n * @public\n */\nexport namespace bitbucketSignInResolvers {\n /**\n * Looks up the user by matching their Bitbucket user ID with the `bitbucket.org/user-id` annotation.\n */\n export const userIdMatchingUserEntityAnnotation = createSignInResolverFactory(\n {\n create() {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { result } = info;\n\n const id = result.fullProfile.id;\n if (!id) {\n throw new Error('Bitbucket user profile does not contain an ID');\n }\n\n return ctx.signInWithCatalogUser({\n annotations: {\n 'bitbucket.org/user-id': id,\n },\n });\n };\n },\n },\n );\n\n /**\n * Looks up the user by matching their Bitbucket username with the `bitbucket.org/username` annotation.\n */\n export const usernameMatchingUserEntityAnnotation =\n createSignInResolverFactory({\n create() {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { result } = info;\n\n const username = result.fullProfile.username;\n if (!username) {\n throw new Error(\n 'Bitbucket user profile does not contain a Username',\n );\n }\n\n return ctx.signInWithCatalogUser({\n annotations: {\n 'bitbucket.org/username': username,\n },\n });\n };\n },\n });\n}\n"],"names":["bitbucketSignInResolvers","createSignInResolverFactory"],"mappings":";;;;AA4BiBA,0CAAA;AAAA,CAAV,CAAUA,yBAAV,KAAA;AAIE,EAAMA,0BAAA,kCAAqC,GAAAC,0CAAA;AAAA,IAChD;AAAA,MACE,MAAS,GAAA;AACP,QAAO,OAAA,OACL,MACA,GACG,KAAA;AACH,UAAM,MAAA,EAAE,QAAW,GAAA,IAAA,CAAA;AAEnB,UAAM,MAAA,EAAA,GAAK,OAAO,WAAY,CAAA,EAAA,CAAA;AAC9B,UAAA,IAAI,CAAC,EAAI,EAAA;AACP,YAAM,MAAA,IAAI,MAAM,+CAA+C,CAAA,CAAA;AAAA,WACjE;AAEA,UAAA,OAAO,IAAI,qBAAsB,CAAA;AAAA,YAC/B,WAAa,EAAA;AAAA,cACX,uBAAyB,EAAA,EAAA;AAAA,aAC3B;AAAA,WACD,CAAA,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACF;AAAA,GACF,CAAA;AAKO,EAAMD,yBAAAA,CAAA,uCACXC,0CAA4B,CAAA;AAAA,IAC1B,MAAS,GAAA;AACP,MAAO,OAAA,OACL,MACA,GACG,KAAA;AACH,QAAM,MAAA,EAAE,QAAW,GAAA,IAAA,CAAA;AAEnB,QAAM,MAAA,QAAA,GAAW,OAAO,WAAY,CAAA,QAAA,CAAA;AACpC,QAAA,IAAI,CAAC,QAAU,EAAA;AACb,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,oDAAA;AAAA,WACF,CAAA;AAAA,SACF;AAEA,QAAA,OAAO,IAAI,qBAAsB,CAAA;AAAA,UAC/B,WAAa,EAAA;AAAA,YACX,wBAA0B,EAAA,QAAA;AAAA,WAC5B;AAAA,SACD,CAAA,CAAA;AAAA,OACH,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AAAA,CAtDY,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-bitbucket-provider",
3
- "version": "0.2.1-next.0",
3
+ "version": "0.2.1",
4
4
  "description": "The bitbucket-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",
38
+ "@backstage/plugin-auth-node": "^0.5.3",
39
39
  "express": "^4.18.2",
40
40
  "passport": "^0.7.0",
41
41
  "passport-bitbucket-oauth2": "^0.1.2"
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",
45
+ "@backstage/backend-test-utils": "^1.0.1",
46
+ "@backstage/cli": "^0.28.0",
47
+ "@backstage/plugin-auth-backend": "^0.23.1",
48
48
  "supertest": "^7.0.0"
49
49
  },
50
50
  "configSchema": "config.d.ts"