Interface FiefAuthParameters

Parameters to instantiate a FiefAuth helper class.

interface FiefAuthParameters {
    accessTokenHeaderName?: string;
    accessTokenInfoHeaderName?: string;
    apiForbiddenResponse?: ((req, res) => Promise<void>);
    apiUnauthorizedResponse?: ((req, res) => Promise<void>);
    client: Fief;
    forbiddenPath?: string;
    loginPath?: string;
    logoutPath?: string;
    logoutRedirectURI: string;
    redirectPath?: string;
    redirectURI: string;
    returnToCookieName?: string;
    returnToDefault?: string;
    sessionCookieName: string;
    userIdHeaderName?: string;
    userInfoCache?: IUserInfoCache;
}

Properties

accessTokenHeaderName?: string

Name of the request header where access token is made available by middleware.

Defaults to X-FiefAuth-Access-Token.

accessTokenInfoHeaderName?: string

Name of the request header where access token information is made available by middleware.

Defaults to X-FiefAuth-Access-Token-Info.

apiForbiddenResponse?: ((req, res) => Promise<void>)

Optional API handler for forbidden response.

The default handler will return a plain text response with status code 403.

Type declaration

    • (req, res): Promise<void>
    • Parameters

      • req: IncomingMessage
      • res: OutgoingMessage<IncomingMessage>

      Returns Promise<void>

apiUnauthorizedResponse?: ((req, res) => Promise<void>)

Optional API handler for unauthorized response.

The default handler will return a plain text response with status code 401.

Type declaration

    • (req, res): Promise<void>
    • Parameters

      • req: IncomingMessage
      • res: OutgoingMessage<IncomingMessage>

      Returns Promise<void>

client: Fief

Instance of a Fief client.

forbiddenPath?: string

Path of the page showing a forbidden error to the user.

This page will be shown when the user doesn't have the required scope or permissions.

Defaults to /forbidden.

loginPath?: string

Path to the login page.

Defaults to /login.

logoutPath?: string

Path to the logout page.

Defaults to /logout.

logoutRedirectURI: string

Absolute callback URI where the user will be redirected after Fief logout.

Example: http://localhost:3000

redirectPath?: string

Path to the callback page where the user will be redirected after Fief authentication.

Defaults to /auth-callback.

redirectURI: string

Absolute callback URI where the user will be redirected after Fief authentication.

Example: http://localhost:3000/auth-callback

returnToCookieName?: string

Name of the cookie that will keep the page the user was trying to access while unauthenticated.

It allows to automatically redirect the user to the page they were looking for after a successul authentication.

Defaults to return_to.

returnToDefault?: string

Path where the user will be redirected by default after a successfull authentication if there is not returnTo cookie.

Defaults to /.

sessionCookieName: string

Name of the cookie that will keep the session.

userIdHeaderName?: string

Name of the request header where authenticated user ID is made available by middleware.

Defaults to X-FiefAuth-User-Id.

userInfoCache?: IUserInfoCache

An instance of a IUserInfoCache class.