gws.base.auth.provider

Base authentication provider.

Source code: gws.base.auth.provider

Module Contents

class gws.base.auth.provider.Config(*args, **kwargs)

Bases: gws.Config

Auth provider config.

allowedMethods: list[str] | None

Authentication methods this provider accepts.

class gws.base.auth.provider.Object

Bases: gws.AuthProvider

Base authentication provider.

Reads the allowedMethods option and serializes users as JSON of all their fields, roles, attributes and data. Subclasses implement authentication and user lookup; the default authenticate returns no user.

authenticate(method, credentials)

Authenticate a user.

Parameters:
  • method – The authentication method.

  • credentials – The credentials, for example username and password.

Returns:

The user, or None if the provider does not know the user.

Raises:

AuthenticationError – If the credentials are wrong or match more than one user.

configure()

Configuration hook.

Called when the node is initialized. Raising an exception here aborts the creation of the node.

serialize_user(user)

Serialize a user to a string.

Parameters:

user – The user.

Returns:

The serialized user.

unserialize_user(data)

Restore a user serialized by serialize_user.

Parameters:

ser – The serialized user.

Returns:

The user, or None if it cannot be restored.