github.com/volatiletech/authboss@v2.4.1+incompatible/otp/twofactor/twofactor.go (about)

     1  package twofactor
     2  
     3  import "github.com/volatiletech/authboss"
     4  
     5  // Page constants
     6  const (
     7  	PageRecovery2FA  = "recovery2fa"
     8  	PageVerify2FA    = "twofactor_verify"
     9  	PageVerifyEnd2FA = "twofactor_verify_end"
    10  )
    11  
    12  // Email constants
    13  const (
    14  	EmailVerifyHTML = "twofactor_verify_email_html"
    15  	EmailVerifyTxt  = "twofactor_verify_email_txt"
    16  )
    17  
    18  // Form value constants
    19  const (
    20  	FormValueToken = "token"
    21  )
    22  
    23  // Data constants
    24  const (
    25  	DataRecoveryCode     = "recovery_code"
    26  	DataRecoveryCodes    = "recovery_codes"
    27  	DataNumRecoveryCodes = "n_recovery_codes"
    28  	DataVerifyEmail      = "email"
    29  	DataVerifyURL        = "url"
    30  )
    31  
    32  const (
    33  	alphabet             = "abcdefghijkmnopqrstuvwxyz0123456789"
    34  	recoveryCodeLength   = 10
    35  	verifyEmailTokenSize = 16
    36  )
    37  
    38  // User interface
    39  type User interface {
    40  	authboss.User
    41  
    42  	GetEmail() string
    43  	PutEmail(string)
    44  
    45  	// GetRecoveryCodes retrieves a CSV string of bcrypt'd recovery codes
    46  	GetRecoveryCodes() string
    47  	// PutRecoveryCodes uses a single string to store many
    48  	// bcrypt'd recovery codes
    49  	PutRecoveryCodes(codes string)
    50  }