Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(auth): bypass dev signup allowlist (#6847)
Will Hutchinson5723b198ab55
diff --git a/services/authentication_service/README.md b/services/authentication_service/README.mdindex da9d9e3aa6..b64ded4c7b 100644--- a/services/authentication_service/README.md+++ b/services/authentication_service/README.md@@ -13,15 +13,18 @@ faster user-facing `403` response. They are advisory. The transactional webhookis the enforcement boundary for all signup paths, including SSO and futureFusionAuth-created users.-### Setting+### Settings- Doppler project: `authentication-service`- Develop Doppler config: `dev`- Production Doppler config: `prd`-- Setting name: `DEVELOPMENT_SIGNUP_ALLOWLIST_JSON`-- Format: JSON array of exact email-address strings-Synthetic example only:+| Setting | Format | Default |+| --- | --- | --- |+| `DEVELOPMENT_SIGNUP_ALLOWLIST_JSON` | JSON array of exact email-address strings | No default |+| `DEVELOPMENT_BYPASS_SIGNUP_ALLOWLIST` | Exactly `true` or `false` | `false` when absent |++Synthetic allowlist example only:```json@@ -32,21 +35,28 @@ or generated files.### Environment behavior-| Runtime environment | Doppler slug | Effective signup policy |-| --- | --- | --- |-| `Environment::Develop` | `dev` | Requires `DEVELOPMENT_SIGNUP_ALLOWLIST_JSON` to be present, nonblank, valid, and non-empty. |-| `Environment::Production` | `prd` | Allows all public signups. The allowlist setting is ignored even if present or malformed. |-| `Environment::Local` | `lcl` | Allows all public signups. The allowlist setting is ignored even if present or malformed. |+| Runtime environment | Doppler slug | Bypass | Effective signup policy |+| --- | --- | --- | --- |+| `Environment::Develop` | `dev` | Off | Requires `DEVELOPMENT_SIGNUP_ALLOWLIST_JSON` to be present, nonblank, valid, and non-empty. |+| `Environment::Develop` | `dev` | On | Allows all public signups. The allowlist setting is ignored even if missing or malformed. |+| `Environment::Production` | `prd` | No effect | Allows all public signups. The allowlist setting is ignored even if present or malformed. |+| `Environment::Local` | `lcl` | No effect | Allows all public signups. The allowlist setting is ignored even if present or malformed. |-Develop startup fails if the setting is missing, blank, malformed JSON, not a-JSON array, empty, contains a non-string entry, contains a blank entry, or-contains an invalid email address. Production and Local do not require the-setting and do not parse it.+With the bypass off, Develop startup fails if the allowlist setting is missing,+blank, malformed JSON, not a JSON array, empty, contains a non-string entry,+contains a blank entry, or contains an invalid email address. With the bypass+on, Develop neither requires nor parses the allowlist setting, so the bypass+takes precedence over any allowlist value. Production and Local do not require+the allowlist setting and do not parse it.++The bypass accepts only the exact values `true` and `false`. Values such as+`True`, `1`, `yes`, or an empty string fail startup in every environment,+including Production and Local, where the bypass otherwise has no effect.### Matching and validation semantics-The allowlist is parsed once at service startup and stored in memory. Request-handlers perform hash lookups only.+With the bypass off, the service parses the allowlist once at startup and+stores it in memory. Request handlers perform hash lookups only.Normalization rules:@@ -87,25 +97,29 @@ dashboard reads it through `GET /gtm-invite/links`.## Shared mailboxesInternal shared-mailbox grant relocation creates ordinary FusionAuth users for-mailbox grants. In Develop, those mailbox addresses must be listed explicitly in-`DEVELOPMENT_SIGNUP_ALLOWLIST_JSON` before relocation creates the FusionAuth-user. There is no metadata-based signup-policy bypass for shared mailboxes.+mailbox grants. In Develop with the bypass off, those mailbox addresses must be+listed explicitly in `DEVELOPMENT_SIGNUP_ALLOWLIST_JSON` before relocation+creates the FusionAuth user. With the bypass on, Develop allows those addresses+like any other signup. Shared mailboxes get no metadata-based exemption from the+signup policy.## Rollout1. Configure `DEVELOPMENT_SIGNUP_ALLOWLIST_JSON` in Doppler project`authentication-service`, config `dev`, using only the approved operationaladdresses for the deployment. Keep values out of source control and chat.-2. Validate the Doppler configs and semantic policy resolution:+2. Validate the Doppler configs and semantic policy resolution. The validator+ reads configs `dev` and `prd` with the Doppler token in the `DOPPLER_TOKEN`+ environment variable:```bash- nix develop --command cargo check -p authentication_service --bin authentication_service_doppler_config+ nix develop --command cargo run -p authentication_service --bin authentication_service_doppler_config```3. Deploy the authentication service build that contains the signup policy.-4. Restart or replace all Develop authentication service tasks. The setting is- loaded once at startup; changing Doppler after deployment does not update- running tasks.+4. Restart or replace all Develop authentication service tasks. The service+ reads both settings once at startup. Changing Doppler after deployment does+ not update running tasks.5. Confirm Develop signups for allowed synthetic/test accounts succeed andunlisted synthetic/test accounts receive a generic `403` without onboardingside effects.@@ -113,15 +127,47 @@ user. There is no metadata-based signup-policy bypass for shared mailboxes.Production and Local remain allow-all and can deploy independently of theDevelop allowlist value.+### Change the bypass++To allow every public signup in Develop:++1. Set `DEVELOPMENT_BYPASS_SIGNUP_ALLOWLIST` to `true` in Doppler project+ `authentication-service`, config `dev`.+2. Restart or replace all Develop authentication service tasks.+3. Confirm that an unlisted synthetic test account can sign up.++To enforce the allowlist again:++1. Confirm that `DEVELOPMENT_SIGNUP_ALLOWLIST_JSON` lists every non-Macro+ address that still needs to sign up in Develop, including shared mailboxes.+2. Set `DEVELOPMENT_BYPASS_SIGNUP_ALLOWLIST` to `false` in config `dev`, or+ delete it.+3. Run the Doppler config validator from rollout step 2.+4. Restart or replace all Develop authentication service tasks. If the+ allowlist is missing or invalid, Develop startup fails until you fix it.+5. Confirm that an unlisted synthetic test account receives a generic `403`.++The validator skips `DEVELOPMENT_SIGNUP_ALLOWLIST_JSON` while the bypass is on.+The allowlist can become invalid without detection, so validate it before you+turn the bypass off. Accounts created while the bypass is on remain afterward.+## Rollback-- If Develop startup fails, fix the Doppler JSON value and restart the service- tasks. The service will not accept traffic until the Develop value is valid.+- If Develop startup fails because of the allowlist, fix the Doppler JSON value+ and restart the service tasks. The service will not accept traffic until the+ Develop value is valid. Turning the bypass on also lets Develop start, but+ Develop then allows every public signup until you turn the bypass off.+- If startup fails because of `DEVELOPMENT_BYPASS_SIGNUP_ALLOWLIST`, set it to+ exactly `true` or `false`, or delete it. Then restart or replace the service+ tasks. This failure can happen in any environment.- If a legitimate Develop signup is denied, add the address to the Doppler JSONarray and restart or replace the authentication service tasks.+- If Develop must stop allowing every public signup, follow+ [Change the bypass](#change-the-bypass) to enforce the allowlist again.- If the release must be reverted, roll Develop back to the previous- authentication service deployment or task definition. Keep a valid Develop- allowlist configured so the forward version can be redeployed safely.+ authentication service deployment or task definition. Builds from before the+ bypass ignore `DEVELOPMENT_BYPASS_SIGNUP_ALLOWLIST` and enforce the allowlist,+ so keep a valid Develop allowlist configured even while the bypass is on.## Focused verificationdiff --git a/services/authentication_service/src/config.rs b/services/authentication_service/src/config.rsindex 1ae47254a8..31863d73af 100644--- a/services/authentication_service/src/config.rs+++ b/services/authentication_service/src/config.rs@@ -156,6 +156,10 @@ pub struct Config {////// All `@macro.com` email addresses are allowed by the Develop policy automatically.pub development_signup_allowlist_json: DevelopmentSignupAllowlistJson,+ /// Whether Develop allows every public signup without reading+ /// `DEVELOPMENT_SIGNUP_ALLOWLIST_JSON`. Production and Local ignore it.+ #[macro_config_default(false)]+ pub development_bypass_signup_allowlist: bool,/// Stripe promotion code applied at checkout for accounts that signed up/// through a GTM invite link (optional, defaults to `1MF`).pub gtm_invite_promo_code: GtmInvitePromoCode,@@ -241,7 +245,11 @@ impl Config {&self,environment: Environment,) -> anyhow::Result<SignupPolicy> {- resolve_signup_policy(environment, &self.development_signup_allowlist_json)+ resolve_signup_policy(+ environment,+ self.development_bypass_signup_allowlist,+ &self.development_signup_allowlist_json,+ )}/// Resolves the offer GTM invite links carry.@@ -282,10 +290,14 @@ fn resolve_microsoft_credentials(fn resolve_signup_policy(environment: Environment,+ development_bypass_signup_allowlist: bool,development_signup_allowlist_json: &DevelopmentSignupAllowlistJson,) -> anyhow::Result<SignupPolicy> {match environment {Environment::Production | Environment::Local => Ok(SignupPolicy::allow_all()),+ Environment::Develop if development_bypass_signup_allowlist => {+ Ok(SignupPolicy::allow_all())+ }Environment::Develop => {let raw_allowlist = nonblank_value(development_signup_allowlist_json.value()).context("DEVELOPMENT_SIGNUP_ALLOWLIST_JSON is required in Develop")?;diff --git a/services/authentication_service/src/config/test.rs b/services/authentication_service/src/config/test.rsindex bf6312a1e6..fb719683b0 100644--- a/services/authentication_service/src/config/test.rs+++ b/services/authentication_service/src/config/test.rs@@ -1,3 +1,5 @@+use authentication_service::service::signup_policy::SignupPolicyDenial;+use super::*;#[test]@@ -147,11 +149,22 @@ fn development_allowlist(value: Option<&'static str>) -> DevelopmentSignupAllowl}}+const ALLOWLIST_SETTING_CASES: [Option<&str>; 5] = [+ None,+ Some(""),+ Some(" \t "),+ Some("[email protected]"),+ Some(r#"["[email protected]"]"#),+];++const UNLISTED_PUBLIC_EMAIL: &str = "[email protected]";+#[test]fn develop_signup_policy_requires_configured_allowlist() {for value in [None, Some(""), Some(" \t ")] {- let error = resolve_signup_policy(Environment::Develop, &development_allowlist(value))- .expect_err("Develop should require a nonblank allowlist setting");+ let error =+ resolve_signup_policy(Environment::Develop, false, &development_allowlist(value))+ .expect_err("Develop should require a nonblank allowlist setting");assert!(error@@ -165,6 +178,7 @@ fn develop_signup_policy_requires_configured_allowlist() {fn develop_signup_policy_uses_configured_allowlist() {let policy = resolve_signup_policy(Environment::Develop,+ false,&development_allowlist(Some(r#"["[email protected]", "[email protected]"]"#,)),@@ -175,6 +189,10 @@ fn develop_signup_policy_uses_configured_allowlist() {policy.authorize_public_email("[email protected]").expect("configured email should be allowed");+ assert_eq!(+ policy.authorize_public_email(UNLISTED_PUBLIC_EMAIL),+ Err(SignupPolicyDenial::PublicEmailNotAllowed)+ );}#[test]@@ -182,6 +200,7 @@ fn develop_signup_policy_rejects_malformed_allowlist_without_leaking_value() {let configured_value = "[email protected]";let error = resolve_signup_policy(Environment::Develop,+ false,&development_allowlist(Some(configured_value)),).expect_err("malformed Develop allowlist should be rejected");@@ -193,18 +212,32 @@ fn develop_signup_policy_rejects_malformed_allowlist_without_leaking_value() {}#[test]-fn production_and_local_signup_policy_ignore_allowlist_setting() {- for environment in [Environment::Production, Environment::Local] {- let policy = resolve_signup_policy(- environment,- &development_allowlist(Some("[email protected]")),- )- .expect("non-Develop environments should not parse the allowlist setting");+fn develop_signup_policy_bypass_ignores_allowlist_setting() {+ for value in ALLOWLIST_SETTING_CASES {+ let policy =+ resolve_signup_policy(Environment::Develop, true, &development_allowlist(value))+ .expect("Develop bypass should not parse the allowlist setting");assert_eq!(policy.allowed_email_count(), None);- policy- .authorize_public_email("[email protected]")- .expect("non-Develop environments should allow all public signups");+ assert_eq!(policy.authorize_public_email(UNLISTED_PUBLIC_EMAIL), Ok(()));+ }+}++#[test]+fn production_and_local_signup_policy_ignore_allowlist_and_bypass() {+ for environment in [Environment::Production, Environment::Local] {+ for bypass in [false, true] {+ for value in ALLOWLIST_SETTING_CASES {+ let policy =+ resolve_signup_policy(environment, bypass, &development_allowlist(value))+ .expect("non-Develop environments should not parse the allowlist setting");++ assert_eq!(policy.allowed_email_count(), None);+ policy+ .authorize_public_email("[email protected]")+ .expect("non-Develop environments should allow all public signups");+ }+ }}}