Replace HTTP Basic Auth with a login page and session cookie
- /login form checks DASHBOARD_USER / DASHBOARD_PASSWORD from .env in constant time; failed attempts are serialized with a 1s delay - Sessions are random tokens kept in memory for 30 days, in an HttpOnly, SameSite=Lax cookie (Secure behind HTTPS); sign out ends them server-side - Signed-out requests redirect to /login and return to the page afterwards, with redirects limited to local paths - Dashboard pages send no-store and X-Frame-Options: DENY - Tests for the login flow and redirect safety; docs updated Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
f8e851fdb9
commit
0a1d6a8927
8 files changed
+299
-32
No files matched your search
@@ -0,0 +1,16 @@
|
||||
{{define "title"}}Sign in · pocketkv{{end}}
|
||||
{{define "header"}}{{end}}
|
||||
{{define "content"}}
|
||||
<form class="login" method="post" action="/login">
|
||||
<h1>pocketkv</h1>
|
||||
{{if .Error}}<p class="error">{{.Error}}</p>{{end}}
|
||||
<input type="hidden" name="next" value="{{.Next}}">
|
||||
<label>Username
|
||||
<input type="text" name="user" value="{{.User}}" autocomplete="username" required {{if not .User}}autofocus{{end}}>
|
||||
</label>
|
||||
<label>Password
|
||||
<input type="password" name="password" autocomplete="current-password" required {{if .User}}autofocus{{end}}>
|
||||
</label>
|
||||
<button class="primary" type="submit">Sign in</button>
|
||||
</form>
|
||||
{{end}}
|
||||
Reference in new issue
Block a user