Generate & return webauthn registration challenge

This commit is contained in:
2022-04-20 21:06:53 +02:00
parent 10982190e7
commit 1f0e6d05c8
11 changed files with 336 additions and 4 deletions

View File

@ -1,3 +1,5 @@
use std::sync::Arc;
use actix::Actor;
use actix_identity::{CookieIdentityPolicy, IdentityService};
use actix_web::{App, get, HttpResponse, HttpServer, web};
@ -17,6 +19,7 @@ use basic_oidc::data::client::ClientManager;
use basic_oidc::data::entity_manager::EntityManager;
use basic_oidc::data::jwt_signer::JWTSigner;
use basic_oidc::data::user::{hash_password, User};
use basic_oidc::data::webauthn_manager::WebAuthManager;
use basic_oidc::middlewares::auth_middleware::AuthMiddleware;
#[get("/health")]
@ -68,6 +71,7 @@ async fn main() -> std::io::Result<()> {
let openid_sessions_actor = OpenIDSessionsActor::default().start();
let jwt_signer = JWTSigner::gen_from_memory()
.expect("Failed to generate JWKS key");
let webauthn_manager = Arc::new(WebAuthManager::init(&config));
log::info!("Server will listen on {}", config.listen_address);
let listen_address = config.listen_address.to_string();
@ -91,6 +95,7 @@ async fn main() -> std::io::Result<()> {
.app_data(web::Data::new(config.clone()))
.app_data(web::Data::new(clients))
.app_data(web::Data::new(jwt_signer.clone()))
.app_data(web::Data::new(webauthn_manager.clone()))
.wrap(Logger::default())
.wrap(AuthMiddleware {})
@ -124,6 +129,7 @@ async fn main() -> std::io::Result<()> {
.route("/settings/change_password", web::post().to(settings_controller::change_password_route))
.route("/settings/two_factors", web::get().to(two_factors_controller::two_factors_route))
.route("/settings/two_factors/add_totp", web::get().to(two_factors_controller::add_totp_factor_route))
.route("/settings/two_factors/add_webauthn", web::get().to(two_factors_controller::add_webauthn_factor_route))
// User API
.route("/settings/api/two_factor/save_totp_factor", web::post().to(two_factor_api::save_totp_factor))