Skip to main content

Module sso

Module sso 

Source
Available on crate feature sso only.
Expand description

OAuth 2.0 / OIDC SSO client support.

Enabled by the sso Cargo feature:

rust-web-server = { version = "17", features = ["sso"] }

§Quick start

use std::sync::Arc;
use rust_web_server::app::App;
use rust_web_server::core::New;
use rust_web_server::session::SessionStore;
use rust_web_server::sso::{OidcAuth, OidcConfig};

let sessions = Arc::new(SessionStore::new(86_400));
let config   = OidcConfig::google(
    "my-client-id",
    "my-client-secret",
    "https://example.com/auth/callback",
);
let app = App::new().wrap(OidcAuth::new(config, sessions));

§Module layout

Sub-modulePurpose
configOidcConfig + provider presets + from_env()
discoveryOidcProvider endpoints + hardcoded presets
jwksJwksCache, JWT RS256/ES256 verify, OidcClaims
pkcePkceVerifier, PkceChallenge, base64url
clientOidcClient: auth URL, token exchange, user info
oidc_authOidcAuth middleware
serverAuthServer — rws as its own OAuth 2.0 Authorization Server (sso-server feature)
client_storeClientStore / OAuthClient — clients registered with server::AuthServer (sso-server feature)
samlsaml::SamlSp — SAML 2.0 Service Provider (sso-saml feature)

Modules§

client
OIDC / OAuth 2.0 client — authorization URL builder, token exchange, and UserInfo fetch.
client_storesso-server
Registered OAuth 2.0 clients for super::server::AuthServer.
config
OIDC client configuration and provider presets.
discovery
OIDC provider discovery and hardcoded presets.
jwks
JSON Web Key Set (JWKS) cache and JWT verification.
oidc_auth
OidcAuth middleware — full OIDC / OAuth 2.0 authorization code flow with PKCE, session management, and claim injection.
pkce
PKCE (Proof Key for Code Exchange) helpers — RFC 7636.
samlsso-saml
SamlSp — a SAML 2.0 Service Provider middleware.
serversso-server
AuthServer — a minimal OAuth 2.0 Authorization Server / token issuer.

Structs§

AuthServer
A minimal OAuth 2.0 Authorization Server — see the module docs.
AuthServerConfig
Configuration for AuthServer.
ClientStore
In-memory registry of OAuthClients, looked up by client_id.
JwksCache
Thread-safe cache of public keys from a JWKS endpoint.
OAuthClient
A registered OAuth 2.0 client.
OidcAuth
OIDC / OAuth 2.0 authentication middleware.
OidcClaims
Standard OIDC claims extracted from an id_token or userinfo response.
OidcClient
A thin OIDC / OAuth 2.0 client that performs the authorization code flow.
OidcConfig
All parameters needed to perform an OIDC / OAuth 2.0 authorization flow.
OidcProvider
Endpoint URLs for an OIDC / OAuth 2.0 identity provider.
PkceChallenge
SHA-256 base64url challenge derived from the verifier.
PkceVerifier
Cryptographically random code verifier (43–128 base64url chars, per RFC 7636).
SignedIn
A signed-in user (OidcAuth::signed_in).
SsoError
An error produced by the SSO / OIDC flow.
TokenResponse
Result of a successful token-endpoint exchange.
VerifyOptions
Options for JWT verification.

Enums§

GrantType
An OAuth 2.0 grant type a registered client is authorized to use.