]> git.ipfire.org Git - pbs.git/commitdiff
API: auth: Add an endpoint for the currently logged in user
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 20 Jun 2025 11:38:48 +0000 (11:38 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 20 Jun 2025 11:38:48 +0000 (11:38 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/api/auth.py

index 7cfce981dab07d7338ed9a497df140a5f1b9c359..0293ff7c5d5379fa49f23fd94ae4ab70c37837f3 100644 (file)
@@ -209,5 +209,9 @@ async def auth_refresh(request: fastapi.Request, data: typing.Optional[RefreshRe
        # Send the response
        return AuthResponse(access_token=access_token, refresh_token=refresh_token)
 
+@router.get("/whoami")
+async def whoami(current_principal = fastapi.Depends(get_current_principal)) -> users.User:
+       return current_principal
+
 # Add everything to the app
 apiv1.include_router(router)