Enforce managed authentication requirements locally (#37132)

## Why

Authentication restrictions must apply before stored or environment-provided credentials can be used, including during bootstrap before cloud requirements are fetched.

## What changed

- Add local `requirements.toml` allowlists for login methods and ChatGPT workspaces. Ignore these fields in cloud-provided requirements.
- Combine managed workspace allowlists with existing workspace restrictions by intersection, and fail closed when the resulting policy permits no usable login method.
- Centralize policy checks in the authentication manager so CLI, TUI, app-server, external-auth, and credential-loading paths consistently reject disallowed authentication before token hydration or network requests.

## Testing

- Cover policy composition, workspace intersection, invalid stored and external credentials, bootstrap enforcement, and login endpoint restrictions.

GitOrigin-RevId: efef22b248f3c3333e9aa55423e539efa2d2dd48
This commit is contained in:
Abhinav authored and copyberry committed 2026-08-05 18:09:26 +00:00
1 parent 4cb8676d3a
commit 2994f545a7
36 files changed
+1121 -328

No files matched your search

+8 -1
View File
@@ -192,7 +192,14 @@ pub async fn load_config_layers_state(
requirements_layers.extend(managed_preferences_requirements_layer);
}
let config_requirements_toml = compose_requirements(requirements_layers)?.unwrap_or_default();
let mut config_requirements_toml =
compose_requirements(requirements_layers)?.unwrap_or_default();
// Remote app servers enforce auth policy for their workspaces; do not let local
// requirements reintroduce authentication restrictions for those workspaces.
if overrides.ignore_login_requirements {
config_requirements_toml.allowed_login_methods = None;
config_requirements_toml.allowed_chatgpt_workspaces = None;
}
let thread_config_context = ThreadConfigContext {
thread_id: None,