twofa

package
v1.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package twofa generates and verifies TOTP secrets for the CSuit apps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSecret

func NewSecret(issuer, account string) (string, error)

NewSecret returns a fresh base32 TOTP secret for the account.

func QRDataURL

func QRDataURL(issuer, secret, account string) (string, error)

QRDataURL renders the setup QR code for an existing base32 secret as a data:image/png URL. The secret is base32-decoded first so the code encodes the same secret that Verify checks against.

func Verify

func Verify(secret, code string) bool

Verify checks a code against a plaintext base32 secret.

func VerifyStep added in v1.2.4

func VerifyStep(secret, code string, now time.Time) (int64, bool)

VerifyStep checks a code like Verify and also returns the 30-second step it matched. Store the step per user and accept only a larger one next time, so a code cannot be used twice inside its validity window.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL