Skip to main content

Interface: AuthStrategy

Defined in: service-core/src/auth/AuthStrategy.ts:29

Describes an interface for implementing strategies that will perform authentication.

Properties

name

readonly name: string

Defined in: service-core/src/auth/AuthStrategy.ts:31

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

Methods

authenticate()

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

Defined in: service-core/src/auth/AuthStrategy.ts:42

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>


authenticateSync()

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

Defined in: service-core/src/auth/AuthStrategy.ts:55

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