Skip to content

fix(auth): record sign-ins when the URL names no congregation - #401

Merged
mindsers merged 2 commits into
mainfrom
fix/login-audit-attribution
Oct 13, 2026
Merged

mindsers merged 2 commits into
mainfrom
fix/login-audit-attribution

Conversation

@mindsers

@mindsers mindsers commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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.failed and the failed two-factor challenge only if (urlCongregation), the congregation resolved from the request's host. In single-tenant mode that is always null, 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):

Event URL names a congregation URL names none
Sign-in, with or without two-factor that congregation (unchanged) the account's congregation
Failed two-factor challenge that congregation (unchanged) the account's congregation
Failed attempt, email of an existing account that congregation (unchanged) that account's congregation
Failed attempt, email no account uses that congregation (unchanged) not recorded

The last cell stays empty on purpose: an audit entry needs a congregation, and that attempt belongs to none.

What changes for an instance

  • Single-tenant: sign-ins, failed attempts on existing accounts and failed two-factor challenges start appearing in the audit log. Nothing is backfilled.
  • Multi-tenant, on a congregation's subdomain or custom domain: nothing changes.
  • Multi-tenant, on the base domain: a sign-in there is now recorded in the account's congregation.

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

  • Bug fix
  • Nouvelle fonctionnalité
  • Refactoring (pas de changement fonctionnel)
  • Documentation
  • Autre : ___

Checklist

  • J'ai formaté mon code avant de pousser (pnpm build:format)
  • J'ai mis à jour la documentation si nécessaire

Issue liée

None.

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.
@mindsers
mindsers merged commit b349467 into main Oct 13, 2026
7 checks passed
@mindsers
mindsers deleted the fix/login-audit-attribution branch October 13, 2026 19:59
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