[PR #4385] [CLOSED] fix(admin): allow calling admin endpoints in server #22252

Closed
opened 2026-04-15 20:54:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4385
Author: @frectonz
Created: 9/3/2025
Status: Closed

Base: canaryHead: fix/allow-calling-admin-endpoints-in-server


📝 Commits (3)

  • 65a79ac fix(admin): allow calling admin endpoints in server
  • cc886ee fix(admin): fallback to empty string
  • ee51b89 Merge branch 'canary' into fix/allow-calling-admin-endpoints-in-server

📊 Changes

1 file changed (+75 additions, -39 deletions)

View changed files

📝 packages/better-auth/src/plugins/admin/admin.ts (+75 -39)

📄 Description

closes #3717


Summary by cubic

Enables calling admin plugin endpoints from server-side code without an HTTP request, fixing failures in background tasks and internal jobs. External requests still require normal auth and permissions.

  • Bug Fixes
    • Detect in-server calls (ctx.request === undefined) and bypass session/header requirements.
    • Guard permission checks for internal calls; enforce them for external requests.
    • Use optional chaining on session access to prevent crashes.
    • Remove requireHeaders on set-role and stop-impersonating routes.
    • Keep safety checks like preventing self-ban and self-delete.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4385 **Author:** [@frectonz](https://github.com/frectonz) **Created:** 9/3/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/allow-calling-admin-endpoints-in-server` --- ### 📝 Commits (3) - [`65a79ac`](https://github.com/better-auth/better-auth/commit/65a79ac0fa4a96b148b6e81a30d37a445b2befe0) fix(admin): allow calling admin endpoints in server - [`cc886ee`](https://github.com/better-auth/better-auth/commit/cc886eec511f77d29f4037c2705e4188d7f3cfdd) fix(admin): fallback to empty string - [`ee51b89`](https://github.com/better-auth/better-auth/commit/ee51b896c8b690efe2bf4de1ba976b213be95e32) Merge branch 'canary' into fix/allow-calling-admin-endpoints-in-server ### 📊 Changes **1 file changed** (+75 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/admin/admin.ts` (+75 -39) </details> ### 📄 Description closes #3717 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Enables calling admin plugin endpoints from server-side code without an HTTP request, fixing failures in background tasks and internal jobs. External requests still require normal auth and permissions. - **Bug Fixes** - Detect in-server calls (ctx.request === undefined) and bypass session/header requirements. - Guard permission checks for internal calls; enforce them for external requests. - Use optional chaining on session access to prevent crashes. - Remove requireHeaders on set-role and stop-impersonating routes. - Keep safety checks like preventing self-ban and self-delete. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 20:54:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#22252