mirror of
https://github.com/langgenius/dify.git
synced 2026-11-10 21:35:45 +08:00
chore(api): remove unnecessary str calls in openapi controllers (#42931)
This commit is contained in:
1 parent
2062d5e892
commit
174a908786
3 files changed
+7
-7
No files matched your search
@@ -106,7 +106,7 @@ def _fetch_workspace(ctx: Context) -> Tenant:
|
||||
|
||||
def _workspace_from_app(ctx: Context) -> Tenant:
|
||||
app = load_app(ctx)
|
||||
tenant = TenantService.get_tenant_by_id(str(app.tenant_id), session=ctx.session)
|
||||
tenant = TenantService.get_tenant_by_id(app.tenant_id, session=ctx.session)
|
||||
if tenant is None or tenant.status == TenantStatus.ARCHIVE:
|
||||
raise Forbidden("workspace unavailable")
|
||||
return tenant
|
||||
@@ -131,7 +131,7 @@ def _fetch_workspace_role(ctx: Context) -> TenantAccountRole:
|
||||
caller = load_caller(ctx)
|
||||
if not isinstance(caller, Account) or caller.status != AccountStatus.ACTIVE:
|
||||
raise NotFound("workspace not found")
|
||||
role = TenantService.get_account_role_in_tenant(str(ctx.subject.account_id), str(workspace.id), session=ctx.session)
|
||||
role = TenantService.get_account_role_in_tenant(str(ctx.subject.account_id), workspace.id, session=ctx.session)
|
||||
if role is None:
|
||||
raise NotFound("workspace not found")
|
||||
return role
|
||||
@@ -134,7 +134,7 @@ class CheckRBACPermission(Requirement):
|
||||
if not dify_config.RBAC_ENABLED:
|
||||
return
|
||||
enforce_rbac_checks(
|
||||
tenant_id=str(load_workspace(ctx).id),
|
||||
tenant_id=load_workspace(ctx).id,
|
||||
account_id=str(subject.account_id),
|
||||
checks=self.checks,
|
||||
path_args=dict(ctx.view_args),
|
||||
@@ -170,7 +170,7 @@ class CheckAppAccess(Requirement):
|
||||
def run(self, subject: Subject, ctx: Context, session: Session) -> None:
|
||||
if dify_config.DEPLOYMENT_EDITION != DeploymentEdition.ENTERPRISE:
|
||||
return
|
||||
access_mode = self._access_mode(str(load_app(ctx).id))
|
||||
access_mode = self._access_mode(load_app(ctx).id)
|
||||
if SystemFeatureService.get_public_system_features().webapp_auth.enabled:
|
||||
self._assert_mode_allowed(subject, access_mode)
|
||||
if access_mode == WebAppAccessMode.PRIVATE:
|
||||
|
||||
@@ -126,8 +126,8 @@ class ExternalSsoSubject(Subject):
|
||||
raise Unauthorized("missing context for external user resolution")
|
||||
return application_services().app_scoped_end_users.commands.get_or_create_end_user_by_type(
|
||||
EndUserType.OPENAPI,
|
||||
tenant_id=str(load_workspace(ctx).id),
|
||||
app_id=str(load_app(ctx).id),
|
||||
tenant_id=load_workspace(ctx).id,
|
||||
app_id=load_app(ctx).id,
|
||||
user_id=identity.email,
|
||||
)
|
||||
|
||||
@@ -144,7 +144,7 @@ class ExternalSsoSubject(Subject):
|
||||
if identity is None:
|
||||
return None
|
||||
account = AccountService.get_account_by_email(identity.email, session=session)
|
||||
return str(account.id) if account is not None else None
|
||||
return account.id if account is not None else None
|
||||
|
||||
|
||||
def subject_from_auth(auth: AuthContext) -> Subject:
|
||||
|
||||
Reference in new issue
Block a user