parent
4fb0e17b69
commit
ef91558600
8 changed files with 73 additions and 19 deletions
|
@ -1,20 +1,31 @@
|
|||
package auth
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
// The provided authentication method is not known to the server
|
||||
ErrUnknownAuthMethod = errors.New("unknown authentication method")
|
||||
// The user hasn't setup the provided authentication method
|
||||
ErrUnsupportedAuthMethod = errors.New("authentication method not supported for this user")
|
||||
ErrInvalidCombination = errors.New("invalid account and token combination")
|
||||
ErrProcessTimeout = errors.New("authentication process timed out")
|
||||
// The given combination of token and account is invalid
|
||||
// Explicitly doesn't mention which part is valid to improve security
|
||||
ErrInvalidCombination = errors.New("invalid account and token combination")
|
||||
// The current authentication attempt has expired and needs to be restarted
|
||||
ErrProcessTimeout = errors.New("authentication process timed out")
|
||||
// A user may not login, for whatever reason
|
||||
ErrCantLogin = errors.New("user can't login")
|
||||
ErrCantLogin = errors.New("user can't login")
|
||||
// Failed to decrypt the relevant data
|
||||
ErrDecryptionFailure = errors.New("failed to decrypt content")
|
||||
ErrTotpRecentlyUsed = errors.New("totp token was used too recently")
|
||||
// The given totp token was recently (90 seconds) used for that username
|
||||
// For security reasons, this case will be caught and blocked
|
||||
ErrTotpRecentlyUsed = errors.New("totp token was used too recently")
|
||||
)
|
||||
|
||||
// Helper error type to combine two errors into one
|
||||
// For when two different errors need to be passed together
|
||||
// since fmt.Errorf doesn't really allow that as far as I know
|
||||
type CombinedError struct {
|
||||
Err1, Err2 error
|
||||
}
|
||||
|
@ -26,3 +37,7 @@ func (c *CombinedError) Is(e error) bool {
|
|||
func (c *CombinedError) Error() string {
|
||||
return c.Err1.Error() + " + " + c.Err2.Error()
|
||||
}
|
||||
|
||||
func (c *CombinedError) Unwrap() []error {
|
||||
return []error{c.Err1, c.Err2}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue