mirror of
https://github.com/sstent/FitTrack_GarminSync.git
synced 2026-01-25 16:41:41 +00:00
Adds the technical plan, data model, API contracts, and research for the persisted Garmin authentication feature.
3.0 KiB
3.0 KiB
Data Model: Garmin Authentication State
Date: 2025-12-22
This document defines the data model for storing a user's persisted Garmin Connect authentication state, as required by the Persist Garmin Authentication for Stateless Sync feature.
Entity: GarminAuthenticationState
This entity represents a user's authenticated session with Garmin Connect. It is designed to be stored in the CentralDB and is associated with a single application user.
Fields
| Field Name | Data Type | Nullable | Description |
|---|---|---|---|
user_id |
Foreign Key | False | The unique identifier for the application user this authentication state belongs to. |
session_data |
Text / Blob | True | The serialized, possibly encrypted, session data from the garth library. Null if no session is stored. |
mfa_pending |
Boolean | False | A flag indicating if the authentication process is currently paused, awaiting an MFA code from the user. |
last_validated |
Timestamp | True | The timestamp when the session was last successfully used to communicate with the Garmin API. |
created_at |
Timestamp | False | The timestamp when this record was created. |
updated_at |
Timestamp | False | The timestamp when this record was last updated. |
Relationships
- Belongs to:
User. A one-to-one relationship exists between aUserand theirGarminAuthenticationState.
State Transitions
The GarminAuthenticationState entity can transition through several states:
- Non-existent: No record exists for the user. This is the initial state.
- MFA Pending: A record exists with
mfa_pending = trueandsession_datais likelynull. This occurs after an initial login attempt triggers an MFA challenge. - Active / Persisted: A record exists with
mfa_pending = falseandsession_datais populated. This is the state for a successfully authenticated user, allowing for stateless background syncs. - Invalid / Stale: The
session_datais present but no longer valid for authentication with Garmin's servers, and it could not be refreshed. This state is not explicitly stored but is determined at runtime, leading to the clearing of thesession_data.
Validation Rules
user_idmust correspond to an existing user in theuserstable.session_datashould be stored in an encrypted format to protect sensitive session information. [NEEDS CLARIFICATION: The encryption method and key management strategy needs to be defined during implementation.]last_validatedshould be updated after every successful background sync or API call to Garmin Connect.