FastAPI - Authentication and Security
What will be the output if a user with roles ['user', 'admin'] accesses this FastAPI endpoint?
async def admin_only(user: User = Depends(get_current_user)):
if 'admin' not in user.roles:
raise HTTPException(status_code=403)
@app.get('/admin')
async def admin_panel(dep=Depends(admin_only)):
return {'status': 'Access granted'}