Skip to content

Commit

Permalink
bump packages and update internals for fido2 >= 1.0 api
Browse files Browse the repository at this point in the history
  • Loading branch information
bodik committed Jul 8, 2022
1 parent 466155e commit 3511062
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ all: lint coverage

venv:
sudo apt-get -y install python3-virtualenv
virtualenv -p python3 venv
python3 -m venv venv

install-deps:
pip install -r requirements-dev.lock
Expand Down
65 changes: 33 additions & 32 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
astroid==2.3.3
attrs==19.3.0
cffi==1.14.0
Click==7.0
coverage==5.0.3
cryptography==2.8
entrypoints==0.3
fido2==0.9.3
flake8==3.7.9
Flask==1.1.1
importlib-metadata==1.5.0
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.11.1
lazy-object-proxy==1.4.3
MarkupSafe==1.1.1
astroid==2.11.6
attrs==21.4.0
cffi==1.15.1
click==8.1.3
coverage==6.4.1
cryptography==37.0.4
dill==0.3.5.1
fido2==1.0.0
flake8==4.0.1
Flask==2.1.2
importlib-metadata==4.12.0
iniconfig==1.1.1
isort==5.10.1
itsdangerous==2.1.2
Jinja2==3.1.2
lazy-object-proxy==1.7.1
MarkupSafe==2.1.1
mccabe==0.6.1
more-itertools==8.2.0
packaging==20.1
pluggy==0.13.1
py==1.8.1
pycodestyle==2.5.0
pycparser==2.19
pyflakes==2.1.1
pylint==2.4.4
pyparsing==2.4.6
pytest==5.3.5
six==1.14.0
typed-ast==1.4.1
wcwidth==0.1.8
Werkzeug==1.0.0
wrapt==1.11.2
zipp==3.0.0
packaging==21.3
platformdirs==2.5.2
pluggy==1.0.0
py==1.11.0
pycodestyle==2.8.0
pycparser==2.21
pyflakes==2.4.0
pylint==2.14.4
pyparsing==3.0.9
pytest==7.1.2
tomli==2.0.1
tomlkit==0.11.1
typing-extensions==4.3.0
Werkzeug==2.1.2
wrapt==1.14.1
zipp==3.8.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='soft-webauthn',
version='0.1.3',
version='0.1.4',
author='Radoslav Bodó',
author_email='[email protected]',
description='Python webauthn software authenticator',
Expand All @@ -14,7 +14,7 @@
url='https://github.com/bodik/soft-webauthn',
py_modules=['soft_webauthn'],
install_requires=[
'fido2>=0.8,<1.0.0',
'fido2>=1.0,<2.0',
'cryptography'
],
classifiers=[
Expand Down
4 changes: 2 additions & 2 deletions soft_webauthn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from cryptography.hazmat.primitives.asymmetric import ec
from fido2 import cbor
from fido2.cose import ES256
from fido2.ctap2 import AttestedCredentialData
from fido2.webauthn import AttestedCredentialData
from fido2.utils import sha256


Expand Down Expand Up @@ -54,7 +54,7 @@ def create(self, options, origin):
if {'alg': -7, 'type': 'public-key'} not in options['publicKey']['pubKeyCredParams']:
raise ValueError('Requested pubKeyCredParams does not contain supported type')

if ('attestation' in options['publicKey']) and (options['publicKey']['attestation'] != 'none'):
if ('attestation' in options['publicKey']) and (options['publicKey']['attestation'] not in [None, 'none']):
raise ValueError('Only none attestation supported')

# prepare new key
Expand Down
26 changes: 15 additions & 11 deletions tests/example_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
Navigate to https://localhost:5000 in a supported web browser.
"""
from __future__ import print_function, absolute_import, unicode_literals

from fido2.webauthn import PublicKeyCredentialRpEntity
from fido2.client import ClientData
from fido2.webauthn import (
CollectedClientData,
PublicKeyCredentialRpEntity,
AttestationObject,
AuthenticatorData,
)
from fido2.server import Fido2Server
from fido2.ctap2 import AttestationObject, AuthenticatorData
from fido2 import cbor
from flask import Flask, session, request, redirect, abort

Expand All @@ -48,7 +49,7 @@
app = Flask(__name__, static_url_path="")
app.secret_key = os.urandom(32) # Used for session.

rp = PublicKeyCredentialRpEntity("localhost", "Demo server")
rp = PublicKeyCredentialRpEntity(name="Demo server", id="localhost")
server = Fido2Server(rp)


Expand All @@ -69,7 +70,6 @@ def register_begin():
"id": b"user_id",
"name": "a_user",
"displayName": "A. User",
"icon": "https://example.com/image.png",
},
credentials,
user_verification="discouraged",
Expand All @@ -86,7 +86,7 @@ def register_begin():
@app.route("/api/register/complete", methods=["POST"])
def register_complete():
data = cbor.decode(request.get_data())
client_data = ClientData(data["clientDataJSON"])
client_data = CollectedClientData(data["clientDataJSON"])
att_obj = AttestationObject(data["attestationObject"])
print("clientData", client_data)
print("AttestationObject:", att_obj)
Expand Down Expand Up @@ -115,7 +115,7 @@ def authenticate_complete():

data = cbor.decode(request.get_data())
credential_id = data["credentialId"]
client_data = ClientData(data["clientDataJSON"])
client_data = CollectedClientData(data["clientDataJSON"])
auth_data = AuthenticatorData(data["authenticatorData"])
signature = data["signature"]
print("clientData", client_data)
Expand All @@ -133,6 +133,10 @@ def authenticate_complete():
return cbor.encode({"status": "OK"})


if __name__ == "__main__":
def main():
print(__doc__)
app.run(ssl_context="adhoc", debug=True)
app.run(ssl_context="adhoc", debug=False)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion tests/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from fido2.ctap2 import AttestedCredentialData
from fido2.webauthn import AttestedCredentialData
from fido2.utils import sha256

from soft_webauthn import SoftWebauthnDevice
Expand Down
12 changes: 5 additions & 7 deletions tests/test_interop.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""SoftWebauthnDevice class tests"""

from fido2.client import ClientData
from fido2.ctap2 import AttestationObject, AuthenticatorData
from fido2.server import Fido2Server
from fido2.webauthn import PublicKeyCredentialRpEntity
from fido2.webauthn import AttestationObject, AuthenticatorData, CollectedClientData, PublicKeyCredentialRpEntity

from soft_webauthn import SoftWebauthnDevice

Expand All @@ -13,7 +11,7 @@ def test_register():

device = SoftWebauthnDevice()

server = Fido2Server(PublicKeyCredentialRpEntity('example.org', 'test server'))
server = Fido2Server(PublicKeyCredentialRpEntity(name='test server', id='example.org'))
exclude_credentials = []
options, state = server.register_begin(
{'id': b'randomhandle', 'name': 'username', 'displayName': 'User Name'},
Expand All @@ -22,7 +20,7 @@ def test_register():
attestation = device.create(options, 'https://example.org')
auth_data = server.register_complete(
state,
ClientData(attestation['response']['clientDataJSON']),
CollectedClientData(attestation['response']['clientDataJSON']),
AttestationObject(attestation['response']['attestationObject'])
)

Expand All @@ -36,14 +34,14 @@ def test_authenticate():
device.cred_init('example.org', b'randomhandle')
registered_credential = device.cred_as_attested()

server = Fido2Server(PublicKeyCredentialRpEntity('example.org', 'test server'))
server = Fido2Server(PublicKeyCredentialRpEntity(name='test server', id='example.org'))
options, state = server.authenticate_begin([registered_credential])
assertion = device.get(options, 'https://example.org')
server.authenticate_complete(
state,
[registered_credential],
assertion['rawId'],
ClientData(assertion['response']['clientDataJSON']),
CollectedClientData(assertion['response']['clientDataJSON']),
AuthenticatorData(assertion['response']['authenticatorData']),
assertion['response']['signature']
)

0 comments on commit 3511062

Please sign in to comment.