@backstage/plugin-auth-backend-module-google-provider 0.2.0 → 0.2.1-next.1

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,22 @@
1
1
  # @backstage/plugin-auth-backend-module-google-provider
2
2
 
3
+ ## 0.2.1-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 217458a: Updated configuration schema to include the new `allowedDomains` option for the `emailLocalPartMatchingUserEntityName` sign-in resolver.
8
+ - Updated dependencies
9
+ - @backstage/plugin-auth-node@0.5.3-next.1
10
+ - @backstage/backend-plugin-api@1.0.1-next.1
11
+
12
+ ## 0.2.1-next.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+ - @backstage/plugin-auth-node@0.5.3-next.0
18
+ - @backstage/backend-plugin-api@1.0.1-next.0
19
+
3
20
  ## 0.2.0
4
21
 
5
22
  ### Minor Changes
package/config.d.ts CHANGED
@@ -30,7 +30,10 @@ export interface Config {
30
30
  signIn?: {
31
31
  resolvers: Array<
32
32
  | { resolver: 'emailMatchingUserEntityAnnotation' }
33
- | { resolver: 'emailLocalPartMatchingUserEntityName' }
33
+ | {
34
+ resolver: 'emailLocalPartMatchingUserEntityName';
35
+ allowedDomains?: string[];
36
+ }
34
37
  | { resolver: 'emailMatchingUserEntityProfileEmail' }
35
38
  >;
36
39
  };
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ var pluginAuthNode = require('@backstage/plugin-auth-node');
4
+ var googleAuthLibrary = require('google-auth-library');
5
+ var passportGoogleOauth20 = require('passport-google-oauth20');
6
+
7
+ const googleAuthenticator = pluginAuthNode.createOAuthAuthenticator({
8
+ defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
9
+ scopes: {
10
+ required: [
11
+ "openid",
12
+ `https://www.googleapis.com/auth/userinfo.email`,
13
+ `https://www.googleapis.com/auth/userinfo.profile`
14
+ ]
15
+ },
16
+ initialize({ callbackUrl, config }) {
17
+ const clientId = config.getString("clientId");
18
+ const clientSecret = config.getString("clientSecret");
19
+ return pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
20
+ new passportGoogleOauth20.Strategy(
21
+ {
22
+ clientID: clientId,
23
+ clientSecret,
24
+ callbackURL: callbackUrl,
25
+ passReqToCallback: false
26
+ },
27
+ (accessToken, refreshToken, params, fullProfile, done) => {
28
+ done(
29
+ void 0,
30
+ {
31
+ fullProfile,
32
+ params,
33
+ accessToken
34
+ },
35
+ {
36
+ refreshToken
37
+ }
38
+ );
39
+ }
40
+ )
41
+ );
42
+ },
43
+ async start(input, helper) {
44
+ return helper.start(input, {
45
+ accessType: "offline",
46
+ prompt: "consent"
47
+ });
48
+ },
49
+ async authenticate(input, helper) {
50
+ return helper.authenticate(input);
51
+ },
52
+ async refresh(input, helper) {
53
+ return helper.refresh(input);
54
+ },
55
+ async logout(input) {
56
+ if (input.refreshToken) {
57
+ const oauthClient = new googleAuthLibrary.OAuth2Client();
58
+ await oauthClient.revokeToken(input.refreshToken);
59
+ }
60
+ }
61
+ });
62
+
63
+ exports.googleAuthenticator = googleAuthenticator;
64
+ //# sourceMappingURL=authenticator.cjs.js.map
@@ -0,0 +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 });\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,uCAAyB,CAAA;AAAA,EAC1D,yBACEC,+CAAiC,CAAA,uBAAA;AAAA,EACnC,MAAQ,EAAA;AAAA,IACN,QAAU,EAAA;AAAA,MACR,QAAA;AAAA,MACA,CAAA,8CAAA,CAAA;AAAA,MACA,CAAA,gDAAA,CAAA;AAAA,KACF;AAAA,GACF;AAAA,EACA,UAAW,CAAA,EAAE,WAAa,EAAA,MAAA,EAAU,EAAA;AAClC,IAAM,MAAA,QAAA,GAAW,MAAO,CAAA,SAAA,CAAU,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,GACF;AACF,CAAC;;;;"}
package/dist/index.cjs.js CHANGED
@@ -2,110 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var pluginAuthNode = require('@backstage/plugin-auth-node');
6
- var googleAuthLibrary = require('google-auth-library');
7
- var passportGoogleOauth20 = require('passport-google-oauth20');
8
- var backendPluginApi = require('@backstage/backend-plugin-api');
5
+ var authenticator = require('./authenticator.cjs.js');
6
+ var module$1 = require('./module.cjs.js');
7
+ var resolvers = require('./resolvers.cjs.js');
9
8
 
10
- const googleAuthenticator = pluginAuthNode.createOAuthAuthenticator({
11
- defaultProfileTransform: pluginAuthNode.PassportOAuthAuthenticatorHelper.defaultProfileTransform,
12
- scopes: {
13
- required: [
14
- "openid",
15
- `https://www.googleapis.com/auth/userinfo.email`,
16
- `https://www.googleapis.com/auth/userinfo.profile`
17
- ]
18
- },
19
- initialize({ callbackUrl, config }) {
20
- const clientId = config.getString("clientId");
21
- const clientSecret = config.getString("clientSecret");
22
- return pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
23
- new passportGoogleOauth20.Strategy(
24
- {
25
- clientID: clientId,
26
- clientSecret,
27
- callbackURL: callbackUrl,
28
- passReqToCallback: false
29
- },
30
- (accessToken, refreshToken, params, fullProfile, done) => {
31
- done(
32
- void 0,
33
- {
34
- fullProfile,
35
- params,
36
- accessToken
37
- },
38
- {
39
- refreshToken
40
- }
41
- );
42
- }
43
- )
44
- );
45
- },
46
- async start(input, helper) {
47
- return helper.start(input, {
48
- accessType: "offline",
49
- prompt: "consent"
50
- });
51
- },
52
- async authenticate(input, helper) {
53
- return helper.authenticate(input);
54
- },
55
- async refresh(input, helper) {
56
- return helper.refresh(input);
57
- },
58
- async logout(input) {
59
- if (input.refreshToken) {
60
- const oauthClient = new googleAuthLibrary.OAuth2Client();
61
- await oauthClient.revokeToken(input.refreshToken);
62
- }
63
- }
64
- });
65
9
 
66
- exports.googleSignInResolvers = void 0;
67
- ((googleSignInResolvers2) => {
68
- googleSignInResolvers2.emailMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
69
- create() {
70
- return async (info, ctx) => {
71
- const { profile } = info;
72
- if (!profile.email) {
73
- throw new Error("Google profile contained no email");
74
- }
75
- return ctx.signInWithCatalogUser({
76
- annotations: {
77
- "google.com/email": profile.email
78
- }
79
- });
80
- };
81
- }
82
- });
83
- })(exports.googleSignInResolvers || (exports.googleSignInResolvers = {}));
84
10
 
85
- const authModuleGoogleProvider = backendPluginApi.createBackendModule({
86
- pluginId: "auth",
87
- moduleId: "google-provider",
88
- register(reg) {
89
- reg.registerInit({
90
- deps: {
91
- providers: pluginAuthNode.authProvidersExtensionPoint
92
- },
93
- async init({ providers }) {
94
- providers.registerProvider({
95
- providerId: "google",
96
- factory: pluginAuthNode.createOAuthProviderFactory({
97
- authenticator: googleAuthenticator,
98
- signInResolverFactories: {
99
- ...exports.googleSignInResolvers,
100
- ...pluginAuthNode.commonSignInResolvers
101
- }
102
- })
103
- });
104
- }
105
- });
106
- }
11
+ exports.googleAuthenticator = authenticator.googleAuthenticator;
12
+ exports.default = module$1.authModuleGoogleProvider;
13
+ Object.defineProperty(exports, "googleSignInResolvers", {
14
+ enumerable: true,
15
+ get: function () { return resolvers.googleSignInResolvers; }
107
16
  });
108
-
109
- exports.default = authModuleGoogleProvider;
110
- exports.googleAuthenticator = googleAuthenticator;
111
17
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/authenticator.ts","../src/resolvers.ts","../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 {\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 });\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","/*\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';\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 create() {\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 annotations: {\n 'google.com/email': profile.email,\n },\n });\n };\n },\n });\n}\n","/*\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":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","GoogleStrategy","OAuth2Client","googleSignInResolvers","createSignInResolverFactory","createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","commonSignInResolvers"],"mappings":";;;;;;;;;AA0BO,MAAM,sBAAsBA,uCAAyB,CAAA;AAAA,EAC1D,yBACEC,+CAAiC,CAAA,uBAAA;AAAA,EACnC,MAAQ,EAAA;AAAA,IACN,QAAU,EAAA;AAAA,MACR,QAAA;AAAA,MACA,CAAA,8CAAA,CAAA;AAAA,MACA,CAAA,gDAAA,CAAA;AAAA,KACF;AAAA,GACF;AAAA,EACA,UAAW,CAAA,EAAE,WAAa,EAAA,MAAA,EAAU,EAAA;AAClC,IAAM,MAAA,QAAA,GAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA,CAAA;AAC5C,IAAM,MAAA,YAAA,GAAe,MAAO,CAAA,SAAA,CAAU,cAAc,CAAA,CAAA;AAEpD,IAAA,OAAOA,+CAAiC,CAAA,IAAA;AAAA,MACtC,IAAIC,8BAAA;AAAA,QACF;AAAA,UACE,QAAU,EAAA,QAAA;AAAA,UACV,YAAA;AAAA,UACA,WAAa,EAAA,WAAA;AAAA,UACb,iBAAmB,EAAA,KAAA;AAAA,SACrB;AAAA,QACA,CACE,WAAA,EACA,YACA,EAAA,MAAA,EACA,aACA,IACG,KAAA;AACH,UAAA,IAAA;AAAA,YACE,KAAA,CAAA;AAAA,YACA;AAAA,cACE,WAAA;AAAA,cACA,MAAA;AAAA,cACA,WAAA;AAAA,aACF;AAAA,YACA;AAAA,cACE,YAAA;AAAA,aACF;AAAA,WACF,CAAA;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACF;AAAA,EAEA,MAAM,KAAM,CAAA,KAAA,EAAO,MAAQ,EAAA;AACzB,IAAO,OAAA,MAAA,CAAO,MAAM,KAAO,EAAA;AAAA,MACzB,UAAY,EAAA,SAAA;AAAA,MACZ,MAAQ,EAAA,SAAA;AAAA,KACT,CAAA,CAAA;AAAA,GACH;AAAA,EAEA,MAAM,YAAa,CAAA,KAA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,0CAAA;AAAA,OACb;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAa,EAAA;AACxB,QAAA,SAAA,CAAU,gBAAiB,CAAA;AAAA,UACzB,UAAY,EAAA,QAAA;AAAA,UACZ,SAASC,yCAA2B,CAAA;AAAA,YAClC,aAAe,EAAA,mBAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGJ,6BAAA;AAAA,cACH,GAAGK,oCAAA;AAAA,aACL;AAAA,WACD,CAAA;AAAA,SACF,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var backendPluginApi = require('@backstage/backend-plugin-api');
4
+ var pluginAuthNode = require('@backstage/plugin-auth-node');
5
+ var authenticator = require('./authenticator.cjs.js');
6
+ var resolvers = require('./resolvers.cjs.js');
7
+
8
+ const authModuleGoogleProvider = backendPluginApi.createBackendModule({
9
+ pluginId: "auth",
10
+ moduleId: "google-provider",
11
+ register(reg) {
12
+ reg.registerInit({
13
+ deps: {
14
+ providers: pluginAuthNode.authProvidersExtensionPoint
15
+ },
16
+ async init({ providers }) {
17
+ providers.registerProvider({
18
+ providerId: "google",
19
+ factory: pluginAuthNode.createOAuthProviderFactory({
20
+ authenticator: authenticator.googleAuthenticator,
21
+ signInResolverFactories: {
22
+ ...resolvers.googleSignInResolvers,
23
+ ...pluginAuthNode.commonSignInResolvers
24
+ }
25
+ })
26
+ });
27
+ }
28
+ });
29
+ }
30
+ });
31
+
32
+ exports.authModuleGoogleProvider = authModuleGoogleProvider;
33
+ //# sourceMappingURL=module.cjs.js.map
@@ -0,0 +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,oCAAoB,CAAA;AAAA,EAC1D,QAAU,EAAA,MAAA;AAAA,EACV,QAAU,EAAA,iBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,SAAW,EAAAC,0CAAA;AAAA,OACb;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,SAAA,EAAa,EAAA;AACxB,QAAA,SAAA,CAAU,gBAAiB,CAAA;AAAA,UACzB,UAAY,EAAA,QAAA;AAAA,UACZ,SAASC,yCAA2B,CAAA;AAAA,YAClC,aAAe,EAAAC,iCAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGC,+BAAA;AAAA,cACH,GAAGC,oCAAA;AAAA,aACL;AAAA,WACD,CAAA;AAAA,SACF,CAAA,CAAA;AAAA,OACH;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var pluginAuthNode = require('@backstage/plugin-auth-node');
4
+
5
+ exports.googleSignInResolvers = void 0;
6
+ ((googleSignInResolvers2) => {
7
+ googleSignInResolvers2.emailMatchingUserEntityAnnotation = pluginAuthNode.createSignInResolverFactory({
8
+ create() {
9
+ return async (info, ctx) => {
10
+ const { profile } = info;
11
+ if (!profile.email) {
12
+ throw new Error("Google profile contained no email");
13
+ }
14
+ return ctx.signInWithCatalogUser({
15
+ annotations: {
16
+ "google.com/email": profile.email
17
+ }
18
+ });
19
+ };
20
+ }
21
+ });
22
+ })(exports.googleSignInResolvers || (exports.googleSignInResolvers = {}));
23
+ //# sourceMappingURL=resolvers.cjs.js.map
@@ -0,0 +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';\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 create() {\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 annotations: {\n 'google.com/email': profile.email,\n },\n });\n };\n },\n });\n}\n"],"names":["googleSignInResolvers","createSignInResolverFactory"],"mappings":";;;;AA4BiBA,uCAAA;AAAA,CAAV,CAAUA,sBAAV,KAAA;AAIE,EAAMA,sBAAAA,CAAA,oCAAoCC,0CAA4B,CAAA;AAAA,IAC3E,MAAS,GAAA;AACP,MAAO,OAAA,OACL,MACA,GACG,KAAA;AACH,QAAM,MAAA,EAAE,SAAY,GAAA,IAAA,CAAA;AAEpB,QAAI,IAAA,CAAC,QAAQ,KAAO,EAAA;AAClB,UAAM,MAAA,IAAI,MAAM,mCAAmC,CAAA,CAAA;AAAA,SACrD;AAEA,QAAA,OAAO,IAAI,qBAAsB,CAAA;AAAA,UAC/B,WAAa,EAAA;AAAA,YACX,oBAAoB,OAAQ,CAAA,KAAA;AAAA,WAC9B;AAAA,SACD,CAAA,CAAA;AAAA,OACH,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AAAA,CAvBc,EAAAD,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.2.0",
3
+ "version": "0.2.1-next.1",
4
4
  "description": "A Google auth provider module for the Backstage auth backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -38,15 +38,15 @@
38
38
  "test": "backstage-cli package test"
39
39
  },
40
40
  "dependencies": {
41
- "@backstage/backend-plugin-api": "^1.0.0",
42
- "@backstage/plugin-auth-node": "^0.5.2",
41
+ "@backstage/backend-plugin-api": "1.0.1-next.1",
42
+ "@backstage/plugin-auth-node": "0.5.3-next.1",
43
43
  "google-auth-library": "^9.0.0",
44
44
  "passport-google-oauth20": "^2.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@backstage/backend-test-utils": "^1.0.0",
48
- "@backstage/cli": "^0.27.1",
49
- "@backstage/plugin-auth-backend": "^0.23.0",
47
+ "@backstage/backend-test-utils": "1.0.1-next.2",
48
+ "@backstage/cli": "0.28.0-next.2",
49
+ "@backstage/plugin-auth-backend": "0.23.1-next.1",
50
50
  "@types/passport-google-oauth20": "^2.0.3",
51
51
  "supertest": "^7.0.0"
52
52
  },