Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
Display a more lisible timestamp.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Jan 12, 2016
1 parent 8288faf commit 8727e85
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/read-assertion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import base64
import datetime
import json
import sys


Expand Down Expand Up @@ -28,5 +31,13 @@ def base64url_decode(input):
# Ignore signatures and cryptographic hashes
if decoded_fragment.startswith('{'):
print(decoded_fragment)
fragment = json.loads(decoded_fragment)
for key in ("iat", "exp", "fxa-generation", "fxa-lastAuthAt"):
if key in fragment:
timestamp = fragment[key]
if len(str(timestamp)) > 11:
timestamp /= 1e3
date = datetime.datetime.fromtimestamp(timestamp)
print(key, ":", date.strftime("%Y-%m-%d %H:%M:%S"))

print("---- END ASSERTION ----")

0 comments on commit 8727e85

Please sign in to comment.