Skip to content

Commit

Permalink
Adds threedos config and jwt for e2e test (#828)
Browse files Browse the repository at this point in the history
* Adds threedos config and jwt for e2e test

* Updates threedos n parameter in the test vector file
  • Loading branch information
StefPler authored Sep 11, 2024
1 parent 781398d commit 501225e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 37 deletions.
1 change: 1 addition & 0 deletions fastcrypto-zkp/src/bn254/unit_tests/zk_login_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ async fn test_get_jwks() {
OIDCProvider::KarrierOne,
OIDCProvider::Credenza3,
OIDCProvider::Playtron,
OIDCProvider::Threedos,
] {
let res = fetch_jwks(&p, &client).await;
assert!(res.is_ok());
Expand Down
1 change: 1 addition & 0 deletions fastcrypto-zkp/src/bn254/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub fn get_oidc_url(
OIDCProvider::AwsTenant((region, tenant_id)) => format!("https://{}.auth.{}.amazoncognito.com/login?response_type=token&client_id={}&redirect_uri={}&nonce={}", tenant_id, region, client_id, redirect_url, nonce),
OIDCProvider::TestIssuer => return Err(FastCryptoError::InvalidInput), // Test issuer does not issue JWTs interactively, this is not valid to call.
OIDCProvider::Playtron => return Err(FastCryptoError::InvalidInput), // Playtron does not issue JWTs interactively, this is not valid to call.
OIDCProvider::Threedos => return Err(FastCryptoError::InvalidInput), // Threedos does not issue JWTs interactively yet, this is not valid to call.
})
}

Expand Down
9 changes: 9 additions & 0 deletions fastcrypto-zkp/src/bn254/zk_login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ pub enum OIDCProvider {
TestIssuer,
/// https://oauth2.playtron.one/.well-known/jwks.json
Playtron,
/// https://auth.3dos.io/.well-known/openid-configuration
Threedos,
}

impl FromStr for OIDCProvider {
Expand All @@ -131,6 +133,7 @@ impl FromStr for OIDCProvider {
"KarrierOne" => Ok(Self::KarrierOne),
"Credenza3" => Ok(Self::Credenza3),
"Playtron" => Ok(Self::Playtron),
"Threedos" => Ok(Self::Threedos),
_ => {
let re = Regex::new(
r"AwsTenant-region:(?P<region>[^.]+)-tenant_id:(?P<tenant_id>[^/]+)",
Expand Down Expand Up @@ -162,6 +165,7 @@ impl ToString for OIDCProvider {
Self::KarrierOne => "KarrierOne".to_string(),
Self::Credenza3 => "Credenza3".to_string(),
Self::Playtron => "Playtron".to_string(),
Self::Threedos => "Threedos".to_string(),
Self::AwsTenant((region, tenant_id)) => {
format!("AwsTenant-region:{}-tenant_id:{}", region, tenant_id)
}
Expand Down Expand Up @@ -223,6 +227,10 @@ impl OIDCProvider {
"https://oauth2.playtron.one",
"https://oauth2.playtron.one/.well-known/jwks.json",
),
OIDCProvider::Threedos => ProviderConfig::new(
"https://auth.3dos.io",
"https://auth.3dos.io/.well-known/jwks.json",
),
}
}

Expand All @@ -239,6 +247,7 @@ impl OIDCProvider {
"https://accounts.karrier.one/" => Ok(Self::KarrierOne),
"https://accounts.credenza3.com" => Ok(Self::Credenza3),
"https://oauth2.playtron.one" => Ok(Self::Playtron),
"https://auth.3dos.io" => Ok(Self::Threedos),
iss if match_micrsoft_iss_substring(iss) => Ok(Self::Microsoft),
_ => match parse_aws_iss_substring(iss) {
Ok((region, tenant_id)) => {
Expand Down
Loading

0 comments on commit 501225e

Please sign in to comment.