fix: rename uri to url

Signed-off-by: Ryan Hanchett <ryan.hanchett@invitae.com>
This commit is contained in:
Ryan Hanchett
2024-05-08 09:12:28 -07:00
parent 9b0db3f495
commit 96e30c54ab
2 changed files with 8 additions and 8 deletions
+3 -3
View File
@@ -96,7 +96,7 @@ backend:
externalAccess:
- type: jwks
options:
uri: https://example.com/.well-known/jwks.json
url: https://example.com/.well-known/jwks.json
issuers:
- https://example.com
algorithms:
@@ -105,12 +105,12 @@ backend:
- example
- type: jwks
options:
uri: https://another-example.com/.well-known/jwks.json
url: https://another-example.com/.well-known/jwks.json
issuers:
- https://example.com
```
The URI should point at an unauthenticated endpoint that returns the JWKS.
The URL should point at an unauthenticated endpoint that returns the JWKS.
Issuers specifies the issuer(s) of the JWT that the authenticating app will accept.
Passed JWTs must have an `iss` claim which matches one of the specified issuers.
@@ -28,26 +28,26 @@ export class JWKSHandler implements TokenHandler {
algorithms: string[];
audiences: string[] | string;
issuers: string[];
uri: string;
url: string;
}> = [];
add(options: Config) {
const algorithms = options.getOptionalStringArray('algorithms') ?? [];
const issuers = options.getOptionalStringArray('issuers') ?? [];
const audiences = options.getOptionalStringArray('audiences') ?? '';
const uri = options.getString('uri');
const url = options.getString('url');
if (!uri.match(/^\S+$/)) {
if (!url.match(/^\S+$/)) {
throw new Error('Illegal URI, must be a set of non-space characters');
}
this.#entries.push({ algorithms, audiences, issuers, uri });
this.#entries.push({ algorithms, audiences, issuers, url });
}
async verifyToken(token: string) {
for (const entry of this.#entries) {
try {
const jwks = createRemoteJWKSet(new URL(entry.uri));
const jwks = createRemoteJWKSet(new URL(entry.url));
const {
payload: { sub },
} = await jwtVerify(token, jwks, {