gws.plugin.qfieldcloud.auth

Token authorization method for QField clients.

Source code: gws.plugin.qfieldcloud.auth

Module Contents

class gws.plugin.qfieldcloud.auth.Config

Bases: gws.base.auth.method.Config

Token authentication for QField clients.

class gws.plugin.qfieldcloud.auth.Object

Bases: gws.base.auth.method.Object

QField Cloud authorization method.

Token authorization for QField clients. The qfieldcloud action creates sessions with this method on login and accepts only tokens of its sessions.

authenticate_from_credentials(credentials: gws.Data, req: gws.WebRequester) → Result

Authenticate a user by username and password and create a session.

Parameters:
  • credentials – Data with username and password.

  • req – Web request.

Returns:

Authentication result with the new session and its expiry time.

Raises:

gws.AuthenticationError – If the credentials are invalid.

authenticate_from_token(req: gws.WebRequester) → Result

Authenticate a request by the Authorization: Token ... header and touch the session.

Parameters:

req – Web request.

Returns:

Authentication result with the existing session and its new expiry time.

Raises:
  • gws.AuthenticationError – If the header is missing, or the token is invalid or belongs to another method.

  • gws.ForbiddenError – If the method cannot be used in this context, e.g. without a secure connection.

configure()
class gws.plugin.qfieldcloud.auth.Result

Bases: gws.Data

Result of a successful authentication.

expiresAt: datetime.datetime

Expiry time of the session.

sess: gws.AuthSession

Session of the user.

token: str

Session token, sent by QField in the Authorization header.

user: gws.User

Authenticated user.