Skip to content

Commit 08de746

Browse files
authored
Merge pull request #77 from samuelcolvin/relax-aud-check
relax 'aud' check
2 parents 9be3128 + 5f10fd1 commit 08de746

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
dist: xenial
12
language: python
23
python:
34
- "2.7"
45
- "3.5"
6+
- "3.6"
7+
- "3.7"
58
install:
69
- cd python
710
- pip install -r requirements.txt

python/py_vapid/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def _base_sign(self, claims):
264264
raise VapidException(
265265
"Missing 'sub' from claims. "
266266
"'sub' is your admin email as a mailto: link.")
267-
if not re.match(r"^https?://[^/.:]+\.[^/:]+(:\d+)?$",
267+
if not re.match(r"^https?://[^/:]+(:\d+)?$",
268268
cclaims.get("aud", ""),
269269
re.IGNORECASE):
270270
raise VapidException(

python/py_vapid/tests/test_vapid.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,17 @@ def test_sign_02(self):
179179
for k in claims:
180180
eq_(t_val[k], claims[k])
181181

182+
def test_sign_02_localhost(self):
183+
v = Vapid02.from_file("/tmp/private")
184+
claims = {"aud": "http://localhost:8000",
185+
"sub": "mailto:[email protected]",
186+
"foo": "extra value"}
187+
result = v.sign(claims, "id=previous")
188+
auth = result['Authorization']
189+
eq_(auth[:6], 'vapid ')
190+
ok_(' t=' in auth)
191+
ok_(',k=' in auth)
192+
182193
def test_integration(self):
183194
# These values were taken from a test page. DO NOT ALTER!
184195
key = ("BDd3_hVL9fZi9Ybo2UUzA284WG5FZR30_95YeZJsiApwXKpNcF1rRPF3foI"

0 commit comments

Comments
 (0)