Skip to main content

Class: BasicStrategyOptions

Defined in: src/auth/BasicStrategy.ts:14

Describes the configuration options that can be used to initialize BasicStrategy.

Constructors

Constructor

new BasicStrategyOptions(): BasicStrategyOptions

Returns

BasicStrategyOptions

Properties

allowQueryParam

allowQueryParam: boolean = false

Defined in: src/auth/BasicStrategy.ts:26

Set to true to allow credentials to be supplied via the queryKey URL parameter. Disabled by default — query parameters appear in server logs, browser history, and Referer headers, which permanently exposes credentials outside the application.


headerKey

headerKey: string = "authorization"

Defined in: src/auth/BasicStrategy.ts:16

The name of the header to look for when performing header based authentication. Default value is Authorization.


headerScheme

headerScheme: string = "basic"

Defined in: src/auth/BasicStrategy.ts:18

The authorization scheme type when using header based authentication. Default value is jwt.


queryKey

queryKey: string = "auth_basic"

Defined in: src/auth/BasicStrategy.ts:20

The name of the request query parameter to retrieve the token from when using query based authentication. Default value is auth_basic.

Methods

checkRateLimit()?

optional checkRateLimit(identifier, req): Promise<void>

Defined in: src/auth/BasicStrategy.ts:32

Optional hook invoked with the claimed identifier before credentials are verified. Implementations should throw to reject the request once a caller-defined attempt threshold has been exceeded (see RateLimiter). A no-op when not provided.

Parameters

identifier

string

req

HttpRequest

Returns

Promise<void>


checkRateLimitSync()?

optional checkRateLimitSync(identifier, req): void

Defined in: src/auth/BasicStrategy.ts:42

The synchronous counterpart to checkRateLimit, invoked with the claimed identifier before verifySync runs. This exists because authenticateSync/verifySync are used from contexts (e.g. a WebSocket upgrade handshake) that cannot await a promise, so the normal Redis/async-backed RateLimiter can't be used here — implementations that supply verifySync should also supply this hook (e.g. backed by an in-memory counter) if brute-force protection is required on this path. Implementations should throw to reject the request once an attempt threshold has been exceeded. A no-op when not provided.

Parameters

identifier

string

req

HttpRequest

Returns

void


verify()

verify(uid, secret): JWTUser | Promise<JWTUser | undefined> | undefined

Defined in: src/auth/BasicStrategy.ts:44

Override this function to handle asynchronous (non-blocking) verification of the login info.

Parameters

uid

string

secret

string

Returns

JWTUser | Promise<JWTUser | undefined> | undefined


verifySync()

verifySync(uid, secret): JWTUser | undefined

Defined in: src/auth/BasicStrategy.ts:48

Override this function to handle synchronous (blocking) verification of the login info.

Parameters

uid

string

secret

string

Returns

JWTUser | undefined