inclueded user ID and keyNumber in Register.py

This commit is contained in:
EggMan20339 2024-05-09 20:10:01 -04:00
parent 00d62ef7e4
commit 7cc25d2c26
2 changed files with 29 additions and 24 deletions

View File

@ -9,6 +9,7 @@ from fido2.server import Fido2Server
from getpass import getpass
import sys
import ctypes
import psycopg2
from fido2.ctap2 import Ctap2
@ -31,6 +32,7 @@ if WindowsClient.is_available() and not ctypes.windll.shell32.IsUserAnAdmin():
client = WindowsClient("https://example.com")
else:
# Locate a device
dev = next(CtapHidDevice.list_devices(), None)
if dev is not None:
print("Use USB HID channel.")
@ -82,8 +84,10 @@ pk__1 = auth_data.credential_data.public_key.get(-1)
pk__2 = auth_data.credential_data.public_key.get(-2)
pk__3 = auth_data.credential_data.public_key.get(-3)
pickled = pickle.dumps(credentials)
user_id = int(input("Please enter user ID number: "))
keyNumber = (int
(input("Please enter key number: ")))
import psycopg2
# Replace these variables with your connection parameters
dbname = "CNSA-276-FP-DAS"
@ -93,43 +97,44 @@ host = "postgres.eggtech.net"
# Function to connect to the PostgreSQL database and insert data
def insert_data(aaguid, cred_id, pk_algo, pk_1, pk_3, pk__1, pk__2, pk__3):
def insert_data(aaguid, user_id, cred_id, pk_algo, pk_1, pk_3, pk__1, pk__2, pk__3, keyNumber):
conn = None
try:
# Connect to the PostgreSQL server
conn = psycopg2.connect(dbname=dbname, user=user, password=password, host=host)
cur = conn.cursor()
# Define the SQL query for inserting data
insert_query = '''
INSERT INTO credential_data ("AAGUID", "credential_id", "pk_algo", "pk_1", "pk_3", "pk_neg1", "pk_neg2", "pk_neg3", "pickled")
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s);
INSERT INTO credential_data ("AAGUID", "user_id", "credential_id", "pk_algo", "pk_1", "pk_3", "pk_neg1", "pk_neg2", "pk_neg3", "pickled", "keyNumber")
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);
'''
# Execute the SQL query
cur.execute(insert_query, (aaguid, cred_id, pk_algo, pk_1, pk_3, pk__1, pk__2, pk__3, pickled))
cur.execute(insert_query, (aaguid, user_id, cred_id, pk_algo, pk_1, pk_3, pk__1, pk__2, pk__3, pickled, keyNumber))
# Commit the changes
conn.commit()
# Close communication with the database
cur.close()
except (Exception, psycopg2.DatabaseError) as error:
print(error)
finally:
if conn is not None:
conn.close()
# Assuming auth_data is defined and you've extracted your data as you've shown above
insert_data(
AAGUID,
user_id,
cred_id,
pk_algo,
pk_1,
pk_3,
pk__1,
pk__2,
pk__3
pk__3,
keyNumber
)
print("New credential created!")

View File

@ -326,7 +326,7 @@ while True:
GPIO.output(greenLed, GPIO.HIGH)
GPIO.output(door, GPIO.HIGH)
time.sleep(5)
time.sleep(1)
GPIO.output(greenLed, GPIO.LOW)