Repository navigation
Conversation
…ring hook bug, and validate audit-read options
The audit trail misclassified /sign-in/social and /sign-in/magic-link
(which only dispatch a redirect/email) as completed sign-ins, while
/callback/:id, /magic-link/verify, and every /two-factor/verify-*
endpoint -- where a session is actually issued -- were never recorded
at all. Split dispatch from completion: the two dispatch-only paths
now record sign-in-initiated, and the four completion endpoints join
credential sign-ins as sign-in. A failed sign-in now also carries
targetEmail (the attempted identifier, read from the request body) as
a top-level column -- never inside detail, since @visulima/redact
scrubs email-shaped values there regardless of key name -- so
credential-stuffing attempts can be grouped by target even without an
authenticated actor.
Pinning the better-auth 1.7.0-rc.2 hook contract against a real
instance (packages/auth/__tests__/audit-hooks.behaviour.test.ts)
surfaced two things beyond what was being pinned:
1. better-auth runs the app's own hooks.after BEFORE a plugin's after
hooks, so authAuditHook cannot observe the two-factor plugin's
{twoFactorRedirect:true} rewrite -- a "sign-in-challenged" event
is not observable from this hook and is not implemented here.
2. authAuditHook's trailing `return {};` is a live bug: better-auth's
after-hook runner treats any non-undefined return as the endpoint's
new response, so returning {} silently replaced every hooked
endpoint's response body with {} -- sign-up, sign-in, everything.
Fixed to `return undefined;`, which does not throw (the removed
comment's claim otherwise was false) and is a true no-op.
Also hardens the audit-read boundary: AuthDO#readAudit now parses and
validates the request body instead of trusting it, returning 400 for
a malformed body or an unknown/ill-typed option instead of throwing
(a 500) or letting a non-numeric limit reach the SQL LIMIT clause as
NaN. readAuthAuditLog's own clamp is NaN-safe independent of that
boundary, protecting every other caller too.
onRecord/SIEM consumers keyed on event strings will see fewer
sign-in events for social/magic-link dispatch and more for the
previously-unrecorded completion endpoints -- see the mapping table
in authAuditHook's docblock.
|
Warning Review limit reached
Next review available in: 58 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you for following the naming conventions! 🙏 |
❌ Deploy Preview for lunorash failed.
|
|
Thank you for confirming the Contributor License Agreement! 🙏 |
|
Closing: this PR was opened in error by an automated run, outside the scope of its task. No work is lost — the branch is retained on origin and this PR can be reopened at any time. Context: this branch predates the merges of #288 and #289, so much of its content is already on |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Branched before #288/#289 landed, so it needs a rebase onto current alpha before merge.
Commits
Files this branch still changes relative to alpha