Skip to main content

Crate jiayang

Crate jiayang 

Source
Expand description

Verifies the identity token the edge sends your Jiayang Cloud app in X-Jiayang-Identity. X-Jiayang-Email and X-Jiayang-Role are for display only.

// Once, at startup: reads JIAYANG_APP_ID, JIAYANG_IDENTITY_ISSUER and JIAYANG_JWKS_URL.
let verifier = jiayang::Verifier::from_env()?;
// Per request (axum's `HeaderMap` is the same type):
let user = verifier.require_user(&headers).await?;
Ok(format!("hello {}", user.email.as_deref().unwrap_or(&user.sub)))

The platform sets all three variables. Without them from_env returns an error and nothing verifies.

A webhook delivery on a verified public path carries a token too, of its own kind: Verifier::require_webhook checks it, and Verifier::require_user refuses it.

Docs: https://jiayang.cloud/docs/sdks/rust/

Modules§

axum
axum, behind the axum feature.

Structs§

Config
What a token is checked against.
Forbidden
The caller is who they say they are, but not allowed to do this. Respond with 403.
KeySet
The edge’s public keys, cached for five minutes, with unknown-kid refetches limited to one per ten seconds.
Unauthorized
No valid identity for this app, so respond with 401.
User
A verified caller.
Verifier
Build once and share, since it caches the signing keys.
Webhook
A delivery whose signature the platform checked before it reached your app, on a public path with a verifier. Not a person: it has no email and no role.

Enums§

Kind
Who is calling: a person, or a script, an agent or a scheduled job.
Provider
Who signs a webhook the platform can check for you.
Role
What a caller may do with this app. Ordered: an owner can do what an editor can.

Constants§

IDENTITY_HEADER
The header the edge sends the identity token in.

Type Aliases§

Clock
Seconds since the epoch.
Fetch
Fetches the JWKS at a URL.
FetchFuture