Skip to content

fix(auth): dispatch honours the factory-resolved opt-out again - #4602

Merged
chernistry merged 1 commit into
mainfrom
fix/auth-optout-honours-config
Aug 26, 2026
Merged

fix(auth): dispatch honours the factory-resolved opt-out again#4602
chernistry merged 1 commit into
mainfrom
fix/auth-optout-honours-config

Conversation

@chernistry

Copy link
Copy Markdown
Collaborator

Problem

SSOAuthMiddleware.dispatch gates its unauthenticated pass-through on auth_disabled_via_opt_out() alone — a live read of BERNSTEIN_AUTH_DISABLED. The constructor still resolves the factory argument (auth.enabled: false in configuration arrives as auth_disabled=True) into self._auth_disabled, but nothing reads that attribute any more. The regression shipped inside #4577, which is about skill collision guards; the middleware line was unrelated to that change.

Net effect: a deployment that disables auth by configuration logs the loud "auth is DISABLED" warning at startup and then returns 401 on every protected route anyway. The documented opt-out surface (docs/security/manager-auth.md) no longer matched behaviour.

Fix

Dispatch honours both signals:

if self._auth_disabled or auth_disabled_via_opt_out():

The live environment read is kept on purpose — a variable exported after the middleware stack is built still counts, which is the one property the #4577 change added.

Tests

  • test_config_resolved_opt_out_survives_without_the_env_varauth_disabled=True from the factory bypasses the gate with no env var set; fails before this fix.
  • test_env_opt_out_set_after_construction_still_counts — pins the live-read property so honouring the flag cannot regress the env path.

Both run in the existing test_auth_middleware_defaults.py suite (33 passed).

A change that shipped inside an unrelated PR replaced the dispatch-time
check of the resolved opt-out flag with a live read of the environment
variable alone. The constructor kept resolving auth_disabled (explicit
arg from the app factory, i.e. auth.enabled: false in configuration, OR
the environment) into self._auth_disabled -- and nothing read it. A
deployment that switches auth off by configuration got 401s on every
protected route while still logging the auth-is-disabled warning at
startup.

Dispatch now honours both signals: the factory-resolved flag and the
live environment read, so a variable exported after construction still
counts. Two regression tests pin each signal separately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant