Auth: username/password (email login)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by locating the Go HTTP entry points for /login, /auth/login, /auth/logout, /auth/me, and /auth/register, along with database initialization. Use the users and sessions schema, session TTL, bcrypt requirements, cookie behavior, and route exceptions as the acceptance map. Done means authentication, bootstrap registration, session middleware, and protected-route behavior all match the issue.
Written by the indexing model from the issue text.
Description
Sub-issue of #2.
Implement the foundational authentication layer using email + password. This is the prerequisite for all other auth methods and the authorization model (#3).
Database
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
name TEXT NOT NULL,
password_hash TEXT, -- NULL for SSO-only accounts
created_at TIMESTAMPTZ DEFAULT now()
);
CREATE TABLE sessions (
id TEXT PRIMARY KEY, -- random 32-byte hex token
user_id BIGINT REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ DEFAULT now(),
expires_at TIMESTAMPTZ NOT NULL
);
password_hash is nullable so the same users table works for SSO accounts (Google #16, Apple #17) that have no password.
Endpoints
| Method | Path | Description |
|---|---|---|
GET |
/login |
Serve the login page |
POST |
/auth/login |
Validate email + password, set session cookie |
POST |
/auth/logout |
Clear session cookie |
GET |
/auth/me |
Return current user (used by frontend) |
Session management
- On successful login: generate a random session token, insert into
sessions, setSet-Cookie: session=<token>; HttpOnly; SameSite=Strict. - Auth middleware: read
sessioncookie, look up in DB, attach user tor.Context(). - Session TTL: configurable via
SESSION_TTL_HOURSenv var (default 720 = 30 days).
Password requirements
- Minimum 12 characters.
- Stored as bcrypt hash (cost 12).
- No complexity rules — length is sufficient.
What to protect
All routes except POST /snaps (API key auth — #4) and GET /photos/{token} (token is the auth) should require a valid session.
First-run bootstrap
If the users table is empty, the first POST /auth/register call succeeds without restriction and creates an admin account. Subsequent registrations require an existing admin to invite or a configurable ALLOW_REGISTRATION=true flag.
Related
- #2 Authentication (parent)
- #3 Authorization
- #4 API keys
- Dominant language
- Go
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from williamokano/SentinelSnap
-
enhancement infrastructure security
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
williamokano/SentinelSnap#36 ·
-
enhancement infrastructure
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
williamokano/SentinelSnap#35 ·
-
improvement low priority
Difficulty 5/5 Over a week Newbie friendliness 38/100
williamokano/SentinelSnap#75 ·
-
chore low priority
Difficulty 3/5 1-2 days Newbie friendliness 72/100
williamokano/SentinelSnap#74 ·
-
ci enhancement infrastructure security
Difficulty 4/5 3-5 days Newbie friendliness 48/100
williamokano/SentinelSnap#46 ·
All issues in williamokano/SentinelSnap
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100