Add middleware to check authentication
This commit is contained in:
@ -12,6 +12,7 @@ use virtweb_backend::constants::{
|
||||
MAX_INACTIVITY_DURATION, MAX_SESSION_DURATION, SESSION_COOKIE_NAME,
|
||||
};
|
||||
use virtweb_backend::controllers::{auth_controller, server_controller};
|
||||
use virtweb_backend::middlewares::auth_middleware::AuthChecker;
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
@ -37,6 +38,7 @@ async fn main() -> std::io::Result<()> {
|
||||
|
||||
App::new()
|
||||
.wrap(Logger::default())
|
||||
.wrap(AuthChecker)
|
||||
.wrap(identity_middleware)
|
||||
.wrap(session_mw)
|
||||
.app_data(web::Data::new(RemoteIPConfig {
|
||||
@ -53,6 +55,10 @@ async fn main() -> std::io::Result<()> {
|
||||
"/api/auth/local",
|
||||
web::post().to(auth_controller::local_auth),
|
||||
)
|
||||
.route(
|
||||
"/api/auth/user",
|
||||
web::get().to(auth_controller::current_user),
|
||||
)
|
||||
})
|
||||
.bind(&AppConfig::get().listen_address)?
|
||||
.run()
|
||||
|
Reference in New Issue
Block a user