Skip to content

Simple Java 2FA library using Google Authenticator

Notifications You must be signed in to change notification settings

Maploop/Atlas2FA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Atlas2FA API

badge

Advanced 2FA Library for java Java Docs

Getting started

Import Atlas 2FA into your project

Replace Tag with the version you see above this line

Maven
<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

<dependency>
   <groupId>com.github.Maploop</groupId>
   <artifactId>Atlas2FA</artifactId>
   <version>Tag</version>
</dependency>
Gradle
repositories {
	maven { url 'https://jitpack.io' }
}
    
implementation 'com.github.Maploop:Atlas2FA:Tag'

Generating a QR Code

TwoFactorAuth auth = new TwoFactorAuth("clientName").label("username of your user");

// You need to save this secret key that's generated for your user
String secretKey = auth.generateSecret();

// After all of that we need to use the simple method to generate the QR Code
String imageURL = auth.generateQRCode();
BufferedImage asImage = auth.generateQRCodeAsImage();

// You can also get a scaled instance of the BufferedImage like this (width, height)
BufferedImage asImage = auth.generateQRCodeAsImage(500, 500);

Validating a 6-digit Code

// The 6-digit code the user provides
String code = "255656";

// Secret must be the secret you saved for this user once you generated it
// Code can be a string or an integer
boolean isValidCode = TwoFactorAPI.isValidKey(secret, code);

About

Simple Java 2FA library using Google Authenticator

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages