一键导入
authentication-system
Guide to the authentication and authorization system in Docklift.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guide to the authentication and authorization system in Docklift.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | Authentication System |
| description | Guide to the authentication and authorization system in Docklift. |
Docklift uses a token-based authentication system (JWT) to secure the API and frontend.
backend/src/routes/auth.tsbackend/src/lib/authMiddleware.tsbackend/src/lib/originCheck.ts (CORS + WebSocket)frontend/src/components/AuthProvider.tsxfrontend/src/lib/auth.ts (getAuthHeaders, authFetch, fetchWithAuth)User (email, password hash, role, passwordChangedAt).Registration:
POST /api/auth/registerx-bootstrap-secret or body) — printed by install /
backend logs / data/.bootstrap-secret. Never returned by a public API.fs.rename of data/.bootstrap-secret → .claimed-<random>
(lib/bootstrap.ts). Only the winner may create the admin; losers get 403.recoverStaleBootstrapClaims() restores a leftover
.claimed-* back to .bootstrap-secret so setup is not bricked./register and /setup-token use a stricter limiter (10 / 15 min)
in addition to the general auth limiter.Login:
POST /api/auth/logintoken (7-day expiry) that includes a pwdv claim.express-rate-limit on all /api/auth routes (100 / 15 min general).Session Management:
localStorage key docklift_token.authFetch() for protected APIs — it attaches the Bearer header and on 401
clears storage + calls logout() (registered from AuthProvider). Prefer it over raw
fetch + getAuthHeaders().AuthProvider.tsx validates /api/auth/me on page load and clears invalid tokens.pwdv === passwordChangedAt.getTime().
Exact match (not iat comparison) — same-second reissue after password change works correctly.All routes except the following require JWT via authMiddleware:
/api/auth/register, /api/auth/login, /api/auth/status (public, rate limited)/api/github/webhook, /manifest/callback, /setup (GitHub App flow)
/api/github/callback OAuth token exchange is disabled (install-id redirect only)/api/backup/restore-upload with valid setup token (fresh install restore; token consumed only
after successful restore — see lib/setupRestoreAuth.ts)Routes /me, /profile, /change-password all use authMiddleware (not manual JWT decoding).
Server-Sent Events (logs) use short-lived tokens instead of long-lived JWTs in URLs:
POST /api/auth/sse-token → returns a 5-minute JWT with purpose: 'sse' (requires Bearer session JWT)?token=<sseToken>authMiddleware: Authorization: Bearer session JWT only — no query tokenssseAuthMiddleware: query ?token= with purpose === 'sse' onlyGET /api/system/logs/:serviceGET /api/logs/:projectId/stream/:containerNameLocated in backend/src/lib/authMiddleware.ts.
authMiddleware: Bearer session JWT; rejects SSE-purpose tokens; never reads ?token=;
rejects when pwdv is missing or does not match passwordChangedAt.sseAuthMiddleware: Query SSE token only; rejects tokens without purpose: 'sse'; same pwdv check.config.dataPath (never a hardcoded ./data).catch blocks in auth routes return generic messages (e.g., 'Login failed'), never error.message.index.ts (X-Content-Type-Options, X-Frame-Options, X-XSS-Protection, Referrer-Policy, Permissions-Policy, plus HSTS when the request arrived over HTTPS). Helmet is not used.isTrustedOrigin(), plus any
exact origins configured in CORS_ORIGIN. See the security_hardening skill for why hostname-only
matching is unsafe here./api/auth routes./api/system/upgrade, update-system, reboot, reset, purge): session JWT plus requireStepUpPassword body password. Canceling the password dialog must not call these APIs.fetch + Authorization: Bearer header + blob download pattern — never put JWTs in URL query parameters (prevents token leakage in browser history, server logs, and referrer headers).bcrypt with 12 salt rounds.cd backend
bun run reset-password
localStorage.Guide for server management, system APIs, backups, and maintenance operations.
Guide for developing features in the Vite + React Router frontend.
Guide to Docklift's automated release pipeline using semantic-release.
Guide for setting up, running, and developing the Docklift project.
Guide for setting up and managing Docklift's GitHub App integration.
Coolify/Dokploy-style managed databases with Dokku-style app linking.