WSU-Software-Development-Club / WSU-Software-Development-Club/self-hosting

Register and login endpoints with cookie sessions

Open
#6 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

advanced
Dominant language
JavaScript
Stars
2
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Why

Every file-related feature is scoped to a user, so auth has to exist first. We're using HTTP-only session cookies rather than JWTs: they're simpler for a browser app and the browser handles sending them.

Depends on: the SQLAlchemy/Alembic issue.

Files to touch

  • backend/app/auth.py (new)
  • backend/app/main.py: include the auth router
  • backend/tests/test_auth.py (new)
  • backend/requirements.txt: password hashing lib

Definition of done

  • POST /auth/register with {email, password} hashes the password (bcrypt or argon2) and returns 201; duplicate email returns 409
  • POST /auth/login verifies credentials and sets an HTTP-only session cookie; bad credentials return 401
  • POST /auth/logout clears the cookie
  • GET /auth/me returns the current user, or 401 if not logged in
  • A get_current_user FastAPI dependency exists that later routes can reuse
  • Tests cover register, duplicate email, login, and unauthorized /me

Hints

Never store plain-text passwords. passlib or argon2-cffi handle hashing. For sessions, a signed cookie (e.g. itsdangerous) is enough for now; a server-side session table can come later.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the planned entry points in backend/app/auth.py and backend/app/main.py, then review the SQLAlchemy/Alembic dependency before choosing the password-hashing and signed-cookie approach. Add backend/tests/test_auth.py for registration, duplicate email, login, and unauthorized /me behavior. Done means all listed endpoints, reusable get_current_user dependency, cookie handling, status codes, and tests are present.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python, sqlalchemy
Domain
api, authentication, backend, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.