@@ -102,7 +102,7 @@ func New(validationKeys interface{}, validationFunc goa.Middleware, scheme *goa.
102
102
panic ("how did this happen ? unsupported algo in jwt middleware" )
103
103
}
104
104
if err != nil {
105
- return ErrJWTError ("JWT validation failed" )
105
+ return ErrJWTError ("JWT validation failed: %s" , err )
106
106
}
107
107
108
108
scopesInClaim , scopesInClaimList , err := parseClaimScopes (token )
@@ -129,7 +129,9 @@ func New(validationKeys interface{}, validationFunc goa.Middleware, scheme *goa.
129
129
}
130
130
131
131
// parseClaimScopes parses the "scopes" parameter in the Claims. It supports two formats:
132
+ //
132
133
// * a list of string
134
+ //
133
135
// * a single string with space-separated scopes (akin to OAuth2's "scope").
134
136
func parseClaimScopes (token * jwt.Token ) (map [string ]bool , []string , error ) {
135
137
scopesInClaim := make (map [string ]bool )
@@ -156,8 +158,8 @@ func parseClaimScopes(token *jwt.Token) (map[string]bool, []string, error) {
156
158
return scopesInClaim , scopesInClaimList , nil
157
159
}
158
160
159
- // ErrJWTError is the error returned by this middleware when any sort
160
- // of validation or assertion fails during processing.
161
+ // ErrJWTError is the error returned by this middleware when any sort of validation or assertion
162
+ // fails during processing.
161
163
var ErrJWTError = goa .NewErrorClass ("jwt_security_error" , 401 )
162
164
163
165
type contextKey int
@@ -166,8 +168,7 @@ const (
166
168
jwtKey contextKey = iota + 1
167
169
)
168
170
169
- // ContextJWT retrieves the JWT token from a `context` that went through our security
170
- // middleware.
171
+ // ContextJWT retrieves the JWT token from a `context` that went through our security middleware.
171
172
func ContextJWT (ctx context.Context ) * jwt.Token {
172
173
token , ok := ctx .Value (jwtKey ).(* jwt.Token )
173
174
if ! ok {
0 commit comments