VirtWebRemote/remote_backend/src/main.rs

46 lines
1.4 KiB
Rust
Raw Normal View History

2024-04-24 19:51:53 +00:00
use actix_remote_ip::RemoteIPConfig;
use actix_web::middleware::Logger;
use actix_web::web::Data;
use actix_web::{web, App, HttpServer};
2024-04-24 19:51:53 +00:00
use light_openid::basic_state_manager::BasicStateManager;
use remote_backend::app_config::AppConfig;
use remote_backend::controllers::auth_controller;
2024-04-25 16:51:42 +00:00
use remote_backend::virtweb_client;
2024-04-24 19:51:53 +00:00
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
let state_manager = Data::new(BasicStateManager::new());
2024-04-25 16:51:42 +00:00
println!("{:#?}", virtweb_client::get_token_rights().await.unwrap());
2024-04-24 19:51:53 +00:00
HttpServer::new(move || {
App::new()
.wrap(Logger::default())
.app_data(state_manager.clone())
.app_data(Data::new(RemoteIPConfig {
proxy: AppConfig::get().proxy_ip.clone(),
}))
.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/user",
web::get().to(auth_controller::current_user),
)
.route(
"/api/auth/sign_out",
web::get().to(auth_controller::sign_out),
)
2024-04-24 19:51:53 +00:00
})
.bind(&AppConfig::get().listen_address)?
.run()
.await
}