Allow reason/description (and ban metadata) when banning a user so audit logs capture why #54087
Unanswered
nicoabie
asked this question in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
Admin ban is only:
That sets
auth.users.banned_until, but the audit entry is a genericuser_modifiedwith traits likeuser_id/user_email/user_phone. There is no way to pass why the user was banned (or unbanned), so compliance / support / security review can’t rely on Auth audit alone.Apps that need ban reason/description today keep a parallel history table (e.g. reason
SELFBAN,MFA_VERIFICATION_ATTEMPTS_EXCEEDED, plus free-text description). That duplicates Auth’s ban state and can diverge if GoTrue succeeds and the app’s history write fails (or the reverse).Proposal
Extend admin user update (ban path) with optional fields, for example:
When
ban_durationis set (including"none"), include in the audit log payload / traits at least:ban_duration(or resolvedbanned_until)ban_reason(if provided)ban_description(if provided)Ideally also a clearer action than generic
user_modified, e.g.user_banned/user_unbanned, so bans are easy to filter inauth.audit_log_entriesand dashboard audit logs.Why this belongs in Auth
banned_until.Alternatives considered
app_metadata/user_metadataon the same update — works as a workaround, but pollutes user metadata, isn’t typed for bans, and still doesn’t make audit traits ban-aware unless Auth copies those fields into the log.Suggested API shape (non-normative)
ban_durationban_reasonban_descriptionValidation: allow
ban_reason/ban_descriptiononly whenban_durationis present (ban or unban).Acceptance criteria
ban_durationbanned_until) and the optional reason/descriptionban_duration: "none") can also carry an optional reason/descriptionban_durationkeep workingAll reactions