@backstage/plugin-auth-backend-module-oidc-provider 0.0.0-nightly-20240122021809
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 +15 -0
- package/README.md +8 -0
- package/config.d.ts +38 -0
- package/dist/index.cjs.js +161 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/package.json +51 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @backstage/plugin-auth-backend-module-oidc-provider
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20240122021809
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5d2fcba: Created new `@backstage/plugin-auth-backend-module-oidc-provider` module package to house oidc auth provider migration.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/plugin-auth-backend@0.0.0-nightly-20240122021809
|
|
13
|
+
- @backstage/backend-common@0.0.0-nightly-20240122021809
|
|
14
|
+
- @backstage/plugin-auth-node@0.0.0-nightly-20240122021809
|
|
15
|
+
- @backstage/backend-plugin-api@0.0.0-nightly-20240122021809
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Auth Module: Oidc Provider
|
|
2
|
+
|
|
3
|
+
This module provides an Oidc auth provider implementation for `@backstage/plugin-auth-backend`.
|
|
4
|
+
|
|
5
|
+
## Links
|
|
6
|
+
|
|
7
|
+
- [Repository](https://oidc.com/backstage/backstage/tree/master/plugins/auth-backend-module-oidc-provider)
|
|
8
|
+
- [Backstage Project Homepage](https://backstage.io)
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 The Backstage Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface Config {
|
|
18
|
+
auth?: {
|
|
19
|
+
providers?: {
|
|
20
|
+
/** @visibility frontend */
|
|
21
|
+
oidc?: {
|
|
22
|
+
[authEnv: string]: {
|
|
23
|
+
clientId: string;
|
|
24
|
+
/**
|
|
25
|
+
* @visibility secret
|
|
26
|
+
*/
|
|
27
|
+
clientSecret: string;
|
|
28
|
+
metadataUrl: string;
|
|
29
|
+
callbackUrl?: string;
|
|
30
|
+
tokenEndpointAuthMethod?: string;
|
|
31
|
+
tokenSignedResponseAlg?: string;
|
|
32
|
+
scope?: string;
|
|
33
|
+
prompt?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var openidClient = require('openid-client');
|
|
6
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
7
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
8
|
+
|
|
9
|
+
const oidcAuthenticator = pluginAuthNode.createOAuthAuthenticator({
|
|
10
|
+
defaultProfileTransform: async (input) => ({
|
|
11
|
+
profile: {
|
|
12
|
+
email: input.fullProfile.userinfo.email,
|
|
13
|
+
picture: input.fullProfile.userinfo.picture,
|
|
14
|
+
displayName: input.fullProfile.userinfo.name
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
17
|
+
initialize({ callbackUrl, config }) {
|
|
18
|
+
const clientId = config.getString("clientId");
|
|
19
|
+
const clientSecret = config.getString("clientSecret");
|
|
20
|
+
const metadataUrl = config.getString("metadataUrl");
|
|
21
|
+
const customCallbackUrl = config.getOptionalString("callbackUrl");
|
|
22
|
+
const tokenEndpointAuthMethod = config.getOptionalString(
|
|
23
|
+
"tokenEndpointAuthMethod"
|
|
24
|
+
);
|
|
25
|
+
const tokenSignedResponseAlg = config.getOptionalString(
|
|
26
|
+
"tokenSignedResponseAlg"
|
|
27
|
+
);
|
|
28
|
+
const initializedScope = config.getOptionalString("scope");
|
|
29
|
+
const initializedPrompt = config.getOptionalString("prompt");
|
|
30
|
+
const promise = openidClient.Issuer.discover(metadataUrl).then((issuer) => {
|
|
31
|
+
const client = new issuer.Client({
|
|
32
|
+
access_type: "offline",
|
|
33
|
+
// this option must be passed to provider to receive a refresh token
|
|
34
|
+
client_id: clientId,
|
|
35
|
+
client_secret: clientSecret,
|
|
36
|
+
redirect_uris: [customCallbackUrl || callbackUrl],
|
|
37
|
+
response_types: ["code"],
|
|
38
|
+
token_endpoint_auth_method: tokenEndpointAuthMethod || "client_secret_basic",
|
|
39
|
+
id_token_signed_response_alg: tokenSignedResponseAlg || "RS256",
|
|
40
|
+
scope: initializedScope || ""
|
|
41
|
+
});
|
|
42
|
+
const strategy = new openidClient.Strategy(
|
|
43
|
+
{
|
|
44
|
+
client,
|
|
45
|
+
passReqToCallback: false
|
|
46
|
+
},
|
|
47
|
+
(tokenset, userinfo, done) => {
|
|
48
|
+
if (typeof done !== "function") {
|
|
49
|
+
throw new Error(
|
|
50
|
+
"OIDC IdP must provide a userinfo_endpoint in the metadata response"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
done(
|
|
54
|
+
void 0,
|
|
55
|
+
{ tokenset, userinfo },
|
|
56
|
+
{ refreshToken: tokenset.refresh_token }
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
const helper = pluginAuthNode.PassportOAuthAuthenticatorHelper.from(strategy);
|
|
61
|
+
return { helper, client, strategy };
|
|
62
|
+
});
|
|
63
|
+
return { initializedScope, initializedPrompt, promise };
|
|
64
|
+
},
|
|
65
|
+
async start(input, ctx) {
|
|
66
|
+
const { initializedScope, initializedPrompt, promise } = ctx;
|
|
67
|
+
const { helper, strategy } = await promise;
|
|
68
|
+
const options = {
|
|
69
|
+
scope: input.scope || initializedScope || "openid profile email",
|
|
70
|
+
state: input.state
|
|
71
|
+
};
|
|
72
|
+
const prompt = initializedPrompt || "none";
|
|
73
|
+
if (prompt !== "auto") {
|
|
74
|
+
options.prompt = prompt;
|
|
75
|
+
}
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
strategy.error = reject;
|
|
78
|
+
return helper.start(input, {
|
|
79
|
+
...options
|
|
80
|
+
}).then(resolve);
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
async authenticate(input, ctx) {
|
|
84
|
+
var _a;
|
|
85
|
+
const { strategy } = await ctx.promise;
|
|
86
|
+
const { result, privateInfo } = await pluginAuthNode.PassportHelpers.executeFrameHandlerStrategy(input.req, strategy);
|
|
87
|
+
return {
|
|
88
|
+
fullProfile: result,
|
|
89
|
+
session: {
|
|
90
|
+
accessToken: result.tokenset.access_token,
|
|
91
|
+
tokenType: (_a = result.tokenset.token_type) != null ? _a : "bearer",
|
|
92
|
+
scope: result.tokenset.scope,
|
|
93
|
+
expiresInSeconds: result.tokenset.expires_in,
|
|
94
|
+
idToken: result.tokenset.id_token,
|
|
95
|
+
refreshToken: privateInfo.refreshToken
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
async refresh(input, ctx) {
|
|
100
|
+
const { client } = await ctx.promise;
|
|
101
|
+
const tokenset = await client.refresh(input.refreshToken);
|
|
102
|
+
if (!tokenset.access_token) {
|
|
103
|
+
throw new Error("Refresh failed");
|
|
104
|
+
}
|
|
105
|
+
if (!tokenset.scope) {
|
|
106
|
+
tokenset.scope = input.scope;
|
|
107
|
+
}
|
|
108
|
+
const userinfo = await client.userinfo(tokenset.access_token);
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
var _a;
|
|
111
|
+
if (!tokenset.access_token) {
|
|
112
|
+
reject(new Error("Refresh Failed"));
|
|
113
|
+
}
|
|
114
|
+
resolve({
|
|
115
|
+
fullProfile: { userinfo, tokenset },
|
|
116
|
+
session: {
|
|
117
|
+
accessToken: tokenset.access_token,
|
|
118
|
+
tokenType: (_a = tokenset.token_type) != null ? _a : "bearer",
|
|
119
|
+
scope: tokenset.scope,
|
|
120
|
+
expiresInSeconds: tokenset.expires_in,
|
|
121
|
+
idToken: tokenset.id_token,
|
|
122
|
+
refreshToken: tokenset.refresh_token
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
exports.oidcSignInResolvers = void 0;
|
|
130
|
+
((oidcSignInResolvers2) => {
|
|
131
|
+
oidcSignInResolvers2.emailLocalPartMatchingUserEntityName = pluginAuthNode.commonSignInResolvers.emailLocalPartMatchingUserEntityName;
|
|
132
|
+
oidcSignInResolvers2.emailMatchingUserEntityProfileEmail = pluginAuthNode.commonSignInResolvers.emailMatchingUserEntityProfileEmail;
|
|
133
|
+
})(exports.oidcSignInResolvers || (exports.oidcSignInResolvers = {}));
|
|
134
|
+
|
|
135
|
+
const authModuleOidcProvider = backendPluginApi.createBackendModule({
|
|
136
|
+
pluginId: "auth",
|
|
137
|
+
moduleId: "oidc-provider",
|
|
138
|
+
register(reg) {
|
|
139
|
+
reg.registerInit({
|
|
140
|
+
deps: {
|
|
141
|
+
providers: pluginAuthNode.authProvidersExtensionPoint
|
|
142
|
+
},
|
|
143
|
+
async init({ providers }) {
|
|
144
|
+
providers.registerProvider({
|
|
145
|
+
providerId: "oidc",
|
|
146
|
+
factory: pluginAuthNode.createOAuthProviderFactory({
|
|
147
|
+
authenticator: oidcAuthenticator,
|
|
148
|
+
signInResolverFactories: {
|
|
149
|
+
...exports.oidcSignInResolvers,
|
|
150
|
+
...pluginAuthNode.commonSignInResolvers
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
exports["default"] = authModuleOidcProvider;
|
|
160
|
+
exports.oidcAuthenticator = oidcAuthenticator;
|
|
161
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +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 Issuer,\n ClientAuthMethod,\n TokenSet,\n UserinfoResponse,\n Strategy as OidcStrategy,\n} from 'openid-client';\nimport {\n createOAuthAuthenticator,\n OAuthAuthenticatorResult,\n PassportDoneCallback,\n PassportHelpers,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthPrivateInfo,\n} from '@backstage/plugin-auth-node';\n\n/**\n * authentication result for the OIDC which includes the token set and user\n * profile response\n * @public\n */\nexport type OidcAuthResult = {\n tokenset: TokenSet;\n userinfo: UserinfoResponse;\n};\n\n/** @public */\nexport const oidcAuthenticator = createOAuthAuthenticator({\n defaultProfileTransform: async (\n input: OAuthAuthenticatorResult<OidcAuthResult>,\n ) => ({\n profile: {\n email: input.fullProfile.userinfo.email,\n picture: input.fullProfile.userinfo.picture,\n displayName: input.fullProfile.userinfo.name,\n },\n }),\n initialize({ callbackUrl, config }) {\n const clientId = config.getString('clientId');\n const clientSecret = config.getString('clientSecret');\n const metadataUrl = config.getString('metadataUrl');\n const customCallbackUrl = config.getOptionalString('callbackUrl');\n const tokenEndpointAuthMethod = config.getOptionalString(\n 'tokenEndpointAuthMethod',\n ) as ClientAuthMethod;\n const tokenSignedResponseAlg = config.getOptionalString(\n 'tokenSignedResponseAlg',\n );\n const initializedScope = config.getOptionalString('scope');\n const initializedPrompt = config.getOptionalString('prompt');\n\n const promise = Issuer.discover(metadataUrl).then(issuer => {\n const client = new issuer.Client({\n access_type: 'offline', // this option must be passed to provider to receive a refresh token\n client_id: clientId,\n client_secret: clientSecret,\n redirect_uris: [customCallbackUrl || callbackUrl],\n response_types: ['code'],\n token_endpoint_auth_method:\n tokenEndpointAuthMethod || 'client_secret_basic',\n id_token_signed_response_alg: tokenSignedResponseAlg || 'RS256',\n scope: initializedScope || '',\n });\n\n const strategy = new OidcStrategy(\n {\n client,\n passReqToCallback: false,\n },\n (\n tokenset: TokenSet,\n userinfo: UserinfoResponse,\n done: PassportDoneCallback<OidcAuthResult, PassportOAuthPrivateInfo>,\n ) => {\n if (typeof done !== 'function') {\n throw new Error(\n 'OIDC IdP must provide a userinfo_endpoint in the metadata response',\n );\n }\n\n done(\n undefined,\n { tokenset, userinfo },\n { refreshToken: tokenset.refresh_token },\n );\n },\n );\n\n const helper = PassportOAuthAuthenticatorHelper.from(strategy);\n return { helper, client, strategy };\n });\n\n return { initializedScope, initializedPrompt, promise };\n },\n\n async start(input, ctx) {\n const { initializedScope, initializedPrompt, promise } = ctx;\n const { helper, strategy } = await promise;\n const options: Record<string, string> = {\n scope: input.scope || initializedScope || 'openid profile email',\n state: input.state,\n };\n const prompt = initializedPrompt || 'none';\n if (prompt !== 'auto') {\n options.prompt = prompt;\n }\n\n return new Promise((resolve, reject) => {\n strategy.error = reject;\n\n return helper\n .start(input, {\n ...options,\n })\n .then(resolve);\n });\n },\n\n async authenticate(\n input,\n ctx,\n ): Promise<OAuthAuthenticatorResult<OidcAuthResult>> {\n const { strategy } = await ctx.promise;\n const { result, privateInfo } =\n await PassportHelpers.executeFrameHandlerStrategy<\n OidcAuthResult,\n PassportOAuthPrivateInfo\n >(input.req, strategy);\n\n return {\n fullProfile: result,\n session: {\n accessToken: result.tokenset.access_token!,\n tokenType: result.tokenset.token_type ?? 'bearer',\n scope: result.tokenset.scope!,\n expiresInSeconds: result.tokenset.expires_in,\n idToken: result.tokenset.id_token,\n refreshToken: privateInfo.refreshToken,\n },\n };\n },\n\n async refresh(input, ctx) {\n const { client } = await ctx.promise;\n const tokenset = await client.refresh(input.refreshToken);\n if (!tokenset.access_token) {\n throw new Error('Refresh failed');\n }\n if (!tokenset.scope) {\n tokenset.scope = input.scope;\n }\n const userinfo = await client.userinfo(tokenset.access_token);\n\n return new Promise((resolve, reject) => {\n if (!tokenset.access_token) {\n reject(new Error('Refresh Failed'));\n }\n resolve({\n fullProfile: { userinfo, tokenset },\n session: {\n accessToken: tokenset.access_token!,\n tokenType: tokenset.token_type ?? 'bearer',\n scope: tokenset.scope!,\n expiresInSeconds: tokenset.expires_in,\n idToken: tokenset.id_token,\n refreshToken: tokenset.refresh_token,\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 { commonSignInResolvers } from '@backstage/plugin-auth-node';\n\n/**\n * Available sign-in resolvers for the Oidc auth provider.\n *\n * @public\n */\nexport namespace oidcSignInResolvers {\n /**\n * A oidc resolver that looks up the user using the local part of\n * their email address as the entity name.\n */\n export const emailLocalPartMatchingUserEntityName =\n commonSignInResolvers.emailLocalPartMatchingUserEntityName;\n\n /**\n * A oidc resolver that looks up the user using their email address\n * as email of the entity.\n */\n export const emailMatchingUserEntityProfileEmail =\n commonSignInResolvers.emailMatchingUserEntityProfileEmail;\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 { oidcAuthenticator } from './authenticator';\nimport { oidcSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleOidcProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'oidc-provider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'oidc',\n factory: createOAuthProviderFactory({\n authenticator: oidcAuthenticator,\n signInResolverFactories: {\n ...oidcSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createOAuthAuthenticator","Issuer","OidcStrategy","PassportOAuthAuthenticatorHelper","PassportHelpers","oidcSignInResolvers","commonSignInResolvers","createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory"],"mappings":";;;;;;;;AA2CO,MAAM,oBAAoBA,uCAAyB,CAAA;AAAA,EACxD,uBAAA,EAAyB,OACvB,KACI,MAAA;AAAA,IACJ,OAAS,EAAA;AAAA,MACP,KAAA,EAAO,KAAM,CA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AAA,CAAA,sCACXC,oCAAsB,CAAA,mCAAA,CAAA;AAAA,CAbT,EAAAD,2BAAA,KAAAA,2BAAA,GAAA,EAAA,CAAA,CAAA;;ACEV,MAAM,yBAAyBE,oCAAoB,CAAA;AAAA,EACxD,QAAU,EAAA,MAAA;AAAA,EACV,QAAU,EAAA,eAAA;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,MAAA;AAAA,UACZ,SAASC,yCAA2B,CAAA;AAAA,YAClC,aAAe,EAAA,iBAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGJ,2BAAA;AAAA,cACH,GAAGC,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
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as _backstage_plugin_auth_node from '@backstage/plugin-auth-node';
|
|
2
|
+
import { PassportOAuthAuthenticatorHelper } from '@backstage/plugin-auth-node';
|
|
3
|
+
import * as openid_client from 'openid-client';
|
|
4
|
+
import { TokenSet, UserinfoResponse, Strategy } from 'openid-client';
|
|
5
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* authentication result for the OIDC which includes the token set and user
|
|
9
|
+
* profile response
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
type OidcAuthResult = {
|
|
13
|
+
tokenset: TokenSet;
|
|
14
|
+
userinfo: UserinfoResponse;
|
|
15
|
+
};
|
|
16
|
+
/** @public */
|
|
17
|
+
declare const oidcAuthenticator: _backstage_plugin_auth_node.OAuthAuthenticator<{
|
|
18
|
+
initializedScope: string | undefined;
|
|
19
|
+
initializedPrompt: string | undefined;
|
|
20
|
+
promise: Promise<{
|
|
21
|
+
helper: PassportOAuthAuthenticatorHelper;
|
|
22
|
+
client: openid_client.BaseClient;
|
|
23
|
+
strategy: Strategy<OidcAuthResult, openid_client.BaseClient>;
|
|
24
|
+
}>;
|
|
25
|
+
}, OidcAuthResult>;
|
|
26
|
+
|
|
27
|
+
/** @public */
|
|
28
|
+
declare const authModuleOidcProvider: () => _backstage_backend_plugin_api.BackendFeature;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Available sign-in resolvers for the Oidc auth provider.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
declare namespace oidcSignInResolvers {
|
|
36
|
+
/**
|
|
37
|
+
* A oidc resolver that looks up the user using the local part of
|
|
38
|
+
* their email address as the entity name.
|
|
39
|
+
*/
|
|
40
|
+
const emailLocalPartMatchingUserEntityName: _backstage_plugin_auth_node.SignInResolverFactory<unknown, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* A oidc resolver that looks up the user using their email address
|
|
43
|
+
* as email of the entity.
|
|
44
|
+
*/
|
|
45
|
+
const emailMatchingUserEntityProfileEmail: _backstage_plugin_auth_node.SignInResolverFactory<unknown, unknown>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { OidcAuthResult, authModuleOidcProvider as default, oidcAuthenticator, oidcSignInResolvers };
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/plugin-auth-backend-module-oidc-provider",
|
|
3
|
+
"description": "The oidc-provider backend module for the auth plugin.",
|
|
4
|
+
"version": "0.0.0-nightly-20240122021809",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"main": "dist/index.cjs.js",
|
|
11
|
+
"types": "dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"backstage": {
|
|
14
|
+
"role": "backend-plugin-module"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "backstage-cli package start",
|
|
18
|
+
"build": "backstage-cli package build",
|
|
19
|
+
"lint": "backstage-cli package lint",
|
|
20
|
+
"test": "backstage-cli package test",
|
|
21
|
+
"clean": "backstage-cli package clean",
|
|
22
|
+
"prepack": "backstage-cli package prepack",
|
|
23
|
+
"postpack": "backstage-cli package postpack"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@backstage/backend-common": "^0.0.0-nightly-20240122021809",
|
|
27
|
+
"@backstage/backend-plugin-api": "^0.0.0-nightly-20240122021809",
|
|
28
|
+
"@backstage/plugin-auth-backend": "^0.0.0-nightly-20240122021809",
|
|
29
|
+
"@backstage/plugin-auth-node": "^0.0.0-nightly-20240122021809",
|
|
30
|
+
"express": "^4.18.2",
|
|
31
|
+
"openid-client": "^5.5.0",
|
|
32
|
+
"passport": "^0.6.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@backstage/backend-defaults": "^0.0.0-nightly-20240122021809",
|
|
36
|
+
"@backstage/backend-test-utils": "^0.0.0-nightly-20240122021809",
|
|
37
|
+
"@backstage/cli": "^0.0.0-nightly-20240122021809",
|
|
38
|
+
"@backstage/config": "^1.1.1",
|
|
39
|
+
"cookie-parser": "^1.4.6",
|
|
40
|
+
"express-promise-router": "^4.1.1",
|
|
41
|
+
"express-session": "^1.17.3",
|
|
42
|
+
"jose": "^4.14.6",
|
|
43
|
+
"msw": "^1.3.1",
|
|
44
|
+
"supertest": "^6.3.3"
|
|
45
|
+
},
|
|
46
|
+
"configSchema": "config.d.ts",
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"config.d.ts"
|
|
50
|
+
]
|
|
51
|
+
}
|