From a58efebb5c77272d854bd0e408374719f945b890 Mon Sep 17 00:00:00 2001 From: caschick221 Date: Thu, 2 May 2024 12:13:51 -0400 Subject: [PATCH] sucessfully pushing to the DB --- .idea/CNSA-276-FP.iml | 2 +- .idea/dataSources.xml | 12 ++++++++++ .idea/misc.xml | 2 +- credentailsex.py | 52 +++++++++++++++++++++++++++++++++++++++++++ tet.py | 8 +++---- 5 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 .idea/dataSources.xml diff --git a/.idea/CNSA-276-FP.iml b/.idea/CNSA-276-FP.iml index edfb3df..b7fe510 100644 --- a/.idea/CNSA-276-FP.iml +++ b/.idea/CNSA-276-FP.iml @@ -5,7 +5,7 @@ - + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..c947738 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,12 @@ + + + + + postgresql + true + org.postgresql.Driver + jdbc:postgresql://postgres.eggtech.net:5432/postgres + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 073d552..92298c3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/credentailsex.py b/credentailsex.py index 492186a..8ff3bc1 100644 --- a/credentailsex.py +++ b/credentailsex.py @@ -112,6 +112,57 @@ 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) + +import psycopg2 + +# Replace these variables with your connection parameters +dbname = "CNSA-276-FP-DAS" +user = "FP-DEV-USER" +password = "purchase-immortal-prescribe-repave-detention-seizing-candied-antiques-episode-list" +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): + 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") + VALUES (%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)) + + # 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, + cred_id, + pk_algo, + pk_1, + pk_3, + pk__1, + pk__2, + pk__3 +) + + + print("New credential created!") print("CLIENT DATA:", result.client_data) @@ -132,6 +183,7 @@ result = result.get_response(0) # Complete authenticator server.authenticate_complete( state, + credentials, result.credential_id, result.client_data, diff --git a/tet.py b/tet.py index 9a0dc2f..4566e8d 100644 --- a/tet.py +++ b/tet.py @@ -6,13 +6,13 @@ from fido2.hid import CtapHidDevice import os # Setup the relying party (RP) entity -rp = PublicKeyCredentialRpEntity("eggtech.net", "Example RP") +rp = PublicKeyCredentialRpEntity("eggtech.net", "test") # Setup the user entity user = PublicKeyCredentialUserEntity( - id=b'user_id', # User ID as bytes - name="user@example.com", - display_name="User Display Name" + id=b'91974', # User ID as bytes + name="cyrus@eggtech.net", + display_name="Cyrus Schick" ) # Define the public key credential parameters