inclueded user ID and keyNumber in Register.py
This commit is contained in:
parent
00d62ef7e4
commit
7cc25d2c26
51
Register.py
51
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!")
|
||||
|
Loading…
Reference in New Issue
Block a user