@backstage/plugin-auth-backend-module-gcp-iap-provider 0.4.3-next.1 → 0.4.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,16 @@
1
1
  # @backstage/plugin-auth-backend-module-gcp-iap-provider
2
2
 
3
+ ## 0.4.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
+ - @backstage/errors@1.2.7
12
+ - @backstage/types@1.2.1
13
+
3
14
  ## 0.4.3-next.1
4
15
 
5
16
  ### Patch Changes
package/config.d.ts CHANGED
@@ -36,13 +36,23 @@ export interface Config {
36
36
 
37
37
  signIn?: {
38
38
  resolvers: Array<
39
- | { resolver: 'emailMatchingUserEntityAnnotation' }
40
- | { resolver: 'idMatchingUserEntityAnnotation' }
39
+ | {
40
+ resolver: 'emailMatchingUserEntityAnnotation';
41
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
42
+ }
43
+ | {
44
+ resolver: 'idMatchingUserEntityAnnotation';
45
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
46
+ }
41
47
  | {
42
48
  resolver: 'emailLocalPartMatchingUserEntityName';
43
49
  allowedDomains?: string[];
50
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
51
+ }
52
+ | {
53
+ resolver: 'emailMatchingUserEntityProfileEmail';
54
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean;
44
55
  }
45
- | { resolver: 'emailMatchingUserEntityProfileEmail' }
46
56
  >;
47
57
  };
48
58
  sessionDuration?: HumanDuration | string;
package/dist/index.d.ts CHANGED
@@ -56,11 +56,15 @@ declare namespace gcpIapSignInResolvers {
56
56
  /**
57
57
  * Looks up the user by matching their email to the `google.com/email` annotation.
58
58
  */
59
- const emailMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<GcpIapResult, unknown>;
59
+ const emailMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<GcpIapResult, {
60
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean | undefined;
61
+ } | undefined>;
60
62
  /**
61
63
  * Looks up the user by matching their user ID to the `google.com/user-id` annotation.
62
64
  */
63
- const idMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<GcpIapResult, unknown>;
65
+ const idMatchingUserEntityAnnotation: _backstage_plugin_auth_node.SignInResolverFactory<GcpIapResult, {
66
+ dangerouslyAllowSignInWithoutUserInCatalog?: boolean | undefined;
67
+ } | undefined>;
64
68
  }
65
69
 
66
70
  export { type GcpIapResult, type GcpIapTokenInfo, authModuleGcpIapProvider as default, gcpIapAuthenticator, gcpIapSignInResolvers };
@@ -1,33 +1,50 @@
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.gcpIapSignInResolvers = void 0;
6
7
  ((gcpIapSignInResolvers2) => {
7
8
  gcpIapSignInResolvers2.emailMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
8
- create() {
9
+ optionsSchema: zod.z.object({
10
+ dangerouslyAllowSignInWithoutUserInCatalog: zod.z.boolean().optional()
11
+ }).optional(),
12
+ create(options = {}) {
9
13
  return async (info, ctx) => {
10
14
  const email = info.result.iapToken.email;
11
15
  if (!email) {
12
16
  throw new Error("Google IAP sign-in result is missing email");
13
17
  }
14
- return ctx.signInWithCatalogUser({
15
- annotations: {
16
- "google.com/email": email
18
+ return ctx.signInWithCatalogUser(
19
+ {
20
+ annotations: {
21
+ "google.com/email": email
22
+ }
23
+ },
24
+ {
25
+ dangerousEntityRefFallback: options?.dangerouslyAllowSignInWithoutUserInCatalog ? { entityRef: { name: email } } : void 0
17
26
  }
18
- });
27
+ );
19
28
  };
20
29
  }
21
30
  });
22
31
  gcpIapSignInResolvers2.idMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
23
- create() {
32
+ optionsSchema: zod.z.object({
33
+ dangerouslyAllowSignInWithoutUserInCatalog: zod.z.boolean().optional()
34
+ }).optional(),
35
+ create(options = {}) {
24
36
  return async (info, ctx) => {
25
37
  const userId = info.result.iapToken.sub.split(":")[1];
26
- return ctx.signInWithCatalogUser({
27
- annotations: {
28
- "google.com/user-id": userId
38
+ return ctx.signInWithCatalogUser(
39
+ {
40
+ annotations: {
41
+ "google.com/user-id": userId
42
+ }
43
+ },
44
+ {
45
+ dangerousEntityRefFallback: options?.dangerouslyAllowSignInWithoutUserInCatalog ? { entityRef: { name: userId } } : void 0
29
46
  }
30
- });
47
+ );
31
48
  };
32
49
  }
33
50
  });
@@ -1 +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 SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { GcpIapResult } from './types';\n\n/**\n * Available sign-in resolvers for the Google auth provider.\n *\n * @public\n */\nexport namespace gcpIapSignInResolvers {\n /**\n * Looks up the user by matching their email to the `google.com/email` annotation.\n */\n export const emailMatchingUserEntityAnnotation = createSignInResolverFactory({\n create() {\n return async (info: SignInInfo<GcpIapResult>, ctx) => {\n const email = info.result.iapToken.email;\n\n if (!email) {\n throw new Error('Google IAP sign-in result is missing email');\n }\n\n return ctx.signInWithCatalogUser({\n annotations: {\n 'google.com/email': email,\n },\n });\n };\n },\n });\n\n /**\n * Looks up the user by matching their user ID to the `google.com/user-id` annotation.\n */\n export const idMatchingUserEntityAnnotation = createSignInResolverFactory({\n create() {\n return async (info: SignInInfo<GcpIapResult>, ctx) => {\n const userId = info.result.iapToken.sub.split(':')[1];\n\n return ctx.signInWithCatalogUser({\n annotations: {\n 'google.com/user-id': userId,\n },\n });\n };\n },\n });\n}\n"],"names":["gcpIapSignInResolvers","createSignInResolverFactory"],"mappings":";;;;AA2BiBA;AAAA,CAAV,CAAUA,sBAAV,KAAA;AAIE,EAAMA,sBAAAA,CAAA,oCAAoCC,0CAA4B,CAAA;AAAA,IAC3E,MAAS,GAAA;AACP,MAAO,OAAA,OAAO,MAAgC,GAAQ,KAAA;AACpD,QAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,MAAA,CAAO,QAAS,CAAA,KAAA;AAEnC,QAAA,IAAI,CAAC,KAAO,EAAA;AACV,UAAM,MAAA,IAAI,MAAM,4CAA4C,CAAA;AAAA;AAG9D,QAAA,OAAO,IAAI,qBAAsB,CAAA;AAAA,UAC/B,WAAa,EAAA;AAAA,YACX,kBAAoB,EAAA;AAAA;AACtB,SACD,CAAA;AAAA,OACH;AAAA;AACF,GACD,CAAA;AAKM,EAAMD,sBAAAA,CAAA,iCAAiCC,0CAA4B,CAAA;AAAA,IACxE,MAAS,GAAA;AACP,MAAO,OAAA,OAAO,MAAgC,GAAQ,KAAA;AACpD,QAAM,MAAA,MAAA,GAAS,KAAK,MAAO,CAAA,QAAA,CAAS,IAAI,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAEpD,QAAA,OAAO,IAAI,qBAAsB,CAAA;AAAA,UAC/B,WAAa,EAAA;AAAA,YACX,oBAAsB,EAAA;AAAA;AACxB,SACD,CAAA;AAAA,OACH;AAAA;AACF,GACD,CAAA;AAAA,CArCc,EAAAD,6BAAA,KAAAA,6BAAA,GAAA,EAAA,CAAA,CAAA;;"}
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 SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { GcpIapResult } from './types';\nimport { z } from 'zod';\n\n/**\n * Available sign-in resolvers for the Google auth provider.\n *\n * @public\n */\nexport namespace gcpIapSignInResolvers {\n /**\n * Looks up the user by matching their email to the `google.com/email` annotation.\n */\n export const emailMatchingUserEntityAnnotation = createSignInResolverFactory({\n optionsSchema: z\n .object({\n dangerouslyAllowSignInWithoutUserInCatalog: z.boolean().optional(),\n })\n .optional(),\n create(options = {}) {\n return async (info: SignInInfo<GcpIapResult>, ctx) => {\n const email = info.result.iapToken.email;\n\n if (!email) {\n throw new Error('Google IAP sign-in result is missing email');\n }\n\n return ctx.signInWithCatalogUser(\n {\n annotations: {\n 'google.com/email': email,\n },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: email } }\n : undefined,\n },\n );\n };\n },\n });\n\n /**\n * Looks up the user by matching their user ID to the `google.com/user-id` annotation.\n */\n export const idMatchingUserEntityAnnotation = createSignInResolverFactory({\n optionsSchema: z\n .object({\n dangerouslyAllowSignInWithoutUserInCatalog: z.boolean().optional(),\n })\n .optional(),\n create(options = {}) {\n return async (info: SignInInfo<GcpIapResult>, ctx) => {\n const userId = info.result.iapToken.sub.split(':')[1];\n\n return ctx.signInWithCatalogUser(\n {\n annotations: {\n 'google.com/user-id': userId,\n },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: userId } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["gcpIapSignInResolvers","createSignInResolverFactory","z"],"mappings":";;;;;AA4BiBA;AAAA,CAAV,CAAUA,sBAAV,KAAA;AAIE,EAAMA,sBAAAA,CAAA,oCAAoCC,0CAA4B,CAAA;AAAA,IAC3E,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,OAAO,MAAgC,GAAQ,KAAA;AACpD,QAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,MAAA,CAAO,QAAS,CAAA,KAAA;AAEnC,QAAA,IAAI,CAAC,KAAO,EAAA;AACV,UAAM,MAAA,IAAI,MAAM,4CAA4C,CAAA;AAAA;AAG9D,QAAA,OAAO,GAAI,CAAA,qBAAA;AAAA,UACT;AAAA,YACE,WAAa,EAAA;AAAA,cACX,kBAAoB,EAAA;AAAA;AACtB,WACF;AAAA,UACA;AAAA,YACE,0BAAA,EACE,SAAS,0CACL,GAAA,EAAE,WAAW,EAAE,IAAA,EAAM,KAAM,EAAA,EAC3B,GAAA,KAAA;AAAA;AACR,SACF;AAAA,OACF;AAAA;AACF,GACD,CAAA;AAKM,EAAMF,sBAAAA,CAAA,iCAAiCC,0CAA4B,CAAA;AAAA,IACxE,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,OAAO,MAAgC,GAAQ,KAAA;AACpD,QAAM,MAAA,MAAA,GAAS,KAAK,MAAO,CAAA,QAAA,CAAS,IAAI,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAEpD,QAAA,OAAO,GAAI,CAAA,qBAAA;AAAA,UACT;AAAA,YACE,WAAa,EAAA;AAAA,cACX,oBAAsB,EAAA;AAAA;AACxB,WACF;AAAA,UACA;AAAA,YACE,0BAAA,EACE,SAAS,0CACL,GAAA,EAAE,WAAW,EAAE,IAAA,EAAM,MAAO,EAAA,EAC5B,GAAA,KAAA;AAAA;AACR,SACF;AAAA,OACF;AAAA;AACF,GACD,CAAA;AAAA,CA/Dc,EAAAF,6BAAA,KAAAA,6BAAA,GAAA,EAAA,CAAA,CAAA;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-auth-backend-module-gcp-iap-provider",
3
- "version": "0.4.3-next.1",
3
+ "version": "0.4.3-next.2",
4
4
  "description": "A GCP IAP auth provider module for the Backstage auth backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -41,15 +41,16 @@
41
41
  "test": "backstage-cli package test"
42
42
  },
43
43
  "dependencies": {
44
- "@backstage/backend-plugin-api": "1.3.1-next.1",
44
+ "@backstage/backend-plugin-api": "1.3.1-next.2",
45
45
  "@backstage/errors": "1.2.7",
46
- "@backstage/plugin-auth-node": "0.6.3-next.1",
46
+ "@backstage/plugin-auth-node": "0.6.3-next.2",
47
47
  "@backstage/types": "1.2.1",
48
- "google-auth-library": "^9.0.0"
48
+ "google-auth-library": "^9.0.0",
49
+ "zod": "^3.22.4"
49
50
  },
50
51
  "devDependencies": {
51
- "@backstage/backend-test-utils": "1.5.0-next.1",
52
- "@backstage/cli": "0.32.1-next.1",
52
+ "@backstage/backend-test-utils": "1.5.0-next.3",
53
+ "@backstage/cli": "0.32.1-next.3",
53
54
  "express": "^4.18.2"
54
55
  },
55
56
  "configSchema": "config.d.ts",