Technical document

Admin Panel Login with BetterAuth and Google OAuth

We will organize how to separate login, user approval, sessions, and permissions in an admin panel using BetterAuth and Google OAuth.
Authentication / TypeScript~10 minPublication Date September 22, 2026Update date September 22, 2026
Admin Panel Login with BetterAuth and Google OAuth

Summary

Key points of this document

  • Where are the design challenges?
  • How to define boundaries
  • Details that matter in implementation

Overview

Implementing admin panel login becomes easier with Google OAuth. However, being able to authenticate with a Google account is different from being authorized to use the admin panel. For admin panel login, it's more important how external accounts are linked to internal permissions, and how they are unlinked, rather than just adding an authentication library.

Where are the design challenges?

Adding an authentication library makes the login function work immediately. However, if you automatically treat first-time logged-in users as active users, the boundaries of the admin panel become weak.

Google OAuth can verify identity, but it doesn't provide information about roles or responsibilities within an organization. Permissions such as administrator, editor, or viewer must be maintained on the application side.

Using BetterAuth and Google OAuth can shorten the login flow. However, in an admin panel, you must differentiate between those who can log in and those who can perform administrative operations. If administrative permissions are determined solely by the state of external accounts, it becomes vulnerable to operational changes.

How to define boundaries

BetterAuth handles sessions and OAuth flows, while the application's DB manages user states and roles. Upon initial login, users are set to 'pending approval' and activated after matching with an invitation email or administrator approval.

In the design, we separate 'auth user', 'oauth account', 'admin membership', and 'role'. Google OAuth serves as the entry point for identity verification, and the usability of the admin panel is determined by the 'membership' status in the internal DB.

Details that matter in implementation

In Hono API, the authentication middleware reads the session, then retrieves the application-side user. On the React Router side, even if logged in, a dedicated screen is displayed if approval is pending. Permissions are checked per API, not solely relying on screen display.

At the boundaries of Hono and React Router, the administrator context is resolved after session acquisition. In loaders, if not an administrator, a redirect occurs, and the same judgment is made in API handlers. It's crucial not to rely solely on screen display for permissions.

  • Check not only the allowed domain but also whether it's active in internal admin_memberships.
  • Log login, logout, permission changes, and denied access to the audit log.
  • Verify Secure, SameSite, and domain attributes of session cookies per environment.

Observe how it breaks

During verification, check for unapproved users, disabled users, insufficient permissions, session expiration, and OAuth callback failures. A case where an administrator accidentally disables themselves is also an operational consideration.

During verification, check for allowed accounts, unauthorized accounts, suspended permissions, session expiration, and direct API access. In the admin panel, test that the same denial occurs for both screen transitions and API calls.

Discarded options and tradeoffs

Adding an approval flow increases the effort for first-time use. For small internal tools, starting with domain restrictions only is an option, but if the admin panel handles important information, having application-side approval is safer.

Relying on external OAuth reduces password management, but you need to design for external account changes and handling of users outside the organization. If internal roles are separated, the permission model can be maintained even if the authentication method changes.

Decision criteria to leave for the team

BetterAuth and Google OAuth simplify login, but the security of the admin panel is determined by application-side approval and permissions. Designing authentication and authorization separately is fundamental.

BetterAuth and Google OAuth make login easy, but the security of the admin panel is determined by the internal permission model. Separating external authentication and internal authorization is the foundation for a maintainable admin panel.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list