Crate git_oidc

Source
Expand description

§git-oidc

git-oidc is a library for validating GitHub OIDC tokens.

§Features

  • Fetch JWKS from GitHub’s OIDC provider
  • Validate GitHub OIDC tokens
  • Check token claims against expected values

§Usage

use git_oidc::{fetch_jwks, validate_github_token};
use std::sync::Arc;
use tokio::sync::RwLock;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let jwks = fetch_jwks("https://token.actions.githubusercontent.com").await?;
    let jwks = Arc::new(RwLock::new(jwks));
     
    let token = "your_github_oidc_token";
    let expected_audience = "your_expected_audience";
     
    let claims = validate_github_token(token, jwks, expected_audience).await?;
    println!("Validated claims: {:?}", claims);
     
    Ok(())
}

Structs§

GitHubClaims

Functions§

fetch_jwks
Fetches the JSON Web Key Set (JWKS) from the specified OIDC provider URL.
validate_github_token
Validates a GitHub OIDC token against the provided JSON Web Key Set (JWKS) and expected audience.