auth
2014-08-01
Child:65c49af1ed3f
auth/errors.go
Continue our descent to horribleness. Remove all the nonsense about "extensibility" and "clean separation of concerns", instead hardcoding connections to decisions. Remove all those "test" things that stopped passing.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/errors.go Fri Aug 01 23:08:38 2014 -0400 1.3 @@ -0,0 +1,45 @@ 1.4 +package oauth2 1.5 + 1.6 +import "errors" 1.7 + 1.8 +const ( 1.9 + ErrorServerError = "server_error" 1.10 + ErrorInvalidRequest = "invalid_request" 1.11 + ErrorAccessDenied = "access_denied" 1.12 +) 1.13 + 1.14 +var ( 1.15 + ClientNotFoundError = errors.New("Client not found.") 1.16 + URIMissingError = errors.New("Redirect URI missing.") 1.17 + InvalidMethodError = errors.New("Invalid request method.") 1.18 + InternalServerError = errors.New("Internal server error.") 1.19 + ErrorNotAuthenticated = errors.New("Not authenticated.") 1.20 +) 1.21 + 1.22 +type URIFormatError string 1.23 + 1.24 +func (err URIFormatError) Error() string { 1.25 + return "Invalid URI format: " + string(err) 1.26 +} 1.27 + 1.28 +type InvalidClientIDError string 1.29 + 1.30 +func (err InvalidClientIDError) Error() string { 1.31 + return "Invalid client ID: " + string(err) 1.32 +} 1.33 + 1.34 +type URIMismatchError struct { 1.35 + uri string 1.36 + mismatch string 1.37 +} 1.38 + 1.39 +func (err URIMismatchError) Error() string { 1.40 + return "Supplied redirect URI " + err.mismatch + " does not match the redirect in the database (" + err.uri + ")" 1.41 +} 1.42 + 1.43 +func NewURIMismatchError(uri, mismatch string) error { 1.44 + return URIMismatchError{ 1.45 + uri: uri, 1.46 + mismatch: mismatch, 1.47 + } 1.48 +}