gws.plugin.auth_method.token

HTTP token authentication method.

The client passes a token in an HTTP header. The method reads the configured header, checks the optional prefix and passes the token to the authentication providers as token credentials. For an authenticated user, the token is stored in user.authToken and a transient session is opened. No cookie is set.

The prefix is compared case-insensitively. Without a prefix, the header value must be the token alone.

Example:

auth.methods+ {
    type "token"
    header "X-My-Auth"
    prefix "Bearer"
}

With this configuration, the application expects a header like X-My-Auth: Bearer <token>.

Source code: gws.plugin.auth_method.token

Package Contents

class gws.plugin.auth_method.token.Config

Bases: gws.base.auth.method.Config

Authentication with a token passed in an HTTP header.

header: str

HTTP header that carries the token.

prefix: str = ''

Prefix expected before the token in the header value.

class gws.plugin.auth_method.token.Object

Bases: gws.base.auth.method.Object

HTTP token authentication method.

header: str

Name of the HTTP header that carries the token.

prefix: str

Prefix expected before the token, empty if none.

configure()
open_session(req)