Skip to content

Commit 14331e4

Browse files
authored
Merge pull request #95 from arlopurcell/bug/94
Add default 'exp' field to vapid claims dict
2 parents aa66fde + ef54603 commit 14331e4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pywebpush/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from copy import deepcopy
77
import json
88
import os
9+
import time
910

1011
try:
1112
from urllib.parse import urlparse
@@ -378,6 +379,9 @@ def webpush(subscription_info,
378379
url = urlparse(subscription_info.get('endpoint'))
379380
aud = "{}://{}".format(url.scheme, url.netloc)
380381
vapid_claims['aud'] = aud
382+
if not vapid_claims.get('exp'):
383+
# encryption lives for 12 hours
384+
vapid_claims['exp'] = int(time.time()) + (12 * 60 * 60)
381385
if not vapid_private_key:
382386
raise WebPushException("VAPID dict missing 'private_key'")
383387
if isinstance(vapid_private_key, Vapid):

0 commit comments

Comments
 (0)