Skip to main content

Class: BasicStrategy

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

Implements an authentication strategy that performs basic id and password authentication. This strategy requires an existing user account to have already registered a valid password that will be validated. The strategy does not implement how that password is to be validated or stored.

Implements

  • AuthStrategy

Constructors

Constructor

new BasicStrategy(options?): BasicStrategy

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

Parameters

options?

BasicStrategyOptions = ...

Returns

BasicStrategy

Properties

name

readonly name: string = "basic"

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

The unique name of the strategy used to register with the AuthMiddleware.

Implementation of

AuthStrategy.name

Methods

authenticate()

authenticate(req, res, required?): Promise<AuthResult | undefined>

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

Attempts to perform authentication with the given request data. If authentication was successful, returns an AuthResult containing the authentication details. If authentication fails and required is set to true throws an error, otherwise returns undefined.

Parameters

req

HttpRequest

The request containing data to attempt authentication with.

res

HttpResponse

The response to use when writing back directly to the client.

required?

boolean

Set to true to if authentication is required to pass, otherwise set to false.

Returns

Promise<AuthResult | undefined>

Implementation of

AuthStrategy.authenticate


authenticateSync()

authenticateSync(req, res, required?): AuthResult | undefined

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

Attempts to perform authentication with the given request data. If authentication was successful, returns an AuthResult containing the authentication details. If authentication fails and required is set to true throws an error, otherwise returns undefined.

This is the synchronous version of authenticate that performs blocking based authentication.

Parameters

req

HttpRequest

The request containing data to attempt authentication with.

res

HttpResponse

The response to use when writing back directly to the client.

required?

boolean

Set to true to if authentication is required to pass, otherwise set to false.

Returns

AuthResult | undefined

Implementation of

AuthStrategy.authenticateSync