HenniOKF
Documentation

Concept

Security

Public reading, the sign-in requirement, open paths, origin of a request, sign-in attempts and the headers of every response.

Public reading and the sign-in requirement

Reading is public: the start page and this documentation need no account. Every other request requires signing in: in the browser the session, otherwise an API key as Authorization: Bearer …. The check stands in one place in front of all routes, in proxy.ts. It checks the session completely; a cookie alone is not enough.

What happens without signing in:

RequestAnswer
an open path, see belowthe page or the file
a page (GET or HEAD that accepts text/html or carries the header rsc)307 to /sign-in?next=<path>, back after signing in
every other, such as curl without Accept: text/html401 with a message as JSON

Navigating in the browser is a request with the header rsc. It counts as a page and is therefore redirected.

What stays open

AddressWhy
/the start page, reading is public
/docs, /docs/*, /docs-image/*this documentation with its images
/sign-insigning in itself
/api/auth/*the API of Better Auth, which protects itself
/_next/static/*, /_next/image/*the built scripts and styles
/favicon.ico, /icons/*, /manifest.webmanifestthe app icon for browsers and home screens
/sign-in/*images of the sign-in page from public/sign-in/; there are none yet

Everything else, also the images of the tiles under /settings/, requires signing in. With the next phases the bundles, the search and the tags become open paths too; the MCP server never does.

Without configuration (HENNIOKF_ROOT missing) there are no accounts. Then every protected page leads to /status, which is then open and says what is missing; every other protected request gets 503. The start page and the documentation still answer.

Permissions

Once someone is signed in, every page checks its permission itself. Whoever lacks it comes to the start page. A route of its own answers without signing in with 401 and without the permission with 403. The permissions are under Permissions.

Origin of a request

A request that changes something and carries a cookie must come from the same address it goes to. Otherwise the application answers 403. So a foreign page cannot send a request in the name of a signed-in browser.

  • Better Auth gets the main address fixed and per request the address under which the request arrived, from host and x-forwarded-host. A wildcard for every address is excluded; it would make every origin trusted.
  • Better Auth protects only its own routes. A route of its own checks the origin with requirePermission() from lib/access.ts.
  • A request with an API key carries no cookie and needs no origin.

Sign-in attempts

At most HENNIOKF_SIGN_IN_LIMIT sign-ins per minute and address, default 10. Above that the application answers "Too many sign-in attempts". Behind a proxy all readers may arrive with the same address and share the limit; then set the value higher.

Headers of every response

Every response carries these headers, set in next.config.mjs:

HeaderWhat it does
Content-Security-Policyscripts, styles, images, fonts and connections only from the instance itself. No embedding in foreign pages, no plugins, no foreign form targets
Strict-Transport-Security: max-age=31536000the browser takes only HTTPS for a year
X-Content-Type-Options: nosniffthe browser guesses no content type
X-Frame-Options: DENYno embedding, also for older browsers
Referrer-Policy: strict-origin-when-cross-originforeign pages learn only the address of the instance, not the path
Permissions-Policycamera, microphone, location, payment and USB off

The policy allows 'unsafe-inline' for scripts and styles, because Next.js writes data into every page. The development server adds 'unsafe-eval' and ws:.

A stricter route needs a rule of its own. Next.js sends one value per header, and the last matching rule wins. How to make a route stricter, for example for files that must never run script, is under Recipes for extending.

What else applies

  • Every page carries noindex, nofollow.
  • Passwords and keys stand only as hashes in the database. A key appears only once.
  • The instance token and the session secret appear nowhere, also not on /status.
  • Images of the documentation come only from the bundle, without SVG, with nosniff.

Next: Setup.