@backstage/plugin-auth-backend-module-oauth2-provider 0.1.16-next.1 → 0.2.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 +27 -0
- package/config.d.ts +2 -0
- package/dist/index.cjs.js +5 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +24 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-oauth2-provider
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8efc6cf: **BREAKING**: The `scope` config option have been removed and replaced by the standard `additionalScopes` config.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 78a0b08: Internal refactor to handle `BackendFeature` contract change.
|
|
12
|
+
- d44a20a: Added additional plugin metadata to `package.json`.
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/backend-plugin-api@0.6.19
|
|
15
|
+
- @backstage/plugin-auth-node@0.4.14
|
|
16
|
+
|
|
17
|
+
## 0.2.0-next.2
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 8efc6cf: **BREAKING**: The `scope` config option have been removed and replaced by the standard `additionalScopes` config.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- d44a20a: Added additional plugin metadata to `package.json`.
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/backend-plugin-api@0.6.19-next.3
|
|
28
|
+
- @backstage/plugin-auth-node@0.4.14-next.3
|
|
29
|
+
|
|
3
30
|
## 0.1.16-next.1
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/config.d.ts
CHANGED
|
@@ -27,7 +27,9 @@ export interface Config {
|
|
|
27
27
|
clientSecret: string;
|
|
28
28
|
authorizationUrl: string;
|
|
29
29
|
tokenUrl: string;
|
|
30
|
+
/** @deprecated use `additionalScopes` instead */
|
|
30
31
|
scope?: string;
|
|
32
|
+
additionalScopes?: string | string[];
|
|
31
33
|
disableRefresh?: boolean;
|
|
32
34
|
includeBasicAuth?: boolean;
|
|
33
35
|
};
|
package/dist/index.cjs.js
CHANGED
|
@@ -13,8 +13,12 @@ const oauth2Authenticator = pluginAuthNode.createOAuthAuthenticator({
|
|
|
13
13
|
const clientSecret = config.getString("clientSecret");
|
|
14
14
|
const authorizationUrl = config.getString("authorizationUrl");
|
|
15
15
|
const tokenUrl = config.getString("tokenUrl");
|
|
16
|
-
const scope = config.getOptionalString("scope");
|
|
17
16
|
const includeBasicAuth = config.getOptionalBoolean("includeBasicAuth");
|
|
17
|
+
if (config.has("scope")) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
'The oauth2 provider no longer supports the "scope" configuration option. Please use the "additionalScopes" option instead.'
|
|
20
|
+
);
|
|
21
|
+
}
|
|
18
22
|
return pluginAuthNode.PassportOAuthAuthenticatorHelper.from(
|
|
19
23
|
new passportOauth2.Strategy(
|
|
20
24
|
{
|
|
@@ -24,7 +28,6 @@ const oauth2Authenticator = pluginAuthNode.createOAuthAuthenticator({
|
|
|
24
28
|
authorizationURL: authorizationUrl,
|
|
25
29
|
tokenURL: tokenUrl,
|
|
26
30
|
passReqToCallback: false,
|
|
27
|
-
scope,
|
|
28
31
|
customHeaders: includeBasicAuth ? {
|
|
29
32
|
Authorization: `Basic ${encodeClientCredentials(
|
|
30
33
|
clientId,
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -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 { 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
|
|
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 { 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","/*\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 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 create() {\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({ entityRef: { name: id } });\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 */\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":["createOAuthAuthenticator","PassportOAuthAuthenticatorHelper","Oauth2Strategy","oauth2SignInResolvers","createSignInResolverFactory","createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","commonSignInResolvers"],"mappings":";;;;;;;;AAyBO,MAAM,sBAAsBA,uCAAyB,CAAA;AAAA,EAC1D,yBACEC,+CAAiC,CAAA,uBAAA;AAAA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CAAA;;ACHV,MAAM,2BAA2BE,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,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;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
|
6
6
|
declare const oauth2Authenticator: _backstage_plugin_auth_node.OAuthAuthenticator<PassportOAuthAuthenticatorHelper, PassportProfile>;
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
|
-
declare const authModuleOauth2Provider:
|
|
9
|
+
declare const authModuleOauth2Provider: _backstage_backend_plugin_api.BackendFeatureCompat;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Available sign-in resolvers for the oauth2 auth provider.
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-backend-module-oauth2-provider",
|
|
3
|
+
"version": "0.2.0",
|
|
3
4
|
"description": "The oauth2-provider backend module for the auth plugin.",
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
"backstage": {
|
|
6
|
+
"role": "backend-plugin-module",
|
|
7
|
+
"pluginId": "auth",
|
|
8
|
+
"pluginPackage": "@backstage/plugin-auth-backend"
|
|
9
|
+
},
|
|
8
10
|
"publishConfig": {
|
|
9
11
|
"access": "public",
|
|
10
12
|
"main": "dist/index.cjs.js",
|
|
@@ -15,34 +17,34 @@
|
|
|
15
17
|
"url": "https://github.com/backstage/backstage",
|
|
16
18
|
"directory": "plugins/auth-backend-module-oauth2-provider"
|
|
17
19
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"main": "dist/index.cjs.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"config.d.ts"
|
|
26
|
+
],
|
|
21
27
|
"scripts": {
|
|
22
|
-
"start": "backstage-cli package start",
|
|
23
28
|
"build": "backstage-cli package build",
|
|
24
|
-
"lint": "backstage-cli package lint",
|
|
25
|
-
"test": "backstage-cli package test",
|
|
26
29
|
"clean": "backstage-cli package clean",
|
|
30
|
+
"lint": "backstage-cli package lint",
|
|
27
31
|
"prepack": "backstage-cli package prepack",
|
|
28
|
-
"postpack": "backstage-cli package postpack"
|
|
32
|
+
"postpack": "backstage-cli package postpack",
|
|
33
|
+
"start": "backstage-cli package start",
|
|
34
|
+
"test": "backstage-cli package test"
|
|
29
35
|
},
|
|
30
36
|
"dependencies": {
|
|
31
|
-
"@backstage/backend-plugin-api": "^0.6.19
|
|
32
|
-
"@backstage/plugin-auth-node": "^0.4.14
|
|
37
|
+
"@backstage/backend-plugin-api": "^0.6.19",
|
|
38
|
+
"@backstage/plugin-auth-node": "^0.4.14",
|
|
33
39
|
"passport": "^0.7.0",
|
|
34
40
|
"passport-oauth2": "^1.6.1"
|
|
35
41
|
},
|
|
36
42
|
"devDependencies": {
|
|
37
|
-
"@backstage/backend-defaults": "^0.3.0
|
|
38
|
-
"@backstage/backend-test-utils": "^0.4.0
|
|
39
|
-
"@backstage/cli": "^0.26.7
|
|
40
|
-
"@backstage/plugin-auth-backend": "^0.22.6
|
|
43
|
+
"@backstage/backend-defaults": "^0.3.0",
|
|
44
|
+
"@backstage/backend-test-utils": "^0.4.0",
|
|
45
|
+
"@backstage/cli": "^0.26.7",
|
|
46
|
+
"@backstage/plugin-auth-backend": "^0.22.6",
|
|
41
47
|
"supertest": "^6.3.3"
|
|
42
48
|
},
|
|
43
|
-
"configSchema": "config.d.ts"
|
|
44
|
-
"files": [
|
|
45
|
-
"dist",
|
|
46
|
-
"config.d.ts"
|
|
47
|
-
]
|
|
49
|
+
"configSchema": "config.d.ts"
|
|
48
50
|
}
|