Options
All
  • Public
  • Public/Protected
  • All
Menu
description

This trait implements a passport strategy that refreshes a user's expired access tokens using JwT tokens that are attached to the HTTP request using a Bearer token header.

todo

Investigate whether a PEM-encoded public key makes more sense for signing tokens in production environments.

since

v0.3.0

Hierarchy

  • Strategy<this>
    • RefreshStrategy

Index

Constructors

Properties

name: string

Methods

  • authenticate(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, options?: any): void
  • Performs authentication for the request. Note: Virtual function - re-implement in the strategy.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

      The request to authenticate.

    • Optional options: any

      Options passed to the strategy.

    Returns void

  • error(err: Error): void
  • Internal error while performing authentication.

    Strategies should call this function when an internal error occurs during the process of performing authentication; for example, if the user directory is not available.

    api

    public

    Parameters

    • err: Error

    Returns void

  • fail(challenge: any, status: number): void
  • fail(status: number): void
  • Fail authentication, with optional challenge and status, defaulting to 401.

    Strategies should call this function to fail an authentication attempt.

    api

    public

    Parameters

    • challenge: any

      (Can also be an object with 'message' and 'type' fields).

    • status: number

    Returns void

  • Parameters

    • status: number

    Returns void

  • pass(): void
  • Pass without making a success or fail decision.

    Under most circumstances, Strategies should not need to call this function. It exists primarily to allow previous authentication state to be restored, for example from an HTTP session.

    api

    public

    Returns void

  • redirect(url: string, status?: number): void
  • Redirect to url with optional status, defaulting to 302.

    Strategies should call this function to redirect the user (via their user agent) to a third-party website for authentication.

    api

    public

    Parameters

    • url: string
    • Optional status: number

    Returns void

  • success(user: any, info?: any): void
  • Authenticate user, with optional info.

    Strategies should call this function to successfully authenticate a user. user should be an object supplied by the application after it has been given an opportunity to verify credentials. info is an optional argument containing additional user information. This is useful for third-party authentication strategies to pass profile details.

    api

    public

    Parameters

    • user: any
    • Optional info: any

    Returns void

  • validate(request: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, payload: Record<string, any>): Promise<AuthenticationPayload>
  • This method is called internally by Passport after having validated a JwT token and is used merely to decode the data of an already authenticated user.

    This method is guaranteed to receive a valid token that has been previously signed and issued to a valid user.

    Parameters

    • request: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • payload: Record<string, any>

      The valid token JSON object.

    Returns Promise<AuthenticationPayload>

Generated using TypeDoc