fix(settings): read security.totp_required as a boolean, and seed auth.default_role - #53
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs found during the access-handler refactor (#48).
security.totp_requiredwas never trueIt is stored as a JSON boolean (seeded
false; the admin UI writestrue), butGET /api/auth/totp/statusread it withget_string(...) == "true"—as_str()on a boolean isNone, sorequiredwas alwaysfalse. Now:DynamicConfig::totp_required()in the boolean getter list, used by the status endpoint;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:
requireddrives 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_rolecould not be setNo seeded
system_settingsrow existed, and the settings update only changes existing rows, soPATCH /api/admin/settings {"auth.default_role": …}reported success without effect. Seeded empty (""= no role) indb/seeds.sql, which is applied idempotently on every boot like the other settings.Tests
requiring_totp_is_reported_to_users: status isfalse, a string value is refused,truevia the admin API makes status reportrequired: true.registration_assigns_the_default_role…no longer writes the row by hand before using the admin API.--all-targets,--lib), 688 unit tests, full integration suite (342 passed) on own containers.🤖 Generated with Claude Code