|
9 | 9 | Copyright (C) 2019 Taylor Dean ([email protected])
|
10 | 10 | Copyright (C) 2020 Max Lanin ([email protected])
|
11 | 11 | Copyright (C) 2019-2020 Tino Lange ([email protected])
|
| 12 | + Copyright (C) 2022 David Keijser ([email protected]) |
12 | 13 |
|
13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy
|
14 | 15 | of this software and associated documentation files (the "Software"), to deal
|
|
56 | 57 | from fido2.utils import websafe_decode
|
57 | 58 | from fido2.hid import CtapHidDevice
|
58 | 59 | from fido2.client import Fido2Client
|
| 60 | + from fido2.webauthn import PublicKeyCredentialRequestOptions, PublicKeyCredentialDescriptor, PublicKeyCredentialType |
59 | 61 | have_fido = True
|
60 | 62 | except ImportError:
|
61 | 63 | pass
|
@@ -649,27 +651,35 @@ def okta_mfa_webauthn(conf, factor, state_token):
|
649 | 651 | profile = rfactor['profile']
|
650 | 652 | purl = parse_url(conf.okta_url)
|
651 | 653 | origin = '{0}://{1}'.format(purl[0], purl[1])
|
652 |
| - challenge = rfactor['_embedded']['challenge']['challenge'] |
653 | 654 | credentialId = websafe_decode(profile['credentialId'])
|
654 | 655 | allow_list = [{'type': 'public-key', 'id': credentialId}]
|
| 656 | + request_options = PublicKeyCredentialRequestOptions( |
| 657 | + challenge = websafe_decode(rfactor['_embedded']['challenge']['challenge']), |
| 658 | + rp_id = purl[1], |
| 659 | + allow_credentials = [ |
| 660 | + PublicKeyCredentialDescriptor( |
| 661 | + PublicKeyCredentialType.PUBLIC_KEY, |
| 662 | + websafe_decode(profile['credentialId'])) |
| 663 | + ] |
| 664 | + ) |
655 | 665 | for dev in devices:
|
656 | 666 | client = Fido2Client(dev, origin)
|
657 | 667 | print('!!! Touch the flashing U2F device to authenticate... !!!')
|
658 | 668 | try:
|
659 |
| - result = client.get_assertion(purl[1], challenge, allow_list) |
660 |
| - dbg(conf.debug, 'assertion.result', result) |
| 669 | + result = client.get_assertion(request_options) |
| 670 | + dbg(conf.debug, 'assertion.result', vars(result)) |
661 | 671 | break
|
662 | 672 | except Exception:
|
663 | 673 | traceback.print_exc(file=sys.stderr)
|
664 | 674 | result = None
|
665 | 675 | if not result:
|
666 | 676 | return None
|
667 |
| - assertion, client_data = result[0][0], result[1] # only one cred in allowList, so only one response. |
| 677 | + response = result.get_response(0) # only one cred in allowList, so only one response. |
668 | 678 | data = {
|
669 | 679 | 'stateToken': state_token,
|
670 |
| - 'clientData': to_n((base64.b64encode(client_data)).decode('ascii')), |
671 |
| - 'signatureData': to_n((base64.b64encode(assertion.signature)).decode('ascii')), |
672 |
| - 'authenticatorData': to_n((base64.b64encode(assertion.auth_data)).decode('ascii')) |
| 680 | + 'clientData': to_n((base64.b64encode(response.client_data)).decode('ascii')), |
| 681 | + 'signatureData': to_n((base64.b64encode(response.signature)).decode('ascii')), |
| 682 | + 'authenticatorData': to_n((base64.b64encode(response.authenticator_data)).decode('ascii')) |
673 | 683 | }
|
674 | 684 | log('mfa {0} signature request [okta_url]'.format(provider))
|
675 | 685 | _, _h, j = send_json_req(conf, 'okta', 'uf2 mfa signature', j['_links']['next']['href'], data, expected_url=conf.okta_url)
|
|
0 commit comments