# My admin page is reachable without login. How do I secure it?

> Short answer: enforce authentication and role authorization on the server for every admin request, not only by hiding the page or navigation link. This guide explains what to verify and what the public scan cannot prove, without logging in, changing records, or treating an inconclusive response as a pass.

## What the admin route reachable without authorization check covers

A route that returns an admin interface to an anonymous request may expose functionality or information, but a visible page alone does not prove that every admin operation is available.

The finding describes a public condition, not proof that someone has abused it. First preserve the relevant deployment details, then rotate exposed credentials or close the access path before investigating billing, logs, or affected records.

Frontend route guards improve navigation but are not a security boundary. A user can call an API route directly, so each server action and data request must independently verify the caller's identity and role.

## Understand the evidence before changing code

List the protected page, APIs, server actions, files, and mutations. Define an explicit admin role and decide how that role is granted, revoked, and audited before changing middleware or database rules.

Severity reflects potential impact and reach, not certainty of exploitation. A public key can be intentionally visible; the important distinction is what the provider allows that key to do and which server-side policy still applies.

## Apply the narrow, safe change

Require authentication on the server and check authorization for the specific action. Return a denial before reading or changing protected data, and avoid relying on a user-editable browser flag.

Server-side role check:

```ts
const user = await requireUser();
if (!user.roles.includes("admin")) {
  return new Response("Forbidden", { status: 403 });
}
// Read protected data only after authorization.
```

Prefer the smallest repair that restores the intended boundary. Keep public client configuration public, move privileged operations behind an authenticated server route, and make data rules depend on the authenticated owner or an explicit role.

## Verify the production result

Test the route and each API as anonymous, as a normal user, and as an admin. Confirm denied responses do not include private data and that the admin flow still works after the change.

Use the snippet as a starting point, not a blind migration. Confirm the real table, environment, route, identity claim, and deployment platform first; a copied policy with the wrong owner field can block legitimate users or expose the wrong records.

## Keep the issue from returning

Centralize authorization checks, add tests for role changes, and log administrative actions without recording secrets. Review new routes because a protected page can link to an unprotected endpoint.

Verify the repair from the same public vantage point that exposed it. Check the deployed response, confirm the finding is gone, and test the intended signed-in user and an unrelated user through the normal application flow.

## Limits and next steps

A public page response cannot reveal every server-side permission rule. Review the server code and test direct requests to each protected operation.

Prevent recurrence with a reviewed migration, a secret scanner, and a small regression test that runs before deploy. Store only the minimum required credential, scope it to one project, and define who can rotate it.

A public scanner cannot establish whether private records were accessed or whether an account was compromised. If a real secret shipped, revoke it with the provider and review the provider's usage and audit history.

## FAQ

**Can a clean admin route reachable without authorization check prove the app is secure?**

No. It is evidence about the advertised public surface only. Not by itself; check whether protected data or operations are returned without authentication.

**What should I do first if the finding is real?**

Add server-side authentication and role checks to every admin operation.

**Does ProofForge change application data?**

No. The scan is read-only and does not sign in, write records, or use a discovered secret. You make and review any remediation in your own project.

**What should I do after the repair?**

Test direct requests for anonymous, ordinary, and admin accounts.

## Key facts

- Hiding an admin link does not prevent direct HTTP requests.
- Every protected API and mutation needs its own server-side authorization.
- Authentication establishes identity; authorization decides permitted actions.

## Sources

- [cheatsheetseries.owasp.org](https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html)
- [nextjs.org](https://nextjs.org/docs/app/guides/authentication)

## Related

- https://proofforge.live/fix
- https://proofforge.live/tools
- https://proofforge.live/check
- https://proofforge.live/methodology

---
Last updated 2026-11-25 · Reviewed by ProofForge. Methodology: https://proofforge.live/methodology. Scan your app: https://proofforge.live/
