Skip to main content

Crate ruscker_sso

Crate ruscker_sso 

Source
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:

  1. Client::discover once at startup;
  2. Client::start_sign_in in the “sign in” route — redirect the browser to the URL and keep the Pending value until it returns;
  3. Client::finish_sign_in in the callback route — it returns the verified Identity, 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 Arc inside), 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_in and Client::finish_sign_in, bound to the person’s browser.
SignInOptions
Options for Client::start_sign_in_with. The default is what Client::start_sign_in sends.
SignOutOptions
Options for Client::sign_out_url; every field is optional and is left out of the address when None.
TokenResponse
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::scopes is not called: every claim the provider offers.
MAX_SIGN_OUT_STATE_LEN
The longest state Client::sign_out_url accepts, in characters (the same limit in every package; the portal refuses longer ones).