progressd
This commit is contained in:
parent
e3e0b3853b
commit
594aaa18d6
@ -5,7 +5,7 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.12 (CNSA-276-FP)" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.11 (CNSA-276-FP)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -3,5 +3,5 @@
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.12 (CNSA-276-FP)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (CNSA-276-FP)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (CNSA-276-FP)" project-jdk-type="Python SDK" />
|
||||
</project>
|
65
tet.py
65
tet.py
@ -1,21 +1,56 @@
|
||||
from fido2.server import Fido2Server
|
||||
from fido2.webauthn import PublicKeyCredentialRpEntity
|
||||
|
||||
rp = PublicKeyCredentialRpEntity("example.com", "Example RP")
|
||||
server = Fido2Server(rp)
|
||||
registration_data, state = server.register_begin({
|
||||
"91974": b"user_id", # user ID as bytes
|
||||
"Cyrus": "cyrus@eggtech.net",
|
||||
"displayName": "Admin"
|
||||
})
|
||||
from fido2.webauthn import (PublicKeyCredentialRpEntity, PublicKeyCredentialUserEntity,
|
||||
PublicKeyCredentialParameters, PublicKeyCredentialCreationOptions)
|
||||
from fido2.client import Fido2Client
|
||||
from fido2.hid import CtapHidDevice
|
||||
import os
|
||||
|
||||
# List FIDO devices on the system
|
||||
devices = list(CtapHidDevice.list_devices())
|
||||
if not devices:
|
||||
# Setup the relying party (RP) entity
|
||||
rp = PublicKeyCredentialRpEntity("10.1.1.245", "Example RP")
|
||||
|
||||
# Setup the user entity
|
||||
user = PublicKeyCredentialUserEntity(
|
||||
id=b'user_id', # User ID as bytes
|
||||
name="user@example.com",
|
||||
display_name="User Display Name"
|
||||
)
|
||||
|
||||
# Define the public key credential parameters
|
||||
cred_params = [
|
||||
PublicKeyCredentialParameters("public-key", -7), # ES256
|
||||
PublicKeyCredentialParameters("public-key", -257) # RS256
|
||||
]
|
||||
|
||||
# FIDO2 Server setup
|
||||
server = Fido2Server(rp)
|
||||
|
||||
# Generate a random challenge
|
||||
challenge = os.urandom(32)
|
||||
|
||||
# Manually create the PublicKeyCredentialCreationOptions
|
||||
options = PublicKeyCredentialCreationOptions(
|
||||
rp=rp,
|
||||
user=user,
|
||||
challenge=challenge,
|
||||
pub_key_cred_params=cred_params
|
||||
)
|
||||
|
||||
# Start the registration process (adjust this method if needed)
|
||||
registration_data, state = server.register_begin(
|
||||
user=user,
|
||||
challenge=challenge
|
||||
)
|
||||
|
||||
# Assuming the device is the first one connected
|
||||
device = next(CtapHidDevice.list_devices(), None)
|
||||
if device is None:
|
||||
raise ValueError("No FIDO device found")
|
||||
device = devices[0]
|
||||
|
||||
client = Fido2Client(device, "https://example.com")
|
||||
attestation_object, client_data = client.make_credential(registration_data)
|
||||
# Client instance for the device
|
||||
client = Fido2Client(device, "10.1.1.245")
|
||||
|
||||
# Use the manual options we created for make_credential
|
||||
attestation_object, client_data = client.make_credential(options)
|
||||
|
||||
# Finalize the registration to validate the response and store the credentials
|
||||
auth_data = server.register_complete(state, client_data, attestation_object)
|
||||
|
Loading…
Reference in New Issue
Block a user