fix: a fixed preset outranks a default - #885
Merged
Merged
Conversation
Which preset applies is decided by `score`, which is `priority + 3 / + 2 / + 1` by how specifically it matches. `priority` is administrator-set, 0 to 128, so a group preset at priority 5 outranks a user-scoped one left at the default 0. That much is the feature: the field exists to arbitrate across scopes and this does not change it. What it quietly did was let a *default* outrank a *rule*. Only a fixed preset is a rule — `AccountPreset::checkPasswordPreset()` and `checkPasswordExpiry()` do nothing at all unless `getFixed()` is 1 — so a non-fixed preset winning the selection means no policy is enforced. An administrator who marked a password policy fixed for one person, and separately gave that person's group a non-fixed preset carrying default values at any priority above zero, got no policy for them. Nothing anywhere said so: the losing preset is not refused, it is simply not selected, and `getByFilter()` returns one row. `fixed` leads the ordering now. Between two fixed presets, or two non-fixed ones, the score decides exactly as before — this only changes the mixed case, which is the case where the answer was wrong. It is a change to which preset applies for an installation configured that way, which is why it is stated here rather than buried: the alternative is a rule an administrator explicitly marked as one, silently doing nothing. Asserted on the emitted ORDER BY rather than against rows, for the same reason as the tie-break test beside it — which row a database returns for a tie is its own business, and a behavioural test passes on this MariaDB whether or not the query asked for anything. Checked by dropping `fixed DESC`: the new test fails.
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.
Which preset applies is decided by
score, which ispriority + 3 / + 2 / + 1by howspecifically it matches.
priorityis administrator-set, 0 to 128, so a group preset atpriority 5 outranks a user-scoped one left at the default 0. That much is the feature: the
field exists to arbitrate across scopes and this does not change it.
What it quietly did was let a default outrank a rule. Only a fixed preset is a rule —
AccountPreset::checkPasswordPreset()andcheckPasswordExpiry()do nothing at all unlessgetFixed()is 1 — so a non-fixed preset winning the selection means no policy is enforced.An administrator who marked a password policy fixed for one person, and separately gave
that person's group a non-fixed preset carrying default values at any priority above zero,
got no policy for them. Nothing anywhere said so: the losing preset is not refused, it is
simply not selected, and
getByFilter()returns one row.fixedleads the ordering now. Between two fixed presets, or two non-fixed ones, the scoredecides exactly as before — this only changes the mixed case, which is the case where the
answer was wrong.
It is a change to which preset applies for an installation configured that way, which is
why it is stated here rather than buried: the alternative is a rule an administrator
explicitly marked as one, silently doing nothing.
Asserted on the emitted ORDER BY rather than against rows, for the same reason as the
tie-break test beside it — which row a database returns for a tie is its own business, and
a behavioural test passes on this MariaDB whether or not the query asked for anything.
Checked by dropping
fixed DESC: the new test fails.