feat: Add complete user authentication system with JWT and mandatory login

Implemented a comprehensive authentication system requiring all users to be
logged in to access the web interface. Features include:

Backend:
- JWT-based authentication with 7-day token expiration
- bcrypt password hashing with 72-byte limit handling
- User management with JSON file storage (config/users.json)
- Pydantic models for validation (UserCreate, UserLogin, User, Token)
- Authentication endpoints: register, login, me, logout
- Protected route dependency with HTTPBearer security

Frontend:
- Login/register page with dual-tab interface (/login)
- Client-side authentication check with automatic redirect
- All content hidden by default, shown only after auth validation
- User info display with logout button
- Main content and tabs hidden when not authenticated
- Auto-redirect to /login if token missing or invalid

Security:
- Password truncation to 72 bytes (bcrypt limitation)
- Token verification on each page load
- Automatic logout and redirect on token expiry
- Username-to-SHA256 user ID generation

Dependencies:
- passlib[bcrypt]==1.7.4
- python-jose[cryptography]==3.3.0
- bcrypt<4.0

Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
root
2026-01-29 17:25:50 +00:00
parent c1c31d7685
commit ef72e221be
10 changed files with 974 additions and 14 deletions
+10 -9
View File
@@ -9,15 +9,16 @@
<link rel="stylesheet" href="/static/css/style.css">
<!-- JavaScript -->
<script src="/static/js/api.js?v=1.5" defer></script>
<script src="/static/js/utils.js?v=1.5" defer></script>
<script src="/static/js/downloads.js?v=1.5" defer></script>
<script src="/static/js/anime.js?v=1.5" defer></script>
<script src="/static/js/anime-details.js?v=1.5" defer></script>
<script src="/static/js/series-search.js?v=1.5" defer></script>
<script src="/static/js/recommendations.js?v=1.5" defer></script>
<script src="/static/js/tabs.js?v=1.5" defer></script>
<script src="/static/js/main.js?v=1.5" defer></script>
<script src="/static/js/auth.js?v=1.9" defer></script>
<script src="/static/js/api.js?v=1.9" defer></script>
<script src="/static/js/utils.js?v=1.9" defer></script>
<script src="/static/js/downloads.js?v=1.9" defer></script>
<script src="/static/js/anime.js?v=1.9" defer></script>
<script src="/static/js/anime-details.js?v=1.9" defer></script>
<script src="/static/js/series-search.js?v=1.9" defer></script>
<script src="/static/js/recommendations.js?v=1.9" defer></script>
<script src="/static/js/tabs.js?v=1.9" defer></script>
<script src="/static/js/main.js?v=1.9" defer></script>
</head>
<body>
<div class="container">