How would you secure approvals in an Android expense application?

Instruction: Design authentication and authorization for an expense app where employees submit expenses and managers approve only within their tenant. Cover provider sign-in, token lifecycle, server checks, offline actions, role revocation and account switching.

Context: Apply native authentication to an object-level authorization scenario. Distinguish local UI restrictions, stored-data protection and enforceable server policy.

Updated

Official answer

Authentication establishes the account; authorization decides which action that account may perform on a particular object. Use the provider's supported OIDC/native sign-in flow and validated API access tokens, but treat an Android client as untrusted even after sign-in.

For each expense approval, the server checks current membership, tenant, role, object ownership/workflow state and relevant limits. It must reject a guessed cross-tenant expense ID and an ordinary employee calling the approval endpoint directly. Hiding the Approve button is useful UX, not enforcement. Third-party sign-in does not automatically grant an application role.

Keep local data and caches separated by account/tenant, minimize stored sensitive fields and protect tokens/keys with an appropriate design. Keystore-backed keys may resist extraction, but an authorized compromised process can still request operations; encryption is not immunity to device compromise. Never package a privileged server credential in the app.

A role can be revoked while a short-lived token or offline screen still exists. Define how quickly the server must apply revocation using token/session/policy validation. Restrict offline approval: record a pending request if allowed, then re-authorize at synchronization and show rejection/conflict honestly. Do not label a local edit as a completed approval.

Coordinate refresh so concurrent requests do not race token rotation. On logout/account switch, invalidate the intended session, cancel or account-scope pending work, clear sensitive cached state and avoid replaying old work as another user. Test expired/revoked tokens, wrong audience, duplicate submission, role changes and cross-tenant object access on the server as well as the client.

OAuth security practices, OpenID Connect validation, Keystore boundaries, Object authorization

Related Questions