auth

Paddy 2014-08-13 Parent:65c49af1ed3f Child:3423c552e249

5:7ae3f16002c1 Go to Latest

auth/errors.go

Handle more errors. Handle client errors. Match redirect handling with the spec.

History
1 package oauth2
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 )
25 type URIFormatError string
27 func (err URIFormatError) Error() string {
28 return "Invalid URI format: " + string(err)
29 }
31 type InvalidClientIDError string
33 func (err InvalidClientIDError) Error() string {
34 return "Invalid client ID: " + string(err)
35 }
37 type URIMismatchError struct {
38 uri string
39 mismatch string
40 }
42 func (err URIMismatchError) Error() string {
43 return "Supplied redirect URI " + err.mismatch + " does not match the redirect in the database (" + err.uri + ")"
44 }
46 func NewURIMismatchError(uri, mismatch string) error {
47 return URIMismatchError{
48 uri: uri,
49 mismatch: mismatch,
50 }
51 }