mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-27 20:40:13 +03:00
Add timing to API key auth path and log api_keys count
This commit is contained in:
parent
3c41dea48f
commit
04f0657661
@ -58,9 +58,12 @@ async def get_user_from_token(
|
||||
|
||||
# API Key authentication
|
||||
if token.startswith("gns3_"):
|
||||
log.info(f"[CTRL-TIMING] get_user_from_token API_KEY auth elapsed={time.time()-_t0:.3f}s")
|
||||
query = select(models.ApiKey).where(models.ApiKey.revoked == False)
|
||||
result = await api_keys_repo._db_session.execute(query)
|
||||
for db_key in result.scalars().all():
|
||||
api_keys_list = result.scalars().all()
|
||||
log.info(f"[CTRL-TIMING] get_user_from_token api_keys_count={len(api_keys_list)} elapsed={time.time()-_t0:.3f}s")
|
||||
for db_key in api_keys_list:
|
||||
if bcrypt.checkpw(token.encode(), db_key.key_hash.encode()):
|
||||
await api_keys_repo.update_last_used(db_key.api_key_id)
|
||||
user = await user_repo.get_user(db_key.user_id)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user