sucessfully pushing to the DB

This commit is contained in:
caschick221 2024-05-02 12:13:51 -04:00
parent 6dfc0a2568
commit a58efebb5c
5 changed files with 70 additions and 6 deletions

View File

@ -5,7 +5,7 @@
<excludeFolder url="file://$MODULE_DIR$/.venv" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.12" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.12 (CNSA-276-FP)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

12
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="postgres@postgres.eggtech.net" uuid="75581ce6-3e75-4c9c-8544-e6c26149df60">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://postgres.eggtech.net:5432/postgres</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@ -3,5 +3,5 @@
<component name="Black">
<option name="sdkName" value="Python 3.12 (CNSA-276-FP)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (CNSA-276-FP)" project-jdk-type="Python SDK" />
</project>

View File

@ -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,

8
tet.py
View File

@ -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