-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathapp.py
50 lines (35 loc) · 1.58 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
See https://www.w3.org/TR/webauthn/#api
"""
import base64
from botocore import xform_name
from chalice import Chalice, Response
from pywarp import RelyingPartyManager
from pywarp.backends import DynamoBackend
app = Chalice(app_name="cwa")
app.debug = True
@app.route("/")
def index():
with open("chalicelib/index.html") as fh:
return Response(status_code=200, headers={"Content-Type": "text/html"}, body=fh.read())
@app.route("/getCredentialCreateOptions", methods=["POST"])
def get_credential_create_options():
rp.rp_id = app.current_request.context["domainName"]
return rp.get_registration_options(**app.current_request.json_body)
@app.route("/registerCredential", methods=["POST"])
def register_credential():
rp.rp_id = app.current_request.context["domainName"]
req = {xform_name(f): base64.b64decode(app.current_request.json_body[f]) for f in app.current_request.json_body}
print("registerCredential inputs:", req)
return rp.register(**req)
@app.route("/getCredentialGetOptions", methods=["POST"])
def get_credential_get_options():
rp.rp_id = app.current_request.context["domainName"]
return rp.get_authentication_options(**app.current_request.json_body)
@app.route("/verifyAssertion", methods=["POST"])
def verify_assertion():
rp.rp_id = app.current_request.context["domainName"]
req = {xform_name(f): base64.b64decode(app.current_request.json_body[f]) for f in app.current_request.json_body}
print("verifyAssertion inputs:", req)
return rp.verify(**req)
rp = RelyingPartyManager("PyWARP demo", credential_storage_backend=DynamoBackend())