DecaneDocs
VerificationVerifying tokens
Verification

Verifying tokens

Decane access tokens are ES256 JWTs. Verification checks the signature and expiry with zero clock tolerance and, when app_id is set, that the token’s project_id matches. It needs only a public key, which the client gets one of two ways.

Static verification key

Recommended for backends. Set your project’s ES256 public key (SPKI PEM, from the dashboard) and every check runs locally. A literal \n in the PEM is accepted, which helps with single-line env vars. A malformed key fails at build(), not on the first request.

rust
let decane = DecaneClient::builder()
    .app_id(app_id)
    .verification_key(std::env::var("DECANE_VERIFICATION_KEY")?)
    .build()?;

JWKS

Leave the key out and the client verifies against the key set Decane publishes at /.well-known/jwks.json. It is fetched on first use, cached for ten minutes, and refetched once when a signature fails, so a key rotation needs no redeploy.

rust
let decane = DecaneClient::builder().app_id(app_id).build()?;

Fail-closed checks

safe_verify_access_token returns Ok(None) for a token that cannot be trusted:

rust
let claims = match decane.safe_verify_access_token(token).await? {
    Some(claims) => claims,
    None => return Err(StatusCode::UNAUTHORIZED),
};
i

The ? still propagates a JWKS fetch failure as DecaneError::Api with ApiErrorCode::NetworkError, so an outage answers 500, not 401.

Verification is stateless

It checks signature, expiry and project, not Decane’s revocation list. A token revoked with revoke_access_token still verifies until it expires; backend calls such as get_addresses do honour revocation at once. For immediate sign-out on a sensitive route, make one of those calls as well.