github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/auth/errors.go (about) 1 package auth 2 3 import ( 4 "errors" 5 "fmt" 6 libkb "github.com/keybase/client/go/libkb" 7 keybase1 "github.com/keybase/client/go/protocol/keybase1" 8 ) 9 10 // ErrShutdown is raised when an operation is pending but the CA is shutting down 11 var ErrShutdown = errors.New("shutting down") 12 13 // ErrUserDeleted is raised when a user is deleted, but was loaded without the loadDeleted flag 14 var ErrUserDeleted = errors.New("user was deleted") 15 16 // BadUsernameError is raised when the given username disagrees with the expected 17 // username 18 type BadUsernameError struct { 19 expected libkb.NormalizedUsername 20 received libkb.NormalizedUsername 21 } 22 23 func (e BadUsernameError) Error() string { 24 return fmt.Sprintf("bad username; wanted %s but got %s", e.expected, e.received) 25 } 26 27 // BadKeyError is raised when the given KID is not valid for the given UID. 28 type BadKeyError struct { 29 uid keybase1.UID 30 kid keybase1.KID 31 } 32 33 func (e BadKeyError) Error() string { 34 return fmt.Sprintf("Bad key error: %s not active for %s", e.kid, e.uid) 35 } 36 37 // ErrKeysNotEqual is raised when compared keys sets aren't equal. 38 var ErrKeysNotEqual = errors.New("keys not equal") 39 40 // InvalidTokenTypeError is raised when the given token is not of the expected type. 41 type InvalidTokenTypeError struct { 42 expected string 43 received string 44 } 45 46 func (e InvalidTokenTypeError) Error() string { 47 return fmt.Sprintf("Invalid token type, expected: %s, received: %s", 48 e.expected, e.received) 49 } 50 51 // MaxTokenExpiresError is raised when the given token expires too far in the future. 52 type MaxTokenExpiresError struct { 53 creationTime int64 54 expireIn int 55 now int64 56 maxExpireIn int 57 remaining int 58 } 59 60 func (e MaxTokenExpiresError) Error() string { 61 return fmt.Sprintf("Max token expiration exceeded, ctime/expire_in: %d/%d, "+ 62 "now/max: %d/%d, remaining: %d", e.creationTime, e.expireIn, 63 e.now, e.maxExpireIn, e.remaining) 64 } 65 66 // TokenExpiredError is raised when the given token is expired. 67 type TokenExpiredError struct { 68 creationTime int64 69 expireIn int 70 now int64 71 } 72 73 func (e TokenExpiredError) Error() string { 74 return fmt.Sprintf("Token expired, ctime/expire_in: %d/%d, now: %d", 75 e.creationTime, e.expireIn, e.now) 76 } 77 78 // InvalidTokenKeyError is raised when the public key presented in the token does not 79 // correspond to the private key used to sign the token. 80 type InvalidTokenKeyError struct { 81 expected string 82 received string 83 } 84 85 func (e InvalidTokenKeyError) Error() string { 86 return fmt.Sprintf("Invalid token key, expected: %s, received: %s", 87 e.expected, e.received) 88 } 89 90 // InvalidTokenServerError is raised when the server presented in the token does not 91 // correspond to the server being asked to verify the token. 92 type InvalidTokenServerError struct { 93 expected string 94 received string 95 } 96 97 func (e InvalidTokenServerError) Error() string { 98 return fmt.Sprintf("Invalid server in token, expected: %s, received: %s", 99 e.expected, e.received) 100 } 101 102 // InvalidTokenChallengeError is raised when the challenge presented in the token does not 103 // correspond to the challenge of the verifier. 104 type InvalidTokenChallengeError struct { 105 expected string 106 received string 107 } 108 109 func (e InvalidTokenChallengeError) Error() string { 110 return fmt.Sprintf("Invalid challenge in token, expected: %s, received: %s", 111 e.expected, e.received) 112 }