-
Notifications
You must be signed in to change notification settings - Fork 0
📝 Add comments #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
…satisfy type inference; all tests pass
…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
…pendency; run fmt/clippy. 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.
055d64c to
26e9865
Compare
No description provided.