Skip to content

fix(settings): read security.totp_required as a boolean, and seed auth.default_role - #53

Merged
fylorn merged 1 commit into
devfrom
fix/settings-typed-reads
Sep 24, 2026
Merged

fylorn merged 1 commit into
devfrom
fix/settings-typed-reads

Conversation

@fylorn

@fylorn fylorn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Two bugs found during the access-handler refactor (#48).

security.totp_required was never true

It is stored as a JSON boolean (seeded false; the admin UI writes true), but GET /api/auth/totp/status read it with get_string(...) == "true" — as_str() on a boolean is None, so required was always false. Now:

  • a typed DynamicConfig::totp_required() in the boolean getter list, used by the status endpoint;
  • both setting validators (admin API and DynamicConfig) require a boolean for this key, so a string "true" — which would read as "not required" — is refused with 400.

Grepped every get_string( call: no other setting is compared with "true"/"false".

Note: required drives the console's notice asking users to enable TOTP; the server does not otherwise enforce the setting at login. That is how it was designed, not changed here.

auth.default_role could not be set

No seeded system_settings row existed, and the settings update only changes existing rows, so PATCH /api/admin/settings {"auth.default_role": …} reported success without effect. Seeded empty ("" = no role) in db/seeds.sql, which is applied idempotently on every boot like the other settings.

Tests

  • requiring_totp_is_reported_to_users: status is false, a string value is refused, true via the admin API makes status report required: true.
  • registration_assigns_the_default_role… no longer writes the row by hand before using the admin API.
  • Both fail on the old code and pass with the fix.
  • Local: fmt, clippy (--all-targets, --lib), 688 unit tests, full integration suite (342 passed) on own containers.

🤖 Generated with Claude Code

…h.default_role

security.totp_required is stored as a JSON boolean but was read with
get_string(...) == "true", which never matched: a platform that required
TOTP told every user it did not. It now has a typed getter like the
other boolean settings, and both validators refuse a non-boolean value
(a string "true" would have read as false). No other setting was read
this way.

auth.default_role had no seeded row, and the settings API only updates
rows that exist, so PATCH /api/admin/settings could never set it. It is
seeded empty (no role), like the other auth settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit d92c2d1 into dev Sep 24, 2026
6 checks passed
@fylorn
fylorn deleted the fix/settings-typed-reads branch September 24, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant