Erase secrets after view #1

Merged
root merged 2 commits from erase-secrets-after-view into main 2024-12-25 10:07:14 +00:00
Showing only changes of commit 66acd51b6d - Show all commits

View file

@ -1,4 +1,5 @@
from fastapi import FastAPI
from fastapi.exceptions import HTTPException
from rectes.models import Secret, SecretSaveResult
from rectes.redis_db import redis
@ -18,8 +19,18 @@ async def set_secret(data: Secret):
}
@app.get("/secret/{secret_key}", response_model=Secret)
@app.get(
"/secret/{secret_key}",
response_model=Secret,
responses={404: {"description": "The item was not found"}},
)
async def get_secret(secret_key):
data = await redis.get(secret_key)
if data is None:
raise HTTPException(404)
await redis.delete(secret_key)
return {
"data": await redis.get(secret_key),
"data": data,
}