feat: add disable_auth feature flag to block login and credential loading#911
feat: add disable_auth feature flag to block login and credential loading#911
disable_auth feature flag to block login and credential loading#911Conversation
…ding Add a new feature flag 'disable_auth' (default: false for both debug and release) that, when enabled: - Blocks 'git-ai login' with a clear error message - Blocks 'git-ai exchange-nonce' with a clear error message - Prevents credential loading in try_load_auth_token() (returns None) - Prevents CredentialStore.store() (returns error) - Prevents CredentialStore.load() (returns Ok(None)) Controllable via config file (feature_flags.disable_auth) or env var (GIT_AI_DISABLE_AUTH=true). Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Devin Review found 1 potential issue.
⚠️ 1 issue in files not directly in the diff
⚠️ Missing disable_auth guard in handle_logout makes logout silently fail with misleading message (src/commands/logout.rs:4)
handle_login (src/commands/login.rs:6-9) and handle_exchange_nonce (src/commands/exchange_nonce.rs:19-22) both received explicit disable_auth guards that print a descriptive error and exit. However, handle_logout (src/commands/logout.rs:4) was not updated. When disable_auth is enabled, store.load() at src/commands/logout.rs:8 hits the new guard in CredentialStore::load() (src/auth/credentials.rs:123-126) and returns Ok(None), causing the function to print "Not currently logged in." — even when credentials are actually stored on disk. This means the user gets a misleading message, and credentials can never be cleared via git-ai logout while the flag is active.
View 3 additional findings in Devin Review.
Prevents misleading 'Not currently logged in' message when disable_auth flag is enabled. Now errors out clearly like login and exchange-nonce. Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
|
Addressed the Devin Review finding: added |
|
|
Summary
Adds a new
disable_authfeature flag (defaultfalsein both debug and release) that, when enabled via config (feature_flags.disable_auth) or environment variable (GIT_AI_DISABLE_AUTH=true):git-ai login— exits with code 1 and a clear error messagegit-ai logout— same behavior (prevents misleading "Not currently logged in" message)git-ai exchange-nonce— same behaviortry_load_auth_token()returnsNoneimmediatelyCredentialStore::store()returnsErr,CredentialStore::load()returnsOk(None)Existing feature flag tests updated to include the new field. Two new unit tests added for the flag definition itself.
Updates since last revision
disable_authguard tohandle_logout(src/commands/logout.rs) — without this,store.load()would hit theCredentialStore::load()guard and returnOk(None), printing a misleading "Not currently logged in" even when credentials exist on disk.Review & Testing Checklist for Human
GIT_AI_DISABLE_AUTH=true git-ai loginandGIT_AI_DISABLE_AUTH=true git-ai logoutboth print the error message and exit with code 1.#[cfg(not(test))]guards onCredentialStore::store/load: The disable_auth checks incredentials.rsare compiled out in test builds (becauseConfig::get()isn't available in tests). This means the credential-blocking behavior has zero unit test coverage. Verify this trade-off is acceptable, or consider adding an integration test that setsGIT_AI_DISABLE_AUTH=trueand exercises the credential path."Error: Authentication is disabled..."is hardcoded inlogin.rs,logout.rs, andexchange_nonce.rsseparately from theAUTH_DISABLED_MSGconstant incredentials.rs. Consider whether these should share a single constant.try_load_auth_token()flag check is NOT behind#[cfg(not(test))]unlike the CredentialStore checks — confirm this doesn't cause issues in test builds that exercise API client paths.Notes
auth_keyring,async_mode, etc.) viadefine_feature_flags!macro.#[cfg(not(test))]approach incredentials.rsmirrors the existing pattern already used there forConfig::get()access.Link to Devin session: https://app.devin.ai/sessions/fcabbdff9cd04e38a5c21ba9e6fc598d
Requested by: @svarlamov