Add users authentication routes
This commit is contained in:
@@ -5,7 +5,8 @@ use actix_session::storage::RedisSessionStore;
|
||||
use actix_web::cookie::Key;
|
||||
use actix_web::{App, HttpServer, web};
|
||||
use matrixgw_backend::app_config::AppConfig;
|
||||
use matrixgw_backend::controllers::server_controller;
|
||||
use matrixgw_backend::controllers::{auth_controller, server_controller};
|
||||
use matrixgw_backend::users::User;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
@@ -17,6 +18,13 @@ async fn main() -> std::io::Result<()> {
|
||||
.await
|
||||
.expect("Failed to connect to Redis!");
|
||||
|
||||
// Auto create default account, if requested
|
||||
if let Some(mail) = &AppConfig::get().unsecure_auto_login_email() {
|
||||
User::create_or_update_user(mail, "Anonymous")
|
||||
.await
|
||||
.expect("Failed to create auto-login account!");
|
||||
}
|
||||
|
||||
log::info!(
|
||||
"Starting to listen on {} for {}",
|
||||
AppConfig::get().listen_address,
|
||||
@@ -40,6 +48,20 @@ async fn main() -> std::io::Result<()> {
|
||||
"/api/server/config",
|
||||
web::get().to(server_controller::config),
|
||||
)
|
||||
// Auth controller
|
||||
.route(
|
||||
"/api/auth/start_oidc",
|
||||
web::get().to(auth_controller::start_oidc),
|
||||
)
|
||||
.route(
|
||||
"/api/auth/finish_oidc",
|
||||
web::post().to(auth_controller::finish_oidc),
|
||||
)
|
||||
.route("/api/auth/info", web::get().to(auth_controller::auth_info))
|
||||
.route(
|
||||
"/api/auth/sign_out",
|
||||
web::get().to(auth_controller::sign_out),
|
||||
)
|
||||
})
|
||||
.workers(4)
|
||||
.bind(&AppConfig::get().listen_address)?
|
||||
|
||||
Reference in New Issue
Block a user