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:
"auth": {
"enabled": true,
"public": ["^/$", "^/static/"]
}
freepod apply
| Field | Meaning |
|---|---|
enabled | Require sign-in |
access | anyone (the default): any Freepod account can sign in. listed: only you and the people on the deployment's access list. |
public | Paths 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:
"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:
| Header | Value |
|---|---|
X-Freepod-User | Account identifier. Stable for the lifetime of the account; use it as the key for users. |
X-Freepod-Email | Verified email address. It can change. |
X-Freepod-Name | Display name, percent-encoded UTF-8 |
X-Freepod-Username | The visitor's Freepod handle: lowercase letters and digits, unique, never changes. Absent until they claim a handle. |
Remote-User, X-Forwarded-User | Same as X-Freepod-User |
X-Forwarded-Email | Same as X-Freepod-Email |
X-Forwarded-Preferred-Username | Same 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.
- Node.js
- Python
- Go
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
from urllib.parse import unquote
user_id = request.headers.get("X-Freepod-User")
email = request.headers.get("X-Freepod-Email")
name = unquote(request.headers.get("X-Freepod-Name", ""))
username = request.headers.get("X-Freepod-Username") # None without a handle
userID := r.Header.Get("X-Freepod-User")
email := r.Header.Get("X-Freepod-Email")
name, _ := url.PathUnescape(r.Header.Get("X-Freepod-Name"))
username := r.Header.Get("X-Freepod-Username") // "" without a handle
Requests without a session
For a path that is not public:
- A browser page load (
Sec-Fetch-Mode: navigate, or anAcceptheader that includestext/html) is redirected to sign-in, and returns to the requested URL afterwards. - Any other request, including
fetchcalls and form posts, receives401and does not reach the application. A single-page application should handle401by navigating to the sign-in link.
Sign-in and sign-out links
Paths under /.freepod/auth/ are handled by the platform and never reach the application.
| Link | Effect |
|---|---|
/.freepod/auth/login?rd=/path | Signs in, then returns to /path |
/.freepod/auth/logout?rd=/path | Signs 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.
Sessions and consent
- 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.