@backstage/plugin-auth-backend-module-aws-alb-provider 0.0.0-nightly-20240126021148
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/README.md +8 -0
- package/dist/index.cjs.js +200 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/package.json +53 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @backstage/plugin-auth-backend-module-aws-alb-provider
|
|
2
|
+
|
|
3
|
+
## 0.0.0-nightly-20240126021148
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 23a98f8: Migrated the AWS ALB auth provider to new `@backstage/plugin-auth-backend-module-aws-alb-provider` module package.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/plugin-auth-backend@0.0.0-nightly-20240126021148
|
|
13
|
+
- @backstage/backend-common@0.0.0-nightly-20240126021148
|
|
14
|
+
- @backstage/plugin-auth-node@0.0.0-nightly-20240126021148
|
|
15
|
+
- @backstage/backend-plugin-api@0.0.0-nightly-20240126021148
|
|
16
|
+
- @backstage/errors@1.2.3
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Auth Module: AWS ALB Provider
|
|
2
|
+
|
|
3
|
+
This module provides an GitHub auth provider implementation for `@backstage/plugin-auth-backend`.
|
|
4
|
+
|
|
5
|
+
## Links
|
|
6
|
+
|
|
7
|
+
- [Backstage](https://backstage.io)
|
|
8
|
+
- [Repository](https://github.com/backstage/backstage/tree/master/plugins/auth-backend-module-github-provider)
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var errors = require('@backstage/errors');
|
|
6
|
+
var jose = require('jose');
|
|
7
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
8
|
+
var NodeCache = require('node-cache');
|
|
9
|
+
var jwtDecoder = require('jwt-decode');
|
|
10
|
+
var crypto = require('crypto');
|
|
11
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
function _interopNamespace(e) {
|
|
16
|
+
if (e && e.__esModule) return e;
|
|
17
|
+
var n = Object.create(null);
|
|
18
|
+
if (e) {
|
|
19
|
+
Object.keys(e).forEach(function (k) {
|
|
20
|
+
if (k !== 'default') {
|
|
21
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return e[k]; }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
n["default"] = e;
|
|
30
|
+
return Object.freeze(n);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var NodeCache__default = /*#__PURE__*/_interopDefaultLegacy(NodeCache);
|
|
34
|
+
var jwtDecoder__default = /*#__PURE__*/_interopDefaultLegacy(jwtDecoder);
|
|
35
|
+
var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
|
|
36
|
+
|
|
37
|
+
const makeProfileInfo = (profile, idToken) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
let email = void 0;
|
|
40
|
+
if (profile.emails && profile.emails.length > 0) {
|
|
41
|
+
const [firstEmail] = profile.emails;
|
|
42
|
+
email = firstEmail.value;
|
|
43
|
+
}
|
|
44
|
+
let picture = void 0;
|
|
45
|
+
if (profile.avatarUrl) {
|
|
46
|
+
picture = profile.avatarUrl;
|
|
47
|
+
} else if (profile.photos && profile.photos.length > 0) {
|
|
48
|
+
const [firstPhoto] = profile.photos;
|
|
49
|
+
picture = firstPhoto.value;
|
|
50
|
+
}
|
|
51
|
+
let displayName = (_b = (_a = profile.displayName) != null ? _a : profile.username) != null ? _b : profile.id;
|
|
52
|
+
if ((!email || !picture || !displayName) && idToken) {
|
|
53
|
+
try {
|
|
54
|
+
const decoded = jwtDecoder__default["default"](idToken);
|
|
55
|
+
if (!email && decoded.email) {
|
|
56
|
+
email = decoded.email;
|
|
57
|
+
}
|
|
58
|
+
if (!picture && decoded.picture) {
|
|
59
|
+
picture = decoded.picture;
|
|
60
|
+
}
|
|
61
|
+
if (!displayName && decoded.name) {
|
|
62
|
+
displayName = decoded.name;
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
throw new Error(`Failed to parse id token and get profile info, ${e}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
email,
|
|
70
|
+
picture,
|
|
71
|
+
displayName
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const provisionKeyCache = (region, keyCache) => {
|
|
75
|
+
return async (header) => {
|
|
76
|
+
if (!header.kid) {
|
|
77
|
+
throw new errors.AuthenticationError("No key id was specified in header");
|
|
78
|
+
}
|
|
79
|
+
const optionalCacheKey = keyCache.get(header.kid);
|
|
80
|
+
if (optionalCacheKey) {
|
|
81
|
+
return crypto__namespace.createPublicKey(optionalCacheKey);
|
|
82
|
+
}
|
|
83
|
+
const keyText = await fetch(
|
|
84
|
+
`https://public-keys.auth.elb.${encodeURIComponent(
|
|
85
|
+
region
|
|
86
|
+
)}.amazonaws.com/${encodeURIComponent(header.kid)}`
|
|
87
|
+
).then((response) => response.text());
|
|
88
|
+
const keyValue = crypto__namespace.createPublicKey(keyText);
|
|
89
|
+
keyCache.set(header.kid, keyValue.export({ format: "pem", type: "spki" }));
|
|
90
|
+
return keyValue;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const ALB_JWT_HEADER = "x-amzn-oidc-data";
|
|
95
|
+
const ALB_ACCESS_TOKEN_HEADER = "x-amzn-oidc-accesstoken";
|
|
96
|
+
const awsAlbAuthenticator = pluginAuthNode.createProxyAuthenticator({
|
|
97
|
+
defaultProfileTransform: async (result) => {
|
|
98
|
+
return {
|
|
99
|
+
profile: makeProfileInfo(result.fullProfile, result.accessToken)
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
initialize({ config }) {
|
|
103
|
+
const issuer = config.getString("issuer");
|
|
104
|
+
const region = config.getString("region");
|
|
105
|
+
const keyCache = new NodeCache__default["default"]({ stdTTL: 3600 });
|
|
106
|
+
const getKey = provisionKeyCache(region, keyCache);
|
|
107
|
+
return { issuer, getKey };
|
|
108
|
+
},
|
|
109
|
+
async authenticate({ req }, { issuer, getKey }) {
|
|
110
|
+
const jwt = req.header(ALB_JWT_HEADER);
|
|
111
|
+
const accessToken = req.header(ALB_ACCESS_TOKEN_HEADER);
|
|
112
|
+
if (jwt === void 0) {
|
|
113
|
+
throw new errors.AuthenticationError(
|
|
114
|
+
`Missing ALB OIDC header: ${ALB_JWT_HEADER}`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (accessToken === void 0) {
|
|
118
|
+
throw new errors.AuthenticationError(
|
|
119
|
+
`Missing ALB OIDC header: ${ALB_ACCESS_TOKEN_HEADER}`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const verifyResult = await jose.jwtVerify(jwt, getKey);
|
|
124
|
+
const claims = verifyResult.payload;
|
|
125
|
+
if (issuer && (claims == null ? void 0 : claims.iss) !== issuer) {
|
|
126
|
+
throw new errors.AuthenticationError("Issuer mismatch on JWT token");
|
|
127
|
+
}
|
|
128
|
+
const fullProfile = {
|
|
129
|
+
provider: "unknown",
|
|
130
|
+
id: claims.sub,
|
|
131
|
+
displayName: claims.name,
|
|
132
|
+
username: claims.email.split("@")[0].toLowerCase(),
|
|
133
|
+
name: {
|
|
134
|
+
familyName: claims.family_name,
|
|
135
|
+
givenName: claims.given_name
|
|
136
|
+
},
|
|
137
|
+
emails: [{ value: claims.email.toLowerCase() }],
|
|
138
|
+
photos: [{ value: claims.picture }]
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
result: {
|
|
142
|
+
fullProfile,
|
|
143
|
+
expiresInSeconds: claims.exp,
|
|
144
|
+
accessToken
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
} catch (e) {
|
|
148
|
+
throw new Error(`Exception occurred during JWT processing: ${e}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
exports.awsAlbSignInResolvers = void 0;
|
|
154
|
+
((awsAlbSignInResolvers2) => {
|
|
155
|
+
awsAlbSignInResolvers2.emailMatchingUserEntityProfileEmail = pluginAuthNode.createSignInResolverFactory({
|
|
156
|
+
create() {
|
|
157
|
+
return async (info, ctx) => {
|
|
158
|
+
if (!info.result.fullProfile.emails) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
"Login failed, user profile does not contain an email"
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
return ctx.signInWithCatalogUser({
|
|
164
|
+
filter: {
|
|
165
|
+
kind: ["User"],
|
|
166
|
+
"spec.profile.email": info.result.fullProfile.emails[0].value
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
})(exports.awsAlbSignInResolvers || (exports.awsAlbSignInResolvers = {}));
|
|
173
|
+
|
|
174
|
+
const authModuleAwsAlbProvider = backendPluginApi.createBackendModule({
|
|
175
|
+
pluginId: "auth",
|
|
176
|
+
moduleId: "awsAlbProvider",
|
|
177
|
+
register(reg) {
|
|
178
|
+
reg.registerInit({
|
|
179
|
+
deps: {
|
|
180
|
+
providers: pluginAuthNode.authProvidersExtensionPoint
|
|
181
|
+
},
|
|
182
|
+
async init({ providers }) {
|
|
183
|
+
providers.registerProvider({
|
|
184
|
+
providerId: "awsalb",
|
|
185
|
+
factory: pluginAuthNode.createProxyAuthProviderFactory({
|
|
186
|
+
authenticator: awsAlbAuthenticator,
|
|
187
|
+
signInResolverFactories: {
|
|
188
|
+
...pluginAuthNode.commonSignInResolvers,
|
|
189
|
+
...exports.awsAlbSignInResolvers
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
exports.authModuleAwsAlbProvider = authModuleAwsAlbProvider;
|
|
199
|
+
exports.awsAlbAuthenticator = awsAlbAuthenticator;
|
|
200
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/helpers.ts","../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 type { PassportProfile } from '@backstage/plugin-auth-node/';\nimport { ProfileInfo } from '@backstage/plugin-auth-node';\nimport { KeyObject } from 'crypto';\nimport jwtDecoder from 'jwt-decode';\nimport NodeCache from 'node-cache';\nimport * as crypto from 'crypto';\nimport { JWTHeaderParameters } from 'jose';\nimport { AuthenticationError } from '@backstage/errors';\n\nexport const makeProfileInfo = (\n profile: PassportProfile,\n idToken?: string,\n): ProfileInfo => {\n let email: string | undefined = undefined;\n if (profile.emails && profile.emails.length > 0) {\n const [firstEmail] = profile.emails;\n email = firstEmail.value;\n }\n\n let picture: string | undefined = undefined;\n if (profile.avatarUrl) {\n picture = profile.avatarUrl;\n } else if (profile.photos && profile.photos.length > 0) {\n const [firstPhoto] = profile.photos;\n picture = firstPhoto.value;\n }\n\n let displayName: string | undefined =\n profile.displayName ?? profile.username ?? profile.id;\n\n if ((!email || !picture || !displayName) && idToken) {\n try {\n const decoded: Record<string, string> = jwtDecoder(idToken);\n if (!email && decoded.email) {\n email = decoded.email;\n }\n if (!picture && decoded.picture) {\n picture = decoded.picture;\n }\n if (!displayName && decoded.name) {\n displayName = decoded.name;\n }\n } catch (e) {\n throw new Error(`Failed to parse id token and get profile info, ${e}`);\n }\n }\n\n return {\n email,\n picture,\n displayName,\n };\n};\n\nexport const provisionKeyCache = (region: string, keyCache: NodeCache) => {\n return async (header: JWTHeaderParameters): Promise<KeyObject> => {\n if (!header.kid) {\n throw new AuthenticationError('No key id was specified in header');\n }\n const optionalCacheKey = keyCache.get<KeyObject>(header.kid);\n if (optionalCacheKey) {\n return crypto.createPublicKey(optionalCacheKey);\n }\n const keyText: string = await fetch(\n `https://public-keys.auth.elb.${encodeURIComponent(\n region,\n )}.amazonaws.com/${encodeURIComponent(header.kid)}`,\n ).then(response => response.text());\n\n const keyValue = crypto.createPublicKey(keyText);\n keyCache.set(header.kid, keyValue.export({ format: 'pem', type: 'spki' }));\n return keyValue;\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 { AuthenticationError } from '@backstage/errors';\nimport { AwsAlbClaims, AwsAlbResult } from './types';\nimport { jwtVerify } from 'jose';\nimport {\n PassportProfile,\n createProxyAuthenticator,\n} from '@backstage/plugin-auth-node';\nimport NodeCache from 'node-cache';\nimport { makeProfileInfo, provisionKeyCache } from './helpers';\n\nexport const ALB_JWT_HEADER = 'x-amzn-oidc-data';\nexport const ALB_ACCESS_TOKEN_HEADER = 'x-amzn-oidc-accesstoken';\n\n/** @public */\nexport const awsAlbAuthenticator = createProxyAuthenticator({\n defaultProfileTransform: async (result: AwsAlbResult) => {\n return {\n profile: makeProfileInfo(result.fullProfile, result.accessToken),\n };\n },\n initialize({ config }) {\n const issuer = config.getString('issuer');\n const region = config.getString('region');\n const keyCache = new NodeCache({ stdTTL: 3600 });\n const getKey = provisionKeyCache(region, keyCache);\n return { issuer, getKey };\n },\n async authenticate({ req }, { issuer, getKey }) {\n const jwt = req.header(ALB_JWT_HEADER);\n const accessToken = req.header(ALB_ACCESS_TOKEN_HEADER);\n\n if (jwt === undefined) {\n throw new AuthenticationError(\n `Missing ALB OIDC header: ${ALB_JWT_HEADER}`,\n );\n }\n\n if (accessToken === undefined) {\n throw new AuthenticationError(\n `Missing ALB OIDC header: ${ALB_ACCESS_TOKEN_HEADER}`,\n );\n }\n\n try {\n const verifyResult = await jwtVerify(jwt, getKey);\n const claims = verifyResult.payload as AwsAlbClaims;\n\n if (issuer && claims?.iss !== issuer) {\n throw new AuthenticationError('Issuer mismatch on JWT token');\n }\n\n const fullProfile: PassportProfile = {\n provider: 'unknown',\n id: claims.sub,\n displayName: claims.name,\n username: claims.email.split('@')[0].toLowerCase(),\n name: {\n familyName: claims.family_name,\n givenName: claims.given_name,\n },\n emails: [{ value: claims.email.toLowerCase() }],\n photos: [{ value: claims.picture }],\n };\n\n return {\n result: {\n fullProfile,\n expiresInSeconds: claims.exp,\n accessToken,\n },\n };\n } catch (e) {\n throw new Error(`Exception occurred during JWT processing: ${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 { AwsAlbResult } from './types';\n/**\n * Available sign-in resolvers for the Google auth provider.\n *\n * @public\n */\nexport namespace awsAlbSignInResolvers {\n export const emailMatchingUserEntityProfileEmail =\n createSignInResolverFactory({\n create() {\n return async (info: SignInInfo<AwsAlbResult>, ctx) => {\n if (!info.result.fullProfile.emails) {\n throw new Error(\n 'Login failed, user profile does not contain an email',\n );\n }\n return ctx.signInWithCatalogUser({\n filter: {\n kind: ['User'],\n 'spec.profile.email': info.result.fullProfile.emails[0].value,\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 createProxyAuthProviderFactory,\n} from '@backstage/plugin-auth-node';\nimport { awsAlbAuthenticator } from './authenticator';\nimport { awsAlbSignInResolvers } from './resolvers';\n\n/** @public */\nexport const authModuleAwsAlbProvider = createBackendModule({\n pluginId: 'auth',\n moduleId: 'awsAlbProvider',\n register(reg) {\n reg.registerInit({\n deps: {\n providers: authProvidersExtensionPoint,\n },\n async init({ providers }) {\n providers.registerProvider({\n providerId: 'awsalb',\n factory: createProxyAuthProviderFactory({\n authenticator: awsAlbAuthenticator,\n signInResolverFactories: {\n ...commonSignInResolvers,\n ...awsAlbSignInResolvers,\n },\n }),\n });\n },\n });\n },\n});\n"],"names":["jwtDecoder","AuthenticationError","crypto","createProxyAuthenticator","NodeCache","jwtVerify","awsAlbSignInResolvers","createSignInResolverFactory","createBackendModule","authProvidersExtensionPoint","createProxyAuthProviderFactory","commonSignInResolvers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBa,MAAA,eAAA,GAAkB,CAC7B,OAAA,EACA,OACgB,KAAA;AA3BlB,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AA4BE,EAAA,IAAI,KAA4B,GAAA,KAAA,CAAA,CAAA;AAChC,EAAA,IAAI,OAAQ,CAAA,MAAA,IAAU,OAAQ,CAAA,MAAA,CAAO,SAAS,CAAG,EAAA;AAC/C,IAAM,MAAA,CAAC,UAAU,CAAA,GAAI,OAAQ,CAAA,MAAA,CAAA;AAC7B,IAAA,KAAA,GAAQ,UAAW,CAAA,KAAA,CAAA;AAAA,GACrB;AAEA,EAAA,IAAI,OAA8B,GAAA,KAAA,CAAA,CAAA;AAClC,EAAA,IAAI,QAAQ,SAAW,EAAA;AACrB,IAAA,OAAA,GAAU,OAAQ,CAAA,SAAA,CAAA;AAAA,aACT,OAAQ,CAAA,MAAA,IAAU,OAAQ,CAAA,MAAA,CAAO,SAAS,CAAG,EAAA;AACtD,IAAM,MAAA,CAAC,UAAU,CAAA,GAAI,OAAQ,CAAA,MAAA,CAAA;AAC7B,IAAA,OAAA,GAAU,UAAW,CAAA,KAAA,CAAA;AAAA,GACvB;AAEA,EAAA,IAAI,eACF,EAAQ,GAAA,CAAA,EAAA,GAAA,OAAA,CAAA,WAAA,KAAR,YAAuB,OAAQ,CAAA,QAAA,KAA/B,YAA2C,OAAQ,CAAA,EAAA,CAAA;AAErD,EAAA,IAAA,CAAK,CAAC,KAAS,IAAA,CAAC,OAAW,IAAA,CAAC,gBAAgB,OAAS,EAAA;AACnD,IAAI,IAAA;AACF,MAAM,MAAA,OAAA,GAAkCA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A;AAAA,UACZ,SAASC,6CAA+B,CAAA;AAAA,YACtC,aAAe,EAAA,mBAAA;AAAA,YACf,uBAAyB,EAAA;AAAA,cACvB,GAAGC,oCAAA;AAAA,cACH,GAAGL,6BAAA;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,38 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as _backstage_plugin_auth_node from '@backstage/plugin-auth-node';
|
|
3
|
+
import * as crypto from 'crypto';
|
|
4
|
+
import * as jose from 'jose';
|
|
5
|
+
import { PassportProfile } from '@backstage/plugin-auth-node/';
|
|
6
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* JWT header extraction result, containing the raw value and the parsed JWT
|
|
10
|
+
* payload.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
type AwsAlbResult = {
|
|
15
|
+
fullProfile: PassportProfile;
|
|
16
|
+
expiresInSeconds?: number;
|
|
17
|
+
accessToken: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** @public */
|
|
21
|
+
declare const awsAlbAuthenticator: _backstage_plugin_auth_node.ProxyAuthenticator<{
|
|
22
|
+
issuer: string;
|
|
23
|
+
getKey: (header: jose.JWTHeaderParameters) => Promise<crypto.KeyObject>;
|
|
24
|
+
}, AwsAlbResult>;
|
|
25
|
+
|
|
26
|
+
/** @public */
|
|
27
|
+
declare const authModuleAwsAlbProvider: () => _backstage_backend_plugin_api.BackendFeature;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Available sign-in resolvers for the Google auth provider.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
declare namespace awsAlbSignInResolvers {
|
|
35
|
+
const emailMatchingUserEntityProfileEmail: _backstage_plugin_auth_node.SignInResolverFactory<AwsAlbResult, unknown>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { AwsAlbResult, authModuleAwsAlbProvider, awsAlbAuthenticator, awsAlbSignInResolvers };
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/plugin-auth-backend-module-aws-alb-provider",
|
|
3
|
+
"description": "The aws-alb provider module for the Backstage auth backend.",
|
|
4
|
+
"version": "0.0.0-nightly-20240126021148",
|
|
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
|
+
"homepage": "https://backstage.io",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/backstage/backstage",
|
|
20
|
+
"directory": "plugins/auth-backend-module-aws-alb-provider"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"backstage"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"start": "backstage-cli package start",
|
|
27
|
+
"build": "backstage-cli package build",
|
|
28
|
+
"lint": "backstage-cli package lint",
|
|
29
|
+
"test": "backstage-cli package test",
|
|
30
|
+
"clean": "backstage-cli package clean",
|
|
31
|
+
"prepack": "backstage-cli package prepack",
|
|
32
|
+
"postpack": "backstage-cli package postpack"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@backstage/backend-common": "^0.0.0-nightly-20240126021148",
|
|
36
|
+
"@backstage/backend-plugin-api": "^0.0.0-nightly-20240126021148",
|
|
37
|
+
"@backstage/errors": "^1.2.3",
|
|
38
|
+
"@backstage/plugin-auth-backend": "^0.0.0-nightly-20240126021148",
|
|
39
|
+
"@backstage/plugin-auth-node": "^0.0.0-nightly-20240126021148",
|
|
40
|
+
"jose": "^4.6.0",
|
|
41
|
+
"jwt-decode": "^3.1.0",
|
|
42
|
+
"node-cache": "^5.1.2"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@backstage/backend-test-utils": "^0.0.0-nightly-20240126021148",
|
|
46
|
+
"@backstage/cli": "^0.0.0-nightly-20240126021148",
|
|
47
|
+
"@backstage/config": "^1.1.1",
|
|
48
|
+
"express": "^4.18.2"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist"
|
|
52
|
+
]
|
|
53
|
+
}
|