revert to before nfc
This commit is contained in:
parent
51cdc8d4e2
commit
7e3b6678d6
@ -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="inheritedJdk" />
|
||||
<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) (2)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -5,7 +5,6 @@ sudo apt-get upgrade -y
|
||||
sudo apt-get update
|
||||
sudo apt-get install python3-psycopg2 -y
|
||||
sudo apt-get install python3-fido2 -y
|
||||
sudo apt-get install python3-nfcpy -y
|
||||
sudo apt-get install screen -y
|
||||
|
||||
sudo apt-get update
|
||||
|
34
main.py
34
main.py
@ -33,12 +33,11 @@ On Windows, the native WebAuthn API will be used.
|
||||
"""
|
||||
import time
|
||||
import configparser
|
||||
gpie = True
|
||||
gpie = False
|
||||
if gpie:
|
||||
import RPi.GPIO as GPIO
|
||||
import pickle
|
||||
import psycopg2
|
||||
import ndef
|
||||
import fido2.webauthn
|
||||
from fido2.hid import CtapHidDevice
|
||||
from fido2.client import Fido2Client, WindowsClient, UserInteraction
|
||||
@ -48,14 +47,11 @@ import sys
|
||||
import ctypes
|
||||
from fido2.ctap2 import Ctap2
|
||||
from fido2 import cbor
|
||||
import nfc
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
config.read('config.ini')
|
||||
|
||||
isNfc = False
|
||||
|
||||
dbusername = config.get('Setup', 'dbusername')
|
||||
dbpassword = config.get('Setup', 'dbpassword')
|
||||
dbname = config.get('Setup', 'dbname')
|
||||
@ -73,10 +69,6 @@ redLed = 7
|
||||
|
||||
door = 40
|
||||
|
||||
def send_fido2_over_nfc(encoded_message):
|
||||
ndef_message = ndef.Message(ndef.Record('application/fido2', '', encoded_message))
|
||||
return clf.connect(rdwr={'on-connect': lambda tag: tag.ndef.records.append(ndef_message)})
|
||||
|
||||
if gpie:
|
||||
# badCredentials = False
|
||||
GPIO.setup(greenLed, GPIO.OUT)
|
||||
@ -110,21 +102,7 @@ class CliInteraction(UserInteraction):
|
||||
print("User Verification required.")
|
||||
return True
|
||||
|
||||
clf = None
|
||||
def read_nfc_tag():
|
||||
try:
|
||||
import nfc
|
||||
clf = nfc.ContactlessFrontend('usb')
|
||||
tag = clf.connect(rdwr={'on-connect': lambda tag: False})
|
||||
nfc = True
|
||||
return tag.identifier if tag else None
|
||||
except Exception as e:
|
||||
# print("NFC read error:", e)
|
||||
return None
|
||||
finally:
|
||||
if clf:
|
||||
clf.close()
|
||||
pass
|
||||
|
||||
|
||||
while True:
|
||||
isNfc = False
|
||||
@ -137,7 +115,7 @@ while True:
|
||||
GPIO.output(redLed, GPIO.HIGH)
|
||||
while True:
|
||||
try:
|
||||
nfc_tag = read_nfc_tag()
|
||||
|
||||
dev = next(CtapHidDevice.list_devices(), None)
|
||||
|
||||
if dev:
|
||||
@ -248,11 +226,9 @@ while True:
|
||||
request_options, state = server.authenticate_begin(credentials, user_verification=uv)
|
||||
|
||||
# Authenticate the credential
|
||||
if not isNfc:
|
||||
|
||||
result = client.get_assertion(request_options["publicKey"])
|
||||
else:
|
||||
sendme = cbor.encode(credentials)
|
||||
send_fido2_over_nfc(sendme)
|
||||
|
||||
# Only one cred in allowCredentials, only one response.
|
||||
result = result.get_response(0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user