auth
2014-09-01
auth/errors.go.old
Deprecate old implementations. Let's remove all of the osin stuff altogether, in favour of a more testable, unit-based approach. Leave all the old files around, for easy reference, but add the .old suffix so the go tools don't pick them up.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/errors.go.old Mon Sep 01 09:13:52 2014 -0400 1.3 @@ -0,0 +1,55 @@ 1.4 +package auth 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 + ErrorInvalidClient = "invalid_client" 1.13 + ErrorInvalidGrant = "invalid_grant" 1.14 + ErrorUnauthorizedClient = "unauthorized_client" 1.15 + ErrorUnsupportedGrantType = "unsupported_grant_type" 1.16 + ErrorInvalidScope = "invalid_scope" 1.17 +) 1.18 + 1.19 +var ( 1.20 + ClientNotFoundError = errors.New("Client not found.") 1.21 + URIMissingError = errors.New("Redirect URI missing.") 1.22 + InvalidMethodError = errors.New("Invalid request method.") 1.23 + InternalServerError = errors.New("Internal server error.") 1.24 + ErrorNotAuthenticated = errors.New("Not authenticated.") 1.25 + InvalidClientError = errors.New("Invalid client.") 1.26 + AuthorizationNotFoundError = errors.New("Authorization not found.") 1.27 + ErrProfileNotFound = errors.New("Profile not found.") 1.28 + TokenNotFoundError = errors.New("Token not found.") 1.29 + NilClientError = errors.New("Client was nil.") 1.30 +) 1.31 + 1.32 +type URIFormatError string 1.33 + 1.34 +func (err URIFormatError) Error() string { 1.35 + return "Invalid URI format: " + string(err) 1.36 +} 1.37 + 1.38 +type InvalidClientIDError string 1.39 + 1.40 +func (err InvalidClientIDError) Error() string { 1.41 + return "Invalid client ID: " + string(err) 1.42 +} 1.43 + 1.44 +type URIMismatchError struct { 1.45 + uri string 1.46 + mismatch string 1.47 +} 1.48 + 1.49 +func (err URIMismatchError) Error() string { 1.50 + return "Supplied redirect URI " + err.mismatch + " does not match the redirect in the database (" + err.uri + ")" 1.51 +} 1.52 + 1.53 +func NewURIMismatchError(uri, mismatch string) error { 1.54 + return URIMismatchError{ 1.55 + uri: uri, 1.56 + mismatch: mismatch, 1.57 + } 1.58 +}