4169 Commits

Author SHA1 Message Date
João Vitória Silva
9cffa434da Update settings sidebar translations for consistency
Standardized capitalization in the settingsSideBarComponent.json translation file to ensure consistency across section labels.
v0.16.4
2025-12-23 11:42:48 +00:00
João Vitória Silva
359acd674f Add script to restore Postgres from backup
Introduces restore_postgres.sh for Endurain's demo instance to automate restoring the Postgres database from a backup, cleaning logs, pruning Docker images, and restarting containers. Includes usage instructions for scheduling via cron.
2025-12-22 22:54:11 +00:00
João Vitória Silva
0797435d4e Add CASCADE ondelete to relevant foreign keys
Updated foreign key constraints in migration and model files to include ondelete="CASCADE" for idp_id, user_id, and token_family_id. This ensures related records are properly deleted when parent records are removed, improving data integrity and cleanup.
2025-12-22 22:08:56 +00:00
João Vitória Silva
0bc739904c Refactor OAuth state cleanup after token exchange
Updates session token exchange logic to clear the oauth_state_id reference and immediately delete the associated OAuth state per OAuth 2.1 best practices. Adjusts database migration and model to set foreign key ondelete to SET NULL, ensuring referential integrity. Also updates frontend components to use formatHrZoneLabel utility for heart rate zone chart labels.
2025-12-22 16:29:18 +00:00
João Vitória Silva
7c8d4ccccc Merge branch 'pr/442' into pre-release 2025-12-22 15:37:42 +00:00
João Vitória Silva
077df2ef9a Update bare-metal guide and mkdocs navigation
Added a blank line for readability in the bare-metal installation guide and updated the navigation title in mkdocs.yml to 'Bare-Metal installation guide' for consistency.
2025-12-22 11:01:25 +00:00
João Vitória Silva
4c33f8d60a Merge branch 'pr/447' into feature-pkce-oauth-state 2025-12-22 10:59:09 +00:00
João Vitória Silva
21fc940f67 Bump dependencies 2025-12-22 10:58:31 +00:00
João Vitória Silva
6ad6e5a1e0 Remove MFA backup codes API tests and update docs
Deleted the MFA backup codes API router test file. Expanded the authentication developer guide to document MFA backup code usage, format, error responses, and related endpoints for status and regeneration.
2025-12-22 10:42:00 +00:00
João Vitória Silva
43406a2e6d Fix timezone handling in OAuth state expiry check
Ensures that the expires_at field is compared as a UTC-aware datetime to prevent errors when checking if an OAuth state has expired.
2025-12-22 10:15:38 +00:00
João Vitória Silva
39eefd16cb Move MFA backup codes endpoints to profile router
Removed the dedicated MFA backup codes router and integrated its endpoints into the profile router for better organization. Updated frontend to support viewing, generating, and managing MFA backup codes, including a new modal component, status display, and i18n translations. Adjusted backend validation and error handling for MFA codes to support both TOTP and backup codes.
2025-12-21 22:55:24 +00:00
João Vitória Silva
dd63e29f2b Refactor Strava activity function naming and usage
Renamed get_user_garminconnect_activities_by_dates to get_user_strava_activities_by_dates and updated all references in backend code for clarity and correctness. This improves code readability and ensures the correct function is used for Strava activity retrieval. #445
Fix issue when model was not being showed #432
2025-12-20 11:42:12 +00:00
João Vitória Silva
0d89612f5f Add demo environment handling for session endpoints
Session retrieval endpoints now return empty lists and log access attempts when ENVIRONMENT is set to 'demo'. Also, updated session cookie security to treat 'demo' like 'production', and clarified ENVIRONMENT options in documentation. Unused imports were removed from users/user/router.py.
2025-12-20 11:00:02 +00:00
FutureCow
563f55211b Add update instructions for Endurain service
Added instructions for updating to a new version of Endurain, including steps for stopping the service, removing old files, downloading the latest release, building the frontend, setting up the backend, and starting the service.
2025-12-20 10:50:27 +01:00
João Vitória Silva
a2b32bc847 Add tests for identity_providers module and update .gitignore
Added comprehensive unit tests for the identity_providers module, including CRUD operations, schema validation, and utility functions. Updated .gitignore to exclude deeper __pycache__ directories. Removed session test files and old __pycache__ files from the repository.
2025-12-19 11:25:57 +00:00
João Vitória Silva
435647d6c0 Add tests for MFA backup codes and OAuth state modules
Added comprehensive unit tests for MFA backup codes CRUD, router, and utility functions, as well as for OAuth state CRUD and utility functions. Also fixed timezone handling in OAuth state expiry check. These tests improve coverage and reliability for authentication-related features.
2025-12-19 10:01:57 +00:00
João Vitória Silva
17ef865b5c Add MFA backup codes support for user authentication
Introduces database models, migration, API endpoints, and business logic for MFA backup codes as a fallback authentication method. Users can generate, view status, and consume backup codes; codes are securely hashed and invalidated upon use. Integrates backup code verification into MFA flows, updates user and profile logic, and ensures codes are managed on MFA enable/disable actions.
2025-12-18 23:08:27 +00:00
João Vitória Silva
0ba4d7123c Ensure timezone-aware datetime comparisons and OAuth state cleanup
Updated identity provider service to use timezone-aware datetime comparisons for token age, refresh, and expiry checks. Added a function to delete OAuth state by ID and integrated OAuth state cleanup into session deletion to prevent orphaned records.
2025-12-18 17:30:52 +00:00
João Vitória Silva
ded195a202 Implement OAuth 2.1 CSRF bootstrap pattern for refresh
Adopts the OAuth 2.1 bootstrap pattern by not storing the CSRF token hash on initial login or token exchange, allowing the first /refresh call after a page reload to establish the CSRF binding. Updates CSRF validation logic to only require the CSRF token if provided, and documents the security model. Exempts the /refresh endpoint from CSRF middleware for the bootstrap scenario. Also ensures rotated refresh tokens are deleted when a session is deleted.
2025-12-18 17:06:53 +00:00
João Vitória Silva
dc7990875c Update CSP and expand authentication documentation
Enhanced the Content-Security-Policy header to allow inline images, styles, scripts, and OpenStreetMap tiles to allow frontend static serving from FastAPI.
Major expansion of authentication documentation: clarified OAuth 2.1 hybrid token storage, CSRF protection, refresh token rotation, session management, progressive account lockout, and best practices for web and mobile clients.
2025-12-18 16:28:33 +00:00
João Vitória Silva
a116eb25a5 Implement CSRF token hash storage and validation for sessions
Adds a hashed CSRF token field to the users_sessions table and model, updates session creation and refresh logic to store and validate the CSRF token hash, and enforces CSRF validation for web clients during token refresh. Updates middleware to require CSRF headers for web clients, and adds comprehensive tests for CSRF middleware behavior. Also improves frontend fetch utility to prevent concurrent refresh token requests. Fix access token not validated on private /idp routes
2025-12-18 16:02:04 +00:00
João Vitória Silva
188d600280 Update 401 retry logic in fetchWithRetry
Modified fetchWithRetry to remove 'auth/logout' from the list of endpoints that bypass retry on 401 errors to ensure proper session deletion on the DB. Updated comment to reflect the change.
2025-12-18 14:58:43 +00:00
João Vitória Silva
4ee166fbfa Implement refresh token rotation and reuse detection
Adds rotated refresh token tracking to detect and prevent token reuse attacks. Introduces new models, schemas, and utilities for storing and checking rotated tokens, and invalidates all sessions in a token family if reuse is detected. Updates session and authentication logic to support token families, rotation counts, and last rotation timestamps. Includes Alembic migration for new columns and tables, and schedules cleanup of expired rotated tokens. Also improves frontend logout to refresh tokens before logging out.
2025-12-18 12:32:13 +00:00
João Vitória Silva
04b489df7d Add relationships for OAuthState to User and IdentityProvider
Introduces SQLAlchemy relationships between OAuthState, User, and IdentityProvider models to enable easier navigation and cascading deletes. Updates the Alembic migration to add ON DELETE CASCADE to relevant foreign keys and improves column comments for clarity.
2025-12-18 10:54:31 +00:00
João Vitória Silva
20b1149d3d Refactor auth endpoints to use /auth/* paths
Updated backend and frontend to use '/auth/login', '/auth/refresh', '/auth/mfa/verify', and '/auth/logout' endpoints instead of legacy paths. Adjusted CSRF middleware, route prefixes, tests, documentation, and service utilities to match the new endpoint structure for improved clarity and consistency.
2025-12-18 10:40:59 +00:00
João Vitória Silva
f6e06fb3e6 Add session idle and absolute timeout enforcement
Implements optional session idle and absolute timeout logic, including new environment variables for configuration. Adds last_activity_at to sessions, enforces timeouts on token refresh, and introduces a scheduler job to clean up idle sessions. Also introduces progressive lockout for failed logins and updates documentation and examples accordingly.
2025-12-18 10:28:22 +00:00
João Vitória Silva
23cf954a47 Add middleware for security HTTP headers
Introduced SecurityHeadersMiddleware to add essential security headers (e.g., X-Content-Type-Options, X-Frame-Options, X-XSS-Protection, Referrer-Policy, Permissions-Policy, and Content-Security-Policy) to all HTTP responses. Registered the middleware in main.py to enhance protection against common web vulnerabilities.
2025-12-17 17:14:48 +00:00
João Vitória Silva
4727732053 Enforce OAuth 2.1 PKCE, unify token handling, and add MFA lockout
This update enforces PKCE for all OAuth flows, removes legacy cookie-based state, and unifies token handling for both web and mobile clients to comply with OAuth 2.1. It introduces a progressive lockout mechanism for MFA to prevent brute-force attacks, updates CSRF middleware to require only the header, and ensures refresh tokens are set as httpOnly cookies with SameSite=Strict. The frontend is updated to restore tokens on app initialization and handle SSO token exchange failures. Various backend endpoints and utilities are refactored for clarity, security, and consistency.
2025-12-17 17:05:04 +00:00
Boris
d688bdc4bd fix: update timeSeconds type annotation to include null 2025-12-17 10:56:46 +01:00
Boris
c99b4050c3 fix: break long line to comply with PEP8 79 char limit 2025-12-17 10:41:08 +01:00
Boris
f234ffd838 Merge branch 'endurain-project:master' into feature/hr-zones-time-display 2025-12-17 10:32:26 +01:00
João Vitória Silva
b9b9e8c3c5 Refactor OAuth state retrieval and fix datetime usage
Reordered parameters in get_oauth_state_by_id for consistency and updated its usage in identity provider service. Also removed timezone awareness from datetime comparison to prevent potential issues.
2025-12-16 14:22:14 +00:00
João Vitória Silva
fd7542c0cf Add PKCE and server-side OAuth state for mobile SSO
Implements database-backed OAuth state management to support secure PKCE flows for mobile SSO. Adds new models, CRUD, and scheduled cleanup for OAuth state, updates identity provider login and callback flows to use server-side state, and introduces a token exchange endpoint for mobile clients. Updates session and rate limiting logic, and maintains backward compatibility for web clients using cookie-based state.
2025-12-16 14:02:31 +00:00
João Vitória Silva
39a01eca05 Add mobile SSO implementation guide to authentication docs
Expanded the authentication documentation with a detailed step-by-step guide for implementing OAuth/SSO in mobile applications using WebView. The new section covers prerequisites, provider discovery, WebView handling, token extraction, secure storage, authenticated API requests, and token refresh logic.
2025-12-16 11:56:14 +00:00
João Vitória Silva
b9d21801a0 Update IdP API routes and add PocketID icon support
Updated authentication documentation to reflect new public and profile-based identity provider API routes. Also added support for displaying the PocketID icon in the identity provider list component.
2025-12-16 11:33:49 +00:00
João Vitória Silva
5aab1e7e02 Add demo environment information to docs and README
Introduced details about the public demo environment, including URL, credentials, and reset schedule, to the README, and documentation index. This helps users try Endurain before installation and clarifies demo limitations.
2025-12-15 22:24:02 +00:00
João Vitória Silva
9860aeac1f Add Proxmox community script link to navigation
Added an external link to the Proxmox community script under the 'Getting started' section in the navigation menu of mkdocs.yml.
2025-12-15 22:13:54 +00:00
João Vitória Silva
bddc3d44cf Merge branch 'pr/443' into pre-release 2025-12-15 22:09:23 +00:00
João Vitória Silva
c445c0c093 Revise and expand SSO documentation, update nav
Replaces the old 'Single-sign-on' doc with a new, comprehensive 'single-sign-on.md' covering SSO setup for multiple providers, troubleshooting, and security. Updates mkdocs.yml to reference the new file, enhance navigation, and enable additional markdown extensions and icons for improved documentation formatting.
2025-12-15 22:09:09 +00:00
João Vitória Silva
26e08007ca Refactor developer guide into modular sections
Split the monolithic developer-guide.md into three focused documents: setup-dev-env.md, authentication.md, and supported-types.md. Updated mkdocs.yml navigation to reflect the new structure, improving documentation clarity and maintainability.
2025-12-15 21:48:55 +00:00
SiEffen
f513f0370f Create Single-sign-on
This is a set of documentation instructions to set up SSO using either Pocket ID or Tailscale as the SSO provider. It provides the steps needed within the provider as well as how to complete the "Identity Providers" custom form within Endurain.
2025-12-15 15:58:00 +00:00
João Vitória Silva
2121196ee3 Update dependency lock files
Updated poetry.lock and package-lock.json to reflect new versions of dependencies. This includes upgrades for apprise, authlib, and coverage in the backend, as well as changes in frontend dependencies.
v0.16.3
2025-12-15 12:50:35 +00:00
João Vitória Silva
14a4fa4a47 Squashed commit of the following:
commit 27cb9fb31c
Author: João Vitória Silva <joao.vitoria.silva@pm.me>
Date:   Fri Dec 12 05:42:12 2025 +0000

    New translations settingssecurityzonecomponent.json (Galician)

commit 54e7664bbf
Author: João Vitória Silva <joao.vitoria.silva@pm.me>
Date:   Fri Dec 12 05:42:11 2025 +0000

    New translations healthweightlistcomponent.json (Galician)

commit 2595adf9e2
Author: João Vitória Silva <joao.vitoria.silva@pm.me>
Date:   Fri Dec 12 05:42:10 2025 +0000

    New translations healthweightaddeditmodalcomponent.json (Galician)

commit a9183085f1
Author: João Vitória Silva <joao.vitoria.silva@pm.me>
Date:   Fri Dec 12 04:44:53 2025 +0000

    New translations healthweightzonecomponent.json (Galician)

commit 21822237fd
Author: João Vitória Silva <joao.vitoria.silva@pm.me>
Date:   Fri Dec 12 04:44:53 2025 +0000

    New translations healthdashboardzonecomponent.json (Galician)

commit bdc961840c
Author: João Vitória Silva <joao.vitoria.silva@pm.me>
Date:   Fri Dec 12 04:44:51 2025 +0000

    New translations generalitems.json (Galician)

commit 38b9355566
Author: João Vitória Silva <joao.vitoria.silva@pm.me>
Date:   Wed Dec 10 16:14:14 2025 +0000

    New translations settingsuserprofilezonecomponent.json (German)
2025-12-15 12:46:54 +00:00
João Vitória Silva
70b31fc6d3 Fix swapped labels for elapsed and moving time
Corrects the display labels for elapsed time and moving time in ActivityBellowMPillsComponent.vue to match their respective data fields. #440
2025-12-15 12:29:13 +00:00
João Vitória Silva
4d46e88c82 Merge branch 'master' into pre-release 2025-12-15 12:25:12 +00:00
João Vitória Silva
2b5e59a4fe Add Pocket ID as supported OIDC identity provider
Introduces Pocket ID as a new OIDC provider option in both backend and frontend. Adds Pocket ID template to backend, updates provider selection and icon handling in the frontend, and includes the Pocket ID logo asset. Also bumps version numbers to 0.16.3 across backend and frontend.
2025-12-15 12:24:51 +00:00
Boris Stäheli
c18114431e Address PR review comments
- Export formatDuration function from chartUtils.js
- Add formatHrZoneLabel utility function to eliminate duplication
- Use computed properties for HR chart data to avoid repeated calculations
- Fix PEP8 line length violations (79 chars for code, 72 for comments)
- Format backend code with proper line breaks for readability
2025-12-13 23:24:20 +01:00
Boris Stäheli
6b6a6fdf53 Refactor time calculation for heart rate zones and update display logic in activity components 2025-12-13 23:19:46 +01:00
Boris Stäheli
317922d416 Add time duration display to heart rate zones
- Backend: Calculate time_seconds for each HR zone based on waypoint ratio
- Frontend: Display both percentage and time (e.g., '25% (15m)') in HR zone charts
- Update BarChartComponent to support timeSeconds prop
- Use activity total_timer_time for accurate time calculation
2025-12-13 22:42:23 +01:00
João Vitória Silva
b0bc916c44 Update project links to new GitHub organization
Replaced all references to 'joaovitoriasilva/endurain' with 'endurain-project/endurain' across documentation, templates, Docker examples, and code. Updated badge URLs, Docker image paths, and author email in backend metadata to reflect the new organization. This ensures consistency and correct attribution following the repository migration.
2025-12-12 14:08:19 +00:00