refactor: streamline logging and permission checks in auths.py (#22960)

This commit is contained in:
Jacob Leksan
2026-03-25 16:34:45 -05:00
committed by GitHub
parent abe42eaf09
commit 05252e19b5
+3 -2
View File
@@ -1155,8 +1155,9 @@ async def update_ldap_config(request: Request, form_data: LdapConfigForm, user=D
# create api key
@router.post('/api_key', response_model=ApiKey)
async def generate_api_key(request: Request, user=Depends(get_current_user), db: Session = Depends(get_session)):
if not request.app.state.config.ENABLE_API_KEYS or not has_permission(
user.id, 'features.api_keys', request.app.state.config.USER_PERMISSIONS
if not request.app.state.config.ENABLE_API_KEYS or (
user.role != 'admin'
and not has_permission(user.id, 'features.api_keys', request.app.state.config.USER_PERMISSIONS)
):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,