kilork.github.io

openid

OpenID Connect and Discovery for Rust services.

Browser, your service and the identity provider, with the code and token arrows

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

Getting it

cargo add openid

Roughly 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)?;

Where to look

source · crate · docs · examples