@backstage/plugin-auth-backend 0.0.0-nightly-20220419024359 → 0.0.0-nightly-20220422024928
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 -5
- package/dist/index.cjs.js +22 -24
- package/dist/index.cjs.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20220422024928
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9ec4e0613e: Update to `jose` 4.6.0
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-common@0.0.0-nightly-20220422024928
|
|
10
|
+
- @backstage/plugin-auth-node@0.0.0-nightly-20220422024928
|
|
11
|
+
|
|
12
|
+
## 0.13.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
6
15
|
|
|
@@ -131,12 +140,13 @@
|
|
|
131
140
|
- f4cdf4cac1: Defensively encode URL parameters when fetching ELB keys
|
|
132
141
|
- 6ee04078e1: **DEPRECATION**: The `tokenIssuer` option for `OAuthAdapter` is no longer needed and has been deprecated.
|
|
133
142
|
- a45bce06e3: Handle trailing slashes on GitHub `enterpriseInstanceUrl` settings
|
|
143
|
+
- 45f7a261c7: Bumped passport-microsoft to resolve CVE-2021-41580
|
|
134
144
|
- c5aeaf339d: Added exports of the following types: `AuthProviderConfig`, `StateEncoder`, `TokenParams`, `AwsAlbResult`.
|
|
135
145
|
- Updated dependencies
|
|
136
|
-
- @backstage/catalog-model@
|
|
137
|
-
- @backstage/plugin-auth-node@0.
|
|
138
|
-
- @backstage/backend-common@0.
|
|
139
|
-
- @backstage/catalog-client@
|
|
146
|
+
- @backstage/catalog-model@1.0.1
|
|
147
|
+
- @backstage/plugin-auth-node@0.2.0
|
|
148
|
+
- @backstage/backend-common@0.13.2
|
|
149
|
+
- @backstage/catalog-client@1.0.1
|
|
140
150
|
|
|
141
151
|
## 0.13.0-next.2
|
|
142
152
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -763,10 +763,6 @@ const createAuth0Provider = auth0.create;
|
|
|
763
763
|
|
|
764
764
|
const ALB_JWT_HEADER = "x-amzn-oidc-data";
|
|
765
765
|
const ALB_ACCESS_TOKEN_HEADER = "x-amzn-oidc-accesstoken";
|
|
766
|
-
const getJWTHeaders = (input) => {
|
|
767
|
-
const encoded = input.split(".")[0];
|
|
768
|
-
return JSON.parse(Buffer.from(encoded, "base64").toString("utf8"));
|
|
769
|
-
};
|
|
770
766
|
class AwsAlbAuthProvider {
|
|
771
767
|
constructor(options) {
|
|
772
768
|
this.region = options.region;
|
|
@@ -801,9 +797,8 @@ class AwsAlbAuthProvider {
|
|
|
801
797
|
throw new errors.AuthenticationError(`Missing ALB OIDC header: ${ALB_ACCESS_TOKEN_HEADER}`);
|
|
802
798
|
}
|
|
803
799
|
try {
|
|
804
|
-
const
|
|
805
|
-
const
|
|
806
|
-
const claims = jose.JWT.verify(jwt, key);
|
|
800
|
+
const verifyResult = await jose.jwtVerify(jwt, this.getKey);
|
|
801
|
+
const claims = verifyResult.payload;
|
|
807
802
|
if (this.issuer && claims.iss !== this.issuer) {
|
|
808
803
|
throw new errors.AuthenticationError("Issuer mismatch on JWT token");
|
|
809
804
|
}
|
|
@@ -843,14 +838,17 @@ class AwsAlbAuthProvider {
|
|
|
843
838
|
profile
|
|
844
839
|
};
|
|
845
840
|
}
|
|
846
|
-
async getKey(
|
|
847
|
-
|
|
841
|
+
async getKey(header) {
|
|
842
|
+
if (!header.kid) {
|
|
843
|
+
throw new errors.AuthenticationError("No key id was specified in header");
|
|
844
|
+
}
|
|
845
|
+
const optionalCacheKey = this.keyCache.get(header.kid);
|
|
848
846
|
if (optionalCacheKey) {
|
|
849
847
|
return crypto__namespace.createPublicKey(optionalCacheKey);
|
|
850
848
|
}
|
|
851
|
-
const keyText = await fetch__default["default"](`https://public-keys.auth.elb.${encodeURIComponent(this.region)}.amazonaws.com/${encodeURIComponent(
|
|
849
|
+
const keyText = await fetch__default["default"](`https://public-keys.auth.elb.${encodeURIComponent(this.region)}.amazonaws.com/${encodeURIComponent(header.kid)}`).then((response) => response.text());
|
|
852
850
|
const keyValue = crypto__namespace.createPublicKey(keyText);
|
|
853
|
-
this.keyCache.set(
|
|
851
|
+
this.keyCache.set(header.kid, keyValue.export({ format: "pem", type: "spki" }));
|
|
854
852
|
return keyValue;
|
|
855
853
|
}
|
|
856
854
|
}
|
|
@@ -1659,7 +1657,7 @@ class Oauth2ProxyAuthProvider {
|
|
|
1659
1657
|
if (!jwt) {
|
|
1660
1658
|
throw new errors.AuthenticationError(`Missing or in incorrect format - Oauth2Proxy OIDC header: ${OAUTH2_PROXY_JWT_HEADER}`);
|
|
1661
1659
|
}
|
|
1662
|
-
const decodedJWT = jose.
|
|
1660
|
+
const decodedJWT = jose.decodeJwt(jwt);
|
|
1663
1661
|
return {
|
|
1664
1662
|
fullProfile: decodedJWT,
|
|
1665
1663
|
accessToken: jwt
|
|
@@ -2299,10 +2297,10 @@ class TokenFactory {
|
|
|
2299
2297
|
throw new Error('"sub" claim provided by the auth resolver is not a valid EntityRef.');
|
|
2300
2298
|
}
|
|
2301
2299
|
this.logger.info(`Issuing token for ${sub}, with entities ${ent != null ? ent : []}`);
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
});
|
|
2300
|
+
if (!key.alg) {
|
|
2301
|
+
throw new errors.AuthenticationError("No algorithm was provided in the key");
|
|
2302
|
+
}
|
|
2303
|
+
return new jose.SignJWT({ iss, sub, aud, iat, exp }).setProtectedHeader({ alg: key.alg, kid: key.kid }).setIssuer(iss).setAudience(aud).setSubject(sub).setIssuedAt(iat).setExpirationTime(exp).sign(await jose.importJWK(key));
|
|
2306
2304
|
}
|
|
2307
2305
|
async listPublicKeys() {
|
|
2308
2306
|
const { items: keys } = await this.keyStore.listKeys();
|
|
@@ -2339,14 +2337,14 @@ class TokenFactory {
|
|
|
2339
2337
|
seconds: this.keyDurationSeconds
|
|
2340
2338
|
}).toJSDate();
|
|
2341
2339
|
const promise = (async () => {
|
|
2342
|
-
const key = await jose.
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
this.logger.info(`Created new signing key ${
|
|
2348
|
-
await this.keyStore.addKey(
|
|
2349
|
-
return
|
|
2340
|
+
const key = await jose.generateKeyPair("ES256");
|
|
2341
|
+
const publicKey = await jose.exportJWK(key.publicKey);
|
|
2342
|
+
const privateKey = await jose.exportJWK(key.privateKey);
|
|
2343
|
+
publicKey.kid = privateKey.kid = uuid.v4();
|
|
2344
|
+
publicKey.alg = privateKey.alg = "ES256";
|
|
2345
|
+
this.logger.info(`Created new signing key ${publicKey.kid}`);
|
|
2346
|
+
await this.keyStore.addKey(publicKey);
|
|
2347
|
+
return privateKey;
|
|
2350
2348
|
})();
|
|
2351
2349
|
this.privateKeyPromise = promise;
|
|
2352
2350
|
try {
|