http api to just check authentication status

this will be useful for #7
This commit is contained in:
boyska 2022-08-19 19:21:17 +02:00
parent 654873529c
commit 0d31b32429

View file

@ -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))