Documentation
¶
Index ¶
- Constants
- func ParseToken(token string) ([]byte, []byte, error)
- type Token
- type YubiAuth
- func (y *YubiAuth) Bytes() []byte
- func (y *YubiAuth) Done() bool
- func (y *YubiAuth) GetDB() yubidb.Databaser
- func (y *YubiAuth) GetResetCount() int
- func (y *YubiAuth) Public() string
- func (y *YubiAuth) ReadTokenData(reader io.Reader) bool
- func (y *YubiAuth) Reset()
- func (y *YubiAuth) RetryableError(err error) bool
- func (y *YubiAuth) SetToken(token string)
- func (y *YubiAuth) Token() string
- func (y *YubiAuth) Validate() (*model.YubiUser, error)
- func (y *YubiAuth) VerifyToken(user model.YubiUser, token string) (*Token, error)
Constants ¶
const ( UidSize = 6 // nolint PubLen = common.TokenIDLen // of otp token AesSize = 16 OtpSize = common.TokenOTPLen CrcOkResidue = 0xf0b8 ModHexMap = "cbdefghijklnrtuv" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Token ¶
type Token struct { // Uid Private secret ID Uid [UidSize]byte // nolint // Ctr Usage counter Ctr uint16 // Tstpl timestamp Tstpl uint16 // Tstph timestamp hour Tstph uint8 // Use Session usage counter Use uint8 // Rnd Random number Rnd uint16 // Crc checksum of token Crc uint16 }
Token Yubikey token structure. See https://developers.yubico.com/OTP/OTPs_Explained.html
type YubiAuth ¶
type YubiAuth struct {
// contains filtered or unexported fields
}
func NewYubiAuth ¶
NewYubiAuth creates an instance of a Yubi Key authenticator. If dsn is not empty, it specifies an implementation of a Databaser interface where self-hosted yubikeys are stored for valid users. Otherwise, Yubi tokens are validated by the default YubiCo services in the cloud.
func (*YubiAuth) GetResetCount ¶
GetResetCount returns the number of times Reset() has been called
func (*YubiAuth) ReadTokenData ¶
ReadTokenData reads bytes from input until a CR is found. Returns true if the token has been fully consumed.
func (*YubiAuth) RetryableError ¶
RetryableError validation or other error is retryable?
func (*YubiAuth) Validate ¶
Validate will validate the yubikey token we read. Looks up yubikey ID from token to ensure user is registered. For the self-hosted validation, it uses the user records secret key to decrypt the token. Uses Yubico server validation when db is nil or user.secret is empty. For self-hosted, the usage count will be updated in the database when the token successfully validates. Returns a non-nil error if it cannot be validated or found in the database.
func (*YubiAuth) VerifyToken ¶
VerifyToken is not normally called. Use Validate() instead. This simply verifies the OTP but does not determine if the token is registered, nor does it update token session counters in the DB.