Managed to load server configuration from WebUI
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
use actix_cors::Cors;
|
||||
use actix_identity::config::LogoutBehaviour;
|
||||
use actix_identity::IdentityMiddleware;
|
||||
use actix_remote_ip::RemoteIPConfig;
|
||||
@ -9,9 +10,9 @@ use actix_web::web::Data;
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use light_openid::basic_state_manager::BasicStateManager;
|
||||
use remote_backend::app_config::AppConfig;
|
||||
use remote_backend::controllers::auth_controller;
|
||||
use remote_backend::constants;
|
||||
use remote_backend::controllers::{auth_controller, server_controller};
|
||||
use remote_backend::middlewares::auth_middleware::AuthChecker;
|
||||
use remote_backend::{constants, virtweb_client};
|
||||
use std::time::Duration;
|
||||
|
||||
#[actix_web::main]
|
||||
@ -40,15 +41,28 @@ async fn main() -> std::io::Result<()> {
|
||||
.login_deadline(Some(Duration::from_secs(constants::MAX_SESSION_DURATION)))
|
||||
.build();
|
||||
|
||||
let cors = Cors::default()
|
||||
.allowed_origin(&AppConfig::get().website_origin)
|
||||
.allowed_methods(vec!["GET", "POST", "PUT", "PATCH", "DELETE"])
|
||||
.allowed_header("X-Auth-Token")
|
||||
.allow_any_header()
|
||||
.supports_credentials()
|
||||
.max_age(3600);
|
||||
|
||||
App::new()
|
||||
.wrap(Logger::default())
|
||||
.wrap(AuthChecker)
|
||||
.wrap(identity_middleware)
|
||||
.wrap(session_mw)
|
||||
.wrap(cors)
|
||||
.app_data(state_manager.clone())
|
||||
.app_data(Data::new(RemoteIPConfig {
|
||||
proxy: AppConfig::get().proxy_ip.clone(),
|
||||
}))
|
||||
.route(
|
||||
"/api/server/config",
|
||||
web::get().to(server_controller::config),
|
||||
)
|
||||
.route(
|
||||
"/api/auth/start_oidc",
|
||||
web::get().to(auth_controller::start_oidc),
|
||||
|
Reference in New Issue
Block a user