@@ -51,7 +51,7 @@ func (handler *jwtHandler) ServeHTTP(out http.ResponseWriter, r *http.Request) {
51
51
strToken = strings .TrimPrefix (auth , "Bearer " )
52
52
}
53
53
if len (strToken ) == 0 {
54
- http .Error (out , "missing token" , http .StatusForbidden )
54
+ http .Error (out , "missing token" , http .StatusUnauthorized )
55
55
return
56
56
}
57
57
// We explicitly set only HS256 allowed, and also disables the
@@ -63,17 +63,17 @@ func (handler *jwtHandler) ServeHTTP(out http.ResponseWriter, r *http.Request) {
63
63
64
64
switch {
65
65
case err != nil :
66
- http .Error (out , err .Error (), http .StatusForbidden )
66
+ http .Error (out , err .Error (), http .StatusUnauthorized )
67
67
case ! token .Valid :
68
- http .Error (out , "invalid token" , http .StatusForbidden )
68
+ http .Error (out , "invalid token" , http .StatusUnauthorized )
69
69
case ! claims .VerifyExpiresAt (time .Now (), false ): // optional
70
- http .Error (out , "token is expired" , http .StatusForbidden )
70
+ http .Error (out , "token is expired" , http .StatusUnauthorized )
71
71
case claims .IssuedAt == nil :
72
- http .Error (out , "missing issued-at" , http .StatusForbidden )
72
+ http .Error (out , "missing issued-at" , http .StatusUnauthorized )
73
73
case time .Since (claims .IssuedAt .Time ) > jwtExpiryTimeout :
74
- http .Error (out , "stale token" , http .StatusForbidden )
74
+ http .Error (out , "stale token" , http .StatusUnauthorized )
75
75
case time .Until (claims .IssuedAt .Time ) > jwtExpiryTimeout :
76
- http .Error (out , "future token" , http .StatusForbidden )
76
+ http .Error (out , "future token" , http .StatusUnauthorized )
77
77
default :
78
78
handler .next .ServeHTTP (out , r )
79
79
}
0 commit comments