in aa-integration-backend/ui-connector/auth.py [0:0]
def check_jwt(token):
try:
# Decode the payload to fetch the stored details.
data = jwt.decode(token, jwt_secret_key, algorithms=['HS256'])
if 'gcp_agent_assist_project' not in data:
return False, 'The target project in your token is missing.'
if data['gcp_agent_assist_project'] != config.GCP_PROJECT_ID:
return False, 'The target project in your token is invalid.'
if 'exp' not in data:
return False, 'The expiration time in your token is missing.'
if data['exp'] < datetime.datetime.now().timestamp():
return False, 'Your token has expired.'
return True, 'Your token is valid.'
except:
return False, 'Failed to parse your token.'