Repository navigation
fix(auth): record sign-ins when the URL names no congregation - #401
Merged
Merged
Conversation
Sign-in events were written to the audit log only when the request's host resolved to a congregation. In single-tenant mode it never does, so those instances recorded no sign-in, no failed attempt and no failed two-factor challenge, although the audit log has a filter for sign-ins and for failed attempts. The base domain of a multi-tenant instance had the same gap. The event now goes to the congregation the URL names, or else to the account's own: the account that signed in, or the one whose email was typed on a failed attempt. A failed attempt on an email no account uses is still not recorded, because an audit entry needs a congregation and that attempt belongs to none.
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.
Description
An instance without congregation subdomains records no sign-in in its audit log.
The login and two-factor routes write
user.login,user.login.failedand the failed two-factor challenge onlyif (urlCongregation), the congregation resolved from the request's host. In single-tenant mode that is alwaysnull, so none of those events is ever written, although Settings → Audit log has a filter for sign-ins and for failed attempts. The base domain of a multi-tenant instance has the same gap.Fix. The event goes to the congregation the URL names, or else to the account's own (
resolveLoginAuditCongregationId):The last cell stays empty on purpose: an audit entry needs a congregation, and that attempt belongs to none.
What changes for an instance
The failed-attempt path does one extra account lookup by email, whether or not the email exists; the audit write itself is not awaited.
Tests. The resolver was written test-first. A new E2E spec signs in, then looks for the entry in the audit log. The sign-in case failed before the fix on a single-tenant server, which is the mode CI runs in; the failed-attempt case was added alongside the fix.
Type de changement
Checklist
pnpm build:format)Issue liée
None.