Skip to content

Commit 49cb0e6

Browse files
committed
authenticator docs
1 parent 7a9bf3d commit 49cb0e6

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/auth/Authenticator.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
import {Request} from "../Request.js";
22
import {Authorisation} from "./Authorisation.js";
33

4+
/**
5+
* Handles authentication for requests.
6+
*/
47
export interface Authenticator<A extends any> {
5-
authenticate(request: Request<A>): Promise<Authorisation<A> | null>;
6-
8+
/**
9+
* Check whether this can handle authentication for the given request. The authenticator should return `false` if
10+
* the request lacks the information required to begin authentication.
11+
* @param request
12+
*/
713
canAuthenticate(request: Request<A>): boolean;
14+
15+
/**
16+
* Authenticate the given request. If authenticate fails, e.g. due to missing or invalid information, such as
17+
* credentials, the authenticator should return `null`, which can be communicated to the client by implementing
18+
* applications using a 401 status response.
19+
* @param request
20+
*/
21+
authenticate(request: Request<A>): Promise<Authorisation<A> | null>;
822
}

0 commit comments

Comments
 (0)