d489716c9b
This commit introduces the foundation for web-based authentication and user interface. It includes: - **Session Management**: Securely handling user sessions using cryptographically generated tokens, cookies with appropriate security flags, and server-side storage. - **Login/Logout Functionality**: Endpoints for users to log in with their credentials and log out, clearing their session. - **User Interface**: Basic templates for the login page, a list of cases, and a detailed view of a single case, allowing users to navigate and view their data. - **Authorization**: An `AuthenticatedWebUser` extractor to ensure only logged-in users can access protected web routes. - **Configuration**: Added a `cookie_secure` option to the configuration to control the `Secure` flag on session cookies, useful for local development. - **Dependencies**: Added necessary dependencies for password hashing, time handling, and TOML file manipulation. - **Helper Binary**: Included a `hash-password` binary to simplify generating bcrypt hashes for user passwords.
17 lines
435 B
TOML
17 lines
435 B
TOML
# Generate a bcrypt hash for `web_password` e.g. via:
|
|
# python3 -c "import bcrypt; print(bcrypt.hashpw(b'your-password', bcrypt.gensalt()).decode())"
|
|
# or:
|
|
# htpasswd -bnBC 12 '' your-password | tr -d ':\n'
|
|
|
|
[[user]]
|
|
slug = "dr_mueller"
|
|
api_key = "change-me-to-a-secure-key"
|
|
web_password = "$2b$12$..."
|
|
role = "doctor"
|
|
|
|
[[user]]
|
|
slug = "dr_schmidt"
|
|
api_key = "change-me-to-a-secure-key"
|
|
web_password = "$2b$12$..."
|
|
role = "doctor"
|