auth

Paddy 2014-08-13 Parent:10b84165df41 Child:fe7f358ecbe6

12:63e86d129238 Go to Latest

auth/errors.go

Consistently handle context in client storage interface. Let's at least be consistent about passing or not passing context to the client storage interface. Most our methods don't take the context, so let's just remove it.

History
1 package auth
3 import "errors"
5 const (
6 ErrorServerError = "server_error"
7 ErrorInvalidRequest = "invalid_request"
8 ErrorAccessDenied = "access_denied"
9 ErrorInvalidClient = "invalid_client"
10 ErrorInvalidGrant = "invalid_grant"
11 ErrorUnauthorizedClient = "unauthorized_client"
12 ErrorUnsupportedGrantType = "unsupported_grant_type"
13 ErrorInvalidScope = "invalid_scope"
14 )
16 var (
17 ClientNotFoundError = errors.New("Client not found.")
18 URIMissingError = errors.New("Redirect URI missing.")
19 InvalidMethodError = errors.New("Invalid request method.")
20 InternalServerError = errors.New("Internal server error.")
21 ErrorNotAuthenticated = errors.New("Not authenticated.")
22 InvalidClientError = errors.New("Invalid client.")
23 AuthorizationNotFoundError = errors.New("Authorization not found.")
24 ProfileNotFoundError = errors.New("Profile not found.")
25 TokenNotFoundError = errors.New("Token not found.")
26 )
28 type URIFormatError string
30 func (err URIFormatError) Error() string {
31 return "Invalid URI format: " + string(err)
32 }
34 type InvalidClientIDError string
36 func (err InvalidClientIDError) Error() string {
37 return "Invalid client ID: " + string(err)
38 }
40 type URIMismatchError struct {
41 uri string
42 mismatch string
43 }
45 func (err URIMismatchError) Error() string {
46 return "Supplied redirect URI " + err.mismatch + " does not match the redirect in the database (" + err.uri + ")"
47 }
49 func NewURIMismatchError(uri, mismatch string) error {
50 return URIMismatchError{
51 uri: uri,
52 mismatch: mismatch,
53 }
54 }