取消AUTH_DISABLED参数
This commit is contained in:
@@ -14,8 +14,6 @@ oauth2_optional = OAuth2PasswordBearer(
|
||||
async def get_current_keycloak_sub(
|
||||
token: str | None = Depends(oauth2_optional),
|
||||
) -> UUID:
|
||||
if settings.AUTH_DISABLED:
|
||||
return UUID(int=0)
|
||||
if not token:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
|
||||
@@ -20,8 +20,6 @@ async def get_current_metadata_user(
|
||||
keycloak_sub: UUID = Depends(get_current_keycloak_sub),
|
||||
metadata_repo: MetadataRepository = Depends(get_metadata_repository),
|
||||
):
|
||||
if settings.AUTH_DISABLED:
|
||||
return _AuthBypassUser()
|
||||
user = await metadata_repo.get_user_by_keycloak_id(keycloak_sub)
|
||||
if not user or not user.is_active:
|
||||
raise HTTPException(
|
||||
@@ -33,8 +31,6 @@ async def get_current_metadata_user(
|
||||
async def get_current_metadata_admin(
|
||||
user=Depends(get_current_metadata_user),
|
||||
):
|
||||
if settings.AUTH_DISABLED:
|
||||
return user
|
||||
if user.is_superuser or user.role == "admin":
|
||||
return user
|
||||
raise HTTPException(
|
||||
|
||||
@@ -53,13 +53,6 @@ async def get_project_context(
|
||||
status_code=status.HTTP_403_FORBIDDEN, detail="Project is not active"
|
||||
)
|
||||
|
||||
if settings.AUTH_DISABLED:
|
||||
return ProjectContext(
|
||||
project_id=project.id,
|
||||
user_id=UUID(int=0),
|
||||
project_role="owner",
|
||||
)
|
||||
|
||||
user = await metadata_repo.get_user_by_keycloak_id(keycloak_sub)
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user