quart_auth package

Module contents

class quart_auth.Action(value)

Bases: enum.Enum

An enumeration.

PASS = 2
class quart_auth.AuthManager(app: Optional[quart.app.Quart] = None)

Bases: object

after_request(response: quart.wrappers.response.Response) → quart.wrappers.response.Response
init_app(app: quart.app.Quart) → None

alias of AuthUser

class quart_auth.AuthUser(auth_id: Optional[str])

Bases: object

A base class for users.

Any specific user implementation used with Quart-Auth should inherit from this.

property auth_id
property is_authenticated
exception quart_auth.Unauthorized(status: Optional[http.HTTPStatus] = None)

Bases: quart.exceptions.Unauthorized

quart_auth.login_required(func: Callable) → Callable

A decorator to restrict route access to authenticated users.

This should be used to wrap a route handler (or view function) to enforce that only authenticated requests can access it. Note that it is important that this decorator be wrapped by the route decorator and not vice, versa, as below.

async def index():

If the request is not authenticated a quart.exceptions.Unauthorized exception will be raised.

quart_auth.login_user(user: quart_auth.AuthUser, remember: bool = False) → None

Use this to start a session with the authenticated user.

This will result in current_user resolving to the user.

  • user – The user to consider authenticated and to start a session for.

  • remember – If True write consider the session permanent with a duration equal to the QUART_AUTH_DURATION configuration value.

quart_auth.logout_user() → None

Use this to end the session of the current_user.

quart_auth.renew_login() → None

Use this to renew the cookie (a new max age).