diff --git a/pizzicore/pizzicore.py b/pizzicore/pizzicore.py index 171264d..2ae87c7 100644 --- a/pizzicore/pizzicore.py +++ b/pizzicore/pizzicore.py @@ -119,6 +119,9 @@ security = HTTPBasic() class CountersDescription(BaseModel): counters: int +class UserDescription(BaseModel): + role: str + class Value(BaseModel): counter: int @@ -136,6 +139,10 @@ def get_current_role(credentials: HTTPBasicCredentials = Depends(security)): ) return "admin" +@app.get("/v1/whoami/") +async def whoami(role: str = Depends(get_current_role)): + return UserDescription(role=role) + @app.get("/v1/counter/") async def get_counter_number(): return CountersDescription(counters=len(counter_store.values))