Expand description
Sign people in to a Rust backend through a Ruscker portal.
The portal is an OpenID Connect provider with a narrow profile:
authorization code flow, PKCE S256, a confidential client, ID tokens
signed with ES256. This crate is pre-set for exactly that profile so an
integration is three calls:
Client::discoveronce at startup;Client::start_sign_inin the “sign in” route — redirect the browser to the URL and keep thePendingvalue until it returns;Client::finish_sign_inin the callback route — it returns the verifiedIdentity, from which the application issues its own session.
No cryptography is implemented here: signatures are checked by
jsonwebtoken against the provider’s published keys, randomness comes
from the operating system (getrandom), and the PKCE hash from sha2.
Two address builders complete it: Client::sign_out_url (the
portal’s sign-out page, after the application ended its own session)
and Client::password_change_url (the portal’s “change your
password” page).
What the crate deliberately does not do: sessions (the portal’s tokens
live five minutes and there is no refresh — re-run a sign-in with
SignInOptions::prompt "none" to notice that the portal session
ended), back-channel logout, and deciding what groups and roles mean
inside the application.
Structs§
- Client
- A client for one registered system. Cheap to clone (it is an
Arcinside), so put it in the application’s shared state. - Config
- What the portal’s administrator gives the system’s developers.
- Identity
- Who signed in, taken from the verified ID token.
- Pending
- The three values to keep between
Client::start_sign_inandClient::finish_sign_in, bound to the person’s browser. - Sign
InOptions - Options for
Client::start_sign_in_with. The default is whatClient::start_sign_insends. - Sign
OutOptions - Options for
Client::sign_out_url; every field is optional and is left out of the address whenNone. - Token
Response - The token endpoint’s answer. Only the ID token is used; the access
token is valid five minutes and only at
/oauth/userinfo.
Enums§
- Error
- Why a sign-in (or the discovery) failed.
Constants§
- DEFAULT_
SCOPES - The scopes asked for when
Config::scopesis not called: every claim the provider offers. - MAX_
SIGN_ OUT_ STATE_ LEN - The longest
stateClient::sign_out_urlaccepts, in characters (the same limit in every package; the portal refuses longer ones).