Skip to content

Conversation

@ebigunso
Copy link
Owner

No description provided.

@ebigunso ebigunso self-assigned this Aug 11, 2025
Copilot AI review requested due to automatic review settings August 11, 2025 22:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds authentication, CSRF protection, and comprehensive security features to the sleep API. The changes include login/logout functionality, encrypted session cookies, double-submit CSRF protection, security headers, and authentication middleware.

Key changes:

  • Implements single-user authentication with session cookies and CSRF protection
  • Adds security middleware and headers for production deployment
  • Updates all existing endpoints to require authentication and CSRF protection for mutating operations

Reviewed Changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sleep-api/src/auth.rs Core authentication utilities for session management and credential verification
sleep-api/src/security/ CSRF protection and security headers implementation
sleep-api/src/middleware/ Authentication extractors for protecting routes
sleep-api/src/app.rs Updated router with login/logout endpoints and auth requirements
sleep-api/tests/ Test files updated with authentication and CSRF handling
sleep-api/src/config.rs Configuration helpers for admin credentials and cookie settings
Cargo.toml Added dependencies for authentication and testing
openapi.yaml Updated API specification with authentication requirements
README.md Comprehensive documentation for authentication and security features
.env.example Environment configuration template

…login and /logout; protect /trends and mutating APIs; add tests (auth_csrf) and update existing tests; switch CSRF token to URL-safe base64; clippy clean
…ppState, config, and pw-hash; align with existing project style
…y warnings in tests (format args, remove needless borrows); keep unsafe env var blocks per project guidance. Refs #5
…itch RNG sources to password-hash rand_core OsRng to resolve rand_core version mismatch; run cargo fmt and clippy; address PR feedback. Refs #5
…use config-based names for session/CSRF cookies; switch to axum_extra::either::Either for /login form+JSON
… CSRF; update README for COOKIE_SECURE and double-submit
…t(session): add SESSION_TTL_HOURS Max-Age; feat(security): COOKIE_SECURE dev-mode cookie names/flags; refactor(csrf): dynamic cookie names and header handling; docs(openapi,README): add /login.json, securitySchemes and CSRF requirements; chore(CSP): add connect-src 'self'
…-protect /logout; gate GET /sleep/date and trends APIs by session. headers: CSP allow cdn.jsdelivr.net for Chart.js.
… protected endpoints; gate GET endpoints in spec. tests: CSRF required on logout; add percent-encoded CSRF header test and dev cookie flags test.
…tests; add percent-encoded token and dev cookie flags coverage. build: add serial_test dev-dep.
@ebigunso ebigunso force-pushed the feature/2025-08-11/security-update branch from 055d64c to 26e9865 Compare August 11, 2025 22:10
@ebigunso ebigunso merged commit f6efa52 into main Aug 11, 2025
2 checks passed
@ebigunso ebigunso deleted the feature/2025-08-11/security-update branch August 11, 2025 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants