Mercurial > code > home > repos > href
comparison get_agent.py @ 39:c538dc39b851
user login fixes
author | drewp@bigasterisk.com |
---|---|
date | Sat, 19 Nov 2022 17:06:36 -0800 |
parents | |
children | 293a694304b8 |
comparison
equal
deleted
inserted
replaced
38:f3a15a724483 | 39:c538dc39b851 |
---|---|
1 import logging | |
2 | |
3 import bottle | |
4 import jwt | |
5 from rdflib import URIRef | |
6 | |
7 log = logging.getLogger(__name__) | |
8 | |
9 jwks_client = jwt.PyJWKClient(uri='https://authenticate.bigasterisk.com/.well-known/pomerium/jwks.json') | |
10 | |
11 | |
12 def bottleGetAgent() -> URIRef: | |
13 pomAssertion = bottle.request.headers.get('X-Pomerium-Jwt-Assertion', None) | |
14 | |
15 sk = jwks_client.get_signing_key_from_jwt(pomAssertion) | |
16 j = jwt.decode(pomAssertion, | |
17 key=sk.key, | |
18 algorithms=['ES256'], | |
19 audience="bigasterisk.com") | |
20 | |
21 foaf = { | |
22 'drewpca@gmail.com': 'http://bigasterisk.com/foaf.rdf#drewp', | |
23 'kelsimp@gmail.com': 'http://bigasterisk.com/kelsi/foaf.rdf#kelsi', | |
24 }[j['email']] | |
25 return URIRef(foaf) |