File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
pkg/grpc/interceptor/auth Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package auth_interceptor
3
3
import (
4
4
"context"
5
5
"encoding/hex"
6
+ "errors"
6
7
"fmt"
7
8
"math"
8
9
"time"
@@ -75,6 +76,10 @@ func (s *ServerInterceptor) UnaryServerInterceptor(ctx context.Context, req inte
75
76
if err != nil {
76
77
log .WithError (err ).Infof ("validating token" )
77
78
metrics .InterceptorRequest (requestTypeJWT , "invalid_jwt" )
79
+
80
+ if errors .Is (err , jwt .ErrTokenExpired ()) {
81
+ return nil , status .Errorf (codes .Unauthenticated , "authentication token has expired" )
82
+ }
78
83
return nil , status .Errorf (codes .Unauthenticated , err .Error ())
79
84
}
80
85
@@ -179,6 +184,9 @@ func (s *ServerInterceptor) StreamServerInterceptor(srv interface{}, ss grpc.Ser
179
184
if jwtToken != "" {
180
185
t , err := s .TokenValidator .Validate (ss .Context (), jwtToken )
181
186
if err != nil {
187
+ if errors .Is (err , jwt .ErrTokenExpired ()) {
188
+ return status .Errorf (codes .Unauthenticated , "authentication token has expired" )
189
+ }
182
190
return status .Errorf (codes .Unauthenticated , err .Error ())
183
191
}
184
192
You can’t perform that action at this time.
0 commit comments