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 from getpass import getpass
import sys import sys
import ctypes import ctypes
import psycopg2
from fido2.ctap2 import Ctap2 from fido2.ctap2 import Ctap2
@ -31,6 +32,7 @@ if WindowsClient.is_available() and not ctypes.windll.shell32.IsUserAnAdmin():
client = WindowsClient("https://example.com") client = WindowsClient("https://example.com")
else: else:
# Locate a device # Locate a device
dev = next(CtapHidDevice.list_devices(), None) dev = next(CtapHidDevice.list_devices(), None)
if dev is not None: if dev is not None:
print("Use USB HID channel.") 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__2 = auth_data.credential_data.public_key.get(-2)
pk__3 = auth_data.credential_data.public_key.get(-3) pk__3 = auth_data.credential_data.public_key.get(-3)
pickled = pickle.dumps(credentials) 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 # Replace these variables with your connection parameters
dbname = "CNSA-276-FP-DAS" dbname = "CNSA-276-FP-DAS"
@ -93,43 +97,44 @@ host = "postgres.eggtech.net"
# Function to connect to the PostgreSQL database and insert data # 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 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);
'''
# Execute the SQL query # Connect to the PostgreSQL server
cur.execute(insert_query, (aaguid, cred_id, pk_algo, pk_1, pk_3, pk__1, pk__2, pk__3, pickled)) 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", "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);
'''
# Commit the changes # Execute the SQL query
conn.commit() cur.execute(insert_query, (aaguid, user_id, cred_id, pk_algo, pk_1, pk_3, pk__1, pk__2, pk__3, pickled, keyNumber))
# Close communication with the database # Commit the changes
cur.close() conn.commit()
except (Exception, psycopg2.DatabaseError) as error:
print(error) # Close communication with the database
finally: cur.close()
if conn is not None:
conn.close()
conn.close()
# Assuming auth_data is defined and you've extracted your data as you've shown above # Assuming auth_data is defined and you've extracted your data as you've shown above
insert_data( insert_data(
AAGUID, AAGUID,
user_id,
cred_id, cred_id,
pk_algo, pk_algo,
pk_1, pk_1,
pk_3, pk_3,
pk__1, pk__1,
pk__2, pk__2,
pk__3 pk__3,
keyNumber
) )
print("New credential created!") print("New credential created!")

View File

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