Start to build init openid login
This commit is contained in:
geneit_backend
@ -2,7 +2,7 @@ use crate::constants::StaticConstraints;
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::models::{User, UserID};
|
||||
use crate::services::rate_limiter_service::RatedAction;
|
||||
use crate::services::{login_token_service, rate_limiter_service, users_service};
|
||||
use crate::services::{login_token_service, openid_service, rate_limiter_service, users_service};
|
||||
use actix_remote_ip::RemoteIP;
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
@ -227,3 +227,20 @@ async fn finish_login(user: &User) -> HttpResult {
|
||||
token: login_token_service::gen_new_token(user).await?,
|
||||
}))
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct StartOpenIDLoginQuery {
|
||||
provider: String,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
pub struct StartOpenIDLoginResponse {
|
||||
url: String,
|
||||
}
|
||||
|
||||
/// Start OpenID login
|
||||
pub async fn start_openid_login(ip: RemoteIP, req: web::Json<StartOpenIDLoginQuery>) -> HttpResult {
|
||||
let url = openid_service::start_login(&req.provider, ip.0).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(StartOpenIDLoginResponse { url }))
|
||||
}
|
||||
|
@ -8,13 +8,13 @@ pub async fn home() -> impl Responder {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
struct ServerConfig {
|
||||
struct ServerConfig<'a> {
|
||||
constraints: StaticConstraints,
|
||||
mail: &'static str,
|
||||
oidc_providers: Vec<OIDCProvider>,
|
||||
oidc_providers: Vec<OIDCProvider<'a>>,
|
||||
}
|
||||
|
||||
impl Default for ServerConfig {
|
||||
impl Default for ServerConfig<'_> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
mail: AppConfig::get().mail_sender.as_str(),
|
||||
|
Reference in New Issue
Block a user