Skip to main content

Authentication

Sign in with Freepod puts a sign-in in front of a deployment. Visitors sign in with a Freepod account before their requests reach the application, and the application receives their identity in request headers. The application does not handle passwords, sessions or sign-in pages.

By default every Freepod account can sign in to a deployment that enables it, and registration is open. A deployment can instead admit only its owner and the people the owner lists (see Who can sign in). Either way, deciding what a signed-in user may do is the application's responsibility.

Enabling​

Add auth to .freepod.json and apply it:

.freepod.json
"auth": {
"enabled": true,
"public": ["^/$", "^/static/"]
}
freepod apply
FieldMeaning
enabledRequire sign-in
accessanyone (the default): any Freepod account can sign in. listed: only you and the people on the deployment's access list.
publicPaths that do not require sign-in, as RE2 regular expressions matched against the path without the query string. Up to 32 patterns.

Who can sign in​

With "access": "listed", only you and the people you add can sign in:

.freepod.json
"auth": {
"enabled": true,
"access": "listed"
}

You manage the list on the dashboard: expand the deployment and choose Access. Changes take effect without a release.

  • You, the owner, can always sign in, and are not on the list.
  • You add people by email address, up to 500. Each one receives an email inviting them to sign in at the deployment's address with a Freepod account that uses that address.
  • The first account that signs in with an address is tied to it. From then on only that account is admitted, even if its email address changes.
  • Removing someone refuses their requests within 30 seconds, on every path, public paths included.
  • Anyone else who signs in sees a page saying the deployment is open only to the people its owner has added, with a link to sign out and use another account.

The list decides who can sign in, not what they can do. The application still receives the same identity headers and makes every other decision itself.

Identity headers​

Requests from a signed-in visitor carry:

HeaderValue
X-Freepod-UserAccount identifier. Stable for the lifetime of the account; use it as the key for users.
X-Freepod-EmailVerified email address. It can change.
X-Freepod-NameDisplay name, percent-encoded UTF-8
X-Freepod-UsernameThe visitor's Freepod handle: lowercase letters and digits, unique, never changes. Absent until they claim a handle.
Remote-User, X-Forwarded-UserSame as X-Freepod-User
X-Forwarded-EmailSame as X-Freepod-Email
X-Forwarded-Preferred-UsernameSame as X-Freepod-Username

The platform removes these headers from every incoming request before adding its own, so on a deployment they always come from the platform, including on public paths. On a public path they are present only when the visitor is signed in.

const userId = req.headers['x-freepod-user']
const email = req.headers['x-freepod-email']
const name = decodeURIComponent(req.headers['x-freepod-name'] ?? '')
const username = req.headers['x-freepod-username'] // undefined without a handle

Requests without a session​

For a path that is not public:

  • A browser page load (Sec-Fetch-Mode: navigate, or an Accept header that includes text/html) is redirected to sign-in, and returns to the requested URL afterwards.
  • Any other request, including fetch calls and form posts, receives 401 and does not reach the application. A single-page application should handle 401 by navigating to the sign-in link.

Paths under /.freepod/auth/ are handled by the platform and never reach the application.

LinkEffect
/.freepod/auth/login?rd=/pathSigns in, then returns to /path
/.freepod/auth/logout?rd=/pathSigns out of this deployment and ends the Freepod sign-in, then returns to /path

rd must be a path on the same host; any other value returns to /. After signing out, the next sign-in asks for credentials, so the logout link also lets a visitor switch accounts. Because it ends the Freepod sign-in, it also signs that browser out of every other deployment it signed in to, within seconds, and out of the Freepod dashboard within a minute. Other browsers and devices stay signed in.

  • A session lasts up to 7 days and is valid only on the hostname it was issued for.
  • A session ends within seconds when the visitor signs out of Freepod in the same browser, whether from the dashboard or from any deployment.
  • The first time someone signs in to a deployment, they are asked to agree to share their name, email address, handle and account identifier with it. The question is not asked again for that deployment, unless they have since claimed a handle.
  • The session cookie never reaches the application. Do not set cookies whose names start with __Host-freepod_.

Local development​

Sign-in is not available outside Freepod. Send the headers yourself:

curl -H 'X-Freepod-User: dev-user-1' \
-H 'X-Freepod-Email: dev@example.com' \
-H 'X-Freepod-Name: Dev%20User' \
http://localhost:8080/

Only trust the headers when the application runs on Freepod. Do not put another proxy in front of it that passes client-supplied headers through.