diff options
author | Vincent Ambo <tazjin@gmail.com> | 2018-05-01T21·00+0200 |
---|---|---|
committer | Vincent Ambo <github@tazj.in> | 2018-05-01T22·33+0200 |
commit | 6d69f5001eb7d4fdd9e791933b2dfd135f5819e7 (patch) | |
tree | c10451d346d423df5c8354b3d8e76726c20e30b2 | |
parent | 095293e8e3fc0e31a97d8c6d9f7a06c9547112a8 (diff) |
refactor(main): Use actix-web's identity middleware for auth
-rw-r--r-- | src/main.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index bc9fca681015..11dcf84811a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,7 +68,8 @@ pub mod schema; use actix::prelude::*; use actix_web::*; use actix_web::http::Method; -use actix_web::middleware::{Logger, SessionStorage, CookieSessionBackend}; +use actix_web::middleware::Logger; +use actix_web::middleware::identity::{IdentityService, CookieIdentityPolicy}; use db::*; use diesel::pg::PgConnection; use diesel::r2d2::{ConnectionManager, Pool}; @@ -180,13 +181,16 @@ fn start_http_server(base_url: String, renderer: renderer_addr.clone(), }; - let sessions = SessionStorage::new( - CookieSessionBackend::signed(&key) - .secure(base_url.starts_with("https"))); + let identity = IdentityService::new( + CookieIdentityPolicy::new(&key) + .name("converse_auth") + .path("/") + .secure(base_url.starts_with("https")) + ); let app = App::with_state(state) .middleware(Logger::default()) - .middleware(sessions) + .middleware(identity) .resource("/", |r| r.method(Method::GET).with(forum_index)) .resource("/thread/new", |r| r.method(Method::GET).with(new_thread)) .resource("/thread/submit", |r| r.method(Method::POST).with3(submit_thread)) |