Skip to content

Commit 7871f9e

Browse files
committed
feat: support for audience in http validator
1 parent 078ca33 commit 7871f9e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ const httpValidator = new HttpValidator({
7272
)
7373
}
7474
],
75-
issuer: 'eyevinn'
75+
issuer: 'eyevinn',
76+
audience: ['one', 'two'] // Optional
7677
});
7778

7879
const server = http.createServer((req, res) => {

src/validators/http.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface HttpValidatorKey {
99
export interface HttpValidatorOptions {
1010
keys: HttpValidatorKey[];
1111
issuer: string;
12+
audience?: string[];
1213
}
1314

1415
export interface HttpResponse {
@@ -31,6 +32,7 @@ export interface HttpResponse {
3132
* }
3233
* ],
3334
* issuer: 'eyevinn'
35+
* audience: ['one', 'two'] // Optional
3436
* });
3537
* const result = await httpValidator.validateHttpRequest(
3638
* request,
@@ -63,7 +65,8 @@ export class HttpValidator {
6365
try {
6466
await validator.validate(token, 'mac', {
6567
kid,
66-
issuer: this.opts.issuer
68+
issuer: this.opts.issuer,
69+
audience: this.opts.audience
6770
});
6871
return { status: 200 };
6972
} catch (err) {

0 commit comments

Comments
 (0)