Skip to content

Commit 0e60d09

Browse files
add future annotation for 'nbf' claim
1 parent a9a0c3d commit 0e60d09

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/planet_auth_utils/commands/cli/jwt_cmd.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ def __json_pretty_dumps__(self):
5353
def _human_readable_jwt_claim(d):
5454
for key, value in list(d.items()):
5555
if key in ["iat", "exp", "nbf"] and isinstance(value, int):
56-
# UNIX Time stamps in ISO format, with annotations.
56+
# UNIX Timestamps in ISO format, with annotations.
5757
fmt_time = time.strftime("%Y-%m-%dT%H:%M:%S%z", time.localtime(value))
58-
if (key == "exp") and (d[key] < time.time()):
58+
now = time.time()
59+
if (key == "exp") and (d[key] < now):
5960
fmt_time += " (Expired)"
61+
if (key == "nbf") and (d[key] > now):
62+
fmt_time += " (Future)"
6063
d[key] = fmt_time
6164
elif key in ["api_key"]:
6265
# Redact sensitive values

0 commit comments

Comments
 (0)