Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions backend/account_v2/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class UserSessionInfo:
role: str
provider: str
is_staff: bool = False
disable_sso_idp_authorization: bool = False
Comment thread
johnyrahul marked this conversation as resolved.
Comment thread
johnyrahul marked this conversation as resolved.

@staticmethod
def from_dict(data: dict[str, Any]) -> "UserSessionInfo":
Expand All @@ -73,6 +74,9 @@ def from_dict(data: dict[str, Any]) -> "UserSessionInfo":
role=data["role"],
provider=data["provider"],
is_staff=data.get("is_staff", False),
disable_sso_idp_authorization=data.get(
"disable_sso_idp_authorization", False
Comment thread
johnyrahul marked this conversation as resolved.
),
)

def to_dict(self) -> Any:
Expand All @@ -83,6 +87,7 @@ def to_dict(self) -> Any:
"organization_id": self.organization_id,
"role": self.role,
"is_staff": self.is_staff,
"disable_sso_idp_authorization": self.disable_sso_idp_authorization,
Comment thread
johnyrahul marked this conversation as resolved.
}


Expand Down
1 change: 1 addition & 0 deletions backend/account_v2/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ class UserSessionResponseSerializer(serializers.Serializer):
role = serializers.CharField()
provider = serializers.CharField()
is_staff = serializers.BooleanField()
disable_sso_idp_authorization = serializers.BooleanField()
Comment thread
johnyrahul marked this conversation as resolved.
2 changes: 2 additions & 0 deletions backend/account_v2/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from typing import Any

from django.conf import settings
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.request import Request
Expand Down Expand Up @@ -151,6 +152,7 @@ def make_session_response(
role=UserSessionUtils.get_organization_member_role(request),
provider=provider,
is_staff=request.user.is_staff,
disable_sso_idp_authorization=settings.DISABLE_SSO_IDP_AUTHORIZATION,
Comment thread
johnyrahul marked this conversation as resolved.
)
).data

Expand Down
4 changes: 4 additions & 0 deletions backend/backend/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ def filter(self, record):
TENANT_SUBFOLDER_PREFIX = f"{PATH_PREFIX}/unstract"
SHOW_PUBLIC_IF_NO_TENANT_FOUND = True

DISABLE_SSO_IDP_AUTHORIZATION = (
os.environ.get("DISABLE_SSO_IDP_AUTHORIZATION", "False").strip().lower() == "true"
)

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
Expand Down
92 changes: 49 additions & 43 deletions frontend/src/components/settings/users/Users.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,46 +96,51 @@ function Users() {
}
};

const actionItems = [
{
key: "1",
label: (
<Space
direction="horizontal"
className="action-items"
onClick={() =>
navigate(`/${sessionDetails?.orgName}/users/edit`, {
state: selectedUserEmail,
})
}
>
<div>
<EditOutlined />
</div>
<div>
<Typography.Text>Edit</Typography.Text>
</div>
</Space>
),
},
{
key: "2",
label: (
<Space
direction="horizontal"
className="action-items"
onClick={showModal}
>
<div>
<DeleteOutlined />
</div>
<div>
<Typography.Text>Delete</Typography.Text>
</div>
</Space>
),
},
];
const isSsoLocalAuthz =
!!sessionDetails?.provider && !!sessionDetails?.disableSsoIdpAuthorization;
Comment thread
johnyrahul marked this conversation as resolved.
Comment thread
johnyrahul marked this conversation as resolved.

const editItem = {
key: "1",
label: (
<Space
direction="horizontal"
className="action-items"
onClick={() =>
navigate(`/${sessionDetails?.orgName}/users/edit`, {
state: selectedUserEmail,
Comment thread
johnyrahul marked this conversation as resolved.
})
}
>
<div>
<EditOutlined />
</div>
<div>
<Typography.Text>Edit</Typography.Text>
</div>
</Space>
),
};

const deleteItem = {
key: "2",
label: (
<Space
direction="horizontal"
className="action-items"
onClick={showModal}
>
<div>
<DeleteOutlined />
</div>
<div>
<Typography.Text>Delete</Typography.Text>
</div>
</Space>
),
};

const actionItems = isSsoLocalAuthz ? [editItem] : [editItem, deleteItem];
Comment thread
johnyrahul marked this conversation as resolved.
Comment thread
johnyrahul marked this conversation as resolved.
Comment thread
johnyrahul marked this conversation as resolved.

const baseColumns = [
{
title: "Email",
Expand Down Expand Up @@ -165,9 +170,10 @@ function Users() {
),
};

const columns = !sessionDetails?.provider
? [...baseColumns, actionColumn]
: baseColumns;
const columns =
!sessionDetails?.provider || isSsoLocalAuthz
Comment thread
johnyrahul marked this conversation as resolved.
Comment thread
johnyrahul marked this conversation as resolved.
? [...baseColumns, actionColumn]
: baseColumns;

const handleInviteUsers = () => {
navigate(`/${sessionDetails?.orgName}/users/invite`);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/helpers/GetSessionData.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function getSessionData(sessionData) {
role: sessionData?.role,
provider: sessionData?.provider,
isStaff: sessionData?.is_staff,
disableSsoIdpAuthorization: sessionData?.disable_sso_idp_authorization,
Comment thread
johnyrahul marked this conversation as resolved.
};
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/hooks/useSessionValid.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ function useSessionValid() {
}
userAndOrgDetails["role"] = userSessionData.role;
userAndOrgDetails["provider"] = userSessionData.provider;
userAndOrgDetails["disable_sso_idp_authorization"] =
Comment thread
johnyrahul marked this conversation as resolved.
userSessionData.disable_sso_idp_authorization;
Comment thread
johnyrahul marked this conversation as resolved.
} catch (err) {
// TODO: Throw popup error message
// REVIEW: Add condition to check for trial period status
Expand Down