Skip to content

Admin and auth ​

Girici stores a single admin account and its settings in a small SQLite database (<data dir>/girici.db). The database is created on first run.

Setup ​

The first time you open Girici with no admin yet, every route sends you to the setup screen. You create one admin (username, name, email, password, at least 8 characters). After setup you are signed in.

Setup asks for a one-time code that Girici prints to its log at startup, whatever LOG_LEVEL says:

Girici setup code: K7QM-2XPA-9FDR
Open Girici in a browser and enter this code to create the admin account.

Only someone who can read the server log can create the admin, so a fresh instance that is already reachable from the internet cannot be claimed by a stranger. A restart prints a new code until setup is done. To choose the code yourself, for example in automated deployments, set GIRICI_SETUP_TOKEN (8 or more characters).

Login ​

Once an admin exists, the proxy requires a login. Visiting a proxied page while signed out redirects you to the login screen, and signing in sends you back where you were headed.

The session is a stateless cookie, signed with a secret stored in the database. Over HTTPS it is __Host-girici; on a plain-HTTP page such as http://localhost it is girici-session, because Safari drops the Secure cookie that __Host- requires there. There is no server-side session table; signing out clears the cookie.

Sign out everywhere on the Account page voids every session the admin has, on every device. Changing the password and running the reset tool below do the same. This also works when GIRICI_SESSION_SECRET fixes the signing secret, because Girici stores the time of the last sign-out and refuses sessions issued before it.

Public access ​

In Settings, an admin can turn on Public access. While it is on, anyone can browse through the proxy without signing in. The admin account and the admin section of Settings still require a login.

Public access is off by default. A public instance is open to abuse, so enable it only when you mean to.

Changing the account (name, email, password) or the admin settings asks for your current password every time. The page keeps it in memory only while it is open. If you forgot it, use the reset tool below.

On a public instance, someone who opens a proxied page from a link, in a browser that has never used Girici, first sees a notice. It says that the page comes from another site through this proxy, not from the people who run the server, and shows the real address with a Continue button. It is meant for links passed around in chats and emails, where the visitor may not know what Girici is.

Each browser sees it once. It stops after the visitor presses Continue, or after they open a site from Girici's home page or Settings. Only loading one of Girici's own pages does not count, so a link or popup that lands there cannot skip the notice. Pages inside frames and the requests a page makes never get the notice.

Settings → Admin → Warn before shared links turns it off for everyone. It is on by default and asks for the current password like the other admin settings. It applies only while Public access is on: a private instance lets no visitor in, so it never shows there. A browser that already has Girici open picks up a change within a minute.

The browser remembers the notice in the service worker's own storage. Clearing site data in Settings does not bring it back; wiping the browser's data for Girici does. A #fragment at the end of a shared link may be lost after Continue, depending on the browser.

In subdomain mode each site has its own host. Opening a site from Girici's own pages marks the browser with a cookie every site host reads, so none of them shows the notice. Continue counts only for the site where it was pressed. A page reached from the root or from another site host, whose Referer names one of Girici's own hosts, never shows it either.

Resetting the admin password ​

If you are locked out, reset the password from the command line. It generates a fresh random password, sets it, and prints it:

bash
node ./reset-admin-password.js
Password reset for admin "halit".

  New password:  iP4dhbzAMXNRnBJFStOtEFcWbtNERb3C

All other sessions have been signed out. Sign in with it on the login page.

In Docker, run it inside the container so it uses the same database:

bash
docker compose exec girici node reset-admin-password.js

The tool reads the same data directory as the server (GIRICI_DATA_DIR), so point it at the right database if you overrode that.

In Settings, an admin can give the instance its own name and logo. Saving needs the current password, like every admin change.

  • The name has 1 to 40 characters. Control characters and text-direction overrides are refused. Leaving it empty goes back to "Girici".
  • The logo is a PNG, JPEG, WebP or SVG file of at most 256 KB. Girici checks the type from the file's bytes, not from its name. Girici serves it with a sandbox policy, so a script inside an SVG never runs.
  • Every visitor sees them, signed in or not: in the header, on the sign-in and setup screens, in the tab title and as the favicon. Error pages from the proxy engine keep the Girici name.
  • The "Source code · AGPL-3.0" link stays, and the sign-in and setup screens show it too.

The name lives in the database and the logo in <data dir>/brand/logo.

Blocked sites ​

Under Settings → Admin → Blocked sites, list one site per line. Girici refuses those sites and all of their subdomains on every relay, including WebSockets, and shows visitors a page that says the site is blocked on this server. You can paste a full URL; Girici keeps only its host name. Sites listed in the GIRICI_BLOCKED_HOSTS environment variable apply too and show under the editor as read-only.

Encrypted page addresses ​

Each visitor can turn on Settings → Encrypt page addresses. Pages then open at addresses such as /~/x/<token> instead of /~/https/example.com/..., so the address bar shows a token instead of the site. It does not keep sites out of the browser's history. A link to another site, window.open and the Navigation API first load the plain /~/https/... address, which the service worker then redirects to the token, and browsers may keep that first address in their history. Girici's own recent sites list (Remember history) also keeps real addresses. The key lives in that browser only: a copied link does not open in another browser, and it stops opening if the browser's data for Girici is wiped. Clearing site data in Settings keeps the key.

An admin can turn on Settings → Admin → Encrypt page addresses for everyone. It asks for the current password, like the other admin settings. While it is on, every visitor's switch shows on and cannot be turned off. A browser that already has Girici open picks the change up on a page load within a minute. Both switches are off by default.

What stays readable, and other limits, are listed under Known limitations.

Browser check ​

Settings → Admin → Browser check for visitors makes every new browser solve a short puzzle before its first proxied page. Turning it on asks for the current password. It applies only while public access is on, and the signed-in admin is never checked. It is off by default.

A visitor without a pass sees a page titled "Checking your browser". The browser hashes a challenge from the server with SHA-256 until it finds a number that gives enough leading zero bits, sends that number back, and receives a girici-visitor cookie (__Host-girici-visitor on https). The page then opens the address the visitor asked for, encrypted or not. Until then the relay, the WebSocket relay and the YouTube token minter refuse that browser. A proxied page inside a frame cannot show the check, so the frame says to reload the page instead.

The check makes automated abuse cost processor time on every new address. It does not stop a determined client: a script can solve the puzzle too, and a real browser driven by a bot passes like any other. It is not a CAPTCHA and does not tell people from machines.

GIRICI_POW_DIFFICULTY sets how hard the puzzle is, from 1 to 24, default 16. Each step doubles the average work, so lower it if many of your visitors use slow phones.

The cookie lasts a day, and a visitor who keeps browsing gets a fresh one every hour. It is tied to the visitor's network address (all of an IPv6 /64 counts as one), so a phone that moves from Wi-Fi to mobile data is checked again and then lands on the page it asked for. Cookies are signed with a key derived from the session secret. Replicas that share GIRICI_SESSION_SECRET accept each other's cookies, and changing the admin password checks every visitor again unless that variable is set.

Limits:

  • The check needs JavaScript and Web Workers.
  • Each challenge can be answered once. Girici remembers answered challenges in memory, so after a restart or on another replica an answer works once more during the five minutes the challenge lives.
  • Girici remembers up to 100,000 answered challenges. If a flood of solves from many addresses fills that within five minutes, it forgets the oldest ones, and those can be answered once more. Other visitors keep passing.

Scaling later ​

The schema already carries a username per account, so the single-admin model can grow into multiple users without a migration.

Released under the AGPL-3.0 License.