Skip to content

Commit

Permalink
errors: add inactive token error
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas (arekkas) committed Dec 6, 2016
1 parent 51ab7bb commit 0151f1e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
ErrTokenExpired = errors.New("Token expired")
ErrScopeNotGranted = errors.New("The token was not granted the requested scope")
ErrTokenClaim = errors.New("The token failed validation due to a claim mismatch")
ErrInactiveToken = errors.New("Token is inactive because it is malformed, expired or otherwise invalid")
)

const (
Expand All @@ -53,6 +54,7 @@ const (
errTokenExpired = "token_expired"
errScopeNotGranted = "scope_not_granted"
errTokenClaim = "token_claim"
errTokenInactive = "token_inactive"
)

type RFC6749Error struct {
Expand All @@ -65,6 +67,17 @@ type RFC6749Error struct {

func ErrorToRFC6749Error(err error) *RFC6749Error {
switch errors.Cause(err) {
case ErrInactiveToken: {
{
return &RFC6749Error{
Name: errTokenInactive,
Description: ErrInactiveToken.Error(),
Debug: err.Error(),
Hint: "Token validation failed.",
StatusCode: http.StatusUnauthorized,
}
}
}
case ErrTokenClaim:
{
return &RFC6749Error{
Expand Down

0 comments on commit 0151f1e

Please sign in to comment.