Put a docs site behind a password, keep some pages open to everyone, and limit
others to a group of readers. aiui serve and aiui dev enforce it; there is
aiui serve
aiui dev
nothing to install and no account system to run.
Every page now asks for the password. A reader who opens any page gets a sign-in
page in the site's own theme, at that URL, and lands on the page they asked for.
The session lasts seven days. /__aiui/login shows who is signed in and a
/__aiui/login
Sign out button (link to it from navbar.links if you want one).
navbar.links
Passwords are always written env:NAME: the build stores the variable's name,
env:NAME
never the password. Change the variable and restart to change the password;
every reader signed in with the old one is signed out.
Most docs want a public home and quickstart and the rest behind sign-in:
public lists page paths relative to the docs (/ is the home page,
public
/
/docs/quickstart also works) and patterns (* matches any part of a path). A
/docs/quickstart
*
page can also say it in its front matter:
public: false keeps a page behind sign-in when a pattern would open it, so
public: false
public: ["*"] plus public: false on a few pages protects only those.
public: ["*"]
Readers sign in with their password alone; it tells the server who they are.
Give readers groups, then name the groups a page is for:
A page with groups is for readers in at least one of them. To any other
groups
signed-in reader it does not exist: a 404, and it is missing from their sidebar,
search, llms.txt, MCP and Ask AI. A signed-out reader who opens it gets the
llms.txt
sign-in page (they may be a member).
A page's rule covers everything made from it: its HTML (including the copy
inside <noscript>), its .md and .source.md files and `Accept:
<noscript>
.md
.source.md
text/markdown answer, its social card under /og/`, its Try it data and its RSS
answer, its social card under
feed. docs-nav.json, search-index.json, llms.txt and llms-full.txt (and
docs-nav.json
search-index.json
llms-full.txt
their /.well-known/ copies) hold only the pages the reader may read (so the
/.well-known/
pages do not carry the navigation, as they do on a site without sign-in, and
the build writes no split search index, search-index/: search reads the cut
search-index/
search-index.json), and the
MCP server, Ask AI,
/api/docs/search and page feedback see only those pages. An AI tool that
/api/docs/search
connects to /mcp without the browser's cookie reads the open pages. The
/mcp
sitemap lists only open pages.
Code, styles, fonts, images and ui-config.json are open to anyone, so open
ui-config.json
pages render (do not put a secret in an image). Any other file (OpenAPI specs, a
nav group's generated page, files you copied in) needs sign-in.
Cache-Control: private
hands one reader's page to another.
HttpOnly
SameSite=Lax
Secure
(also behind a proxy that sets X-Forwarded-Proto). It is signed with a key
X-Forwarded-Proto
derived from the reader's password.
in ten minutes block that address for the rest of the ten minutes (429).
(AIUI_ALLOWED_ORIGINS adds origins, as for the rest of aiui).
AIUI_ALLOWED_ORIGINS
cannot sign in.
Sign-in needs the aiui server. A static host (GitHub Pages, a CDN) serves every
file of the build, so aiui build warns (7017) on a site with
aiui build
content.docs.auth; serve it with aiui serve (deployment).
content.docs.auth
aiui validate reports front matter public or groups on a site without
aiui validate
content.docs.auth, and a group no reader is in (7017). A docs folder served by aiui run uses the app's own
aiui run
sign-in instead (deployment).