@backstage/plugin-auth-backend-module-bitbucket-provider 0.3.3-next.1 → 0.3.3-next.2

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-bitbucket-provider
2
2
 
3
+ ## 0.3.3-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 5cc1f7f: Introduce `dangerouslyAllowSignInWithoutUserInCatalog` auth resolver config.
8
+ - Updated dependencies
9
+ - @backstage/plugin-auth-node@0.6.3-next.2
10
+ - @backstage/backend-plugin-api@1.3.1-next.2
11
+
3
12
  ## 0.3.3-next.1
4
13
 
5
14
  ### Patch Changes
package/config.d.ts CHANGED
@@ -30,12 +30,23 @@ export interface Config {
30
30
  additionalScopes?: string | string[];
31
31
  signIn?: {
32
32
  resolvers: Array<
33
- | { resolver: 'userIdMatchingUserEntityAnnotation' }
33
+ | {
34
+ resolver: 'userIdMatchingUserEntityAnnotation';
35
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
36
+ }
37
+ | {
38
+ resolver: 'usernameMatchingUserEntityAnnotation';
39
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
40
+ }
34
41
  | {
35
42
  resolver: 'emailLocalPartMatchingUserEntityName';
36
43
  allowedDomains?: string[];
44
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
45
+ }
46
+ | {
47
+ resolver: 'emailMatchingUserEntityProfileEmail';
48
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
37
49
  }
38
- | { resolver: 'emailMatchingUserEntityProfileEmail' }
39
50
  >;
40
51
  };
41
52
  sessionDuration?: HumanDuration | string;
package/dist/index.d.ts CHANGED
@@ -17,11 +17,15 @@ declare namespace bitbucketSignInResolvers {
17
17
  /**
18
18
  * Looks up the user by matching their Bitbucket user ID with the `bitbucket.org/user-id` annotation.
19
19
  */
20
- const userIdMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>, unknown>;
20
+ const userIdMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>, {
21
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean | undefined;
22
+ } | undefined>;
21
23
  /**
22
24
  * Looks up the user by matching their Bitbucket username with the `bitbucket.org/username` annotation.
23
25
  */
24
- const usernameMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>, unknown>;
26
+ const usernameMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>, {
27
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean | undefined;
28
+ } | undefined>;
25
29
  }
26
30
 
27
31
  export { bitbucketAuthenticator, bitbucketSignInResolvers, authModuleBitbucketProvider as default };
@@ -1,29 +1,41 @@
1
1
  'use strict';
2
2
 
3
3
  var pluginAuthNode = require('@backstage/plugin-auth-node');
4
+ var zod = require('zod');
4
5
 
5
6
  exports.bitbucketSignInResolvers = void 0;
6
7
  ((bitbucketSignInResolvers2) => {
7
8
  bitbucketSignInResolvers2.userIdMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory(
8
9
  {
9
- create() {
10
+ optionsSchema: zod.z.object({
11
+ dangerouslyAllowSignInWithoutUserInCatalog: zod.z.boolean().optional()
12
+ }).optional(),
13
+ create(options = {}) {
10
14
  return async (info, ctx) => {
11
15
  const { result } = info;
12
16
  const id = result.fullProfile.id;
13
17
  if (!id) {
14
18
  throw new Error("Bitbucket user profile does not contain an ID");
15
19
  }
16
- return ctx.signInWithCatalogUser({
17
- annotations: {
18
- "bitbucket.org/user-id": id
20
+ return ctx.signInWithCatalogUser(
21
+ {
22
+ annotations: {
23
+ "bitbucket.org/user-id": id
24
+ }
25
+ },
26
+ {
27
+ dangerousEntityRefFallback: options?.dangerouslyAllowSignInWithoutUserInCatalog ? { entityRef: { name: id } } : void 0
19
28
  }
20
- });
29
+ );
21
30
  };
22
31
  }
23
32
  }
24
33
  );
25
34
  bitbucketSignInResolvers2.usernameMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
26
- create() {
35
+ optionsSchema: zod.z.object({
36
+ dangerouslyAllowSignInWithoutUserInCatalog: zod.z.boolean().optional()
37
+ }).optional(),
38
+ create(options = {}) {
27
39
  return async (info, ctx) => {
28
40
  const { result } = info;
29
41
  const username = result.fullProfile.username;
@@ -32,11 +44,16 @@ exports.bitbucketSignInResolvers = void 0;
32
44
  "Bitbucket user profile does not contain a Username"
33
45
  );
34
46
  }
35
- return ctx.signInWithCatalogUser({
36
- annotations: {
37
- "bitbucket.org/username": username
47
+ return ctx.signInWithCatalogUser(
48
+ {
49
+ annotations: {
50
+ "bitbucket.org/username": username
51
+ }
52
+ },
53
+ {
54
+ dangerousEntityRefFallback: options?.dangerouslyAllowSignInWithoutUserInCatalog ? { entityRef: { name: username } } : void 0
38
55
  }
39
- });
56
+ );
40
57
  };
41
58
  }
42
59
  });
@@ -1 +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;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;AAEnB,UAAM,MAAA,EAAA,GAAK,OAAO,WAAY,CAAA,EAAA;AAC9B,UAAA,IAAI,CAAC,EAAI,EAAA;AACP,YAAM,MAAA,IAAI,MAAM,+CAA+C,CAAA;AAAA;AAGjE,UAAA,OAAO,IAAI,qBAAsB,CAAA;AAAA,YAC/B,WAAa,EAAA;AAAA,cACX,uBAAyB,EAAA;AAAA;AAC3B,WACD,CAAA;AAAA,SACH;AAAA;AACF;AACF,GACF;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;AAEnB,QAAM,MAAA,QAAA,GAAW,OAAO,WAAY,CAAA,QAAA;AACpC,QAAA,IAAI,CAAC,QAAU,EAAA;AACb,UAAA,MAAM,IAAI,KAAA;AAAA,YACR;AAAA,WACF;AAAA;AAGF,QAAA,OAAO,IAAI,qBAAsB,CAAA;AAAA,UAC/B,WAAa,EAAA;AAAA,YACX,wBAA0B,EAAA;AAAA;AAC5B,SACD,CAAA;AAAA,OACH;AAAA;AACF,GACD,CAAA;AAAA,CAtDY,EAAAD,gCAAA,KAAAA,gCAAA,GAAA,EAAA,CAAA,CAAA;;"}
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';\nimport { z } from 'zod';\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 optionsSchema: z\n .object({\n dangerouslyAllowSignInWithoutUserInCatalog: z.boolean().optional(),\n })\n .optional(),\n create(options = {}) {\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 {\n annotations: {\n 'bitbucket.org/user-id': id,\n },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: id } }\n : undefined,\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 optionsSchema: z\n .object({\n dangerouslyAllowSignInWithoutUserInCatalog: z.boolean().optional(),\n })\n .optional(),\n create(options = {}) {\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 {\n annotations: {\n 'bitbucket.org/username': username,\n },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: username } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["bitbucketSignInResolvers","createSignInResolverFactory","z"],"mappings":";;;;;AA6BiBA;AAAA,CAAV,CAAUA,yBAAV,KAAA;AAIE,EAAMA,0BAAA,kCAAqC,GAAAC,0CAAA;AAAA,IAChD;AAAA,MACE,aAAA,EAAeC,MACZ,MAAO,CAAA;AAAA,QACN,0CAA4C,EAAAA,KAAA,CAAE,OAAQ,EAAA,CAAE,QAAS;AAAA,OAClE,EACA,QAAS,EAAA;AAAA,MACZ,MAAA,CAAO,OAAU,GAAA,EAAI,EAAA;AACnB,QAAO,OAAA,OACL,MACA,GACG,KAAA;AACH,UAAM,MAAA,EAAE,QAAW,GAAA,IAAA;AAEnB,UAAM,MAAA,EAAA,GAAK,OAAO,WAAY,CAAA,EAAA;AAC9B,UAAA,IAAI,CAAC,EAAI,EAAA;AACP,YAAM,MAAA,IAAI,MAAM,+CAA+C,CAAA;AAAA;AAGjE,UAAA,OAAO,GAAI,CAAA,qBAAA;AAAA,YACT;AAAA,cACE,WAAa,EAAA;AAAA,gBACX,uBAAyB,EAAA;AAAA;AAC3B,aACF;AAAA,YACA;AAAA,cACE,0BAAA,EACE,SAAS,0CACL,GAAA,EAAE,WAAW,EAAE,IAAA,EAAM,EAAG,EAAA,EACxB,GAAA,KAAA;AAAA;AACR,WACF;AAAA,SACF;AAAA;AACF;AACF,GACF;AAKO,EAAMF,yBAAAA,CAAA,uCACXC,0CAA4B,CAAA;AAAA,IAC1B,aAAA,EAAeC,MACZ,MAAO,CAAA;AAAA,MACN,0CAA4C,EAAAA,KAAA,CAAE,OAAQ,EAAA,CAAE,QAAS;AAAA,KAClE,EACA,QAAS,EAAA;AAAA,IACZ,MAAA,CAAO,OAAU,GAAA,EAAI,EAAA;AACnB,MAAO,OAAA,OACL,MACA,GACG,KAAA;AACH,QAAM,MAAA,EAAE,QAAW,GAAA,IAAA;AAEnB,QAAM,MAAA,QAAA,GAAW,OAAO,WAAY,CAAA,QAAA;AACpC,QAAA,IAAI,CAAC,QAAU,EAAA;AACb,UAAA,MAAM,IAAI,KAAA;AAAA,YACR;AAAA,WACF;AAAA;AAGF,QAAA,OAAO,GAAI,CAAA,qBAAA;AAAA,UACT;AAAA,YACE,WAAa,EAAA;AAAA,cACX,wBAA0B,EAAA;AAAA;AAC5B,WACF;AAAA,UACA;AAAA,YACE,0BAAA,EACE,SAAS,0CACL,GAAA,EAAE,WAAW,EAAE,IAAA,EAAM,QAAS,EAAA,EAC9B,GAAA,KAAA;AAAA;AACR,SACF;AAAA,OACF;AAAA;AACF,GACD,CAAA;AAAA,CAhFY,EAAAF,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.3.3-next.1",
3
+ "version": "0.3.3-next.2",
4
4
  "description": "The bitbucket-provider backend module for the auth plugin.",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -37,17 +37,18 @@
37
37
  "test": "backstage-cli package test"
38
38
  },
39
39
  "dependencies": {
40
- "@backstage/backend-plugin-api": "1.3.1-next.1",
41
- "@backstage/plugin-auth-node": "0.6.3-next.1",
40
+ "@backstage/backend-plugin-api": "1.3.1-next.2",
41
+ "@backstage/plugin-auth-node": "0.6.3-next.2",
42
42
  "express": "^4.18.2",
43
43
  "passport": "^0.7.0",
44
- "passport-bitbucket-oauth2": "^0.1.2"
44
+ "passport-bitbucket-oauth2": "^0.1.2",
45
+ "zod": "^3.22.4"
45
46
  },
46
47
  "devDependencies": {
47
- "@backstage/backend-defaults": "0.10.0-next.1",
48
- "@backstage/backend-test-utils": "1.5.0-next.1",
49
- "@backstage/cli": "0.32.1-next.1",
50
- "@backstage/plugin-auth-backend": "0.25.0-next.1",
48
+ "@backstage/backend-defaults": "0.10.0-next.3",
49
+ "@backstage/backend-test-utils": "1.5.0-next.3",
50
+ "@backstage/cli": "0.32.1-next.3",
51
+ "@backstage/plugin-auth-backend": "0.25.0-next.2",
51
52
  "@backstage/types": "1.2.1",
52
53
  "supertest": "^7.0.0"
53
54
  },