Repository navigation
Login workflow for the client reference application #17
Replies: 6 comments 7 replies
|
Requirement 2: Offline login/app lock Offline PIN authentication using KDF-based hashing Overview When the user enters their PIN:
The same pattern is used for recovery codes (stored as a separate salted hash), allowing PIN reset without requiring server connectivity. This keeps the design simple with deterministic verification. Why this approach works well
Things to be aware of / Trade-offs
Attempt limits, lockout, and wipe
After the limit is reached:
For usability, we can consider resetting the attempt counter after a timeout (e.g., 24 hours), to avoid permanent lockouts due to user error. |
|
Requirement 3: PIN reset without connectivity Option A - Supervisor recovery code If a user needs to reset their PIN, the supervisor shares this recovery code (in person or over the phone). The app treats the recovery code as an alternative authentication factor: it derives a hash using the same KDF (Argon2id or PBKDF2) and verifies it against the stored recovery hash. If valid, the user is allowed to set a new PIN. Why this works well
Trade-offs
Option B - Supervisor delegation via QR code The supervisor then shares the QR code with the user (in person, or by displaying it on their device). The user scans it with their app, which verifies the token locally using the embedded server public key. If the signature is valid and the token has not expired, the user is allowed to proceed with setting a new PIN. Why this works well
Trade-offs
PIN change policy Technically, this involves recomputing and storing a new KDF-derived hash using the new PIN. Since verification is local, no server interaction is required. A new recovery code should also be generated and issued whenever the PIN is changed. This part however might need an internet connection if components here need to be synced back to the server. |
|
Requirement 4: Supporting multiple users on a shared device We need a reliable way to control which users can access a device, especially in environments where connectivity may be intermittent. Below are two approaches, each with different trade-offs. Option A - Server-synced device manifest The app enforces this list locally, meaning only users in the manifest can log in-whether it’s their first login or a subsequent PIN unlock. When the device reconnects, the manifest is refreshed. If access needs to change (e.g., reassigning the device), the server simply updates the manifest-no reinstall required. Why this works well
Trade-offs
Device retirement and reassignment On the next sync, the app should:
Handling manifest staleness
We can also add stricter controls by introducing a hard lock only after a longer grace period (e.g., 90 days), and ideally only for new login attempts -- not active sessions. |
|
Requirement 5: Configurability We need configurability for these items:
|
|
Additional design considerations Server signing key rotation A practical approach:
This allows keys to be rotated without breaking existing devices or requiring immediate updates. |

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Overview
This discussion thread is focused on the login workflow.
We’re exploring implementation ideas, best practices, and real world use cases. Contributions are welcome—whether it's UX suggestions, security considerations, or technical approaches.
Please share your thoughts clearly and include examples where possible.
The recommended way to implement authentication for mobile applications is by using OAuth2 with the Authorization code Grant Type with PKCE. This grant type ensures that the client does not handle any of the credentials (both user and client credentials) thus limiting the attack surface for a threat actor. Once this flow is triggered, the UI to enter credentials is presented by the Authorization Server in form of a web browser.
The above presents a challenge for CHW mobile apps that are offline first and need to handle Offline login to the device. Offline Login requires that the user log into the app even without an internet connection.
Requirements/Challenges/use cases:
Ideally we want an approach and design that is practical and balances usability, security, and real-world constraints.
All reactions