fix(login): use system identity in ResetTemporaryPassword mediator call#276
Merged
fix(login): use system identity in ResetTemporaryPassword mediator call#276
Conversation
/logins/* skips authentication.Middleware (login flow is pre-authentication), so the request context carries no CurrentUser. ResetTemporaryPassword is the only login-flow handler that issues a mediator command (commands.SetPassword), and PolicyBehaviour calls authentication.GetCurrentUser unconditionally — which panics with "current user not found" when none is set. Inject authentication.SystemUser() into the mediator-call context so PolicyBehaviour short-circuits to Allowed. The login token plus the LoginStepTemporaryPassword guard are the proof that the caller is authorised to reset their own temp password; the server is acting as a trusted system actor on the user's behalf. Latent bug: surfaced as soon as the access-request approve flow in keyline-saas-admin-api could finally provision portal users with temp passwords (Keyline v0.5.2 fixed the system-admin permissions that gated that). Before v0.5.2 nobody ever reached this handler. Signed-off-by: karo <karolin.kostial@gmail.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.
Summary
Why this was latent
Until v0.5.2 the access-request approve flow in keyline-saas-admin-api was 401-blocking on POST /api/virtual-servers/portal/users (system-admin role had no user:create permission). Once v0.5.2 fixed that, the first portal user with a temp password reached the reset-temp-password step in production, and the panic surfaced.
Test plan
go build ./...cleanFollow-up worth considering
internal/handlers/login_test.gois missing). The login flow is exercised end-to-end nowhere. Worth a focused e2e test pass for the temp-password flow.