From 7cc25d2c26aa0f0847a30e48fce418c835c5f2d8 Mon Sep 17 00:00:00 2001 From: EggMan20339 <99349302+EggMan20339@users.noreply.github.com> Date: Thu, 9 May 2024 20:10:01 -0400 Subject: [PATCH] inclueded user ID and keyNumber in Register.py --- Register.py | 51 ++++++++++++++++++++++++++++----------------------- main.py | 2 +- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Register.py b/Register.py index c8e2801..c76c961 100644 --- a/Register.py +++ b/Register.py @@ -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); - ''' - # Execute the SQL query - cur.execute(insert_query, (aaguid, cred_id, pk_algo, pk_1, pk_3, pk__1, pk__2, pk__3, pickled)) + # 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", "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 - conn.commit() + # Execute the SQL query + 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 - cur.close() - except (Exception, psycopg2.DatabaseError) as error: - print(error) - finally: - if conn is not None: - conn.close() + # Commit the changes + conn.commit() + + # Close communication with the database + cur.close() + + + + 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!") diff --git a/main.py b/main.py index 92213b3..39cb69c 100644 --- a/main.py +++ b/main.py @@ -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)