[Notes] [Git][BuildGrid/buildgrid][master] Convert token expirey time to utc time before comparing.



Title: GitLab

Martin Blanchard pushed to branch master at BuildGrid / buildgrid

Commits:

2 changed files:

Changes:

  • buildgrid/server/_authentication.py
    ... ... @@ -282,7 +282,7 @@ class AuthMetadataServerInterceptor(grpc.ServerInterceptor):
    282 282
             if 'exp' not in payload or not isinstance(payload['exp'], int):
    
    283 283
                 raise _UnboundedTokenError("Missing 'exp' in payload")
    
    284 284
     
    
    285
    -        return datetime.fromtimestamp(payload['exp'])
    
    285
    +        return datetime.utcfromtimestamp(payload['exp'])
    
    286 286
     
    
    287 287
     
    
    288 288
     def _unary_unary_rpc_terminator(details):
    

  • tests/auth/test_interceptor.py
    ... ... @@ -188,7 +188,7 @@ def test_jwt_authorization(token, secret, algorithm, validity):
    188 188
     @pytest.mark.skipif(not HAVE_JWT, reason="No pyjwt")
    
    189 189
     def test_jwt_authorization_expiry():
    
    190 190
         secret, algorithm = 'your-256-bit-secret', AuthMetadataAlgorithm.JWT_HS256
    
    191
    -    now = int(datetime.utcnow().timestamp())
    
    191
    +    now = int(datetime.now().timestamp())
    
    192 192
         payload = {'sub': 'BuildGrid Expiry Test', 'iat': now, 'exp': now + 2}
    
    193 193
         token = jwt.encode(payload, secret, algorithm=algorithm.value.upper()).decode()
    
    194 194
     
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]