Remove API key From Console

master
Sebastian Serfling 2023-10-12 14:41:45 +02:00
parent 16d570003c
commit c1254385d0
2 changed files with 9 additions and 3 deletions

View File

@ -104,6 +104,7 @@ class CL_GET_HOST(BaseModel):
class CL_SET_HOST_USER(BaseModel): class CL_SET_HOST_USER(BaseModel):
user: str user: str
dbname: str dbname: str
hardwareID: str
class CL_GET_HOST_USER(BaseModel): class CL_GET_HOST_USER(BaseModel):
user: str user: str

11
main.py
View File

@ -96,7 +96,10 @@ async def gethostname(get: CL.CL_GET_HOST,api_key: APIKey = Depends(auth.get_api
@app.post("/info/sethost") @app.post("/info/sethost")
async def sethostname(get: CL.CL_SET_HOST,api_key: APIKey = Depends(auth.get_api_key)): async def sethostname(get: CL.CL_SET_HOST,api_key: APIKey = Depends(auth.get_api_key)):
result = database(f"INSERT INTO `{get.dbname}`.hardware (hostname,ipadresse,ram,hddused,hddfree,hddtotal) VALUES ('{get.hostname}','{get.ipadresse}','{get.ram}','{get.hddused}','{get.hddfree}','{get.hddtotal}')","","") database(f"INSERT INTO `{get.dbname}`.hardware (hostname,ipadresse,ram,hddused,hddfree,hddtotal) VALUES ('{get.hostname}','{get.ipadresse}','{get.ram}','{get.hddused}','{get.hddfree}','{get.hddtotal}')","","")
result = database(
f"SELECT id FROM `{get.dbname}`.hardware WHERE hostname = '{get.hostname}')",
"", "")
if not result: if not result:
return False return False
else: else:
@ -104,11 +107,13 @@ async def sethostname(get: CL.CL_SET_HOST,api_key: APIKey = Depends(auth.get_api
@app.post("/info/sethost_user") @app.post("/info/sethost_user")
async def sethost_user(get: CL.CL_SET_HOST_USER,api_key: APIKey = Depends(auth.get_api_key)): async def sethost_user(get: CL.CL_SET_HOST_USER,api_key: APIKey = Depends(auth.get_api_key)):
result = database(f"INSERT INTO `{get.dbname}`.user (user) VALUES ('{get.user}')","","") database(f"INSERT INTO `{get.dbname}`.user (user) VALUES ('{get.user}')","","")
result = database(f"SELECT id FROM `{get.dbname}`.user WHERE user = '{get.user}'","","")
database(f"INSERT INTO `{get.dbname}`.hardware_to_user (userID,hardwareID) VALUES ('{result[0][0]}',{get.hardwareID})", "", "")
if not result: if not result:
return False return False
else: else:
return database(f"SELECT id FROM `{get.dbname}`.user WHERE user = '{get.user}'","","") return result
@app.post("/info/gethost_user") @app.post("/info/gethost_user")
async def gethost_user(get: CL.CL_GET_HOST_USER,api_key: APIKey = Depends(auth.get_api_key)): async def gethost_user(get: CL.CL_GET_HOST_USER,api_key: APIKey = Depends(auth.get_api_key)):