[GH-ISSUE #5444] onImpersonationStart / onImpersonationStop configuration hooks... #18876

Closed
opened 2026-04-15 17:33:53 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @brianmjohnson on GitHub (Oct 21, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5444

Is this suited for github?

  • Yes, this is suited for github

I want to log when impersonation sessions are started and ended in the database, but I'm not finding any API hooks or callbacks.

Describe the solution you'd like

I'd like to implement onImpersonationStarting() and onImpersonationStopping() type hooks in the admin configuration object on initialization. I'm sure there might be more sophisticated APIs that might allow blocking starting via an onBeforeImpersonationStarting(), but my logging use case would happily execute after starting and after ending so I can create a simple impersonation audit log.

Describe alternatives you've considered

My work around is to instrument the code around the better-auth admin api calls.

Additional context

No response

Originally created by @brianmjohnson on GitHub (Oct 21, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5444 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I want to log when impersonation sessions are started and ended in the database, but I'm not finding any API hooks or callbacks. ### Describe the solution you'd like I'd like to implement onImpersonationStarting() and onImpersonationStopping() type hooks in the admin configuration object on initialization. I'm sure there might be more sophisticated APIs that might allow blocking starting via an onBeforeImpersonationStarting(), but my logging use case would happily execute after starting and after ending so I can create a simple impersonation audit log. ### Describe alternatives you've considered My work around is to instrument the code around the better-auth admin api calls. ### Additional context _No response_
GiteaMirror added the lockedenhancement labels 2026-04-15 17:33:53 -05:00
Author
Owner

@Bekacru commented on GitHub (Oct 21, 2025):

You can use hooks, but this is a fair ask. We'll implement hooks for those actions

<!-- gh-comment-id:3428695033 --> @Bekacru commented on GitHub (Oct 21, 2025): You can use hooks, but this is a fair ask. We'll implement hooks for those actions
Author
Owner

@dosubot[bot] commented on GitHub (Jan 20, 2026):

Hi, @brianmjohnson. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested adding onImpersonationStarting() and onImpersonationStopping() hooks for audit logging.
  • The maintainer acknowledged the request as reasonable.
  • Plans to implement these hooks were confirmed.
  • You reacted positively to the update.
  • The issue is considered resolved with the implementation planned.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of better-auth by commenting here.
  • Otherwise, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3773741128 --> @dosubot[bot] commented on GitHub (Jan 20, 2026): Hi, @brianmjohnson. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested adding `onImpersonationStarting()` and `onImpersonationStopping()` hooks for audit logging. - The maintainer acknowledged the request as reasonable. - Plans to implement these hooks were confirmed. - You reacted positively to the update. - The issue is considered resolved with the implementation planned. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of better-auth by commenting here. - Otherwise, this issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18876