Skip to content

Commit 853b9a7

Browse files
committed
Small comment / roadmap tweaks
1 parent 88187e8 commit 853b9a7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

middleware/security/jwt/jwt.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func New(validationKeys interface{}, validationFunc goa.Middleware, scheme *goa.
102102
panic("how did this happen ? unsupported algo in jwt middleware")
103103
}
104104
if err != nil {
105-
return ErrJWTError("JWT validation failed")
105+
return ErrJWTError("JWT validation failed: %s", err)
106106
}
107107

108108
scopesInClaim, scopesInClaimList, err := parseClaimScopes(token)
@@ -129,7 +129,9 @@ func New(validationKeys interface{}, validationFunc goa.Middleware, scheme *goa.
129129
}
130130

131131
// parseClaimScopes parses the "scopes" parameter in the Claims. It supports two formats:
132+
//
132133
// * a list of string
134+
//
133135
// * a single string with space-separated scopes (akin to OAuth2's "scope").
134136
func parseClaimScopes(token *jwt.Token) (map[string]bool, []string, error) {
135137
scopesInClaim := make(map[string]bool)
@@ -156,8 +158,8 @@ func parseClaimScopes(token *jwt.Token) (map[string]bool, []string, error) {
156158
return scopesInClaim, scopesInClaimList, nil
157159
}
158160

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.
161163
var ErrJWTError = goa.NewErrorClass("jwt_security_error", 401)
162164

163165
type contextKey int
@@ -166,8 +168,7 @@ const (
166168
jwtKey contextKey = iota + 1
167169
)
168170

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.
171172
func ContextJWT(ctx context.Context) *jwt.Token {
172173
token, ok := ctx.Value(jwtKey).(*jwt.Token)
173174
if !ok {

roadmap.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ Under this proposal the generated code would be:
7575
Update(ctx context.Context, resp *UpdateBottleResponse, req *UpdateBottleRequest) error
7676
```
7777

78-
### Move Errors to Response Object
78+
### Error Handling Improvements
79+
80+
Move from a model using structs to implement goa errors and check for them to a model using checking
81+
for behavior.
7982

8083
Consider changing the goa request handler signature from:
8184

@@ -90,7 +93,7 @@ func (context.Context, http.ResponseWriter, *http.Request)
9093
```
9194

9295
And keep the error in the response struct instead. This means tweaking how error handling is done so
93-
tha the error handler middleware knows where to look for errors.
96+
that the error handler middleware knows where to look for errors.
9497

9598
## Code Generation Improvements
9699

0 commit comments

Comments
 (0)