Categorygithub.com/dev-templates/googleauthenticator
repositorypackage
0.0.0-20211022101923-fb9b7495af54
Repository: https://github.com/dev-templates/googleauthenticator.git
Documentation: pkg.go.dev

# README

googleauthenticator

Two- / Multi- Factor Authenication (2FA / MFA) for Golang

codecov Build Status go.dev go.mod Go Report Card LICENSE

Installation

To get the package, execute:

go get github.com/dev-templates/googleauthenticator

Usage

package main

import (
    "fmt"

    "github.com/dev-templates/googleauthenticator"
)

func main {
    // generate key
    formattedKey := googleauthenticator.GenerateKey()
    authenticator := googleauthenticator.NewAuthenticator("issuer", "[email protected]", formattedKey)
    // generate uri for show
    uri := authenticator.GenerateTotpUri()
    fmt.Println(uri)
    // verify token
    passcode := "<from input>"
    if authenticator.VerifyToken(passcode) {
        // ok
    }
}