Skip to content

Commit

Permalink
pyatls: make max clock skew configurable, version 0.0.6 (#16)
Browse files Browse the repository at this point in the history
* pyatls: make max clock skew configurable

Make the maximum tolerable clock skew configurable to account for the
large skews observed in Azure services.

This change introduces the following environment variable:

- PYATLS_CLOCK_SKEW_SECONDS_MAX

* pyatls: version 0.0.6
  • Loading branch information
HernanGatta authored May 24, 2024
1 parent 8f86719 commit ccba326
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python-package/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pyatls"
version = "0.0.5"
version = "0.0.6"
description = "A Python package that implements Attested TLS (aTLS)."
readme = "README.md"
authors = [{ name = "Opaque Systems", email = "[email protected]" }]
Expand Down
9 changes: 7 additions & 2 deletions python-package/src/atls/validators/azure/aas/aci_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import hashlib
import json
import logging
import os
from datetime import timedelta
from typing import Any, Dict, List, Optional

Expand Down Expand Up @@ -251,10 +252,14 @@ def _verify_and_decode_token(
"""
hdr = jwt.get_unverified_header(token)

max_skew: int = int(os.getenv("PYATLS_CLOCK_SKEW_SECONDS_MAX", 5))
delta = timedelta(seconds=max_skew)

logger.debug("Max allowed clock skew is %s", delta)

return jwt.decode(
token,
_get_key_by_header(hdr, jkus),
[hdr["alg"]],
# Account for clock skew
leeway=timedelta(seconds=5),
leeway=delta,
)

0 comments on commit ccba326

Please sign in to comment.