Remove API key From Console
parent
7b3136a642
commit
944ec36b8a
|
|
@ -164,6 +164,9 @@ class CL_GET_USER(BaseModel):
|
||||||
user: str
|
user: str
|
||||||
database: str
|
database: str
|
||||||
|
|
||||||
|
class CL_GET_USER_CLIENT(BaseModel):
|
||||||
|
dbname: str
|
||||||
|
user: str
|
||||||
|
|
||||||
class CL_ADD_GROUP_VOLUME(BaseModel):
|
class CL_ADD_GROUP_VOLUME(BaseModel):
|
||||||
label: str
|
label: str
|
||||||
|
|
|
||||||
35
main.py
35
main.py
|
|
@ -115,14 +115,22 @@ async def getdatabase(get: CL.CL_GET_DATABASE,api_key: APIKey = Depends(auth.get
|
||||||
|
|
||||||
@app.post("/host/set")
|
@app.post("/host/set")
|
||||||
async def sethost(get: CL.CL_SET_HOST,api_key: APIKey = Depends(auth.get_api_key)):
|
async def sethost(get: CL.CL_SET_HOST,api_key: APIKey = Depends(auth.get_api_key)):
|
||||||
database(f"INSERT INTO `{get.dbname}`.Clients (`Host-Name`,Username,`IP-Adresse`,`Windows-Version`,`CPU-Name`,`Prozessor-Anzahl`,RAM,Speichergesamt,Speicherfrei,Speicherbelegt, NetVolumeUser) VALUES ('{get.hostname}','{get.user}','{get.ipadresse}','{get.winver}','{get.cpuname}','{get.cores}','{get.ram}','{get.hddtotal}','{get.hddfree}','{get.hddused}',{get.netvolumeuser})","","")
|
database(f"INSERT INTO `{get.dbname}`.Clients (`Host-Name`,SamAccountName,`IP-Adresse`,`Windows-Version`,`CPU-Name`,`Prozessor-Anzahl`,RAM,Speichergesamt,Speicherfrei,Speicherbelegt, NetVolumeUser) VALUES ('{get.hostname}','{get.user}','{get.ipadresse}','{get.winver}','{get.cpuname}','{get.cores}','{get.ram}','{get.hddtotal}','{get.hddfree}','{get.hddused}',{get.netvolumeuser})","","")
|
||||||
result = database(
|
hostid = database(
|
||||||
f"SELECT id FROM `{get.dbname}`.Clients WHERE `Host-Name` = '{get.hostname}'",
|
f"SELECT id FROM `{get.dbname}`.Clients WHERE `Host-Name` = '{get.hostname}'",
|
||||||
"", "")
|
"", "")
|
||||||
if not result:
|
userid = database(
|
||||||
|
f"SELECT id FROM `{get.dbname}`.User WHERE `SamAccountName` = '{get.user}'",
|
||||||
|
"", "")
|
||||||
|
if not userid:
|
||||||
|
userid = database(
|
||||||
|
f"SELECT id FROM `{get.dbname}`.`Active-Directory-User` WHERE `SamAccountName` = '{get.user}'",
|
||||||
|
"", "")
|
||||||
|
database(f"INSERT INTO `{get.dbname}`.ClientsToUser (clientsid,userid) VALUES ({hostid},{userid})","","")
|
||||||
|
if not hostid:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return result[0][0]
|
return hostid[0][0]
|
||||||
|
|
||||||
# @app.post("/host/cpu")
|
# @app.post("/host/cpu")
|
||||||
# async def setcpu(get: CL.CL_SET_CPU,api_key: APIKey = Depends(auth.get_api_key)):
|
# async def setcpu(get: CL.CL_SET_CPU,api_key: APIKey = Depends(auth.get_api_key)):
|
||||||
|
|
@ -141,7 +149,7 @@ async def sethost(get: CL.CL_SET_HOST,api_key: APIKey = Depends(auth.get_api_key
|
||||||
|
|
||||||
@app.post("/host/update")
|
@app.post("/host/update")
|
||||||
async def updatehost(get: CL.CL_UPDATE_HOST,api_key: APIKey = Depends(auth.get_api_key)):
|
async def updatehost(get: CL.CL_UPDATE_HOST,api_key: APIKey = Depends(auth.get_api_key)):
|
||||||
database(f"UPDATE `{get.dbname}`.Clients SET Username = '{get.user}',`IP-Adresse` = '{get.ipadresse}',`Windows-Version` = '{get.winver}',`CPU-Name` = '{get.cpuname}',`Prozessor-Anzahl` = {get.cores},RAM = {get.ram},Speichergesamt = '{get.hddtotal}',Speicherfrei = '{get.hddfree}',Speicherbelegt = '{get.hddused}',NetVolumeUser = '{get.netvolumeuser}', LastChange = '{datetime.now()}' WHERE `Host-Name` = '{get.hostname}'","","")
|
database(f"UPDATE `{get.dbname}`.Clients SET SamAccountName = '{get.user}',`IP-Adresse` = '{get.ipadresse}',`Windows-Version` = '{get.winver}',`CPU-Name` = '{get.cpuname}',`Prozessor-Anzahl` = {get.cores},RAM = {get.ram},Speichergesamt = '{get.hddtotal}',Speicherfrei = '{get.hddfree}',Speicherbelegt = '{get.hddused}',NetVolumeUser = '{get.netvolumeuser}', LastChange = '{datetime.now()}' WHERE `Host-Name` = '{get.hostname}'","","")
|
||||||
result = database(f"SELECT id FROM `{get.dbname}`.Clients WHERE `Host-Name` = '{get.hostname}'","", "")
|
result = database(f"SELECT id FROM `{get.dbname}`.Clients WHERE `Host-Name` = '{get.hostname}'","", "")
|
||||||
if not result:
|
if not result:
|
||||||
return False
|
return False
|
||||||
|
|
@ -150,9 +158,7 @@ async def updatehost(get: CL.CL_UPDATE_HOST,api_key: APIKey = Depends(auth.get_a
|
||||||
|
|
||||||
@app.post("/user/set")
|
@app.post("/user/set")
|
||||||
async def set_user(get: CL.CL_SET_HOST_USER,api_key: APIKey = Depends(auth.get_api_key)):
|
async def set_user(get: CL.CL_SET_HOST_USER,api_key: APIKey = Depends(auth.get_api_key)):
|
||||||
database(f"INSERT INTO `{get.dbname}`.user (user) VALUES ('{get.user}')","","")
|
result = database(f"INSERT INTO `{get.dbname}`.ClientsUser (SamAccountName) 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:
|
||||||
|
|
@ -161,6 +167,10 @@ async def set_user(get: CL.CL_SET_HOST_USER,api_key: APIKey = Depends(auth.get_a
|
||||||
@app.post("/user/get")
|
@app.post("/user/get")
|
||||||
async def get_user(get: CL.CL_GET_HOST_USER,api_key: APIKey = Depends(auth.get_api_key)):
|
async def get_user(get: CL.CL_GET_HOST_USER,api_key: APIKey = Depends(auth.get_api_key)):
|
||||||
result = database(f"SELECT id FROM `{get.dbname}`.`Active-Directory-User` WHERE SamAccountName = '{get.user}' ORDER BY ID DESC LIMIT 1","","")
|
result = database(f"SELECT id FROM `{get.dbname}`.`Active-Directory-User` WHERE SamAccountName = '{get.user}' ORDER BY ID DESC LIMIT 1","","")
|
||||||
|
if not result:
|
||||||
|
result = database(
|
||||||
|
f"SELECT id FROM `{get.dbname}`.`Clients` WHERE SamAccountName = '{get.user}' ORDER BY ID DESC LIMIT 1",
|
||||||
|
"", "")
|
||||||
return result[0][0]
|
return result[0][0]
|
||||||
|
|
||||||
@app.post("/user/set/lastlogon")
|
@app.post("/user/set/lastlogon")
|
||||||
|
|
@ -176,6 +186,15 @@ async def getclient(get: CL.CL_GET_CLIENT,api_key: APIKey = Depends(auth.get_api
|
||||||
else:
|
else:
|
||||||
return result[0][0]
|
return result[0][0]
|
||||||
|
|
||||||
|
@app.post("/client/user/get")
|
||||||
|
async def getclient(get: CL.CL_GET_USER_CLIENT,api_key: APIKey = Depends(auth.get_api_key)):
|
||||||
|
result = database(f"SELECT SamAccountName FROM `{get.dbname}`.`Active-Directory-User` INNER JOIN ClientsToUser ON ClientsToUser.userid = where `Client-Name` = '{get.user}'","Stines-GmbH","")
|
||||||
|
if not result:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return result[0][0]
|
||||||
|
|
||||||
|
|
||||||
@app.post("/info/addclient")
|
@app.post("/info/addclient")
|
||||||
async def addclient(addclient: CL.CL_ADD_CLIENT,api_key: APIKey = Depends(auth.get_api_key)):
|
async def addclient(addclient: CL.CL_ADD_CLIENT,api_key: APIKey = Depends(auth.get_api_key)):
|
||||||
print(addclient.query)
|
print(addclient.query)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue