@backstage/plugin-auth-backend-module-oauth2-proxy-provider 0.1.0-next.0 → 0.1.0-next.2
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 +23 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend-module-oauth2-proxy-provider
|
|
2
2
|
|
|
3
|
+
## 0.1.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-common@0.20.0-next.3
|
|
9
|
+
- @backstage/backend-plugin-api@0.6.8-next.3
|
|
10
|
+
- @backstage/errors@1.2.3
|
|
11
|
+
- @backstage/plugin-auth-node@0.4.2-next.3
|
|
12
|
+
|
|
13
|
+
## 0.1.0-next.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- a6be465: Exported the provider as default so it gets discovered when using `featureDiscoveryServiceFactory()`
|
|
18
|
+
- 510dab4: Change provider id from `oauth2ProxyProvider` to `oauth2Proxy`
|
|
19
|
+
- cc4228e: Switched module ID to use kebab-case.
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @backstage/backend-common@0.20.0-next.2
|
|
22
|
+
- @backstage/plugin-auth-node@0.4.2-next.2
|
|
23
|
+
- @backstage/backend-plugin-api@0.6.8-next.2
|
|
24
|
+
- @backstage/errors@1.2.3
|
|
25
|
+
|
|
3
26
|
## 0.1.0-next.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -61,7 +61,7 @@ var oauth2ProxySignInResolvers;
|
|
|
61
61
|
|
|
62
62
|
const authModuleOauth2ProxyProvider = backendPluginApi.createBackendModule({
|
|
63
63
|
pluginId: "auth",
|
|
64
|
-
moduleId: "
|
|
64
|
+
moduleId: "oauth2-proxy-provider",
|
|
65
65
|
register(reg) {
|
|
66
66
|
reg.registerInit({
|
|
67
67
|
deps: {
|
|
@@ -69,7 +69,7 @@ const authModuleOauth2ProxyProvider = backendPluginApi.createBackendModule({
|
|
|
69
69
|
},
|
|
70
70
|
async init({ providers }) {
|
|
71
71
|
providers.registerProvider({
|
|
72
|
-
providerId: "
|
|
72
|
+
providerId: "oauth2Proxy",
|
|
73
73
|
factory: pluginAuthNode.createProxyAuthProviderFactory({
|
|
74
74
|
authenticator: oauth2ProxyAuthenticator,
|
|
75
75
|
signInResolverFactories: {
|
|
@@ -84,6 +84,6 @@ const authModuleOauth2ProxyProvider = backendPluginApi.createBackendModule({
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
exports.OAUTH2_PROXY_JWT_HEADER = OAUTH2_PROXY_JWT_HEADER;
|
|
87
|
-
exports
|
|
87
|
+
exports["default"] = authModuleOauth2ProxyProvider;
|
|
88
88
|
exports.oauth2ProxyAuthenticator = oauth2ProxyAuthenticator;
|
|
89
89
|
//# sourceMappingURL=index.cjs.js.map
|
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 { AuthenticationError } from '@backstage/errors';\nimport {\n createProxyAuthenticator,\n getBearerTokenFromAuthorizationHeader,\n} from '@backstage/plugin-auth-node';\nimport { decodeJwt } from 'jose';\nimport { OAuth2ProxyResult } from './types';\n\n/**\n * NOTE: This may come in handy if you're doing work on this provider:\n * plugins/auth-backend/examples/docker-compose.oauth2-proxy.yaml\n *\n * @public\n */\nexport const OAUTH2_PROXY_JWT_HEADER = 'X-OAUTH2-PROXY-ID-TOKEN';\n\n/** @public */\nexport const oauth2ProxyAuthenticator = createProxyAuthenticator<\n unknown,\n OAuth2ProxyResult\n>({\n defaultProfileTransform: async (result: OAuth2ProxyResult) => {\n return {\n profile: {\n email: result.getHeader('x-forwarded-email'),\n displayName:\n result.getHeader('x-forwarded-preferred-username') ||\n result.getHeader('x-forwarded-user'),\n },\n };\n },\n async initialize() {},\n async authenticate({ req }) {\n try {\n const authHeader = req.header(OAUTH2_PROXY_JWT_HEADER);\n const jwt = getBearerTokenFromAuthorizationHeader(authHeader);\n const decodedJWT = jwt && decodeJwt(jwt);\n\n const result = {\n fullProfile: decodedJWT || {},\n accessToken: jwt || '',\n headers: req.headers,\n getHeader(name: string) {\n if (name.toLocaleLowerCase('en-US') === 'set-cookie') {\n throw new Error('Access Set-Cookie via the headers object instead');\n }\n return req.get(name);\n },\n };\n return { result };\n } catch (e) {\n throw new AuthenticationError('Authentication failed', e);\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 SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { OAuth2ProxyResult } from './types';\n\n/**\n * @public\n */\nexport namespace oauth2ProxySignInResolvers {\n export const forwardedUserMatchingUserEntityName =\n createSignInResolverFactory({\n create() {\n return async (info: SignInInfo<OAuth2ProxyResult>, ctx) => {\n const name = info.result.getHeader('x-forwarded-user');\n if (!name) {\n throw new Error('Request did not contain a user');\n }\n return ctx.signInWithCatalogUser({\n entityRef: { name },\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 createProxyAuthProviderFactory,\n commonSignInResolvers,\n} from '@backstage/plugin-auth-node';\nimport { oauth2ProxyAuthenticator } from './authenticator';\nimport { oauth2ProxySignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleOauth2ProxyProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: '
|
|
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 { AuthenticationError } from '@backstage/errors';\nimport {\n createProxyAuthenticator,\n getBearerTokenFromAuthorizationHeader,\n} from '@backstage/plugin-auth-node';\nimport { decodeJwt } from 'jose';\nimport { OAuth2ProxyResult } from './types';\n\n/**\n * NOTE: This may come in handy if you're doing work on this provider:\n * plugins/auth-backend/examples/docker-compose.oauth2-proxy.yaml\n *\n * @public\n */\nexport const OAUTH2_PROXY_JWT_HEADER = 'X-OAUTH2-PROXY-ID-TOKEN';\n\n/** @public */\nexport const oauth2ProxyAuthenticator = createProxyAuthenticator<\n unknown,\n OAuth2ProxyResult\n>({\n defaultProfileTransform: async (result: OAuth2ProxyResult) => {\n return {\n profile: {\n email: result.getHeader('x-forwarded-email'),\n displayName:\n result.getHeader('x-forwarded-preferred-username') ||\n result.getHeader('x-forwarded-user'),\n },\n };\n },\n async initialize() {},\n async authenticate({ req }) {\n try {\n const authHeader = req.header(OAUTH2_PROXY_JWT_HEADER);\n const jwt = getBearerTokenFromAuthorizationHeader(authHeader);\n const decodedJWT = jwt && decodeJwt(jwt);\n\n const result = {\n fullProfile: decodedJWT || {},\n accessToken: jwt || '',\n headers: req.headers,\n getHeader(name: string) {\n if (name.toLocaleLowerCase('en-US') === 'set-cookie') {\n throw new Error('Access Set-Cookie via the headers object instead');\n }\n return req.get(name);\n },\n };\n return { result };\n } catch (e) {\n throw new AuthenticationError('Authentication failed', e);\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 SignInInfo,\n} from '@backstage/plugin-auth-node';\nimport { OAuth2ProxyResult } from './types';\n\n/**\n * @public\n */\nexport namespace oauth2ProxySignInResolvers {\n export const forwardedUserMatchingUserEntityName =\n createSignInResolverFactory({\n create() {\n return async (info: SignInInfo<OAuth2ProxyResult>, ctx) => {\n const name = info.result.getHeader('x-forwarded-user');\n if (!name) {\n throw new Error('Request did not contain a user');\n }\n return ctx.signInWithCatalogUser({\n entityRef: { name },\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 createProxyAuthProviderFactory,\n commonSignInResolvers,\n} from '@backstage/plugin-auth-node';\nimport { oauth2ProxyAuthenticator } from './authenticator';\nimport { oauth2ProxySignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleOauth2ProxyProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'oauth2-proxy-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'oauth2Proxy',\n factory: createProxyAuthProviderFactory({\n authenticator: oauth2ProxyAuthenticator,\n signInResolverFactories: {\n ...commonSignInResolvers,\n ...oauth2ProxySignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createProxyAuthenticator","getBearerTokenFromAuthorizationHeader","decodeJwt","AuthenticationError","oauth2ProxySignInResolvers","createSignInResolverFactory","createBackendModule","authProvidersExtensionPoint","createProxyAuthProviderFactory","commonSignInResolvers"],"mappings":";;;;;;;;;AA8BO,MAAM,uBAA0B,GAAA,0BAAA;AAGhC,MAAM,2BAA2BA,uCAGtC,CAAA;AAAA,EACA,uBAAA,EAAyB,OAAO,MAA8B,KAAA;AAC5D,IAAO,OAAA;AAAA,MACL,OAAS,EAAA;AAAA,QACP,KAAA,EAAO,M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,QAAA,MAAM,IAAO,GAAA,IAAA,CAAK,MAAO,CAAA,SAAA,CAAU,kBAAkB,CAAA,CAAA;AACrD,QAAA,IAAI,CAAC,IAAM,EAAA;AACT,UAAM,MAAA,IAAI,MAAM,gCAAgC,CAAA,CAAA;AAAA,SAClD;AACA,QAAA,OAAO,IAAI,qBAAsB,CAAA;AAAA,UAC/B,SAAA,EAAW,EAAE,IAAK,EAAA;AAAA,SACnB,CAAA,CAAA;AAAA,OACH,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AAAA,CAdY,EAAA,0BAAA,KAAA,0BAAA,GAAA,EAAA,CAAA,CAAA;;ACCV,MAAM,gCAAgCC,oCAAoB,CAAA;AAAA,EAC/D,QAAU,EAAA,MAAA;AAAA,EACV,QAAU,EAAA,uBAAA;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,aAAA;AAAA,UACZ,SAASC,6CAA+B,CAAA;AAAA,YACtC,aAAe,EAAA,wBAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGC,oCAAA;AAAA,cACH,GAAG,0BAAA;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
|
@@ -56,4 +56,4 @@ declare const OAUTH2_PROXY_JWT_HEADER = "X-OAUTH2-PROXY-ID-TOKEN";
|
|
|
56
56
|
/** @public */
|
|
57
57
|
declare const oauth2ProxyAuthenticator: _backstage_plugin_auth_node.ProxyAuthenticator<unknown, OAuth2ProxyResult>;
|
|
58
58
|
|
|
59
|
-
export { OAUTH2_PROXY_JWT_HEADER, OAuth2ProxyResult, authModuleOauth2ProxyProvider, oauth2ProxyAuthenticator };
|
|
59
|
+
export { OAUTH2_PROXY_JWT_HEADER, OAuth2ProxyResult, authModuleOauth2ProxyProvider as default, oauth2ProxyAuthenticator };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-backend-module-oauth2-proxy-provider",
|
|
3
3
|
"description": "The oauth2-proxy-provider backend module for the auth plugin.",
|
|
4
|
-
"version": "0.1.0-next.
|
|
4
|
+
"version": "0.1.0-next.2",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"postpack": "backstage-cli package postpack"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@backstage/backend-common": "^0.20.0-next.
|
|
27
|
-
"@backstage/backend-plugin-api": "^0.6.8-next.
|
|
26
|
+
"@backstage/backend-common": "^0.20.0-next.3",
|
|
27
|
+
"@backstage/backend-plugin-api": "^0.6.8-next.3",
|
|
28
28
|
"@backstage/errors": "^1.2.3",
|
|
29
|
-
"@backstage/plugin-auth-node": "^0.4.2-next.
|
|
29
|
+
"@backstage/plugin-auth-node": "^0.4.2-next.3",
|
|
30
30
|
"jose": "^4.6.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@backstage/backend-test-utils": "^0.2.9-next.
|
|
34
|
-
"@backstage/cli": "^0.25.0-next.
|
|
33
|
+
"@backstage/backend-test-utils": "^0.2.9-next.3",
|
|
34
|
+
"@backstage/cli": "^0.25.0-next.3"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"dist"
|