Skip to content

Views

Refreshing a session, ending it, and handing the CSRF token to a frontend on another site.

Read from the code itself, so it never falls behind it. The descriptions are the code's own, in English.

RefreshView

Bases: APIView

A new pair for the refresh token presented, which is blacklisted.

SignOutView

Bases: APIView

The refresh token presented is blacklisted, and both cookies cleared.

CsrfTokenView

Bases: APIView

GET: the CSRF token, for a frontend on another site, which cannot read the API's cookie.

Only needed with CSRF = True. The answer is {"csrf_token": "..."}, and the CSRF cookie it belongs with is set on the same response.

enforce_csrf

enforce_csrf(request: Any) -> None

Refuse request with 403 when the CSRF mode is on and its token is missing or wrong.

presented

presented(request: Request) -> tuple[str, bool]

The refresh token this request presents, and whether it came in the cookie.

readable

readable(raw: str) -> RefreshToken | None

raw as a refresh token still good - not expired, garbled or blacklisted.

blacklist

blacklist(refresh: RefreshToken) -> None

Blacklist refresh - when the project runs the blacklist at all.