Add Local Authentication Option #36
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Objective
Implement local username/password authentication in the
tripsapp while preserving existing Synology OIDC login. Users must be able to choose an auth source on/login.Scope
/loginauto-redirect with source picker + local login form.auth_identities,auth_sourcestables).Current State (for agent context)
trips/src/auth.ts(single provider:synologyOIDC).trips/src/routes/login/+page.server.ts(returns Synology sign-in URL only).trips/src/routes/login/+page.svelte(auto-submits hidden form to Synology).trips/src/lib/server/users.ts(upsertUserFromAuth).trips/src/lib/server/admin/auth.ts(env-basedADMIN_USER_IDS).Functional Requirements
/loginmust show:session.user.id.Non-Functional Requirements
Data Model Changes (Phase 1 minimal)
local_credentials:user_id TEXT PRIMARY KEY REFERENCES users(id) ON DELETE CASCADEpassword_hash TEXT NOT NULLcreated_at TEXT NOT NULL DEFAULT (datetime('now'))updated_at TEXT NOT NULL DEFAULT (datetime('now'))trips/src/lib/server/db/migrations.tsusingCREATE TABLE IF NOT EXISTS.usersschema in Phase 1.Environment Variables
trips/.env.example:LOCAL_AUTH_ENABLED=falseLOCAL_AUTH_ARGON2_MEMORY_KB=65536LOCAL_AUTH_ARGON2_TIME_COST=3LOCAL_AUTH_ARGON2_PARALLELISM=1LOCAL_AUTH_MAX_ATTEMPTS=5LOCAL_AUTH_WINDOW_SECONDS=900LOCAL_AUTH_LOCKOUT_SECONDS=900Implementation Tasks
trips/src/auth.ts:credentialsprovider with idlocal.authorize()by looking up user by username/email, verifying Argon2id hash, and returning{ id, name, email }.session.user.id).trips/src/lib/server/local-auth.ts:verifyLocalCredentials(identifier, password, ip)function.trips/src/lib/server/local-credentials.ts:trips/src/routes/login/+page.server.tsshould return available methods and Synology URL.trips/src/routes/login/+page.svelteshould render both options.signin/local./loginavailable options and error state.trips/README.md.Security Requirements
Acceptance Criteria
LOCAL_AUTH_ENABLED=true,/loginshows both auth options..env.exampleand README include local-auth configuration.Deliverables