Security & Privacy
TOTP
A Time-based One-Time Password (TOTP) is a temporary passcode generated by an algorithm using the current time and a shared secret key, commonly used for multi-factor authentication.
also called: time-based one-time password, authenticator app
// definition
The Hash-based Message Authentication Code One-Time Password standard governs this algorithm, which generates unique passcodes using system time instead of an incrementing counter. An authentication server and user device share a secret key in advance. Setup typically occurs by scanning a Quick Response code.
Both client applications and authentication servers independently run the calculation using synchronized time. Passcodes refresh at set intervals, typically every thirty seconds. Stolen passcodes become useless quickly. This verification operates offline on the user device without needing mobile networks or Short Message Service text messages.
// TOTP vs. Row Level Security
A fitness studio chain uses two different controls to protect customer data. Time-based One-Time Password authentication verifies user identity during login using time-based passcodes generated on a client device. This mechanism works offline without network access, which is not true of Row Level Security.
Row Level Security acts inside the database after login to restrict access to specific table rows based on user permissions. While login passcodes confirm who the user is, database row rules restrict what records an authenticated staff member can view across different studio locations.
// why it matters
Implementing time-based passcodes improves security by reducing reliance on static passwords. Weak static passwords leave systems open to credential stuffing and data breaches. Local code generation on user devices removes the operational costs of text messages.
Local generation also eliminates risks from Subscriber Identity Module swapping attacks. By adding this layer, organizations satisfy strict cybersecurity frameworks that require multi-factor authentication for account access, protecting internal systems and client records effectively.
Questions and Answers
- How does an authenticator app make codes without internet?
- An authenticator app generates passcodes offline because it calculates them locally using its internal clock and a stored secret key. During setup, the server and app share this key. Since both sides independently calculate the passcode based on the current time, no network connection or text message is needed.
- Why are time-based passcodes safer than text message codes?
- Time-based passcodes are safer because they generate locally on a device rather than traveling over cellular networks. Text messages are vulnerable to Subscriber Identity Module swapping attacks and interception. Local generation removes these transmission risks while eliminating text messaging fees for the organization.
