@backstage/plugin-auth-backend-module-oauth2-provider 0.4.5 → 0.4.6
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 +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-oauth2-provider
|
|
2
2
|
|
|
3
|
+
## 0.4.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/plugin-auth-node@0.6.6
|
|
9
|
+
- @backstage/backend-plugin-api@1.4.2
|
|
10
|
+
|
|
11
|
+
## 0.4.6-next.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @backstage/plugin-auth-node@0.6.6-next.0
|
|
17
|
+
- @backstage/backend-plugin-api@1.4.2-next.0
|
|
18
|
+
|
|
3
19
|
## 0.4.5
|
|
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 { Strategy as Oauth2Strategy } from 'passport-oauth2';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\n\n/** @public */\nexport const oauth2Authenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const authorizationUrl = config.getString('authorizationUrl');\n const tokenUrl = config.getString('tokenUrl');\n const includeBasicAuth = config.getOptionalBoolean('includeBasicAuth');\n\n if (config.has('scope')) {\n throw new Error(\n 'The oauth2 provider no longer supports the \"scope\" configuration option. Please use the \"additionalScopes\" option instead.',\n );\n }\n\n return PassportOAuthAuthenticatorHelper.from(\n new Oauth2Strategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n authorizationURL: authorizationUrl,\n tokenURL: tokenUrl,\n passReqToCallback: false,\n customHeaders: includeBasicAuth\n ? {\n Authorization: `Basic ${encodeClientCredentials(\n clientId,\n clientSecret,\n )}`,\n }\n : undefined,\n },\n (\n accessToken: any,\n refreshToken: any,\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 return helper.authenticate(input);\n },\n\n async refresh(input, helper) {\n return helper.refresh(input);\n },\n});\n\n/** @private */\nfunction encodeClientCredentials(\n clientID: string,\n clientSecret: string,\n): string {\n return Buffer.from(`${clientID}:${clientSecret}`).toString('base64');\n}\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","Oauth2Strategy"],"mappings":";;;;;AAyBO,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 { Strategy as Oauth2Strategy } from 'passport-oauth2';\nimport {\n createOAuthAuthenticator,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\n\n/** @public */\nexport const oauth2Authenticator = createOAuthAuthenticator({\n defaultProfileTransform:\n PassportOAuthAuthenticatorHelper.defaultProfileTransform,\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const authorizationUrl = config.getString('authorizationUrl');\n const tokenUrl = config.getString('tokenUrl');\n const includeBasicAuth = config.getOptionalBoolean('includeBasicAuth');\n\n if (config.has('scope')) {\n throw new Error(\n 'The oauth2 provider no longer supports the \"scope\" configuration option. Please use the \"additionalScopes\" option instead.',\n );\n }\n\n return PassportOAuthAuthenticatorHelper.from(\n new Oauth2Strategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n authorizationURL: authorizationUrl,\n tokenURL: tokenUrl,\n passReqToCallback: false,\n customHeaders: includeBasicAuth\n ? {\n Authorization: `Basic ${encodeClientCredentials(\n clientId,\n clientSecret,\n )}`,\n }\n : undefined,\n },\n (\n accessToken: any,\n refreshToken: any,\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 return helper.authenticate(input);\n },\n\n async refresh(input, helper) {\n return helper.refresh(input);\n },\n});\n\n/** @private */\nfunction encodeClientCredentials(\n clientID: string,\n clientSecret: string,\n): string {\n return Buffer.from(`${clientID}:${clientSecret}`).toString('base64');\n}\n"],"names":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","Oauth2Strategy"],"mappings":";;;;;AAyBO,MAAM,sBAAsBA,uCAAA,CAAyB;AAAA,EAC1D,yBACEC,+CAAA,CAAiC,uBAAA;AAAA,EACnC,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,gBAAA,GAAmB,MAAA,CAAO,SAAA,CAAU,kBAAkB,CAAA;AAC5D,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,SAAA,CAAU,UAAU,CAAA;AAC5C,IAAA,MAAM,gBAAA,GAAmB,MAAA,CAAO,kBAAA,CAAmB,kBAAkB,CAAA;AAErE,IAAA,IAAI,MAAA,CAAO,GAAA,CAAI,OAAO,CAAA,EAAG;AACvB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAEA,IAAA,OAAOA,+CAAA,CAAiC,IAAA;AAAA,MACtC,IAAIC,uBAAA;AAAA,QACF;AAAA,UACE,QAAA,EAAU,QAAA;AAAA,UACV,YAAA;AAAA,UACA,WAAA,EAAa,WAAA;AAAA,UACb,gBAAA,EAAkB,gBAAA;AAAA,UAClB,QAAA,EAAU,QAAA;AAAA,UACV,iBAAA,EAAmB,KAAA;AAAA,UACnB,eAAe,gBAAA,GACX;AAAA,YACE,eAAe,CAAA,MAAA,EAAS,uBAAA;AAAA,cACtB,QAAA;AAAA,cACA;AAAA,aACD,CAAA;AAAA,WACH,GACA;AAAA,SACN;AAAA,QACA,CACE,WAAA,EACA,YAAA,EACA,MAAA,EACA,aACA,IAAA,KACG;AACH,UAAA,IAAA;AAAA,YACE,MAAA;AAAA,YACA,EAAE,WAAA,EAAa,MAAA,EAAQ,WAAA,EAAY;AAAA,YACnC,EAAE,YAAA;AAAa,WACjB;AAAA,QACF;AAAA;AACF,KACF;AAAA,EACF,CAAA;AAAA,EAEA,MAAM,KAAA,CAAM,KAAA,EAAO,MAAA,EAAQ;AACzB,IAAA,OAAO,MAAA,CAAO,MAAM,KAAA,EAAO;AAAA,MACzB,UAAA,EAAY,SAAA;AAAA,MACZ,MAAA,EAAQ;AAAA,KACT,CAAA;AAAA,EACH,CAAA;AAAA,EAEA,MAAM,YAAA,CAAa,KAAA,EAAO,MAAA,EAAQ;AAChC,IAAA,OAAO,MAAA,CAAO,aAAa,KAAK,CAAA;AAAA,EAClC,CAAA;AAAA,EAEA,MAAM,OAAA,CAAQ,KAAA,EAAO,MAAA,EAAQ;AAC3B,IAAA,OAAO,MAAA,CAAO,QAAQ,KAAK,CAAA;AAAA,EAC7B;AACF,CAAC;AAGD,SAAS,uBAAA,CACP,UACA,YAAA,EACQ;AACR,EAAA,OAAO,MAAA,CAAO,KAAK,CAAA,EAAG,QAAQ,IAAI,YAAY,CAAA,CAAE,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAA;AACrE;;;;"}
|
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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { oauth2Authenticator } from './authenticator';\nimport { oauth2SignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleOauth2Provider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'oauth2-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'oauth2',\n factory: createOAuthProviderFactory({\n authenticator: oauth2Authenticator,\n signInResolverFactories: {\n ...oauth2SignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","oauth2Authenticator","oauth2SignInResolvers","commonSignInResolvers"],"mappings":";;;;;;;AAyBO,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 */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { oauth2Authenticator } from './authenticator';\nimport { oauth2SignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleOauth2Provider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'oauth2-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'oauth2',\n factory: createOAuthProviderFactory({\n authenticator: oauth2Authenticator,\n signInResolverFactories: {\n ...oauth2SignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","oauth2Authenticator","oauth2SignInResolvers","commonSignInResolvers"],"mappings":";;;;;;;AAyBO,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 oauth2 auth provider.\n *\n * @public\n */\nexport namespace oauth2SignInResolvers {\n /**\n * Looks up the user by matching their oauth2 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<PassportProfile>>,\n ctx,\n ) => {\n const { result } = info;\n\n const id = result.fullProfile.username;\n if (!id) {\n throw new Error(`Oauth2 user profile does not contain a username`);\n }\n\n return ctx.signInWithCatalogUser(\n {\n entityRef: { name: id },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: id } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["oauth2SignInResolvers","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 oauth2 auth provider.\n *\n * @public\n */\nexport namespace oauth2SignInResolvers {\n /**\n * Looks up the user by matching their oauth2 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<PassportProfile>>,\n ctx,\n ) => {\n const { result } = info;\n\n const id = result.fullProfile.username;\n if (!id) {\n throw new Error(`Oauth2 user profile does not contain a username`);\n }\n\n return ctx.signInWithCatalogUser(\n {\n entityRef: { name: id },\n },\n {\n dangerousEntityRefFallback:\n options?.dangerouslyAllowSignInWithoutUserInCatalog\n ? { entityRef: { name: id } }\n : undefined,\n },\n );\n };\n },\n });\n}\n"],"names":["oauth2SignInResolvers","createSignInResolverFactory","z"],"mappings":";;;;;AA6BiBA;AAAA,CAAV,CAAUA,sBAAAA,KAAV;AAIE,EAAMA,sBAAAA,CAAA,iCAAiCC,0CAAA,CAA4B;AAAA,IACxE,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,QAAO,GAAI,IAAA;AAEnB,QAAA,MAAM,EAAA,GAAK,OAAO,WAAA,CAAY,QAAA;AAC9B,QAAA,IAAI,CAAC,EAAA,EAAI;AACP,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,EAAA;AAAG,WACxB;AAAA,UACA;AAAA,YACE,0BAAA,EACE,SAAS,0CAAA,GACL,EAAE,WAAW,EAAE,IAAA,EAAM,EAAA,EAAG,EAAE,GAC1B;AAAA;AACR,SACF;AAAA,MACF,CAAA;AAAA,IACF;AAAA,GACD,CAAA;AAAA,CAAA,EAnCcF,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-oauth2-provider",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "The oauth2-provider backend module for the auth plugin.",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
"test": "backstage-cli package test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/backend-plugin-api": "^1.4.
|
|
41
|
-
"@backstage/plugin-auth-node": "^0.6.
|
|
40
|
+
"@backstage/backend-plugin-api": "^1.4.2",
|
|
41
|
+
"@backstage/plugin-auth-node": "^0.6.6",
|
|
42
42
|
"passport": "^0.7.0",
|
|
43
43
|
"passport-oauth2": "^1.6.1",
|
|
44
44
|
"zod": "^3.22.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@backstage/backend-defaults": "^0.
|
|
48
|
-
"@backstage/backend-test-utils": "^1.
|
|
49
|
-
"@backstage/cli": "^0.
|
|
50
|
-
"@backstage/plugin-auth-backend": "^0.25.
|
|
47
|
+
"@backstage/backend-defaults": "^0.12.0",
|
|
48
|
+
"@backstage/backend-test-utils": "^1.8.0",
|
|
49
|
+
"@backstage/cli": "^0.34.0",
|
|
50
|
+
"@backstage/plugin-auth-backend": "^0.25.3",
|
|
51
51
|
"@backstage/types": "^1.2.1",
|
|
52
52
|
"supertest": "^7.0.0"
|
|
53
53
|
},
|