session state persists; using nginx as local dev proxy

This commit is contained in:
Brandon Thomas committed 2021-05-18 06:16:39 -04:00
1 parent c264f09ee2
commit 0f68ce115b
2 files changed
+18 -5

No files matched your search

+6
View File
@@ -91,8 +91,11 @@ pub async fn serve(server_state: ServerState) -> AnyhowResult<()>
App::new()
.app_data(server_state_arc.clone())
.wrap(Cors::default()
.allowed_origin("http://api.jungle.horse")
.allowed_origin("http://api.vo.codes")
.allowed_origin("http://jungle.horse")
.allowed_origin("http://jungle.horse:12345")
.allowed_origin("http://jungle.horse:7000")
.allowed_origin("http://localhost:12345")
.allowed_origin("http://localhost:3000")
.allowed_origin("http://localhost:5555")
@@ -104,15 +107,18 @@ pub async fn serve(server_state: ServerState) -> AnyhowResult<()>
.allowed_origin("http://vo.codes")
.allowed_origin("http://vocodes.com")
.allowed_origin("https://jungle.horse")
.allowed_origin("https://api.jungle.horse")
.allowed_origin("https://mumble.stream")
.allowed_origin("https://trumped.com")
.allowed_origin("https://vo.codes")
.allowed_origin("https://vocodes.com")
.allowed_methods(vec!["GET", "POST", "OPTIONS"])
.supports_credentials()
.allowed_headers(vec![
http::header::ACCEPT,
http::header::ACCESS_CONTROL_ALLOW_ORIGIN, // Tabulator Ajax
http::header::CONTENT_TYPE,
http::header::ACCESS_CONTROL_ALLOW_CREDENTIALS, // https://stackoverflow.com/a/46412839
http::header::HeaderName::from_static("x-requested-with") // Tabulator Ajax sends
])
.max_age(3600))
+12 -5
View File
@@ -1,4 +1,4 @@
use actix_web::cookie::Cookie;
use actix_web::cookie::{Cookie, SameSite};
use actix_web::{HttpRequest, HttpMessage};
use anyhow::anyhow;
use crate::AnyhowResult;
@@ -11,6 +11,7 @@ use sha2::Sha256;
use std::collections::BTreeMap;
use std::ops::Sub;
use time::OffsetDateTime;
use log::LevelFilter::Off;
const COOKIE_VERSION : u32 = 1;
@@ -42,11 +43,17 @@ impl CookieManager {
let jwt_string = claims.sign_with_key(&key)?;
let make_secure = !self.cookie_domain.to_lowercase().contains("jungle.horse")
&& !self.cookie_domain.to_lowercase().contains("localhost");
Ok(Cookie::build(SESSION_COOKIE_NAME, jwt_string)
.domain(&self.cookie_domain)
.path("/")
.secure(true) // HTTPS-only
.http_only(true) // Not exposed to Javascript
//.domain(&self.cookie_domain)
.secure(make_secure) // HTTPS-only
//.path("/")
//.http_only(true) // Not exposed to Javascript
//.expires(OffsetDateTime::now_utc() + time::Duration::days(365))
.permanent()
//.same_site(SameSite::Lax)
.finish())
}