Skip to content

Commit

Permalink
Add FanTV's OIDC provider on Zklogin (#830)
Browse files Browse the repository at this point in the history
* Add FanTV's OIDC provider on Zklogin

* Remove irrelevant comment.

* Add FanTV as OIDC provider.

* Remove comments & Add comments
  • Loading branch information
devan-ko authored Sep 13, 2024
1 parent ba4d3e7 commit 54c060e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 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 @@ -446,6 +446,7 @@ async fn test_get_jwks() {
OIDCProvider::Playtron,
OIDCProvider::Threedos,
OIDCProvider::Onefc,
OIDCProvider::FanTV,
] {
let res = fetch_jwks(&p, &client).await;
assert!(res.is_ok());
Expand Down
3 changes: 3 additions & 0 deletions fastcrypto-zkp/src/bn254/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ pub fn get_oidc_url(
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.
// FanTV case can call the following url to get the Token:
// https://fantv-apis.fantiger.com/v1/oauth2/auth?clientId={}&redirectUri={}&responseType=authorization_code&scope=openid&userId={}&nonce={}
OIDCProvider::FanTV => return Err(FastCryptoError::InvalidInput), // FanTV 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 @@ -117,6 +117,8 @@ pub enum OIDCProvider {
Threedos,
/// https://login.onepassport.onefc.com/de3ee5c1-5644-4113-922d-e8336569a462/b2c_1a_prod_signupsignin_onesuizklogin/v2.0/.well-known/openid-configuration
Onefc,
/// https://accounts.fantv.world/.well-known/openid-configuration
FanTV,
}

impl FromStr for OIDCProvider {
Expand All @@ -137,6 +139,7 @@ impl FromStr for OIDCProvider {
"Playtron" => Ok(Self::Playtron),
"Threedos" => Ok(Self::Threedos),
"Onefc" => Ok(Self::Onefc),
"FanTV" => Ok(Self::FanTV),
_ => {
let re = Regex::new(
r"AwsTenant-region:(?P<region>[^.]+)-tenant_id:(?P<tenant_id>[^/]+)",
Expand Down Expand Up @@ -170,6 +173,7 @@ impl ToString for OIDCProvider {
Self::Playtron => "Playtron".to_string(),
Self::Threedos => "Threedos".to_string(),
Self::Onefc => "Onefc".to_string(),
Self::FanTV => "FanTV".to_string(),
Self::AwsTenant((region, tenant_id)) => {
format!("AwsTenant-region:{}-tenant_id:{}", region, tenant_id)
}
Expand Down Expand Up @@ -239,6 +243,10 @@ impl OIDCProvider {
"https://login.onepassport.onefc.com/de3ee5c1-5644-4113-922d-e8336569a462/v2.0/",
"https://login.onepassport.onefc.com/de3ee5c1-5644-4113-922d-e8336569a462/b2c_1a_prod_signupsignin_onesuizklogin/discovery/v2.0/keys",
),
OIDCProvider::FanTV => ProviderConfig::new(
"https://accounts.fantv.world/",
"https://fantv-apis.fantiger.com/v1/web3/jwks.json",
),
}
}

Expand All @@ -259,6 +267,7 @@ impl OIDCProvider {
"https://login.onepassport.onefc.com/de3ee5c1-5644-4113-922d-e8336569a462/v2.0/" => {
Ok(Self::Onefc)
}
"https://accounts.fantv.world/" => Ok(Self::FanTV),
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 54c060e

Please sign in to comment.