http api to just check authentication status
this will be useful for #7
This commit is contained in:
parent
654873529c
commit
0d31b32429
1 changed files with 7 additions and 0 deletions
|
@ -119,6 +119,9 @@ security = HTTPBasic()
|
||||||
class CountersDescription(BaseModel):
|
class CountersDescription(BaseModel):
|
||||||
counters: int
|
counters: int
|
||||||
|
|
||||||
|
class UserDescription(BaseModel):
|
||||||
|
role: str
|
||||||
|
|
||||||
|
|
||||||
class Value(BaseModel):
|
class Value(BaseModel):
|
||||||
counter: int
|
counter: int
|
||||||
|
@ -136,6 +139,10 @@ def get_current_role(credentials: HTTPBasicCredentials = Depends(security)):
|
||||||
)
|
)
|
||||||
return "admin"
|
return "admin"
|
||||||
|
|
||||||
|
@app.get("/v1/whoami/")
|
||||||
|
async def whoami(role: str = Depends(get_current_role)):
|
||||||
|
return UserDescription(role=role)
|
||||||
|
|
||||||
@app.get("/v1/counter/")
|
@app.get("/v1/counter/")
|
||||||
async def get_counter_number():
|
async def get_counter_number():
|
||||||
return CountersDescription(counters=len(counter_store.values))
|
return CountersDescription(counters=len(counter_store.values))
|
||||||
|
|
Loading…
Reference in a new issue