inclueded user ID and keyNumber in Register.py
This commit is contained in:
parent
00d62ef7e4
commit
7cc25d2c26
27
Register.py
27
Register.py
@ -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
|
# Connect to the PostgreSQL server
|
||||||
conn = psycopg2.connect(dbname=dbname, user=user, password=password, host=host)
|
conn = psycopg2.connect(dbname=dbname, user=user, password=password, host=host)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
# Define the SQL query for inserting data
|
# Define the SQL query for inserting data
|
||||||
insert_query = '''
|
insert_query = '''
|
||||||
INSERT INTO credential_data ("AAGUID", "credential_id", "pk_algo", "pk_1", "pk_3", "pk_neg1", "pk_neg2", "pk_neg3", "pickled")
|
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);
|
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# Execute the SQL query
|
# 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
|
# Commit the changes
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
# Close communication with the database
|
# Close communication with the database
|
||||||
cur.close()
|
cur.close()
|
||||||
except (Exception, psycopg2.DatabaseError) as error:
|
|
||||||
print(error)
|
|
||||||
finally:
|
|
||||||
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!")
|
||||||
|
Loading…
Reference in New Issue
Block a user