Skip to content
Back to skills

Kirby Security And Auth

ASecurity

Secures Kirby sites with access restriction, user roles, permissions, and protected downloads. Use when implementing login/role-based access, permissions, or file protection.

  • 74 stars
  • 0 votes
  • 0 copies
  • 9 views
  • Added February 7, 2026
toolsgotestingapisecurity

Works with

  • api

Security analysis

A100/100

Scanned November 9, 2026

npx -y skills add bnomei/kirby-mcp --skill kirby-security-and-auth --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kirby Security And Auth?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Kirby Security And Auth
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/bnomei-kirby-security-and-auth/badge)](https://www.skillsdirectory.com/skills/bnomei-kirby-security-and-auth)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: kirby-security-and-auth
description: Secures Kirby sites with access restriction, user roles, permissions, and protected downloads. Use when implementing login/role-based access, permissions, or file protection.
---

# Kirby Security and Auth

Use Kirby 6 conventions for new work. For existing authentication integrations, consult `kirby://kb/scenarios/83-migrate-kirby-5-to-6` before changing login or session handling.

## Kirby 6 authorization and login

- Model guards (`isAvailable`, `ensureExecutable`) replace deprecated model permissions checks. Role permissions and blueprint options remain separate: do not mechanically replace `$role->permissions()`.
- Use `authenticate()` and handle `Kirby\Auth\Status` / `State::Pending`; grant access only after successful challenge completion. `login2fa()` is legacy; password-only `login()` cannot complete 2FA.
- Users may opt into 2FA even if not globally required. Basic Auth cannot complete it; use appropriately scoped API accounts instead of weakening editor accounts.
- Old cookies are invalidated on upgrade. Test fresh login, logout, expiry and recovery. Passkeys are host-bound and require HTTPS outside localhost.
- Custom challenges extend `Kirby\Auth\Challenge`; hash secret pending data yourself. Never expose credentials in UI props, logs or migration reports.

## KB entry points

- `kirby://kb/scenarios/62-access-restriction-login`
- `kirby://kb/scenarios/43-user-registration-and-login`
- `kirby://kb/scenarios/63-files-firewall-protected-downloads`
- `kirby://kb/scenarios/64-permission-tricks-role-based`
- `kirby://kb/scenarios/67-indieauth-rel-me`

## Required inputs

- Protected pages/data and required roles.
- Login/logout flow and redirect rules.
- Download protection or route constraints.

## Role matrix template

| Role   | Pages | Actions | Downloads |
| ------ | ----- | ------- | --------- |
| admin  | all   | all     | all       |
| editor | edit  | publish | limited   |

## Default guard pattern

- Check `$kirby->user()` and required role/permission before returning content.
- Redirect or return a 403 for unauthorized requests.
- Enforce CSRF and validation on auth-related forms.

## Login redirect rule

- Store intended URL in the session and redirect after successful login.
- Fall back to the home page when no intent is stored.

## Common pitfalls

- Checking access only in templates while routes remain public.
- Returning a 404 for unauthorized access instead of a 403 or redirect.

## Verification checklist

- Test the role matrix across protected pages and downloads.
- Verify login/logout flows and session handling.
- Confirm CSRF failures render safely.

## Workflow

1. Clarify which pages/data are protected, required roles, and login/logout behavior.
2. Call `kirby:kirby_init` and read `kirby://roots`.
3. Inspect templates/controllers/blueprints to align with existing patterns:
   - `kirby:kirby_templates_index`
   - `kirby:kirby_controllers_index`
   - `kirby:kirby_blueprints_index`
4. For protected downloads or auth routes, inspect routes with `kirby:kirby_routes_index` and `kirby://config/routes` (install runtime if needed).
5. Search the KB with `kirby:kirby_search` (examples: "access restriction login", "user registration and login", "files firewall", "permission tricks", "page on own domain").
6. Implement least-privilege checks in templates/controllers or routes; enforce CSRF and validation on auth forms.
7. Verify by rendering protected pages (`kirby:kirby_render_page`) and manually testing login and download URLs.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.