Skip to content

Renewal

The middleware that renews the access token on the way through, and the steps it is made of.

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

RenewalMiddleware

RenewalMiddleware(get_response: Any)

Renews the access cookie in place, before any view reads it - sync or async.

renew

renew(request: HttpRequest) -> Outcome

What this request's session needs: a new access token, to be cleared, or nothing.

Nothing when there is no refresh cookie - a client signed in by header never had one, and clearing would delete cookies it never set - or when the access token is still good.

settle

settle(outcome: Outcome, response: HttpResponseBase) -> Renewed | Over | None

Put the outcome on response - unless the view already set the session itself.

Answers the outcome that reached the response, or None when nothing did.

announcement

announcement(outcome: Renewed | Over) -> tuple[Signal, dict[str, Any]]

The signal an outcome that reached the response is told by, and what it carries.

Renewed dataclass

Renewed(access: str, lifetime: timedelta, person: Any)

A new access token for person, and how long its cookie may last.

Over dataclass

Over(reason: Ended, person: Any = None)

The session is over: clear both cookies on the way out.