Skip to content

Commit

Permalink
chore: add playtron config (#823)
Browse files Browse the repository at this point in the history
* chore: add playtron config

* fix typo

* add test
  • Loading branch information
joyqvq authored Aug 28, 2024
1 parent bd4999b commit ab408eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
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 @@ -443,6 +443,7 @@ async fn test_get_jwks() {
OIDCProvider::AwsTenant(("us-east-1".to_string(), "us-east-1_qPsZxYqd8".to_string())),
OIDCProvider::KarrierOne,
OIDCProvider::Credenza3,
OIDCProvider::Playtron,
] {
let res = fetch_jwks(&p, &client).await;
assert!(res.is_ok());
Expand Down
3 changes: 2 additions & 1 deletion fastcrypto-zkp/src/bn254/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ pub fn get_oidc_url(
OIDCProvider::Credenza3 => format!("https://accounts.credenza3.com/oauth2/authorize?client_id={}&response_type=token&scope=openid+profile+email+phone&redirect_uri={}&nonce={}&state=state", client_id, redirect_url, nonce),
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.
})
}

/// Return the token exchange URL for the given auth code.
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 @@ -109,6 +109,8 @@ pub enum OIDCProvider {
Credenza3,
/// This is a test issuer that will return a JWT non-interactively.
TestIssuer,
/// https://oauth2.playtron.one/.well-known/jwks.json
Playtron,
}

impl FromStr for OIDCProvider {
Expand All @@ -126,6 +128,7 @@ impl FromStr for OIDCProvider {
"Microsoft" => Ok(Self::Microsoft),
"KarrierOne" => Ok(Self::KarrierOne),
"Credenza3" => Ok(Self::Credenza3),
"Playtron" => Ok(Self::Playtron),
_ => {
let re = Regex::new(
r"AwsTenant-region:(?P<region>[^.]+)-tenant_id:(?P<tenant_id>[^/]+)",
Expand Down Expand Up @@ -156,6 +159,7 @@ impl ToString for OIDCProvider {
Self::Microsoft => "Microsoft".to_string(),
Self::KarrierOne => "KarrierOne".to_string(),
Self::Credenza3 => "Credenza3".to_string(),
Self::Playtron => "Playtron".to_string(),
Self::AwsTenant((region, tenant_id)) => {
format!("AwsTenant-region:{}-tenant_id:{}", region, tenant_id)
}
Expand Down Expand Up @@ -213,6 +217,10 @@ impl OIDCProvider {
"https://oauth.sui.io",
"https://jwt-tester.mystenlabs.com/.well-known/jwks.json",
),
OIDCProvider::Playtron => ProviderConfig::new(
"https://oauth2.playtron.one",
"https://oauth2.playtron.one/.well-known/jwks.json",
),
}
}

Expand All @@ -228,6 +236,7 @@ impl OIDCProvider {
"https://oauth.sui.io" => Ok(Self::TestIssuer),
"https://accounts.karrier.one/" => Ok(Self::KarrierOne),
"https://accounts.credenza3.com" => Ok(Self::Credenza3),
"https://oauth2.playtron.one" => Ok(Self::Playtron),
iss if match_micrsoft_iss_substring(iss) => Ok(Self::Microsoft),
_ => match parse_aws_iss_substring(iss) {
Ok((region, tenant_id)) => {
Expand Down

0 comments on commit ab408eb

Please sign in to comment.