|
| 1 | +diff --git a/node_modules/@backstage/plugin-auth-node/dist/index.cjs.js b/node_modules/@backstage/plugin-auth-node/dist/index.cjs.js |
| 2 | +index d19613e..3a4bfa1 100644 |
| 3 | +--- a/node_modules/@backstage/plugin-auth-node/dist/index.cjs.js |
| 4 | ++++ b/node_modules/@backstage/plugin-auth-node/dist/index.cjs.js |
| 5 | +@@ -7,6 +7,7 @@ var jose = require('jose'); |
| 6 | + var url = require('url'); |
| 7 | + var pickBy = require('lodash/pickBy'); |
| 8 | + var zodToJsonSchema = require('zod-to-json-schema'); |
| 9 | ++var {stringifyEntityRef} = require('@backstage/catalog-model'); |
| 10 | + |
| 11 | + function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } |
| 12 | + |
| 13 | +@@ -857,39 +858,93 @@ function createSignInResolverFactory(options) { |
| 14 | + return factory; |
| 15 | + } |
| 16 | + |
| 17 | +-function readDeclarativeSignInResolver(options) { |
| 18 | +- const resolvers = options.config.getOptionalConfigArray("signIn.resolvers")?.map((resolverConfig) => { |
| 19 | +- const resolverName = resolverConfig.getString("resolver"); |
| 20 | +- if (!Object.hasOwn(options.signInResolverFactories, resolverName)) { |
| 21 | +- throw new Error( |
| 22 | +- `Sign-in resolver '${resolverName}' is not available` |
| 23 | ++const getUserEntity = async (info, ctx) => { |
| 24 | ++ const { fullProfile } = info.result; |
| 25 | ++ const userId = fullProfile.username; |
| 26 | ++ if (!userId) { |
| 27 | ++ throw new Error(`GitHub user profile does not contain a username`); |
| 28 | ++ } |
| 29 | ++ |
| 30 | ++ const userEntity = stringifyEntityRef({ |
| 31 | ++ kind: "User", |
| 32 | ++ name: userId, |
| 33 | ++ namespace:"default" |
| 34 | ++ |
| 35 | ++ }); |
| 36 | ++ return ctx.issueToken({ |
| 37 | ++ claims: { |
| 38 | ++ sub: userEntity, |
| 39 | ++ ent: [userEntity], |
| 40 | ++ } |
| 41 | ++ }); |
| 42 | ++ }; |
| 43 | ++ |
| 44 | ++ function readDeclarativeSignInResolver(options) { |
| 45 | ++ const resolvers = options.config.getOptionalConfigArray("signIn.resolvers")?.map((resolverConfig) => { |
| 46 | ++ const resolverName = resolverConfig.getString("resolver"); |
| 47 | ++ if (!Object.hasOwn(options.signInResolverFactories, resolverName)) { |
| 48 | ++ throw new Error( |
| 49 | ++ `Sign-in resolver '${resolverName}' is not available` |
| 50 | ++ ); |
| 51 | ++ } |
| 52 | ++ const resolver = options.signInResolverFactories[resolverName]; |
| 53 | ++ const { resolver: _ignored, ...resolverOptions } = resolverConfig.get(); |
| 54 | ++ return resolver( |
| 55 | ++ Object.keys(resolverOptions).length > 0 ? resolverOptions : void 0 |
| 56 | + ); |
| 57 | ++ }) ?? []; |
| 58 | ++ if (resolvers.length === 0) { |
| 59 | ++ return void 0; |
| 60 | + } |
| 61 | +- const resolver = options.signInResolverFactories[resolverName]; |
| 62 | +- const { resolver: _ignored, ...resolverOptions } = resolverConfig.get(); |
| 63 | +- return resolver( |
| 64 | +- Object.keys(resolverOptions).length > 0 ? resolverOptions : void 0 |
| 65 | +- ); |
| 66 | +- }) ?? []; |
| 67 | +- if (resolvers.length === 0) { |
| 68 | +- return void 0; |
| 69 | +- } |
| 70 | +- return async (profile, context) => { |
| 71 | +- for (const resolver of resolvers) { |
| 72 | +- try { |
| 73 | +- return await resolver(profile, context); |
| 74 | +- } catch (error) { |
| 75 | +- if (error?.name === "NotFoundError") { |
| 76 | +- continue; |
| 77 | ++ return async (profile, context) => { |
| 78 | ++ for (const resolver of resolvers) { |
| 79 | ++ try { |
| 80 | ++ return await getUserEntity(profile, context); |
| 81 | ++ } catch (error) { |
| 82 | ++ if (error?.name === "NotFoundError") { |
| 83 | ++ console.log ('resolver error---------------',error, error?.name); |
| 84 | ++ continue; |
| 85 | ++ } |
| 86 | ++ throw error; |
| 87 | + } |
| 88 | +- throw error; |
| 89 | + } |
| 90 | +- } |
| 91 | +- throw new Error( |
| 92 | +- "Failed to sign-in, unable to resolve user identity. Please verify that your catalog contains the expected User entities that would match your configured sign-in resolver." |
| 93 | +- ); |
| 94 | +- }; |
| 95 | +-} |
| 96 | ++ throw new Error("Failed to sign-in, unable to resolve user identity"); |
| 97 | ++ }; |
| 98 | ++ } |
| 99 | ++ |
| 100 | ++// function readDeclarativeSignInResolver(options) { |
| 101 | ++// const resolvers = options.config.getOptionalConfigArray("signIn.resolvers")?.map((resolverConfig) => { |
| 102 | ++// const resolverName = resolverConfig.getString("resolver"); |
| 103 | ++// if (!Object.hasOwn(options.signInResolverFactories, resolverName)) { |
| 104 | ++// throw new Error( |
| 105 | ++// `Sign-in resolver '${resolverName}' is not available` |
| 106 | ++// ); |
| 107 | ++// } |
| 108 | ++// const resolver = options.signInResolverFactories[resolverName]; |
| 109 | ++// const { resolver: _ignored, ...resolverOptions } = resolverConfig.get(); |
| 110 | ++// return resolver( |
| 111 | ++// Object.keys(resolverOptions).length > 0 ? resolverOptions : void 0 |
| 112 | ++// ); |
| 113 | ++// }) ?? []; |
| 114 | ++// if (resolvers.length === 0) { |
| 115 | ++// return void 0; |
| 116 | ++// } |
| 117 | ++// return async (profile, context) => { |
| 118 | ++// for (const resolver of resolvers) { |
| 119 | ++// try { |
| 120 | ++// return await resolver(profile, context); |
| 121 | ++// } catch (error) { |
| 122 | ++// if (error?.name === "NotFoundError") { |
| 123 | ++// continue; |
| 124 | ++// } |
| 125 | ++// throw error; |
| 126 | ++// } |
| 127 | ++// } |
| 128 | ++// throw new Error( |
| 129 | ++// "Failed to sign-in, unable to resolve user identity. Please verify that your catalog contains the expected User entities that would match your configured sign-in resolver." |
| 130 | ++// ); |
| 131 | ++// }; |
| 132 | ++// } |
| 133 | + |
| 134 | + const reEmail = /^([^@+]+)(\+[^@]+)?(@.*)$/; |
| 135 | + exports.commonSignInResolvers = void 0; |
0 commit comments