Skip to content

dev-templates/googleauthenticator

Repository files navigation

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", "xxx@gmail.com", formattedKey)
    // generate uri for show
    uri := authenticator.GenerateTotpUri()
    fmt.Println(uri)
    // verify token
    passcode := "<from input>"
    if authenticator.VerifyToken(passcode) {
        // ok
    }
}

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages