refactor(auth): setup convenience for OAuth
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-20 01:25:46 +02:00
parent 0bb7074334
commit acde8b17e1
2 changed files with 41 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
pub use introspection::IntrospectionConfigClap;
use oauth::{OAuth, ZitadelConfig};
mod introspection;
mod oauth;
@@ -47,7 +48,16 @@ pub struct ZitadelClap {
pub token_url: Option<String>,
}
impl AuthClap {}
impl TryFrom<AuthClap> for OAuth {
type Error = anyhow::Error;
fn try_from(value: AuthClap) -> Result<Self, Self::Error> {
match value.engine {
AuthEngine::Noop => Ok(OAuth::new_noop()),
AuthEngine::Zitadel => Ok(OAuth::from(ZitadelConfig::try_from(value.zitadel)?)),
}
}
}
#[cfg(test)]
mod test {