PiVPN Web uses server-side sessions backed by a TypeORM session store. A session cookie (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AZhur771/pivpn-web/llms.txt
Use this file to discover all available pages before exploring further.
connect.sid) is set on successful login and must be present for all authenticated requests. Session cookies are HttpOnly, SameSite: strict, and optionally Secure when the IS_SECURE environment variable is set.
GET /api/session
Returns the authentication status of the current session. This endpoint is always accessible — no active session is required. It is useful for bootstrapping a UI to determine whether to show the login form. Response — authenticatedtrue when a valid session exists for the current request, false otherwise.The SSH user that PiVPN Web uses to connect to the host (the value of the
SSH_USER environment variable). Only present when authenticated is true.The hostname of the PiVPN host as returned by the
hostname shell command. Only present when authenticated is true.true when the logged-in user has the admin flag set in the database. Only present when authenticated is true.POST /api/session
Authenticates a user and creates a new session. Credentials are validated against the user database using bcrypt. On success the server responds with204 No Content and sets a Set-Cookie header containing the session cookie. Store that cookie and send it with every subsequent request.
No prior authentication is required to call this endpoint.
The username of the account to log in with. Corresponds to the
login column in the user table.The plain-text password. It is compared against the bcrypt hash stored in the database.
204 No Content — session created. The Set-Cookie header contains the connect.sid session cookie.
Error responses
| Status | Body | When |
|---|---|---|
500 | { "error": "Missing username" } | username field absent or empty |
500 | { "error": "Missing password" } | password field absent or empty |
500 | { "error": "Wrong username or password" } | User not found or password mismatch |
The same
"Wrong username or password" message is returned for both an unknown username and a wrong password. This is intentional — it prevents user enumeration.-c cookies.txt flag saves the session cookie to a file. Pass -b cookies.txt on subsequent requests to authenticate them.
DELETE /api/session
Logs out the current user and destroys the active session. Requires a valid session — unauthenticated requests are rejected with401.
After a successful logout the session store entry is removed and the cookie becomes invalid.
Response
204 No Content
Error responses
| Status | Body | When |
|---|---|---|
401 | { "error": "Invalid Session: <id>" } | No valid session is attached to the request |