@backstage/plugin-auth-backend-module-vmware-cloud-provider 0.0.0-nightly-20231124021332
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 +7 -0
- package/dist/index.cjs.js +217 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/package.json +47 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @backstage/plugin-auth-backend-module-vmware-cloud-provider
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20231124021332
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ed02c69a3c3b: Add VMware Cloud auth backend module provider
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/backend-common@0.0.0-nightly-20231124021332
|
|
13
|
+
- @backstage/plugin-auth-node@0.0.0-nightly-20231124021332
|
|
14
|
+
- @backstage/backend-plugin-api@0.0.0-nightly-20231124021332
|
|
15
|
+
- @backstage/catalog-model@1.4.3
|
package/README.md
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
6
|
+
var jose = require('jose');
|
|
7
|
+
var passportOauth2 = require('passport-oauth2');
|
|
8
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
9
|
+
var catalogModel = require('@backstage/catalog-model');
|
|
10
|
+
|
|
11
|
+
const vmwareCloudAuthenticator = pluginAuthNode.createOAuthAuthenticator({
|
|
12
|
+
defaultProfileTransform: async (input) => {
|
|
13
|
+
if (!input.session.idToken) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`Failed to parse id token and get profile info, missing token from session`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
const vmwareClaims = ["email", "given_name", "family_name", "context_name"];
|
|
19
|
+
const identity = jose.decodeJwt(input.session.idToken);
|
|
20
|
+
const missingClaims = vmwareClaims.filter((key) => !(key in identity));
|
|
21
|
+
if (missingClaims.length > 0) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`ID token missing required claims: ${missingClaims.join(", ")}`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const typeMismatchClaims = vmwareClaims.filter(
|
|
27
|
+
(key) => typeof identity[key] !== "string"
|
|
28
|
+
);
|
|
29
|
+
if (typeMismatchClaims.length > 0) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`ID token claims type mismatch: ${typeMismatchClaims.join(", ")}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const { email, given_name, family_name, context_name } = identity;
|
|
35
|
+
if (context_name !== input.fullProfile.organizationId) {
|
|
36
|
+
throw new Error(`ID token organizationId mismatch`);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
profile: {
|
|
40
|
+
displayName: `${given_name} ${family_name}`,
|
|
41
|
+
email
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
initialize({ callbackUrl, config }) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
const consoleEndpoint = (_a = config.getOptionalString("consoleEndpoint")) != null ? _a : "https://console.cloud.vmware.com";
|
|
48
|
+
const organizationId = config.getString("organizationId");
|
|
49
|
+
const clientId = config.getString("clientId");
|
|
50
|
+
const clientSecret = "";
|
|
51
|
+
const authorizationUrl = `${consoleEndpoint}/csp/gateway/discovery`;
|
|
52
|
+
const tokenUrl = `${consoleEndpoint}/csp/gateway/am/api/auth/token`;
|
|
53
|
+
const scope = (_b = config.getOptionalString("scope")) != null ? _b : "openid offline_access";
|
|
54
|
+
const providerStrategy = new passportOauth2.Strategy(
|
|
55
|
+
{
|
|
56
|
+
clientID: clientId,
|
|
57
|
+
clientSecret,
|
|
58
|
+
callbackURL: callbackUrl,
|
|
59
|
+
authorizationURL: authorizationUrl,
|
|
60
|
+
tokenURL: tokenUrl,
|
|
61
|
+
passReqToCallback: false,
|
|
62
|
+
pkce: true,
|
|
63
|
+
state: true,
|
|
64
|
+
scope,
|
|
65
|
+
customHeaders: {
|
|
66
|
+
Authorization: `Basic ${encodeClientCredentials(
|
|
67
|
+
clientId,
|
|
68
|
+
clientSecret
|
|
69
|
+
)}`
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
(accessToken, refreshToken, params, fullProfile, done) => {
|
|
73
|
+
done(void 0, { fullProfile, params, accessToken }, { refreshToken });
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
const pkceSessionStore = Object.create(
|
|
77
|
+
providerStrategy._stateStore
|
|
78
|
+
);
|
|
79
|
+
providerStrategy._stateStore = {
|
|
80
|
+
verify(req, state, callback) {
|
|
81
|
+
pkceSessionStore.verify(
|
|
82
|
+
req,
|
|
83
|
+
pluginAuthNode.decodeOAuthState(state).handle,
|
|
84
|
+
callback
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
store(req, verifier, state, meta, callback) {
|
|
88
|
+
pkceSessionStore.store(
|
|
89
|
+
req,
|
|
90
|
+
verifier,
|
|
91
|
+
state,
|
|
92
|
+
meta,
|
|
93
|
+
(err, handle) => {
|
|
94
|
+
callback(
|
|
95
|
+
err,
|
|
96
|
+
pluginAuthNode.encodeOAuthState({
|
|
97
|
+
handle,
|
|
98
|
+
...state,
|
|
99
|
+
...req.state
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
organizationId,
|
|
108
|
+
providerStrategy,
|
|
109
|
+
helper: pluginAuthNode.PassportOAuthAuthenticatorHelper.from(providerStrategy)
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
async start(input, ctx) {
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
const strategy = Object.create(ctx.providerStrategy);
|
|
115
|
+
strategy.redirect = (url, status) => {
|
|
116
|
+
const parsed = new URL(url);
|
|
117
|
+
if (ctx.organizationId) {
|
|
118
|
+
parsed.searchParams.set("orgId", ctx.organizationId);
|
|
119
|
+
}
|
|
120
|
+
resolve({ url: parsed.toString(), status: status != null ? status : void 0 });
|
|
121
|
+
};
|
|
122
|
+
strategy.error = (error) => {
|
|
123
|
+
reject(error);
|
|
124
|
+
};
|
|
125
|
+
strategy.authenticate(input.req, {
|
|
126
|
+
scope: input.scope,
|
|
127
|
+
state: pluginAuthNode.decodeOAuthState(input.state),
|
|
128
|
+
accessType: "offline",
|
|
129
|
+
prompt: "consent"
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
async authenticate(input, ctx) {
|
|
134
|
+
return ctx.helper.authenticate(input).then((result) => ({
|
|
135
|
+
...result,
|
|
136
|
+
fullProfile: {
|
|
137
|
+
...result.fullProfile,
|
|
138
|
+
organizationId: ctx.organizationId
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
},
|
|
142
|
+
async refresh(input, ctx) {
|
|
143
|
+
return ctx.helper.refresh(input).then((result) => ({
|
|
144
|
+
...result,
|
|
145
|
+
fullProfile: {
|
|
146
|
+
...result.fullProfile,
|
|
147
|
+
organizationId: ctx.organizationId
|
|
148
|
+
}
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
function encodeClientCredentials(clientID, clientSecret) {
|
|
153
|
+
return Buffer.from(`${clientID}:${clientSecret}`).toString("base64");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
exports.vmwareCloudSignInResolvers = void 0;
|
|
157
|
+
((vmwareCloudSignInResolvers2) => {
|
|
158
|
+
vmwareCloudSignInResolvers2.profileEmailMatchingUserEntityEmail = pluginAuthNode.createSignInResolverFactory({
|
|
159
|
+
create() {
|
|
160
|
+
return async (info, ctx) => {
|
|
161
|
+
const email = info.profile.email;
|
|
162
|
+
if (!email) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
"VMware login failed, user profile does not contain an email"
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
const userEntityRef = catalogModel.stringifyEntityRef({
|
|
168
|
+
kind: "User",
|
|
169
|
+
name: email
|
|
170
|
+
});
|
|
171
|
+
try {
|
|
172
|
+
return await ctx.signInWithCatalogUser({
|
|
173
|
+
filter: {
|
|
174
|
+
"spec.profile.email": email
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
} catch (e) {
|
|
178
|
+
if (e.name !== "NotFoundError") {
|
|
179
|
+
throw e;
|
|
180
|
+
}
|
|
181
|
+
return ctx.issueToken({
|
|
182
|
+
claims: {
|
|
183
|
+
sub: userEntityRef,
|
|
184
|
+
ent: [userEntityRef]
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
})(exports.vmwareCloudSignInResolvers || (exports.vmwareCloudSignInResolvers = {}));
|
|
192
|
+
|
|
193
|
+
const authModuleVmwareCloudProvider = backendPluginApi.createBackendModule({
|
|
194
|
+
pluginId: "auth",
|
|
195
|
+
moduleId: "vmware-cloud-provider",
|
|
196
|
+
register(reg) {
|
|
197
|
+
reg.registerInit({
|
|
198
|
+
deps: { providers: pluginAuthNode.authProvidersExtensionPoint },
|
|
199
|
+
async init({ providers }) {
|
|
200
|
+
providers.registerProvider({
|
|
201
|
+
providerId: "vmwareCloudServices",
|
|
202
|
+
factory: pluginAuthNode.createOAuthProviderFactory({
|
|
203
|
+
authenticator: vmwareCloudAuthenticator,
|
|
204
|
+
signInResolverFactories: {
|
|
205
|
+
...exports.vmwareCloudSignInResolvers,
|
|
206
|
+
...pluginAuthNode.commonSignInResolvers
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
exports["default"] = authModuleVmwareCloudProvider;
|
|
216
|
+
exports.vmwareCloudAuthenticator = vmwareCloudAuthenticator;
|
|
217
|
+
//# 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 */\nimport {\n createOAuthAuthenticator,\n decodeOAuthState,\n encodeOAuthState,\n OAuthState,\n PassportOAuthAuthenticatorHelper,\n PassportOAuthDoneCallback,\n PassportProfile,\n} from '@backstage/plugin-auth-node';\nimport { decodeJwt } from 'jose';\nimport {\n Metadata,\n StateStoreStoreCallback,\n StateStoreVerifyCallback,\n Strategy as OAuth2Strategy,\n} from 'passport-oauth2';\n\n/** @public */\nexport interface VMwareCloudAuthenticatorContext {\n organizationId?: string;\n providerStrategy: OAuth2Strategy;\n helper: PassportOAuthAuthenticatorHelper;\n}\n\n/** @public */\nexport type VMwarePassportProfile = PassportProfile & {\n organizationId?: string;\n};\n\n/**\n * VMware Cloud Authenticator to be used by `createOAuthProviderFactory`\n *\n * @public\n */\nexport const vmwareCloudAuthenticator = createOAuthAuthenticator<\n VMwareCloudAuthenticatorContext,\n VMwarePassportProfile\n>({\n defaultProfileTransform: async input => {\n if (!input.session.idToken) {\n throw new Error(\n `Failed to parse id token and get profile info, missing token from session`,\n );\n }\n\n const vmwareClaims = ['email', 'given_name', 'family_name', 'context_name'];\n\n const identity = decodeJwt(input.session.idToken);\n const missingClaims = vmwareClaims.filter(key => !(key in identity));\n\n if (missingClaims.length > 0) {\n throw new Error(\n `ID token missing required claims: ${missingClaims.join(', ')}`,\n );\n }\n\n const typeMismatchClaims = vmwareClaims.filter(\n key => typeof identity[key] !== 'string',\n );\n\n if (typeMismatchClaims.length > 0) {\n throw new Error(\n `ID token claims type mismatch: ${typeMismatchClaims.join(', ')}`,\n );\n }\n\n // These claims were checked for presence & type\n const { email, given_name, family_name, context_name } = identity as Record<\n string,\n string\n >;\n\n if (context_name !== input.fullProfile.organizationId) {\n throw new Error(`ID token organizationId mismatch`);\n }\n\n return {\n profile: {\n displayName: `${given_name} ${family_name}`,\n email,\n },\n };\n },\n initialize({ callbackUrl, config }) {\n const consoleEndpoint =\n config.getOptionalString('consoleEndpoint') ??\n 'https://console.cloud.vmware.com';\n const organizationId = config.getString('organizationId');\n\n const clientId = config.getString('clientId');\n const clientSecret = '';\n const authorizationUrl = `${consoleEndpoint}/csp/gateway/discovery`;\n const tokenUrl = `${consoleEndpoint}/csp/gateway/am/api/auth/token`;\n const scope = config.getOptionalString('scope') ?? 'openid offline_access';\n\n const providerStrategy = new OAuth2Strategy(\n {\n clientID: clientId,\n clientSecret: clientSecret,\n callbackURL: callbackUrl,\n authorizationURL: authorizationUrl,\n tokenURL: tokenUrl,\n passReqToCallback: false,\n pkce: true,\n state: true,\n scope: scope,\n customHeaders: {\n Authorization: `Basic ${encodeClientCredentials(\n clientId,\n clientSecret,\n )}`,\n },\n },\n (\n accessToken: any,\n refreshToken: any,\n params: any,\n fullProfile: PassportProfile,\n done: PassportOAuthDoneCallback,\n ) => {\n done(undefined, { fullProfile, params, accessToken }, { refreshToken });\n },\n );\n\n // Both VMware & OAuth2Strategy fight over control of the state when PKCE is on, thus this hack\n const pkceSessionStore = Object.create(\n (providerStrategy as any)._stateStore,\n );\n (providerStrategy as any)._stateStore = {\n verify(req: Request, state: string, callback: StateStoreVerifyCallback) {\n pkceSessionStore.verify(\n req,\n (decodeOAuthState(state) as any).handle,\n callback,\n );\n },\n store(\n req: Request & {\n scope: string;\n state: OAuthState;\n },\n verifier: string,\n state: any,\n meta: Metadata,\n callback: StateStoreStoreCallback,\n ) {\n pkceSessionStore.store(\n req,\n verifier,\n state,\n meta,\n (err: Error, handle: string) => {\n callback(\n err,\n encodeOAuthState({\n handle,\n ...state,\n ...req.state,\n } as OAuthState),\n );\n },\n );\n },\n };\n\n return {\n organizationId,\n providerStrategy,\n helper: PassportOAuthAuthenticatorHelper.from(providerStrategy),\n };\n },\n\n async start(input, ctx) {\n return new Promise((resolve, reject) => {\n const strategy: OAuth2Strategy = Object.create(ctx.providerStrategy);\n\n strategy.redirect = (url: string, status?: number) => {\n const parsed = new URL(url);\n if (ctx.organizationId) {\n parsed.searchParams.set('orgId', ctx.organizationId);\n }\n resolve({ url: parsed.toString(), status: status ?? undefined });\n };\n strategy.error = (error: Error) => {\n reject(error);\n };\n strategy.authenticate(input.req, {\n scope: input.scope,\n state: decodeOAuthState(input.state),\n accessType: 'offline',\n prompt: 'consent',\n });\n });\n },\n\n async authenticate(input, ctx) {\n return ctx.helper.authenticate(input).then(result => ({\n ...result,\n fullProfile: {\n ...result.fullProfile,\n organizationId: ctx.organizationId,\n } as VMwarePassportProfile,\n }));\n },\n\n async refresh(input, ctx) {\n return ctx.helper.refresh(input).then(result => ({\n ...result,\n fullProfile: {\n ...result.fullProfile,\n organizationId: ctx.organizationId,\n } as VMwarePassportProfile,\n }));\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 */\nimport { stringifyEntityRef } from '@backstage/catalog-model';\nimport {\n createSignInResolverFactory,\n OAuthAuthenticatorResult,\n PassportProfile,\n SignInInfo,\n} from '@backstage/plugin-auth-node';\n\n/**\n * Available sign-in resolvers for the VMware Cloud auth provider.\n *\n * @public\n */\nexport namespace vmwareCloudSignInResolvers {\n /**\n * Looks up the user by matching their profile email to the entity's profile email.\n * If that fails, sign in the user without associating with a catalog user.\n */\n export const profileEmailMatchingUserEntityEmail =\n createSignInResolverFactory({\n create() {\n return async (\n info: SignInInfo<OAuthAuthenticatorResult<PassportProfile>>,\n ctx,\n ) => {\n const email = info.profile.email;\n\n if (!email) {\n throw new Error(\n 'VMware login failed, user profile does not contain an email',\n );\n }\n\n const userEntityRef = stringifyEntityRef({\n kind: 'User',\n name: email,\n });\n\n try {\n // we await here so that signInWithCatalogUser throws in the current `try`\n return await ctx.signInWithCatalogUser({\n filter: {\n 'spec.profile.email': email,\n },\n });\n } catch (e) {\n if (e.name !== 'NotFoundError') {\n throw e;\n }\n return ctx.issueToken({\n claims: {\n sub: userEntityRef,\n ent: [userEntityRef],\n },\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 */\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport {\n authProvidersExtensionPoint,\n commonSignInResolvers,\n createOAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\n\nimport { vmwareCloudAuthenticator } from './authenticator';\nimport { vmwareCloudSignInResolvers } from './resolvers';\n\n/**\n * VMware Cloud Provider backend module for the auth plugin\n *\n * @public\n */\nexport const authModuleVmwareCloudProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'vmware-cloud-provider',\n register(reg) {\n reg.registerInit({\n deps: { providers: authProvidersExtensionPoint },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'vmwareCloudServices',\n factory: createOAuthProviderFactory({\n authenticator: vmwareCloudAuthenticator,\n signInResolverFactories: {\n ...vmwareCloudSignInResolvers,\n ...commonSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["createOAuthAuthenticator","decodeJwt","OAuth2Strategy","decodeOAuthState","encodeOAuthState","PassportOAuthAuthenticatorHelper","vmwareCloudSignInResolvers","createSignInResolverFactory","stringifyEntityRef","createBackendModule","authProvidersExtensionPoint","createOAuthProviderFactory","commonSignInResolvers"],"mappings":";;;;;;;;;;AAiDO,MAAM,2BAA2BA,uCAGtC,CAAA;AAAA,EACA,uBAAA,EAAyB,OAAM,KAAS,KAAA;AACtC,IAAI,IAAA,CAAC,KAAM,CAAA,OAAA,CAAQ,OAAS,EAAA;AAC1B,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,yEAAA,CAAA;AAAA,OACF,CAAA;AAAA,KACF;AAEA,IAAA,MAAM,YAAe,GAAA,CAAC,OAAS,EAAA,YAAA,EAAc,eAAe,cAAc,CAAA,CAAA;AAE1E,IAAA,MAAM,QAAW,GAAAC,cAAA,CAAU,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAChD,IAAA,MAAM,gBAAgB,YAAa,CAAA,MAAA,CAAO,CAAO,GAAA,KAAA,EAAE,OAAO,QAAS,CAAA,CAAA,CAAA;AAEnE,IAAI,IAAA,aAAA,CAAc,SAAS,CAAG,EAAA;AAC5B,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAqC,kCAAA,EAAA,aAAA,CAAc,IAAK,CAAA,IAAI,CAAC,CAAA,CAAA;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A,CAAU,gBAAiB,CAAA;AAAA,UACzB,UAAY,EAAA,qBAAA;AAAA,UACZ,SAASC,yCAA2B,CAAA;AAAA,YAClC,aAAe,EAAA,wBAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGL,kCAAA;AAAA,cACH,GAAGM,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,43 @@
|
|
|
1
|
+
import * as _backstage_plugin_auth_node from '@backstage/plugin-auth-node';
|
|
2
|
+
import { PassportOAuthAuthenticatorHelper, PassportProfile, OAuthAuthenticatorResult } from '@backstage/plugin-auth-node';
|
|
3
|
+
import { Strategy } from 'passport-oauth2';
|
|
4
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
5
|
+
|
|
6
|
+
/** @public */
|
|
7
|
+
interface VMwareCloudAuthenticatorContext {
|
|
8
|
+
organizationId?: string;
|
|
9
|
+
providerStrategy: Strategy;
|
|
10
|
+
helper: PassportOAuthAuthenticatorHelper;
|
|
11
|
+
}
|
|
12
|
+
/** @public */
|
|
13
|
+
type VMwarePassportProfile = PassportProfile & {
|
|
14
|
+
organizationId?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* VMware Cloud Authenticator to be used by `createOAuthProviderFactory`
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
declare const vmwareCloudAuthenticator: _backstage_plugin_auth_node.OAuthAuthenticator<VMwareCloudAuthenticatorContext, VMwarePassportProfile>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* VMware Cloud Provider backend module for the auth plugin
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
declare const authModuleVmwareCloudProvider: () => _backstage_backend_plugin_api.BackendFeature;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Available sign-in resolvers for the VMware Cloud auth provider.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
declare namespace vmwareCloudSignInResolvers {
|
|
36
|
+
/**
|
|
37
|
+
* Looks up the user by matching their profile email to the entity's profile email.
|
|
38
|
+
* If that fails, sign in the user without associating with a catalog user.
|
|
39
|
+
*/
|
|
40
|
+
const profileEmailMatchingUserEntityEmail: _backstage_plugin_auth_node.SignInResolverFactory<OAuthAuthenticatorResult<PassportProfile>, unknown>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { VMwareCloudAuthenticatorContext, VMwarePassportProfile, authModuleVmwareCloudProvider as default, vmwareCloudAuthenticator, vmwareCloudSignInResolvers };
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/plugin-auth-backend-module-vmware-cloud-provider",
|
|
3
|
+
"description": "The vmware-cloud-provider backend module for the auth plugin.",
|
|
4
|
+
"version": "0.0.0-nightly-20231124021332",
|
|
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-20231124021332",
|
|
27
|
+
"@backstage/backend-plugin-api": "^0.0.0-nightly-20231124021332",
|
|
28
|
+
"@backstage/catalog-model": "^1.4.3",
|
|
29
|
+
"@backstage/plugin-auth-node": "^0.0.0-nightly-20231124021332",
|
|
30
|
+
"@types/passport-oauth2": "^1.4.15",
|
|
31
|
+
"jose": "^4.6.0",
|
|
32
|
+
"passport-oauth2": "^1.6.1"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@backstage/backend-defaults": "^0.0.0-nightly-20231124021332",
|
|
36
|
+
"@backstage/backend-test-utils": "^0.0.0-nightly-20231124021332",
|
|
37
|
+
"@backstage/cli": "^0.0.0-nightly-20231124021332",
|
|
38
|
+
"@backstage/config": "^1.1.1",
|
|
39
|
+
"@backstage/errors": "^1.2.3",
|
|
40
|
+
"@backstage/plugin-auth-backend": "^0.0.0-nightly-20231124021332",
|
|
41
|
+
"msw": "^2.0.8",
|
|
42
|
+
"supertest": "^6.3.3"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist"
|
|
46
|
+
]
|
|
47
|
+
}
|