#oidc

oidc_verify

A simple-usage OIDC-RS256 token verifier. It works without authorization_endpoint field, such as Firebase Auth.

4 releases

0.2.0 Aug 25, 2024
0.1.2 Aug 24, 2024
0.1.1 Aug 24, 2024
0.1.0 Aug 24, 2024

#782 in Authentication

Download history 283/week @ 2024-08-21 15/week @ 2024-08-28 16/week @ 2024-09-11 8/week @ 2024-09-18 9/week @ 2024-09-25 1/week @ 2024-10-02 1/week @ 2024-10-09

110 downloads per month

Apache-2.0

12KB
182 lines

oidc_verify

Crates.io Crates.io License

This is a simple library to verify the JWT token of RS256 received from the OIDC provider. This works without It works without authorization_endpoint field, such as Firebase Auth.

Dependencies

This library depends on tokio as an async runtime, so your project should select tokio as an async runtime too.

Usage

use oidc_verify::prelude::*;
use serde_json::Value;

#[tokio::main]
async fn main() {
    let verifier = Verifier::new("https://securetoken.google.com/hogehoge-fugafuga/");

    let token = "Bearer 3x4mple.t0k3n".strip_prefix("Bearer ").unwrap();

    match verifier.verify::<Value>(token).await {
        Ok(claims) => {
            println!("Claims: {}", serde_json::to_string_pretty(&claims).unwrap());
        },
        Err(err) => {
            println!("Error: {:?}", err);
        },
    }
}

License

Apache 2.0

Dependencies

~10–17MB
~230K SLoC