about summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-05-01T21·00+0200
committerVincent Ambo <github@tazj.in>2018-05-01T22·33+0200
commit6d69f5001eb7d4fdd9e791933b2dfd135f5819e7 (patch)
treec10451d346d423df5c8354b3d8e76726c20e30b2 /src/main.rs
parent095293e8e3fc0e31a97d8c6d9f7a06c9547112a8 (diff)
refactor(main): Use actix-web's identity middleware for auth
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
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))