@backstage/plugin-auth-backend-module-google-provider 0.3.6-next.0 → 0.3.7-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 +16 -0
- package/dist/authenticator.cjs.js.map +1 -1
- package/dist/module.cjs.js.map +1 -1
- package/dist/resolvers.cjs.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-google-provider
|
|
2
2
|
|
|
3
|
+
## 0.3.7-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-auth-node@0.6.7-next.0
|
|
9
|
+
- @backstage/backend-plugin-api@1.4.3-next.0
|
|
10
|
+
|
|
11
|
+
## 0.3.6
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @backstage/plugin-auth-node@0.6.6
|
|
17
|
+
- @backstage/backend-plugin-api@1.4.2
|
|
18
|
+
|
|
3
19
|
## 0.3.6-next.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -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 {\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n createOAuthAuthenticator,\n} from '@backstage/plugin-auth-node';\nimport { OAuth2Client } from 'google-auth-library';\nimport { Strategy as GoogleStrategy } from 'passport-google-oauth20';\n\n/** @public */\nexport const googleAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n required: [\n 'openid',\n `https://www.googleapis.com/auth/userinfo.email`,\n `https://www.googleapis.com/auth/userinfo.profile`,\n ],\n },\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n\n return PassportOAuthAuthenticatorHelper.from(\n new GoogleStrategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n passReqToCallback: false,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(\n undefined,\n {\n fullProfile,\n params,\n accessToken,\n },\n {\n refreshToken,\n },\n );\n },\n ),\n );\n },\n\n async start(input, helper) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n includeGrantedScopes: 'true',\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 async logout(input) {\n if (input.refreshToken) {\n const oauthClient = new OAuth2Client();\n await oauthClient.revokeToken(input.refreshToken);\n }\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","GoogleStrategy","OAuth2Client"],"mappings":";;;;;;AA0BO,MAAM,sBAAsBA,
|
|
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 {\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n createOAuthAuthenticator,\n} from '@backstage/plugin-auth-node';\nimport { OAuth2Client } from 'google-auth-library';\nimport { Strategy as GoogleStrategy } from 'passport-google-oauth20';\n\n/** @public */\nexport const googleAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n scopes: {\n required: [\n 'openid',\n `https://www.googleapis.com/auth/userinfo.email`,\n `https://www.googleapis.com/auth/userinfo.profile`,\n ],\n },\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n\n return PassportOAuthAuthenticatorHelper.from(\n new GoogleStrategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n passReqToCallback: false,\n },\n (\n accessToken: string,\n refreshToken: string,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(\n undefined,\n {\n fullProfile,\n params,\n accessToken,\n },\n {\n refreshToken,\n },\n );\n },\n ),\n );\n },\n\n async start(input, helper) {\n return helper.start(input, {\n accessType: 'offline',\n prompt: 'consent',\n includeGrantedScopes: 'true',\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 async logout(input) {\n if (input.refreshToken) {\n const oauthClient = new OAuth2Client();\n await oauthClient.revokeToken(input.refreshToken);\n }\n },\n});\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","GoogleStrategy","OAuth2Client"],"mappings":";;;;;;AA0BO,MAAM,sBAAsBA,uCAAA,CAAyB;AAAA,EAC1D,yBACEC,+CAAA,CAAiC,uBAAA;AAAA,EACnC,MAAA,EAAQ;AAAA,IACN,QAAA,EAAU;AAAA,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I,MAAM,YAAA,EAAc;AACtB,MAAA,MAAM,WAAA,GAAc,IAAIC,8BAAA,EAAa;AACrC,MAAA,MAAM,WAAA,CAAY,WAAA,CAAY,KAAA,CAAM,YAAY,CAAA;AAAA,IAClD;AAAA,EACF;AACF,CAAC;;;;"}
|
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 */\n\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { googleAuthenticator } from './authenticator';\nimport { googleSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleGoogleProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'google-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'google',\n factory: createOAuthProviderFactory({\n authenticator: googleAuthenticator,\n signInResolverFactories: {\n ...googleSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","googleAuthenticator","googleSignInResolvers","commonSignInResolvers"],"mappings":";;;;;;;AA0BO,MAAM,2BAA2BA,
|
|
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 */\n\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { googleAuthenticator } from './authenticator';\nimport { googleSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleGoogleProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'google-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'google',\n factory: createOAuthProviderFactory({\n authenticator: googleAuthenticator,\n signInResolverFactories: {\n ...googleSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","googleAuthenticator","googleSignInResolvers","commonSignInResolvers"],"mappings":";;;;;;;AA0BO,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;AAAA,OACb;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAU,EAAG;AACxB,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,+BAAA;AAAA,cACH,GAAGC;AAAA;AACL,WACD;AAAA,SACF,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
|
|
@@ -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 PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { z } from 'zod';\n\n/**\n * Available sign-in resolvers for the Google auth provider.\n *\n * @public\n */\nexport namespace googleSignInResolvers {\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 (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { profile } = info;\n\n if (!profile.email) {\n throw new Error('Google profile contained no email');\n }\n\n return ctx.signInWithCatalogUser(\n {\n annotations: {\n 'google.com/email': profile.email,\n },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: profile.email } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["googleSignInResolvers","createSignInResolverFactory","z"],"mappings":";;;;;AA6BiBA;AAAA,CAAV,CAAUA,
|
|
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 PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { z } from 'zod';\n\n/**\n * Available sign-in resolvers for the Google auth provider.\n *\n * @public\n */\nexport namespace googleSignInResolvers {\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 (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const { profile } = info;\n\n if (!profile.email) {\n throw new Error('Google profile contained no email');\n }\n\n return ctx.signInWithCatalogUser(\n {\n annotations: {\n 'google.com/email': profile.email,\n },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: profile.email } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["googleSignInResolvers","createSignInResolverFactory","z"],"mappings":";;;;;AA6BiBA;AAAA,CAAV,CAAUA,sBAAAA,KAAV;AAIE,EAAMA,sBAAAA,CAAA,oCAAoCC,0CAAA,CAA4B;AAAA,IAC3E,aAAA,EAAeC,MACZ,MAAA,CAAO;AAAA,MACN,0CAAA,EAA4CA,KAAA,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,SAAQ,GAAI,IAAA;AAEpB,QAAA,IAAI,CAAC,QAAQ,KAAA,EAAO;AAClB,UAAA,MAAM,IAAI,MAAM,mCAAmC,CAAA;AAAA,QACrD;AAEA,QAAA,OAAO,GAAA,CAAI,qBAAA;AAAA,UACT;AAAA,YACE,WAAA,EAAa;AAAA,cACX,oBAAoB,OAAA,CAAQ;AAAA;AAC9B,WACF;AAAA,UACA;AAAA,YACE,0BAAA,EACE,OAAA,EAAS,0CAAA,GACL,EAAE,SAAA,EAAW,EAAE,IAAA,EAAM,OAAA,CAAQ,KAAA,EAAM,EAAE,GACrC;AAAA;AACR,SACF;AAAA,MACF,CAAA;AAAA,IACF;AAAA,GACD,CAAA;AAAA,CAAA,EApCcF,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-google-provider",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7-next.0",
|
|
4
4
|
"description": "A Google auth provider module for the Backstage auth backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"test": "backstage-cli package test"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@backstage/backend-plugin-api": "1.4.
|
|
45
|
-
"@backstage/plugin-auth-node": "0.6.
|
|
44
|
+
"@backstage/backend-plugin-api": "1.4.3-next.0",
|
|
45
|
+
"@backstage/plugin-auth-node": "0.6.7-next.0",
|
|
46
46
|
"google-auth-library": "^9.0.0",
|
|
47
47
|
"passport-google-oauth20": "^2.0.0",
|
|
48
48
|
"zod": "^3.22.4"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@backstage/backend-test-utils": "1.
|
|
52
|
-
"@backstage/cli": "0.
|
|
53
|
-
"@backstage/plugin-auth-backend": "0.25.
|
|
51
|
+
"@backstage/backend-test-utils": "1.9.0-next.1",
|
|
52
|
+
"@backstage/cli": "0.34.2-next.1",
|
|
53
|
+
"@backstage/plugin-auth-backend": "0.25.4-next.0",
|
|
54
54
|
"@backstage/types": "1.2.1",
|
|
55
55
|
"@types/passport-google-oauth20": "^2.0.3",
|
|
56
56
|
"supertest": "^7.0.0"
|