912 Commits

Author SHA1 Message Date
João Vitória Silva
3230f68c52 chore: bump version to 0.17.7, fix garminconnect login and update dependencies 2026-04-17 16:36:09 +01:00
João Vitória Silva
bfe73de8d4 Return expires_in in seconds; trust X-Client-Type
Change token endpoints and utils to return expires_in and refresh_token_expires_in as seconds-until-expiry (RFC 6749 §5.1) by computing (expiry - now).total_seconds() instead of returning epoch timestamps. Update docs examples and frontend type comments to reflect the new semantics. Also make token-exchange determine client_type from the X-Client-Type request header (with fallback/sanitization) because stored oauth_state.client_type can be missing for system browser flows.
2026-02-27 22:03:04 +00:00
João Vitória Silva
9191d8ce09 Offload blocking API calls to asyncio threads
Add guidance doc and prevent blocking the asyncio event loop by running synchronous client calls in a thread pool.

- Added .github/agents/se-gitops-ci-specialist.agent.md: DevOps/CI & GitOps specialist guidance for pipelines, debugging, and best practices.
- backend/app/garmin/activity_utils.py: import asyncio and wrap garminconnect_client.get_activities_by_date, get_activity_gear, and download_activity with await asyncio.to_thread to avoid blocking the event loop.
- backend/app/strava/activity_utils.py: import asyncio and run strava_client.get_activities and parse_activity via asyncio.to_thread (parse_activity performs blocking HTTP calls). Added explanatory comments.

These changes keep the async event loop responsive when using third-party synchronous libraries.
2026-02-27 12:11:54 +00:00
João Vitória Silva
230596c034 Include refresh_token_expires_in in token responses
Expose refresh_token_expires_in across auth flows: add the field to the TokenExchangeResponse schema, compute and include refresh token expiry in token exchange and refresh endpoints (public identity provider router and auth router), update utils.complete_login to return it, and update developer docs/examples. This lets clients know the refresh token lifetime alongside access token info. #514
2026-02-27 11:59:25 +00:00
João Vitória Silva
b593836b9e Add Copilot agent/instructions & SSO redirect config
Add Copilot agent and rich instruction docs, and introduce configurable SSO redirect scheme handling.

- Add security reviewer agent (.github/agents/se-security-reviewer.agent.md) and multiple instruction files under .github/instructions/ (agents, github-actions-ci-cd-best-practices, security-and-owasp, prompt, etc.), and rename the frontend instruction file to javascript.instructions.md. Update copilot-instructions.md to reference the new guides.
- Add ALLOWED_REDIRECT_SCHEMES option to .env.example to allow configured custom URI schemes for mobile/system-browser SSO (with security notes). #539
- Update backend auth code and config to support and validate SSO redirect schemes (backend/app/auth/identity_providers/public_router.py, utils.py, backend/app/core/config.py) and adjust related tests and docs (tests, docs/developer-guide/authentication.md, docs/getting-started/advanced-started.md). #539
- Apply frontend updates to login/footer/components and package.json (frontend/app/src/*, frontend/app/package.json) and update pyproject.toml. #539
- Fix for #535
- Fix for #527
- Fix for #502

These changes add documentation and tooling for Copilot agents, improve SSO configurability for mobile flows, and wire through necessary backend, frontend, tests, and docs updates.
2026-02-27 11:52:49 +00:00
João Vitória Silva
13baa6c4c0 Fix for #528
Fix for unable to upload any .fit files my Geoid CC600 #528
2026-02-23 16:46:47 +00:00
João Vitória Silva
505e957224 Bump API version and update dependencies
Bump API_VERSION to v0.17.5 and update project dependencies across backend and frontend. Updated backend dependency manifests (pyproject.toml / poetry.lock) and frontend package.json / package-lock.json; also adjusted FooterComponent.vue. After pulling, run `poetry install` and `npm install` and verify app functionality and compatibility with the updated packages.
2026-02-23 16:24:42 +00:00
João Vitória Silva
5ce7fa3f25 Bump dependencies 2026-02-10 20:46:43 -08:00
João Vitória Silva
0b50d981c0 Bump versions and update frontend deps
Bump release to v0.17.4. Bump project versions (backend pyproject.toml and core config, frontend package.json/package-lock). Relax Users username validation to allow hyphen and underscore (pattern updated and description adjusted) #513. Refresh frontend dependencies in the lockfile (multiple package upgrades) and apply a small frontend component update (FooterComponent.vue).
2026-02-10 14:51:10 -08:00
João Vitória Silva
35e172d460 Bump version to 0.17.3 2026-01-23 09:25:03 +00:00
João Vitória Silva
f3f3eabdc5 Merge branch 'pr/501' into pre-release 2026-01-23 09:23:27 +00:00
João Vitória Silva
46f5fadd79 Revert "Add validator to convert avg_sleep_stress to int"
This reverts commit 5d0fa9770f.
2026-01-23 08:45:35 +00:00
João Vitória Silva
18b0ef8d28 Bump version to 0.17.2 2026-01-22 22:47:05 +00:00
João Vitória Silva
5d0fa9770f Add validator to convert avg_sleep_stress to int
Introduced a field validator for avg_sleep_stress in HealthSleepBase to ensure Decimal and float values are converted to int. Attempt fix for #506
2026-01-22 22:43:29 +00:00
João Vitória Silva
7ffbf27bc2 Merge branch 'master' into pre-release 2026-01-22 22:15:15 +00:00
João Vitória Silva
66c4d73a26 Fix birthdate year extraction in HR calculation
Attempt fix for #503
2026-01-22 22:15:07 +00:00
Joerg Werner
37714e017b Urlencode the Smtp Username and Password, otherwise authentication will fail if they contain characters like =, & etc. 2026-01-22 15:08:19 +01:00
João Vitória Silva
69507e8e60 Bump version to 0.17.1 and update dependencies
Updated backend and frontend version numbers to 0.17.1. Upgraded several backend Python dependencies (markdown, packaging, pycparser, sqlalchemy) and frontend Rollup dependencies to their latest versions. Also updated the FooterComponent.vue to reflect the new version.
2026-01-22 13:42:56 +00:00
João Vitória Silva
3be8d56a7d PKCE for mobile now follows SSO logic for state and nonce 2026-01-21 13:44:11 +00:00
João Vitória Silva
35c0d204b2 Update logout to use refresh token and improve docs
Changed the /logout endpoint to validate and extract session info from the refresh token instead of the access token. Updated authentication documentation to clarify differences between web and mobile endpoints, including logout and token usage.
2026-01-21 12:46:34 +00:00
João Vitória Silva
f8aa9418d3 Merge branch 'pr/479' into pre-release 2026-01-21 09:56:48 +00:00
João Vitória Silva
955c6cc3a2 Bump version to 0.17.0 and update dependencies
Updated project version from 0.16.7 to 0.17.0 across backend and frontend. Upgraded backend dependency 'apprise' to 1.9.7 and updated several frontend dev dependencies including rollup, @typescript-eslint, baseline-browser-mapping, and data-urls. Renamed Alembic migration file to match new version.
2026-01-21 09:56:17 +00:00
João Vitória Silva
f3905afb9a Refactor date validator docstrings in health schemas
Updated and unified the docstrings for the set_default_date validators in HealthSleepCreate, HealthStepsCreate, and HealthWeightCreate models.
2026-01-21 09:51:35 +00:00
João Vitória Silva
ab437409cf Refactor user session modules and add privacy utils
Renamed all 'users_session' modules and tests to 'users_sessions' for consistency. Introduced 'users_privacy_settings.utils' with a utility for converting activity visibility to integer, and updated all relevant usages. Added API reference documentation files and updated mkdocs configuration to include new reference sections.
2026-01-21 09:35:39 +00:00
João Vitória Silva
26fb3c0a36 Normalize access_type and gender values in user creation
Backend now normalizes access_type to a string before password hashing and user creation, ensuring consistent handling. Frontend updates default gender and access_type values to string representations ('male', 'regular'), and adjusts password validation logic to use string values for access_type.
2026-01-20 14:05:32 +00:00
João Vitória Silva
4616aa926e Update MFA log level and add activity icons to goals
Changed MFA verification log level from 'info' to 'debug' in backend. Reverted GoalsListComponent.vue to display icons
2026-01-20 13:19:14 +00:00
João Vitória Silva
db76d05def Update MFA error message for missing pending login
Reverted no pending MFA login message
2026-01-20 12:47:32 +00:00
João Vitória Silva
d2a17d1967 Support nullable refresh_token for PKCE sessions
Refactor session creation and models to allow nullable refresh_token, enabling PKCE/SSO flows to create sessions before token exchange. Update related logic, validation, and tests to handle sessions without refresh tokens. Improve error handling and logging for authentication and token refresh endpoints. Update OAuth state lookup to ensure only unused states are accepted.
2026-01-20 12:33:20 +00:00
João Vitória Silva
a04670c359 Add tests for user session and rotated refresh tokens
Introduce comprehensive test suites for user session and rotated refresh token functionality, including CRUD operations, model and schema validation, and utility functions. These tests improve coverage and reliability for session management and token rotation logic.
2026-01-20 11:02:56 +00:00
João Vitória Silva
1f7a3c7c08 Update auth tests to check for unified error messages
Modified authentication and token manager tests to assert on the new unified error message 'Unable to authenticate' and to check for HTTP 401 status with specific detail in insecure claim scenarios.
2026-01-20 10:41:02 +00:00
João Vitória Silva
140cb3c91d Refactor user session and rotated token modules
Refactored user session and rotated refresh token modules for improved maintainability and consistency. Introduced explicit __init__.py exports, switched to SQLAlchemy 2.0 style models, added and improved Pydantic schemas, and replaced raw SQLAlchemy queries with select/delete statements. Added core_decorators.handle_db_errors for error handling, improved docstrings, and updated API router response models. This refactor also enhances type safety, code clarity, and aligns with modern FastAPI/SQLAlchemy best practices.
2026-01-20 10:40:51 +00:00
João Vitória Silva
653f8bd4fa Refactor session module to users_session namespace
Moved all session-related files and imports from 'session' to 'users/users_session' to improve code organization and clarity. Updated all references throughout the codebase and tests to use the new namespace.
2026-01-19 17:18:20 +00:00
João Vitória Silva
55b1a31a8f Switch rotated token hashing to HMAC-SHA256 for reuse checks
Updated refresh token reuse detection to use HMAC-SHA256 with the server secret for deterministic and secure token hashing and lookup. Refactored related utility functions and updated their usage in the auth router. Also reduced the scheduler interval for cleaning up expired rotated tokens from 5 to 1 minute.
2026-01-19 16:59:44 +00:00
João Vitória Silva
b74e720870 Improve authentication error handling and messages
Added explicit HTTP 401 exception for insecure token claims in TokenManager. Updated error messages in authenticate_user to use a generic authentication failure message for both username and password errors, enhancing security and impersonation
2026-01-19 16:37:15 +00:00
João Vitória Silva
ea808f9fb6 Refactor tests for enum string values and user relationships
Updated tests to use string values for enums (Units, Currency, ActivityVisibility) instead of integers, reflecting schema changes. Changed model relationship attribute checks from 'user' to 'users' across health, gear, goals, identity provider, integrations, and privacy settings tests. Adjusted assertions and test data to match new enum and relationship conventions.
2026-01-19 16:19:58 +00:00
João Vitória Silva
b93db82247 Add signup rate limit and improve user creation security
Introduces a rate limit for signup attempts to prevent account creation abuse. Improves user creation error handling by providing a more generic error message to reduce information leakage. Also includes minor refactoring and logging improvements in session and identity provider logic. Dependency updates for backend and frontend packages are included.
2026-01-19 15:27:40 +00:00
João Vitória Silva
0ef1cfdc9e Add mobile password login with PKCE and schema defaults
Implements PKCE support for mobile password authentication, allowing mobile clients to use a secure token exchange flow similar to OAuth/SSO. Updates authentication endpoints, schemas, and documentation to support PKCE parameters and session-based token exchange for mobile clients. Also standardizes Pydantic schema field defaults using the `default` argument for improved OpenAPI and client code generation.
2026-01-19 13:00:59 +00:00
João Vitória Silva
66a22ee1d5 Rename user modules and relationships to 'users'
Refactored all imports, relationships, and references from 'user' to 'users' across backend modules for consistency. Updated model relationship names, schemas, and CRUD/service calls to use the plural form, and adjusted migration and utility logic accordingly.
2026-01-19 10:50:35 +00:00
João Vitória Silva
b3cd340f74 Migrate activity visibility from int to string enum
Refactor backend and frontend to use string values ('public', 'followers', 'private') for default_activity_visibility instead of integers. Updates database migration, models, schemas, and all related frontend components and stores to reflect this change.
2026-01-19 10:19:25 +00:00
João Vitória Silva
4f6bad12c9 Migrate units and currency fields to string enums
Refactor units and currency fields in both backend and frontend from integer values to string enums (e.g., 'metric', 'imperial', 'euro', 'dollar', 'pound'). Update database migration, models, schemas, and all related frontend components and logic to use string values instead of numeric codes.
2026-01-18 22:27:23 +00:00
João Vitória Silva
e540e51c64 Differentiate token delivery for web and mobile clients 2026-01-18 21:15:03 +00:00
João Vitória Silva
822d887925 Migrate user enums from integers to strings
Refactored user-related enums (gender, access_type, first_day_of_week) in the backend and frontend from integer values to string values for improved clarity and maintainability. Updated Alembic migration to convert existing data, adjusted SQLAlchemy models, Pydantic schemas, and all related logic and UI components to use string-based enums. This change affects user creation, editing, display, and authentication logic throughout the application.
2026-01-17 21:52:02 +00:00
João Vitória Silva
d7843b3929 Refactor file upload handling and improve import robustness
Centralizes file saving logic with a new `save_file` utility, updates all usages related to user to use the new function, and ensures image validation is consistently applied. The import service now properly converts string numeric fields to floats/ints, removes database IDs from imported objects, and uses async file saving for all imported files. Also updates frontend gear fetching logic and upgrades several dependencies.
2026-01-16 22:58:06 +00:00
João Vitória Silva
8ebbbe3bd1 Improve IdP user sync and import validation
Refactored identity provider user info sync to update user fields only if changes are detected and to handle email conflicts gracefully. Updated user creation to use actual server settings. Enhanced import service to validate existence of identity providers before linking, preventing errors when providers are missing.
2026-01-16 14:01:33 +00:00
João Vitória Silva
705b61ff83 Refactor profile module: add MFA store, improve API, and update frontend
Move MFASecretStore to own file for segregation of concerns. Refactors and documents profile-related modules, improves API endpoint consistency (status codes, response models), and updates MFA enable/disable endpoints to use PUT. Updates frontend components and services to match new event and API conventions, adds Strava state management, and synchronizes sidebar section state with URL query parameters for better navigation and UX.
2026-01-16 11:45:55 +00:00
João Vitória Silva
afa38ba872 Add docstrings and improve user module exports
Added comprehensive docstrings to routers and dependencies for better API documentation and clarity. Updated __init__.py to explicitly export CRUD functions, schemas, models, enums, and utilities. Minor refactoring in routers to improve type hints, argument naming, and return values for consistency.
2026-01-15 22:27:52 +00:00
João Vitória Silva
d0adb2825e Remove birthdate formatting from user creation response
The create_user endpoint now returns the created user object directly instead of formatting the birthdate. The unused format_user_birthdate utility function has been removed for code simplification.
2026-01-15 21:55:52 +00:00
João Vitória Silva
761b00e9ea Refactor user profile endpoint to use model_copy for response
Updated the read_users_me endpoint to construct the UserMe response using model_validate and model_copy, ensuring integration and privacy settings are included in the response. This approach improves clarity and maintainability by avoiding direct mutation of the user model.
2026-01-15 21:50:25 +00:00
João Vitória Silva
c684cd84da Improve DB error handling and update tests
Enhanced the handle_db_errors decorator to automatically rollback the session on SQLAlchemy errors. Updated related CRUD and test files to use the new error handling and session rollback logic. Refactored test mocks to use scalar_one and get_server_settings_or_404, and fixed test coverage for user default gear creation and user authentication. Also updated frontend user edit modal to handle external_auth_count after edit.
2026-01-15 21:40:30 +00:00
João Vitória Silva
1e4612ec04 Refactor file upload handling and async user photo management
Centralizes file upload logic in a new core.file_uploads module with security validation and async I/O. Refactors user and server settings image upload endpoints to use the new handler, and updates user photo CRUD operations to be asynchronous. Replaces direct file system operations with async equivalents, improves error handling, and updates related frontend logic to match new API responses. Also standardizes server settings access to use get_server_settings_or_404 and makes several migration and CRUD functions async for consistency.
2026-01-15 18:21:07 +00:00