openid
If you need "log in with Google/Keycloak/Azure/Okta" in a Rust service, this gives you the protocol and nothing else. You keep your web framework; you call the library from the handlers you already have.
What changes for you
- Discovery instead of configuration. Point it at the issuer and
the endpoints, keys and supported flows come from
/.well-known/openid-configuration. - PKCE on by default. The authorization-code flow is the safe one, and the library does not make you opt into it.
- Real token validation. ID tokens are validated against the provider's keys; userinfo is a call away.
- The awkward providers included. Azure/Microsoft needs issuer exceptions and has a feature for exactly that. UMA2 and token introspection are there too.
- Async, on reqwest. Works with the runtime and HTTP client you already use.
Getting it
cargo add openidRoughly the shape of it:
let client = DiscoveredClient::discover(client_id, client_secret, None, issuer).await?;
let (auth_url, _csrf) = client.auth_url(Default::default());
// ...the provider redirects back with a code...
let token = client.request_token(&code).await?;
let claims = client.id_token_claims(&token.id_token)?;