@backstage/plugin-auth-backend-module-github-provider 0.5.7-next.0 → 0.5.8-next.0
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 +22 -0
- package/config.schema.json +2 -1
- package/dist/authenticator.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/module.cjs.js +6 -3
- package/dist/module.cjs.js.map +1 -1
- package/dist/resolvers.cjs.js +93 -9
- package/dist/resolvers.cjs.js.map +1 -1
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-github-provider
|
|
2
2
|
|
|
3
|
+
## 0.5.8-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/errors@1.3.2-next.0
|
|
9
|
+
- @backstage/backend-plugin-api@1.10.2-next.0
|
|
10
|
+
- @backstage/plugin-auth-node@0.7.7-next.0
|
|
11
|
+
- @backstage/catalog-model@1.10.2-next.0
|
|
12
|
+
- @backstage/plugin-catalog-node@2.2.6-next.0
|
|
13
|
+
|
|
14
|
+
## 0.5.7
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 211a61a: Deprecated the GitHub username sign-in resolver in favor of the stable user ID resolver. GitHub user ID catalog lookups now require an exact match and handle candidates that differ only by letter casing.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/catalog-model@1.10.1
|
|
21
|
+
- @backstage/plugin-auth-node@0.7.6
|
|
22
|
+
- @backstage/backend-plugin-api@1.10.1
|
|
23
|
+
- @backstage/plugin-catalog-node@2.2.5
|
|
24
|
+
|
|
3
25
|
## 0.5.7-next.0
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/config.schema.json
CHANGED
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"properties": {
|
|
52
52
|
"resolver": {
|
|
53
53
|
"type": "string",
|
|
54
|
-
"const": "usernameMatchingUserEntityName"
|
|
54
|
+
"const": "usernameMatchingUserEntityName",
|
|
55
|
+
"deprecated": "Use `userIdMatchingUserEntityAnnotation` instead."
|
|
55
56
|
},
|
|
56
57
|
"dangerouslyAllowSignInWithoutUserInCatalog": {
|
|
57
58
|
"type": "boolean"
|
|
@@ -1 +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 { Strategy as GithubStrategy } from 'passport-github2';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\n\n/** @public */\nexport type GithubProfile = PassportProfile & {\n nodeId?: string;\n};\n\nconst ACCESS_TOKEN_PREFIX = 'access-token-v2.';\n\n/** @public */\nexport const githubAuthenticator = createOAuthAuthenticator<\n PassportOAuthAuthenticatorHelper,\n GithubProfile\n>({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n persist: true,\n required: ['read:user'],\n },\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const enterpriseInstanceUrl = config\n .getOptionalString('enterpriseInstanceUrl')\n ?.replace(/\\/$/, '');\n const authorizationUrl = enterpriseInstanceUrl\n ? `${enterpriseInstanceUrl}/login/oauth/authorize`\n : undefined;\n const tokenUrl = enterpriseInstanceUrl\n ? `${enterpriseInstanceUrl}/login/oauth/access_token`\n : undefined;\n const userProfileUrl = enterpriseInstanceUrl\n ? `${enterpriseInstanceUrl}/api/v3/user`\n : undefined;\n\n return PassportOAuthAuthenticatorHelper.from(\n new GithubStrategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n tokenURL: tokenUrl,\n userProfileURL: userProfileUrl,\n authorizationURL: authorizationUrl,\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 const { fullProfile, session } = await helper.authenticate(input);\n\n // If we do not have a real refresh token and we have a non-expiring\n // access token, then we use that as our refresh token.\n if (!session.refreshToken && !session.expiresInSeconds) {\n session.refreshToken = ACCESS_TOKEN_PREFIX + session.accessToken;\n }\n return { fullProfile: fullProfile as GithubProfile, session };\n },\n\n async refresh(input, helper) {\n // This is the OAuth App flow. A non-expiring access token is stored in the\n // refresh token cookie. We use that token to fetch the user profile and\n // refresh the Backstage session when needed.\n if (input.refreshToken?.startsWith(ACCESS_TOKEN_PREFIX)) {\n if (!input.scopeAlreadyGranted) {\n throw new Error(\n 'Refresh failed, session has not been granted the requested scope',\n );\n }\n const accessToken = input.refreshToken.slice(ACCESS_TOKEN_PREFIX.length);\n\n const fullProfile = await helper\n .fetchProfile(accessToken)\n .catch(error => {\n if (error.oauthError?.statusCode === 401) {\n throw new Error('Invalid access token');\n }\n throw error;\n });\n\n return {\n fullProfile: fullProfile as GithubProfile,\n session: {\n accessToken,\n tokenType: 'bearer',\n scope: input.scope,\n refreshToken: input.refreshToken,\n // No expiration\n },\n };\n }\n\n // This is the App flow, which is close to a standard OAuth refresh flow. It has a\n // pretty long session expiration, and it also ignores the requested scope, instead\n // just allowing access to whatever is configured as part of the app installation.\n return helper.refresh(input);\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","GithubStrategy"],"mappings":";;;;;AA6BA,MAAM,mBAAA,GAAsB,kBAAA;AAGrB,MAAM,sBAAsBA,uCAAA,CAGjC;AAAA,EACA,yBACEC,+CAAA,CAAiC,uBAAA;AAAA,EACnC,MAAA,EAAQ;AAAA,IACN,OAAA,EAAS,IAAA;AAAA,IACT,QAAA,EAAU,CAAC,WAAW;AAAA,GACxB;AAAA,EACA,UAAA,CAAW,EAAE,WAAA,EAAa,MAAA,EAAO,EAAG;AAClC,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,SAAA,CAAU,UAAU,CAAA;AAC5C,IAAA,MAAM,YAAA,GAAe,MAAA,CAAO,SAAA,CAAU,cAAc,CAAA;AACpD,IAAA,MAAM,wBAAwB,MAAA,CAC3B,iBAAA,CAAkB,uBAAuB,CAAA,EACxC,OAAA,CAAQ,OAAO,EAAE,CAAA;AACrB,IAAA,MAAM,gBAAA,GAAmB,qBAAA,GACrB,CAAA,EAAG,qBAAqB,CAAA,sBAAA,CAAA,GACxB,MAAA;AACJ,IAAA,MAAM,QAAA,GAAW,qBAAA,GACb,CAAA,EAAG,qBAAqB,CAAA,yBAAA,CAAA,GACxB,MAAA;AACJ,IAAA,MAAM,cAAA,GAAiB,qBAAA,GACnB,CAAA,EAAG,qBAAqB,CAAA,YAAA,CAAA,GACxB,MAAA;AAEJ,IAAA,OAAOA,+CAAA,CAAiC,IAAA;AAAA,MACtC,IAAIC,wBAAA;AAAA,QACF;AAAA,UACE,QAAA,EAAU,QAAA;AAAA,UACV,YAAA;AAAA,UACA,WAAA,EAAa,WAAA;AAAA,UACb,QAAA,EAAU,QAAA;AAAA,UACV,cAAA,EAAgB,cAAA;AAAA,UAChB,gBAAA,EAAkB;AAAA,SACpB;AAAA,QACA,CACE,WAAA,EACA,YAAA,EACA,MAAA,EACA,aACA,IAAA,KACG;AACH,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B,CAAA;AAAA,QACxC;AACA,QAAA,MAAM,KAAA;AAAA,MACR,CAAC,CAAA;AAEH,MAAA,OAAO;AAAA,QACL,WAAA;AAAA,QACA,OAAA,EAAS;AAAA,UACP,WAAA;AAAA,UACA,SAAA,EAAW,QAAA;AAAA,UACX,OAAO,KAAA,CAAM,KAAA;AAAA,UACb,cAAc,KAAA,CAAM;AAAA;AAAA;AAEtB,OACF;AAAA,IACF;AAKA,IAAA,OAAO,MAAA,CAAO,QAAQ,KAAK,CAAA;AAAA,EAC7B;AACF,CAAC
|
|
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 { Strategy as GithubStrategy } from 'passport-github2';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\n\n/** @public */\nexport type GithubProfile = PassportProfile & {\n nodeId?: string;\n};\n\nconst ACCESS_TOKEN_PREFIX = 'access-token-v2.';\n\n/** @public */\nexport const githubAuthenticator = createOAuthAuthenticator<\n PassportOAuthAuthenticatorHelper,\n GithubProfile\n>({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n persist: true,\n required: ['read:user'],\n },\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const enterpriseInstanceUrl = config\n .getOptionalString('enterpriseInstanceUrl')\n ?.replace(/\\/$/, '');\n const authorizationUrl = enterpriseInstanceUrl\n ? `${enterpriseInstanceUrl}/login/oauth/authorize`\n : undefined;\n const tokenUrl = enterpriseInstanceUrl\n ? `${enterpriseInstanceUrl}/login/oauth/access_token`\n : undefined;\n const userProfileUrl = enterpriseInstanceUrl\n ? `${enterpriseInstanceUrl}/api/v3/user`\n : undefined;\n\n return PassportOAuthAuthenticatorHelper.from(\n new GithubStrategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n tokenURL: tokenUrl,\n userProfileURL: userProfileUrl,\n authorizationURL: authorizationUrl,\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 const { fullProfile, session } = await helper.authenticate(input);\n\n // If we do not have a real refresh token and we have a non-expiring\n // access token, then we use that as our refresh token.\n if (!session.refreshToken && !session.expiresInSeconds) {\n session.refreshToken = ACCESS_TOKEN_PREFIX + session.accessToken;\n }\n return { fullProfile: fullProfile as GithubProfile, session };\n },\n\n async refresh(input, helper) {\n // This is the OAuth App flow. A non-expiring access token is stored in the\n // refresh token cookie. We use that token to fetch the user profile and\n // refresh the Backstage session when needed.\n if (input.refreshToken?.startsWith(ACCESS_TOKEN_PREFIX)) {\n if (!input.scopeAlreadyGranted) {\n throw new Error(\n 'Refresh failed, session has not been granted the requested scope',\n );\n }\n const accessToken = input.refreshToken.slice(ACCESS_TOKEN_PREFIX.length);\n\n const fullProfile = await helper\n .fetchProfile(accessToken)\n .catch(error => {\n if (error.oauthError?.statusCode === 401) {\n throw new Error('Invalid access token');\n }\n throw error;\n });\n\n return {\n fullProfile: fullProfile as GithubProfile,\n session: {\n accessToken,\n tokenType: 'bearer',\n scope: input.scope,\n refreshToken: input.refreshToken,\n // No expiration\n },\n };\n }\n\n // This is the App flow, which is close to a standard OAuth refresh flow. It has a\n // pretty long session expiration, and it also ignores the requested scope, instead\n // just allowing access to whatever is configured as part of the app installation.\n return helper.refresh(input);\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","GithubStrategy"],"mappings":";;;;;AA6BA,MAAM,mBAAA,GAAsB,kBAAA;AAGrB,MAAM,sBAAsBA,uCAAA,CAGjC;AAAA,EACA,yBACEC,+CAAA,CAAiC,uBAAA;AAAA,EACnC,MAAA,EAAQ;AAAA,IACN,OAAA,EAAS,IAAA;AAAA,IACT,QAAA,EAAU,CAAC,WAAW;AAAA,GACxB;AAAA,EACA,UAAA,CAAW,EAAE,WAAA,EAAa,MAAA,EAAO,EAAG;AAClC,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,SAAA,CAAU,UAAU,CAAA;AAC5C,IAAA,MAAM,YAAA,GAAe,MAAA,CAAO,SAAA,CAAU,cAAc,CAAA;AACpD,IAAA,MAAM,wBAAwB,MAAA,CAC3B,iBAAA,CAAkB,uBAAuB,CAAA,EACxC,OAAA,CAAQ,OAAO,EAAE,CAAA;AACrB,IAAA,MAAM,gBAAA,GAAmB,qBAAA,GACrB,CAAA,EAAG,qBAAqB,CAAA,sBAAA,CAAA,GACxB,MAAA;AACJ,IAAA,MAAM,QAAA,GAAW,qBAAA,GACb,CAAA,EAAG,qBAAqB,CAAA,yBAAA,CAAA,GACxB,MAAA;AACJ,IAAA,MAAM,cAAA,GAAiB,qBAAA,GACnB,CAAA,EAAG,qBAAqB,CAAA,YAAA,CAAA,GACxB,MAAA;AAEJ,IAAA,OAAOA,+CAAA,CAAiC,IAAA;AAAA,MACtC,IAAIC,wBAAA;AAAA,QACF;AAAA,UACE,QAAA,EAAU,QAAA;AAAA,UACV,YAAA;AAAA,UACA,WAAA,EAAa,WAAA;AAAA,UACb,QAAA,EAAU,QAAA;AAAA,UACV,cAAA,EAAgB,cAAA;AAAA,UAChB,gBAAA,EAA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KAAA,CAAM,UAAA,EAAY,UAAA,KAAe,GAAA,EAAK;AACxC,UAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AAAA,QACxC;AACA,QAAA,MAAM,KAAA;AAAA,MACR,CAAC,CAAA;AAEH,MAAA,OAAO;AAAA,QACL,WAAA;AAAA,QACA,OAAA,EAAS;AAAA,UACP,WAAA;AAAA,UACA,SAAA,EAAW,QAAA;AAAA,UACX,OAAO,KAAA,CAAM,KAAA;AAAA,UACb,cAAc,KAAA,CAAM;AAAA;AAAA;AAEtB,OACF;AAAA,IACF;AAKA,IAAA,OAAO,MAAA,CAAO,QAAQ,KAAK,CAAA;AAAA,EAC7B;AACF,CAAC;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,9 @@ declare const authModuleGithubProvider: _backstage_backend_plugin_api.BackendFea
|
|
|
20
20
|
declare namespace githubSignInResolvers {
|
|
21
21
|
/**
|
|
22
22
|
* Looks up the user by matching their GitHub username to the entity name.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Use {@link githubSignInResolvers.userIdMatchingUserEntityAnnotation}
|
|
25
|
+
* instead, because GitHub usernames can change and be reassigned.
|
|
23
26
|
*/
|
|
24
27
|
const usernameMatchingUserEntityName: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<GithubProfile>, {
|
|
25
28
|
dangerouslyAllowSignInWithoutUserInCatalog?: boolean | undefined;
|
package/dist/module.cjs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
4
5
|
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
5
6
|
var authenticator = require('./authenticator.cjs.js');
|
|
6
7
|
var resolvers = require('./resolvers.cjs.js');
|
|
@@ -11,15 +12,17 @@ const authModuleGithubProvider = backendPluginApi.createBackendModule({
|
|
|
11
12
|
register(reg) {
|
|
12
13
|
reg.registerInit({
|
|
13
14
|
deps: {
|
|
14
|
-
providers: pluginAuthNode.authProvidersExtensionPoint
|
|
15
|
+
providers: pluginAuthNode.authProvidersExtensionPoint,
|
|
16
|
+
auth: backendPluginApi.coreServices.auth,
|
|
17
|
+
catalog: pluginCatalogNode.catalogServiceRef
|
|
15
18
|
},
|
|
16
|
-
async init({ providers }) {
|
|
19
|
+
async init({ providers, auth, catalog }) {
|
|
17
20
|
providers.registerProvider({
|
|
18
21
|
providerId: "github",
|
|
19
22
|
factory: pluginAuthNode.createOAuthProviderFactory({
|
|
20
23
|
authenticator: authenticator.githubAuthenticator,
|
|
21
24
|
signInResolverFactories: {
|
|
22
|
-
...resolvers.
|
|
25
|
+
...resolvers.createGithubProviderSignInResolvers({ auth, catalog }),
|
|
23
26
|
...pluginAuthNode.commonSignInResolvers
|
|
24
27
|
}
|
|
25
28
|
})
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +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 {
|
|
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 {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { githubAuthenticator } from './authenticator';\nimport { createGithubProviderSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleGithubProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'github-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n auth: coreServices.auth,\n catalog: catalogServiceRef,\n },\n async init({ providers, auth, catalog }) {\n providers.registerProvider({\n providerId: 'github',\n factory: createOAuthProviderFactory({\n authenticator: githubAuthenticator,\n signInResolverFactories: {\n ...createGithubProviderSignInResolvers({ auth, catalog }),\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","coreServices","catalogServiceRef","createOAuthProviderFactory","githubAuthenticator","createGithubProviderSignInResolvers","commonSignInResolvers"],"mappings":";;;;;;;;AA6BO,MAAM,2BAA2BA,oCAAA,CAAoB;AAAA,EAC1D,QAAA,EAAU,MAAA;AAAA,EACV,QAAA,EAAU,iBAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,SAAA,EAAWC,0CAAA;AAAA,QACX,MAAMC,6BAAA,CAAa,IAAA;AAAA,QACnB,OAAA,EAASC;AAAA,OACX;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAW,IAAA,EAAM,SAAQ,EAAG;AACvC,QAAA,SAAA,CAAU,gBAAA,CAAiB;AAAA,UACzB,UAAA,EAAY,QAAA;AAAA,UACZ,SAASC,yCAAA,CAA2B;AAAA,YAClC,aAAA,EAAeC,iCAAA;AAAA,YACf,uBAAA,EAAyB;AAAA,cACvB,GAAGC,6CAAA,CAAoC,EAAE,IAAA,EAAM,SAAS,CAAA;AAAA,cACxD,GAAGC;AAAA;AACL,WACD;AAAA,SACF,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;"}
|
package/dist/resolvers.cjs.js
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var catalogModel = require('@backstage/catalog-model');
|
|
4
|
+
var errors = require('@backstage/errors');
|
|
3
5
|
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
4
6
|
var v3 = require('zod/v3');
|
|
5
7
|
|
|
8
|
+
const GITHUB_USER_ID_ANNOTATION = "github.com/user-id";
|
|
9
|
+
function requireMatchingGithubUserId(entity, userId) {
|
|
10
|
+
if (entity.metadata.annotations?.[GITHUB_USER_ID_ANNOTATION] !== userId) {
|
|
11
|
+
throw new Error(`GitHub user ID does not match the catalog user`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function signInWithCatalogEntity(entity, ctx) {
|
|
15
|
+
const { ownershipEntityRefs } = await ctx.resolveOwnershipEntityRefs(entity);
|
|
16
|
+
return ctx.issueToken({
|
|
17
|
+
claims: {
|
|
18
|
+
sub: catalogModel.stringifyEntityRef(entity),
|
|
19
|
+
ent: ownershipEntityRefs
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async function signInWithoutCatalogUser(name, ctx) {
|
|
24
|
+
const userEntityRef = catalogModel.stringifyEntityRef({
|
|
25
|
+
kind: "User",
|
|
26
|
+
namespace: catalogModel.DEFAULT_NAMESPACE,
|
|
27
|
+
name
|
|
28
|
+
});
|
|
29
|
+
return ctx.issueToken({
|
|
30
|
+
claims: {
|
|
31
|
+
sub: userEntityRef,
|
|
32
|
+
ent: [userEntityRef]
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
6
36
|
exports.githubSignInResolvers = void 0;
|
|
7
37
|
((githubSignInResolvers2) => {
|
|
8
38
|
githubSignInResolvers2.usernameMatchingUserEntityName = pluginAuthNode.createSignInResolverFactory({
|
|
@@ -39,19 +69,73 @@ exports.githubSignInResolvers = void 0;
|
|
|
39
69
|
if (!userId) {
|
|
40
70
|
throw new Error(`GitHub user profile does not contain a user ID`);
|
|
41
71
|
}
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
"github.com/user-id": userId
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
dangerousEntityRefFallback: options?.dangerouslyAllowSignInWithoutUserInCatalog ? { entityRef: { name: userId } } : void 0
|
|
72
|
+
const query = {
|
|
73
|
+
annotations: {
|
|
74
|
+
[GITHUB_USER_ID_ANNOTATION]: userId
|
|
50
75
|
}
|
|
51
|
-
|
|
76
|
+
};
|
|
77
|
+
let entity;
|
|
78
|
+
try {
|
|
79
|
+
({ entity } = await ctx.findCatalogUser(query));
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (!errors.isError(error) || error.name !== "NotFoundError" || !options.dangerouslyAllowSignInWithoutUserInCatalog) {
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
return signInWithoutCatalogUser(userId, ctx);
|
|
85
|
+
}
|
|
86
|
+
requireMatchingGithubUserId(entity, userId);
|
|
87
|
+
return signInWithCatalogEntity(entity, ctx);
|
|
52
88
|
};
|
|
53
89
|
}
|
|
54
90
|
}
|
|
55
91
|
);
|
|
56
92
|
})(exports.githubSignInResolvers || (exports.githubSignInResolvers = {}));
|
|
93
|
+
function createGithubProviderSignInResolvers(options) {
|
|
94
|
+
return {
|
|
95
|
+
...exports.githubSignInResolvers,
|
|
96
|
+
userIdMatchingUserEntityAnnotation: pluginAuthNode.createSignInResolverFactory({
|
|
97
|
+
optionsSchema: v3.z.object({
|
|
98
|
+
dangerouslyAllowSignInWithoutUserInCatalog: v3.z.boolean().optional()
|
|
99
|
+
}).optional(),
|
|
100
|
+
create(resolverOptions = {}) {
|
|
101
|
+
return async (info, ctx) => {
|
|
102
|
+
const userId = info.result.fullProfile.nodeId;
|
|
103
|
+
if (!userId) {
|
|
104
|
+
throw new Error(`GitHub user profile does not contain a user ID`);
|
|
105
|
+
}
|
|
106
|
+
const credentials = await options.auth.getOwnServiceCredentials();
|
|
107
|
+
const { items } = await options.catalog.getEntities(
|
|
108
|
+
{
|
|
109
|
+
filter: {
|
|
110
|
+
kind: "user",
|
|
111
|
+
[`metadata.annotations.${GITHUB_USER_ID_ANNOTATION}`]: userId
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{ credentials }
|
|
115
|
+
);
|
|
116
|
+
const exactMatches = items.filter(
|
|
117
|
+
(item) => item.metadata.annotations?.[GITHUB_USER_ID_ANNOTATION] === userId
|
|
118
|
+
);
|
|
119
|
+
if (exactMatches.length > 1) {
|
|
120
|
+
throw new errors.ConflictError(
|
|
121
|
+
"User lookup resulted in multiple exact matches"
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if (exactMatches.length === 1) {
|
|
125
|
+
return signInWithCatalogEntity(exactMatches[0], ctx);
|
|
126
|
+
}
|
|
127
|
+
if (items.length > 0) {
|
|
128
|
+
throw new Error(`GitHub user ID does not match the catalog user`);
|
|
129
|
+
}
|
|
130
|
+
if (resolverOptions.dangerouslyAllowSignInWithoutUserInCatalog) {
|
|
131
|
+
return signInWithoutCatalogUser(userId, ctx);
|
|
132
|
+
}
|
|
133
|
+
throw new errors.NotFoundError("User not found");
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
exports.createGithubProviderSignInResolvers = createGithubProviderSignInResolvers;
|
|
57
141
|
//# sourceMappingURL=resolvers.cjs.js.map
|
|
@@ -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 OAuthAuthenticatorResult,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { z } from 'zod/v3';\n\nimport { GithubProfile } from './authenticator';\n\n/**\n * Available sign-in resolvers for the GitHub auth provider.\n *\n * @public\n */\nexport namespace githubSignInResolvers {\n /**\n * Looks up the user by matching their GitHub username to the entity name.\n */\n export const usernameMatchingUserEntityName = createSignInResolverFactory({\n optionsSchema: z\n .object({\n dangerouslyAllowSignInWithoutUserInCatalog: z.boolean().optional(),\n })\n .optional(),\n create(options = {}) {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<GithubProfile>>,\n ctx,\n ) => {\n const { fullProfile } = info.result;\n\n const userId = fullProfile.username;\n if (!userId) {\n throw new Error(`GitHub user profile does not contain a username`);\n }\n\n return ctx.signInWithCatalogUser(\n {\n entityRef: { name: userId },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: userId } }\n : undefined,\n },\n );\n };\n },\n });\n\n /**\n * Looks up the user by matching their GitHub user ID to the github.com/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<GithubProfile>>,\n ctx,\n ) => {\n const { fullProfile } = info.result;\n\n const userId = fullProfile.nodeId;\n if (!userId) {\n throw new Error(`GitHub user profile does not contain a user ID`);\n }\n\n return ctx.signInWithCatalogUser(\n {\n annotations: {\n 'github.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}\n"],"names":["githubSignInResolvers","createSignInResolverFactory","z"],"mappings":";;;;;AA8BiBA;AAAA,CAAV,CAAUA,sBAAAA,KAAV;AAIE,EAAMA,sBAAAA,CAAA,iCAAiCC,0CAAA,CAA4B;AAAA,IACxE,aAAA,EAAeC,KACZ,MAAA,CAAO;AAAA,MACN,0CAAA,EAA4CA,IAAA,CAAE,OAAA,EAAQ,CAAE,QAAA;AAAS,KAClE,EACA,QAAA,EAAS;AAAA,IACZ,MAAA,CAAO,OAAA,GAAU,EAAC,EAAG;AACnB,MAAA,OAAO,OACL,MACA,GAAA,KACG;AACH,QAAA,MAAM,EAAE,WAAA,EAAY,GAAI,IAAA,CAAK,MAAA;AAE7B,QAAA,MAAM,SAAS,WAAA,CAAY,QAAA;AAC3B,QAAA,IAAI,CAAC,MAAA,EAAQ;AACX,UAAA,MAAM,IAAI,MAAM,CAAA,+CAAA,CAAiD,CAAA;AAAA,QACnE;AAEA,QAAA,OAAO,GAAA,CAAI,qBAAA;AAAA,UACT;AAAA,YACE,SAAA,EAAW,EAAE,IAAA,EAAM,MAAA;AAAO,WAC5B;AAAA,UACA;AAAA,YACE,0BAAA,EACE,SAAS,0CAAA,GACL,EAAE,WAAW,EAAE,IAAA,EAAM,MAAA,EAAO,EAAE,GAC9B;AAAA;AACR,SACF;AAAA,MACF,CAAA;AAAA,IACF;AAAA,GACD,CAAA;AAKM,EAAMF,uBAAA,kCAAA,GAAqCC,0CAAA;AAAA,IAChD;AAAA,MACE,aAAA,EAAeC,KACZ,MAAA,CAAO;AAAA,QACN,0CAAA,EAA4CA,IAAA,CAAE,OAAA,EAAQ,CAAE,QAAA;AAAS,OAClE,EACA,QAAA,EAAS;AAAA,MACZ,MAAA,CAAO,OAAA,GAAU,EAAC,EAAG;AACnB,QAAA,OAAO,OACL,MACA,GAAA,KACG;AACH,UAAA,MAAM,EAAE,WAAA,EAAY,GAAI,IAAA,CAAK,MAAA;AAE7B,UAAA,MAAM,SAAS,WAAA,CAAY,MAAA;AAC3B,UAAA,IAAI,CAAC,MAAA,EAAQ;AACX,YAAA,MAAM,IAAI,MAAM,CAAA,8CAAA,CAAgD,CAAA;AAAA,UAClE;AAEA,UAAA,OAAO,GAAA,CAAI,qBAAA;AAAA,YACT;AAAA,cACE,WAAA,EAAa;AAAA,gBACX,oBAAA,EAAsB;AAAA;AACxB,aACF;AAAA,YACA;AAAA,cACE,0BAAA,EACE,SAAS,0CAAA,GACL,EAAE,WAAW,EAAE,IAAA,EAAM,MAAA,EAAO,EAAE,GAC9B;AAAA;AACR,WACF;AAAA,QACF,CAAA;AAAA,MACF;AAAA;AACF,GACF;AAAA,CAAA,EA3EeF,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 DEFAULT_NAMESPACE,\n stringifyEntityRef,\n type Entity,\n} from '@backstage/catalog-model';\nimport type { AuthService } from '@backstage/backend-plugin-api';\nimport { ConflictError, isError, NotFoundError } from '@backstage/errors';\nimport {\n type AuthResolverContext,\n createSignInResolverFactory,\n OAuthAuthenticatorResult,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport type { CatalogService } from '@backstage/plugin-catalog-node';\nimport { z } from 'zod/v3';\n\nimport { GithubProfile } from './authenticator';\n\nconst GITHUB_USER_ID_ANNOTATION = 'github.com/user-id';\n\nfunction requireMatchingGithubUserId(entity: Entity, userId: string) {\n if (entity.metadata.annotations?.[GITHUB_USER_ID_ANNOTATION] !== userId) {\n throw new Error(`GitHub user ID does not match the catalog user`);\n }\n}\n\nasync function signInWithCatalogEntity(\n entity: Entity,\n ctx: AuthResolverContext,\n) {\n const { ownershipEntityRefs } = await ctx.resolveOwnershipEntityRefs(entity);\n return ctx.issueToken({\n claims: {\n sub: stringifyEntityRef(entity),\n ent: ownershipEntityRefs,\n },\n });\n}\n\nasync function signInWithoutCatalogUser(\n name: string,\n ctx: AuthResolverContext,\n) {\n const userEntityRef = stringifyEntityRef({\n kind: 'User',\n namespace: DEFAULT_NAMESPACE,\n name,\n });\n return ctx.issueToken({\n claims: {\n sub: userEntityRef,\n ent: [userEntityRef],\n },\n });\n}\n\n/**\n * Available sign-in resolvers for the GitHub auth provider.\n *\n * @public\n */\nexport namespace githubSignInResolvers {\n /**\n * Looks up the user by matching their GitHub username to the entity name.\n *\n * @deprecated Use {@link githubSignInResolvers.userIdMatchingUserEntityAnnotation}\n * instead, because GitHub usernames can change and be reassigned.\n */\n export const usernameMatchingUserEntityName = createSignInResolverFactory({\n optionsSchema: z\n .object({\n dangerouslyAllowSignInWithoutUserInCatalog: z.boolean().optional(),\n })\n .optional(),\n create(options = {}) {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<GithubProfile>>,\n ctx,\n ) => {\n const { fullProfile } = info.result;\n\n const userId = fullProfile.username;\n if (!userId) {\n throw new Error(`GitHub user profile does not contain a username`);\n }\n\n return ctx.signInWithCatalogUser(\n {\n entityRef: { name: userId },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: userId } }\n : undefined,\n },\n );\n };\n },\n });\n\n /**\n * Looks up the user by matching their GitHub user ID to the github.com/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<GithubProfile>>,\n ctx,\n ) => {\n const { fullProfile } = info.result;\n\n const userId = fullProfile.nodeId;\n if (!userId) {\n throw new Error(`GitHub user profile does not contain a user ID`);\n }\n\n const query = {\n annotations: {\n [GITHUB_USER_ID_ANNOTATION]: userId,\n },\n };\n\n let entity;\n try {\n ({ entity } = await ctx.findCatalogUser(query));\n } catch (error) {\n if (\n !isError(error) ||\n error.name !== 'NotFoundError' ||\n !options.dangerouslyAllowSignInWithoutUserInCatalog\n ) {\n throw error;\n }\n\n return signInWithoutCatalogUser(userId, ctx);\n }\n\n requireMatchingGithubUserId(entity, userId);\n return signInWithCatalogEntity(entity, ctx);\n };\n },\n },\n );\n}\n\n/**\n * Creates the resolver map used by the built-in GitHub provider module.\n *\n * @remarks\n *\n * The service-aware user ID resolver can inspect all case-insensitive catalog\n * matches and select the exact ID. The public resolver remains fail-closed when\n * its context reports an ambiguous lookup.\n *\n * @internal\n */\nexport function createGithubProviderSignInResolvers(options: {\n auth: AuthService;\n catalog: CatalogService;\n}) {\n return {\n ...githubSignInResolvers,\n userIdMatchingUserEntityAnnotation: createSignInResolverFactory({\n optionsSchema: z\n .object({\n dangerouslyAllowSignInWithoutUserInCatalog: z.boolean().optional(),\n })\n .optional(),\n create(resolverOptions = {}) {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<GithubProfile>>,\n ctx: AuthResolverContext,\n ) => {\n const userId = info.result.fullProfile.nodeId;\n if (!userId) {\n throw new Error(`GitHub user profile does not contain a user ID`);\n }\n\n const credentials = await options.auth.getOwnServiceCredentials();\n const { items } = await options.catalog.getEntities(\n {\n filter: {\n kind: 'user',\n [`metadata.annotations.${GITHUB_USER_ID_ANNOTATION}`]: userId,\n },\n },\n { credentials },\n );\n const exactMatches = items.filter(\n item =>\n item.metadata.annotations?.[GITHUB_USER_ID_ANNOTATION] === userId,\n );\n\n if (exactMatches.length > 1) {\n throw new ConflictError(\n 'User lookup resulted in multiple exact matches',\n );\n }\n if (exactMatches.length === 1) {\n return signInWithCatalogEntity(exactMatches[0], ctx);\n }\n if (items.length > 0) {\n throw new Error(`GitHub user ID does not match the catalog user`);\n }\n if (resolverOptions.dangerouslyAllowSignInWithoutUserInCatalog) {\n return signInWithoutCatalogUser(userId, ctx);\n }\n throw new NotFoundError('User not found');\n };\n },\n }),\n };\n}\n"],"names":["stringifyEntityRef","DEFAULT_NAMESPACE","githubSignInResolvers","createSignInResolverFactory","z","isError","ConflictError","NotFoundError"],"mappings":";;;;;;;AAkCA,MAAM,yBAAA,GAA4B,oBAAA;AAElC,SAAS,2BAAA,CAA4B,QAAgB,MAAA,EAAgB;AACnE,EAAA,IAAI,MAAA,CAAO,QAAA,CAAS,WAAA,GAAc,yBAAyB,MAAM,MAAA,EAAQ;AACvE,IAAA,MAAM,IAAI,MAAM,CAAA,8CAAA,CAAgD,CAAA;AAAA,EAClE;AACF;AAEA,eAAe,uBAAA,CACb,QACA,GAAA,EACA;AACA,EAAA,MAAM,EAAE,mBAAA,EAAoB,GAAI,MAAM,GAAA,CAAI,2BAA2B,MAAM,CAAA;AAC3E,EAAA,OAAO,IAAI,UAAA,CAAW;AAAA,IACpB,MAAA,EAAQ;AAAA,MACN,GAAA,EAAKA,gCAAmB,MAAM,CAAA;AAAA,MAC9B,GAAA,EAAK;AAAA;AACP,GACD,CAAA;AACH;AAEA,eAAe,wBAAA,CACb,MACA,GAAA,EACA;AACA,EAAA,MAAM,gBAAgBA,+BAAA,CAAmB;AAAA,IACvC,IAAA,EAAM,MAAA;AAAA,IACN,SAAA,EAAWC,8BAAA;AAAA,IACX;AAAA,GACD,CAAA;AACD,EAAA,OAAO,IAAI,UAAA,CAAW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
|
2
2
|
"name": "@backstage/plugin-auth-backend-module-github-provider",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8-next.0",
|
|
4
4
|
"description": "The github-provider backend module for the auth plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -37,16 +37,19 @@
|
|
|
37
37
|
"test": "backstage-cli package test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/backend-plugin-api": "1.10.
|
|
41
|
-
"@backstage/
|
|
40
|
+
"@backstage/backend-plugin-api": "1.10.2-next.0",
|
|
41
|
+
"@backstage/catalog-model": "1.10.2-next.0",
|
|
42
|
+
"@backstage/errors": "1.3.2-next.0",
|
|
43
|
+
"@backstage/plugin-auth-node": "0.7.7-next.0",
|
|
44
|
+
"@backstage/plugin-catalog-node": "2.2.6-next.0",
|
|
42
45
|
"passport-github2": "^0.1.12",
|
|
43
46
|
"zod": "^3.25.76 || ^4.0.0"
|
|
44
47
|
},
|
|
45
48
|
"devDependencies": {
|
|
46
|
-
"@backstage/backend-defaults": "0.
|
|
47
|
-
"@backstage/backend-test-utils": "1.11.
|
|
48
|
-
"@backstage/cli": "0.36.
|
|
49
|
-
"@backstage/plugin-auth-backend": "0.30.
|
|
49
|
+
"@backstage/backend-defaults": "0.18.1-next.0",
|
|
50
|
+
"@backstage/backend-test-utils": "1.11.8-next.0",
|
|
51
|
+
"@backstage/cli": "0.36.7-next.0",
|
|
52
|
+
"@backstage/plugin-auth-backend": "0.30.2-next.0",
|
|
50
53
|
"@backstage/types": "1.2.2",
|
|
51
54
|
"@types/passport-github2": "^1.2.4",
|
|
52
55
|
"supertest": "^7.0.0"
|