All Projects → o2ps → TotpAuthenticator

o2ps / TotpAuthenticator

Licence: BSD-3-Clause License
Two-factor authenticator via Google Authenticator app.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to TotpAuthenticator

Twofactor totp
🔑 Second factor TOTP (RFC 6238) provider for Nextcloud
Stars: ✭ 203 (+968.42%)
Mutual labels:  totp, two-factor-authentication
SimpleTOTP
A highly configurable yet simple to use TOTP based two-factor authentication processing module for SimpleSAMLphp.
Stars: ✭ 16 (-15.79%)
Mutual labels:  totp, two-factor-authentication
Speakeasy
**NOT MAINTAINED** Two-factor authentication for Node.js. One-time passcode generator (HOTP/TOTP) with support for Google Authenticator.
Stars: ✭ 2,531 (+13221.05%)
Mutual labels:  totp, two-factor-authentication
Otpauth
One Time Password (HOTP/TOTP) library for Node.js, Deno and browsers.
Stars: ✭ 135 (+610.53%)
Mutual labels:  totp, two-factor-authentication
crystal-two-factor-auth
Two Factor Authentication Crystal code implementing the Time-based One-time Password Algorithm
Stars: ✭ 24 (+26.32%)
Mutual labels:  totp, two-factor-authentication
Authenticatorpro
📱 Two-Factor Authentication (2FA) client for Android + Wear OS
Stars: ✭ 155 (+715.79%)
Mutual labels:  totp, two-factor-authentication
crotp
CrOTP - One Time Passwords for Crystal
Stars: ✭ 62 (+226.32%)
Mutual labels:  totp, two-factor-authentication
Authelia
The Single Sign-On Multi-Factor portal for web apps
Stars: ✭ 11,094 (+58289.47%)
Mutual labels:  totp, two-factor-authentication
totp
Time-Based One-Time Password Code Generator
Stars: ✭ 76 (+300%)
Mutual labels:  totp, two-factor-authentication
apache 2fa
Apache two-factor (2FA) authentication with Google Authenticator based on Time-based One-Time Password (TOTP) or HMAC-based one-time password (HOTP) Algorithms.
Stars: ✭ 63 (+231.58%)
Mutual labels:  totp, two-factor-authentication
One Time
One Time Password (TOTP and HOTP) library for Clojure. TOTP/HOTP is widely used for Two Factor / Multi Factor Authentication.
Stars: ✭ 129 (+578.95%)
Mutual labels:  totp, two-factor-authentication
rx-otp
HMAC-based (HOTP) and Time-based (TOTP) One-Time Password manager. Works with Google Authenticator for Two-Factor Authentication.
Stars: ✭ 79 (+315.79%)
Mutual labels:  totp, two-factor-authentication
Totp Generator
Generates TOTP tokens in the browser
Stars: ✭ 121 (+536.84%)
Mutual labels:  totp, two-factor-authentication
Twofactor
Golang two factor authentication library
Stars: ✭ 179 (+842.11%)
Mutual labels:  totp, two-factor-authentication
Twofa
A TouchID-aware 2-factor authenticator for macOS
Stars: ✭ 105 (+452.63%)
Mutual labels:  totp, two-factor-authentication
Onetimepassword
🔑 A small library for generating TOTP and HOTP one-time passwords on iOS.
Stars: ✭ 243 (+1178.95%)
Mutual labels:  totp, two-factor-authentication
Two Factor Bundle
[OUTDATED] Two-factor authentication for Symfony applications 🔐 (bunde version ≤ 4). Please use version 5 from https://github.com/scheb/2fa.
Stars: ✭ 388 (+1942.11%)
Mutual labels:  totp, two-factor-authentication
Otp.net
A .NET implementation of TOTP and HOTP for things like two-factor authentication codes.
Stars: ✭ 424 (+2131.58%)
Mutual labels:  totp, two-factor-authentication
otp-java
A small and easy-to-use one-time password generator library for Java according to RFC 4226 (HOTP) and RFC 6238 (TOTP).
Stars: ✭ 107 (+463.16%)
Mutual labels:  totp, two-factor-authentication
2FAuth
A Web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
Stars: ✭ 664 (+3394.74%)
Mutual labels:  totp, two-factor-authentication

Oops/TotpAuthenticator

Oops/TotpAuthenticator implements the TOTP algorithm that lets you easily set up a two-factor authentication mechanism. The TOTP, in short, generates a pseudo-random six-digit number based on current Unix time and given seed (a base32 string of at least 16 characters). The seed is shared between you and mobile app and passed to the app via a QR code. Whenever you need to authenticate the user, ask them to enter the code generated by the application, and verify it against the code generated by your server.

Installation and requirements

$ composer require oops/totp-authenticator

Oops/TotpAuthenticator requires PHP >= 7.2.

Usage

If you use Nette's DI container, you can easily integrate Oops/TotpAuthenticator with a few lines of configuration:

extensions:
	totp: Oops\TotpAuthenticator\DI\TotpAuthenticatorExtension

totp:
	timeWindow: 1
	issuer: MyApp

Otherwise, you can directly instantiate Oops\TotpAuthenticator\Security\TotpAuthenticator and optionally configure it:

$totpAuthenticator = (new Oops\TotpAuthenticator\Security\TotpAuthenticator)
   ->setIssuer('MyApp')
   ->setTimeWindow(1);

The timeWindow option sets a benevolence that compensates for possible differences between your server's time and the app's time. The default value is 1, which means the code for previous or next 30-second block would be also considered valid. You can set it to zero if you want to be super strict, but I'd strongly recommend not setting it to a higher value than one.

The issuer is optional, but is quite useful if you use some generic value as the user's account name, such as their email address. As multiple services can use that same value as a way of identifying the user, you should provide issuer to distinguish your app's code in the TOTP app.

Setting up 2FA

First, you need to generate a secret - a base32 string - that is shared between you and the application. TotpAuthenticator provides a method for that. The secret must be unique to the user and should thus be stored somewhere with other user data, e.g. in the database. Just remember to encrypt it as it is a very sensitive piece of information.

$secret = $totpAuthenticator->getRandomSecret();

Then, you can display the secret and unique account name (e.g. user's email address) to the user, or, more conveniently, provide them with a QR code containing the URI in a specific format. Again, TotpAuthenticator can build the URI for you:

$uri = $totpAuthenticator->getTotpUri($secret, $accountName);

Verification

Once the user has set up the account in their TOTP app, you can ask them to enter the 6-digit code and easily verify it against the secret:

if ($totpAuthenticator->verifyCode($code, $secret)) {
	// successfully verified

} else {
	// incorrect code
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].