ramosbugs / openidconnect-rs

OpenID Connect Library for Rust
MIT License
427 stars 103 forks source link

add a Sync for CoreRsaPrivateSigningKey::rng #97

Closed zmlgit closed 1 year ago

zmlgit commented 1 year ago

I'm writing an openid provider with axum, need CoreRsaPrivateSigningKey's instance be sharable,but CoreRsaPrivateSigningKey::rng is !Sync, I only give a Sync marker for this field,then my code can go pass.

lazy_static::lazy_static! {
    pub static ref RSA_KEY:Arc<CoreRsaPrivateSigningKey> = get_rsa_key();
}
fn get_rsa_key() -> Arc<CoreRsaPrivateSigningKey> {
    let pem = std::env::var("JWK_RSA_PRI_PEM").expect("can't read the JWK_RSA_PRI_PEM env var");
    let rsa_pem_file = File::open(pem).expect("can't open the JWK_RSA_PRI_PEM file");
    let mut rsa_pem_reader = std::io::BufReader::new(rsa_pem_file);
    let mut rsa_pem = String::new();
    rsa_pem_reader
        .read_to_string(&mut rsa_pem)
        .expect("can't read the JWK_RSA_PRI_PEM file");

    let rsa_sign_key =
        CoreRsaPrivateSigningKey::from_pem(&rsa_pem, Some(JsonWebKeyId::new("key1".to_string())))
            .expect("can't parse the JWK_RSA_PRI_PEM file");
    Arc::new(rsa_sign_key)
}
codecov[bot] commented 1 year ago

Codecov Report

Merging #97 (da84d75) into main (f3dedb3) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #97   +/-   ##
=======================================
  Coverage   72.46%   72.46%           
=======================================
  Files          16       16           
  Lines        3792     3792           
=======================================
  Hits         2748     2748           
  Misses       1044     1044           
Impacted Files Coverage Δ
src/core/jwk.rs 90.80% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

ramosbugs commented 1 year ago

Looks like I already made the same change in bc09d22afc140e1d2d6caf8756dda4a17cc991fa, which is part of the 3.0.0-alpha.1 release.