feat: with actual return url
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-11-01 21:57:33 +01:00
parent 8711fc2a7b
commit c46bd34e16
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -7,7 +7,7 @@ use oauth2::url::Url;
use crate::{ use crate::{
introspection::IntrospectionService, introspection::IntrospectionService,
login::{auth_clap::AuthEngine, AuthClap}, login::{auth_clap::AuthEngine, config::ConfigClap, AuthClap},
oauth::{zitadel::ZitadelConfig, OAuth}, oauth::{zitadel::ZitadelConfig, OAuth},
session::{SessionService, User}, session::{SessionService, User},
}; };
@ -32,8 +32,12 @@ impl AuthService {
let oauth: OAuth = ZitadelConfig::try_from(config.zitadel.clone())?.into(); let oauth: OAuth = ZitadelConfig::try_from(config.zitadel.clone())?.into();
let introspection: IntrospectionService = let introspection: IntrospectionService =
IntrospectionService::new_zitadel(config).await?; IntrospectionService::new_zitadel(config).await?;
Ok(Self::new_zitadel(
Ok(Self::new_zitadel(oauth, introspection, session)) oauth,
introspection,
session,
&config.config,
))
} }
} }
} }
@ -42,11 +46,13 @@ impl AuthService {
oauth: OAuth, oauth: OAuth,
introspection: IntrospectionService, introspection: IntrospectionService,
session: SessionService, session: SessionService,
config: &ConfigClap,
) -> Self { ) -> Self {
Self(Arc::new(ZitadelAuthService { Self(Arc::new(ZitadelAuthService {
oauth, oauth,
introspection, introspection,
session, session,
config: config.clone(),
})) }))
} }
@ -67,6 +73,7 @@ pub struct ZitadelAuthService {
oauth: OAuth, oauth: OAuth,
introspection: IntrospectionService, introspection: IntrospectionService,
session: SessionService, session: SessionService,
config: ConfigClap,
} }
pub static COOKIE_NAME: &str = "SESSION"; pub static COOKIE_NAME: &str = "SESSION";
@ -89,7 +96,7 @@ impl Auth for ZitadelAuthService {
Ok(( Ok((
headers, headers,
Url::parse("http://localhost:3001/authed") Url::parse(&self.config.return_url)
.context("failed to parse login_authorized zitadel return url")?, .context("failed to parse login_authorized zitadel return url")?,
)) ))
} }