Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat: local cookies (#1145)

Will Hutchinsondf0cdcd6d8b8
diff --git a/docker-compose.yml b/docker-compose.yml
index 69b21b6e12..17b352c450 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -19,6 +19,8 @@ services:
target: authentication_service
ports:
- "8080:8080"
+ depends_on:
+ - redis
networks:
- databases
- services
diff --git a/rust/cloud-storage/authentication_service/src/api/utils.rs b/rust/cloud-storage/authentication_service/src/api/utils.rs
index 29ebd43484..2432c8b8e0 100644
--- a/rust/cloud-storage/authentication_service/src/api/utils.rs
+++ b/rust/cloud-storage/authentication_service/src/api/utils.rs
@@ -67,7 +67,8 @@ pub fn create_access_token_cookie(token: &str) -> Cookie<'static> {
let domain = domain();
let access_token_cookie_name = match Environment::new_or_prod() {
Environment::Production => MACRO_ACCESS_TOKEN_COOKIE.to_string(),
- Environment::Local | Environment::Develop => format!("dev-{MACRO_ACCESS_TOKEN_COOKIE}"),
+ Environment::Develop => format!("dev-{MACRO_ACCESS_TOKEN_COOKIE}"),
+ Environment::Local => format!("local-{MACRO_ACCESS_TOKEN_COOKIE}"),
};
let mut cookie = Cookie::new(
@@ -92,7 +93,8 @@ pub fn create_refresh_token_cookie(token: &str) -> Cookie<'static> {
let domain = domain();
let refresh_token_cookie_name = match Environment::new_or_prod() {
Environment::Production => MACRO_REFRESH_TOKEN_COOKIE.to_string(),
- Environment::Local | Environment::Develop => format!("dev-{MACRO_REFRESH_TOKEN_COOKIE}"),
+ Environment::Develop => format!("dev-{MACRO_REFRESH_TOKEN_COOKIE}"),
+ Environment::Local => format!("local-{MACRO_REFRESH_TOKEN_COOKIE}"),
};
let mut cookie = Cookie::new(
refresh_token_cookie_name,
diff --git a/rust/cloud-storage/macro_auth/src/headers.rs b/rust/cloud-storage/macro_auth/src/headers.rs
index 8f5a5236c5..c82705f84b 100644
--- a/rust/cloud-storage/macro_auth/src/headers.rs
+++ b/rust/cloud-storage/macro_auth/src/headers.rs
@@ -33,9 +33,8 @@ pub fn extract_access_token_from_request_headers(
// Otherwise, we want to prefix the cookie name with dev-
let access_token_cookie_name = match Environment::new_or_prod() {
Environment::Production => MACRO_ACCESS_TOKEN_COOKIE,
- Environment::Local | Environment::Develop => {
- &format!("dev-{MACRO_ACCESS_TOKEN_COOKIE}")
- }
+ Environment::Develop => &format!("dev-{MACRO_ACCESS_TOKEN_COOKIE}"),
+ Environment::Local => &format!("local-{MACRO_ACCESS_TOKEN_COOKIE}"),
};
if cookie.name() == access_token_cookie_name {
@@ -77,9 +76,8 @@ pub fn extract_refresh_token_from_request_headers(
let cookie = Cookie::parse(cookie).ok()?;
let refresh_token_cookie_name = match Environment::new_or_prod() {
Environment::Production => MACRO_REFRESH_TOKEN_COOKIE,
- Environment::Local | Environment::Develop => {
- &format!("dev-{MACRO_REFRESH_TOKEN_COOKIE}")
- }
+ Environment::Develop => &format!("dev-{MACRO_REFRESH_TOKEN_COOKIE}"),
+ Environment::Local => &format!("local-{MACRO_REFRESH_TOKEN_COOKIE}"),
};
if cookie.name() == refresh_token_cookie_name {
Some(cookie.value().to_owned())
diff --git a/rust/cloud-storage/macro_entrypoint/src/lib.rs b/rust/cloud-storage/macro_entrypoint/src/lib.rs
index 6459a26473..a564283e8d 100644
--- a/rust/cloud-storage/macro_entrypoint/src/lib.rs
+++ b/rust/cloud-storage/macro_entrypoint/src/lib.rs
@@ -45,7 +45,9 @@ impl MacroEntrypoint {
(Environment::Local, LocalOptions { tree_tracing: None }) => {
tracing_subscriber::fmt()
.with_ansi(true)
- .with_env_filter(EnvFilter::from_default_env())
+ // Leaving this commented out to show we explicitly don't want with_env_filter when
+ // running locally. RUST_LOG=trace doesn't work if you use this.
+ // .with_env_filter(EnvFilter::from_default_env())
.with_file(true)
.with_line_number(true)
.pretty()