Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore: remove saml_relay_state and scim_slug backfill ops (#81790)

Reece Jones3c57b1422f31
diff --git a/ee/api/scim/test/test_groups_api.py b/ee/api/scim/test/test_groups_api.py
index 76095c6f58ff..97cbbc2da55c 100644
--- a/ee/api/scim/test/test_groups_api.py
+++ b/ee/api/scim/test/test_groups_api.py
@@ -49,7 +49,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
self.client.credentials(**self.scim_headers)
def test_groups_list(self):
- response = self.client.get(f"/scim/v2/{self.domain.id}/Groups")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Groups")
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -63,7 +63,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
# Filter for exact match on displayName
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Groups",
+ f"/scim/v2/{self.config.scim_slug}/Groups",
{"filter": 'displayName eq "Engineering"'},
)
@@ -80,7 +80,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
# Filter for role from other org should return nothing
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Groups",
+ f"/scim/v2/{self.config.scim_slug}/Groups",
{"filter": 'displayName eq "Engineering"'},
)
@@ -94,7 +94,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
# Filter for non-existent group
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Groups",
+ f"/scim/v2/{self.config.scim_slug}/Groups",
{"filter": 'displayName eq "NonExistent"'},
)
@@ -112,7 +112,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Groups", data=group_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups", data=group_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_201_CREATED
@@ -141,7 +141,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Groups", data=group_data_first, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups", data=group_data_first, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_201_CREATED
@@ -156,7 +156,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Groups", data=group_data_second, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups", data=group_data_second, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_201_CREATED
@@ -184,7 +184,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -201,7 +201,9 @@ class TestSCIMGroupsAPI(APILicensedTest):
fake_group_id = str(uuid.uuid4())
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Groups/{fake_group_id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{fake_group_id}",
+ data=put_data,
+ content_type="application/scim+json",
)
assert response.status_code == status.HTTP_404_NOT_FOUND, (
@@ -217,7 +219,9 @@ class TestSCIMGroupsAPI(APILicensedTest):
fake_group_id = str(uuid.uuid4())
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{fake_group_id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{fake_group_id}",
+ data=patch_data,
+ content_type="application/scim+json",
)
assert response.status_code == status.HTTP_404_NOT_FOUND, (
@@ -242,7 +246,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -259,7 +263,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -282,7 +286,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -317,7 +321,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
@@ -340,7 +344,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -357,7 +361,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -392,7 +396,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -421,7 +425,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -449,7 +453,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
"Operations": [op],
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}",
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}",
data=patch_data,
content_type="application/scim+json",
)
@@ -469,7 +473,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
@@ -497,7 +501,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -540,7 +544,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -569,7 +573,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -607,7 +611,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -635,7 +639,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -660,7 +664,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -688,7 +692,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -723,7 +727,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -765,7 +769,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -784,7 +788,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
}
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Groups/{role.id}", data=put_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -798,7 +802,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
def test_groups_list_pagination_with_count(self):
self._create_groups(5)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Groups", {"count": "2"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Groups", {"count": "2"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -810,7 +814,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
def test_groups_list_pagination_with_start_index(self):
self._create_groups(5)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Groups", {"startIndex": "3", "count": "2"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Groups", {"startIndex": "3", "count": "2"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -822,7 +826,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
def test_groups_list_pagination_count_zero(self):
self._create_groups(3)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Groups", {"count": "0"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Groups", {"count": "0"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -833,7 +837,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
def test_groups_list_pagination_start_index_beyond_total(self):
self._create_groups(2)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Groups", {"startIndex": "999"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Groups", {"startIndex": "999"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -843,7 +847,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
assert data["startIndex"] == 999
def test_groups_list_pagination_count_capped_at_max(self):
- response = self.client.get(f"/scim/v2/{self.domain.id}/Groups", {"count": "500"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Groups", {"count": "500"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -859,14 +863,14 @@ class TestSCIMGroupsAPI(APILicensedTest):
]
)
def test_groups_list_pagination_invalid_values(self, _name: str, params: dict, expected_status: int):
- response = self.client.get(f"/scim/v2/{self.domain.id}/Groups", params)
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Groups", params)
assert response.status_code == expected_status
def test_groups_list_pagination_with_filter(self):
self._create_groups(3)
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Groups",
+ f"/scim/v2/{self.config.scim_slug}/Groups",
{"filter": 'displayName eq "PagGroup0"', "count": "1"},
)
@@ -885,7 +889,7 @@ class TestSCIMGroupsAPI(APILicensedTest):
page_size = 2
while True:
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Groups",
+ f"/scim/v2/{self.config.scim_slug}/Groups",
{"startIndex": str(start_index), "count": str(page_size)},
)
assert response.status_code == status.HTTP_200_OK
diff --git a/ee/api/scim/test/test_scim_api.py b/ee/api/scim/test/test_scim_api.py
index 800be6162471..ceeaa2b18969 100644
--- a/ee/api/scim/test/test_scim_api.py
+++ b/ee/api/scim/test/test_scim_api.py
@@ -85,7 +85,7 @@ class TestSCIMAPI(APILicensedTest):
def test_invalid_token(self):
self.client.credentials(HTTP_AUTHORIZATION="Bearer invalid_token")
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users")
assert response.status_code == status.HTTP_403_FORBIDDEN
data = response.json()
assert "schemas" in data
@@ -128,7 +128,7 @@ class TestSCIMAPI(APILicensedTest):
assert response.status_code == status.HTTP_403_FORBIDDEN
def test_no_token(self):
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users")
assert response.status_code == status.HTTP_401_UNAUTHORIZED
data = response.json()
assert "schemas" in data
@@ -138,7 +138,7 @@ class TestSCIMAPI(APILicensedTest):
def test_malformed_auth_header(self):
self.client.credentials(HTTP_AUTHORIZATION="Basic invalid_token")
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users")
assert response.status_code == status.HTTP_401_UNAUTHORIZED
data = response.json()
assert "schemas" in data
@@ -158,7 +158,7 @@ class TestSCIMAPI(APILicensedTest):
def test_service_provider_config(self):
self.client.credentials(**self.scim_headers)
- response = self.client.get(f"/scim/v2/{self.domain.id}/ServiceProviderConfig")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/ServiceProviderConfig")
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -172,7 +172,7 @@ class TestSCIMAPI(APILicensedTest):
self.organization.save()
self.client.credentials(**self.scim_headers)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users")
assert response.status_code == status.HTTP_403_FORBIDDEN
data = response.json()
assert "schemas" in data
@@ -183,14 +183,14 @@ class TestSCIMAPI(APILicensedTest):
def test_scim_users_endpoint(self):
"""Test that SCIM Users endpoint works with valid license"""
self.client.credentials(**self.scim_headers)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users")
assert response.status_code == status.HTTP_200_OK
assert "Resources" in response.json()
def test_scim_groups_endpoint(self):
"""Test that SCIM Groups endpoint works with valid license"""
self.client.credentials(**self.scim_headers)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Groups")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Groups")
assert response.status_code == status.HTTP_200_OK
assert "Resources" in response.json()
@@ -213,7 +213,7 @@ class TestSCIMAPI(APILicensedTest):
other_user = self._create_user_in_other_org()
self.client.credentials(**self.scim_headers)
- url = f"/scim/v2/{self.domain.id}/Users/{other_user.id}"
+ url = f"/scim/v2/{self.config.scim_slug}/Users/{other_user.id}"
if method == "get":
response = self.client.get(url)
@@ -261,7 +261,7 @@ class TestSCIMAPI(APILicensedTest):
other_role = self._create_group_in_other_org()
self.client.credentials(**self.scim_headers)
- url = f"/scim/v2/{self.domain.id}/Groups/{other_role.id}"
+ url = f"/scim/v2/{self.config.scim_slug}/Groups/{other_role.id}"
if method == "get":
response = self.client.get(url)
@@ -410,7 +410,7 @@ class TestSCIMEmailDomainValidation(APILicensedTest):
)
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
self._scim_user_data("[email protected]"),
format="json",
)
@@ -418,7 +418,7 @@ class TestSCIMEmailDomainValidation(APILicensedTest):
user_id = response.json()["id"]
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Users/{user_id}",
+ f"/scim/v2/{self.config.scim_slug}/Users/{user_id}",
self._scim_user_data("[email protected]"),
format="json",
)
@@ -438,7 +438,7 @@ class TestSCIMEmailDomainValidation(APILicensedTest):
self.client.credentials(**self.scim_headers)
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
self._scim_user_data("[email protected]"),
format="json",
)
@@ -454,13 +454,13 @@ class TestSCIMEmailDomainValidation(APILicensedTest):
def _change_email(self, method: str, user_id: str, new_email: str):
if method == "put":
return self.client.put(
- f"/scim/v2/{self.domain.id}/Users/{user_id}",
+ f"/scim/v2/{self.config.scim_slug}/Users/{user_id}",
self._scim_user_data(new_email),
format="json",
)
elif method == "patch_replace":
return self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user_id}",
+ f"/scim/v2/{self.config.scim_slug}/Users/{user_id}",
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
"Operations": [{"op": "replace", "path": "emails", "value": [{"value": new_email}]}],
@@ -469,7 +469,7 @@ class TestSCIMEmailDomainValidation(APILicensedTest):
)
elif method == "patch_add":
return self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user_id}",
+ f"/scim/v2/{self.config.scim_slug}/Users/{user_id}",
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
"Operations": [{"op": "add", "path": "emails", "value": [{"value": new_email}]}],
@@ -517,7 +517,7 @@ class TestSCIMEmailDomainValidation(APILicensedTest):
)
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
self._scim_user_data("[email protected]"),
format="json",
)
@@ -525,7 +525,7 @@ class TestSCIMEmailDomainValidation(APILicensedTest):
user_id = response.json()["id"]
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Users/{user_id}",
+ f"/scim/v2/{self.config.scim_slug}/Users/{user_id}",
self._scim_user_data("[email protected]"),
format="json",
)
@@ -577,7 +577,7 @@ class TestSCIMAuditLogging(APILicensedTest):
def _create_scim_user(self, email: str = "[email protected]") -> str:
self.client.credentials(**self.scim_headers)
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
self._scim_user_data(email),
format="json",
)
@@ -605,13 +605,13 @@ class TestSCIMAuditLogging(APILicensedTest):
pass
elif method == "put":
self.client.put(
- f"/scim/v2/{self.domain.id}/Users/{user_id}",
+ f"/scim/v2/{self.config.scim_slug}/Users/{user_id}",
self._scim_user_data("[email protected]", "Updated", "Name"),
format="json",
)
elif method == "patch":
self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user_id}",
+ f"/scim/v2/{self.config.scim_slug}/Users/{user_id}",
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
"Operations": [{"op": "replace", "path": "name", "value": {"givenName": "Patched"}}],
@@ -619,7 +619,7 @@ class TestSCIMAuditLogging(APILicensedTest):
format="json",
)
elif method == "delete":
- self.client.delete(f"/scim/v2/{self.domain.id}/Users/{user_id}")
+ self.client.delete(f"/scim/v2/{self.config.scim_slug}/Users/{user_id}")
log = ActivityLog.objects.filter(
scope="User",
@@ -673,7 +673,7 @@ class TestSCIMGroupAuditLogging(APILicensedTest):
def _create_scim_group(self, name: str = "Engineering") -> str:
self.client.credentials(**self.scim_headers)
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Groups",
+ f"/scim/v2/{self.config.scim_slug}/Groups",
self._scim_group_data(name),
format="json",
)
@@ -699,13 +699,13 @@ class TestSCIMGroupAuditLogging(APILicensedTest):
pass
elif method == "put":
self.client.put(
- f"/scim/v2/{self.domain.id}/Groups/{group_id}",
+ f"/scim/v2/{self.config.scim_slug}/Groups/{group_id}",
self._scim_group_data("Updated Engineering"),
format="json",
)
elif method == "patch":
self.client.patch(
- f"/scim/v2/{self.domain.id}/Groups/{group_id}",
+ f"/scim/v2/{self.config.scim_slug}/Groups/{group_id}",
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
"Operations": [{"op": "replace", "path": "displayName", "value": "Patched Engineering"}],
@@ -713,7 +713,7 @@ class TestSCIMGroupAuditLogging(APILicensedTest):
format="json",
)
elif method == "delete":
- self.client.delete(f"/scim/v2/{self.domain.id}/Groups/{group_id}")
+ self.client.delete(f"/scim/v2/{self.config.scim_slug}/Groups/{group_id}")
log = ActivityLog.objects.filter(
scope="Role",
diff --git a/ee/api/scim/test/test_scim_legacy_records.py b/ee/api/scim/test/test_scim_legacy_records.py
index c04d3eea04b8..0d4ed993b62e 100644
--- a/ee/api/scim/test/test_scim_legacy_records.py
+++ b/ee/api/scim/test/test_scim_legacy_records.py
@@ -54,8 +54,8 @@ class TestSCIMRecordsWrittenBeforeConfigs(APILicensedTest):
self.legacy_record = self._provision_keyed_on_domain(self.provisioned, "already.okta.username", self.domain)
backfill_scim_provisioned_user_config(apps, SimpleNamespace(connection=connection))
- # The IdP keeps calling the URL it was configured with, which is the domain's id.
- self.scim_url = f"/scim/v2/{self.domain.id}"
+ assert self.config.scim_slug != self.domain.id
+ self.scim_url = f"/scim/v2/{self.config.scim_slug}"
self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {token.plain}")
def _provision_keyed_on_domain(self, user: User, username: str, domain: OrganizationDomain) -> SCIMProvisionedUser:
@@ -67,8 +67,7 @@ class TestSCIMRecordsWrittenBeforeConfigs(APILicensedTest):
active=True,
)
- def test_the_url_the_idp_was_configured_with_still_authenticates(self):
- assert self.config.scim_slug == str(self.domain.id)
+ def test_the_config_url_authenticates(self):
assert self.client.get(f"{self.scim_url}/Users").status_code == status.HTTP_200_OK
def test_record_keeps_its_username(self):
@@ -179,15 +178,13 @@ class TestSCIMRecordsWrittenBeforeConfigs(APILicensedTest):
organization=self.organization,
scim_enabled=True,
scim_bearer_token=second_token.hashed,
- scim_slug="second-config-slug",
- saml_relay_state="second-config-relay",
)
self.domain.identity_provider_config = second_config
self.domain.save()
self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {second_token.plain}")
- read = self.client.get(f"/scim/v2/second-config-slug/Users/{self.provisioned.id}")
- deprovision = self.client.delete(f"/scim/v2/second-config-slug/Users/{self.provisioned.id}")
+ read = self.client.get(f"/scim/v2/{second_config.scim_slug}/Users/{self.provisioned.id}")
+ deprovision = self.client.delete(f"/scim/v2/{second_config.scim_slug}/Users/{self.provisioned.id}")
assert read.json()["userName"] == "[email protected]" # its own view of the user, not the other config's
assert deprovision.status_code == status.HTTP_204_NO_CONTENT
diff --git a/ee/api/scim/test/test_scim_request_log.py b/ee/api/scim/test/test_scim_request_log.py
index 4b2b45c24c06..2fe035daab12 100644
--- a/ee/api/scim/test/test_scim_request_log.py
+++ b/ee/api/scim/test/test_scim_request_log.py
@@ -47,7 +47,7 @@ class TestSCIMRequestLogCapture(APILicensedTest):
def test_get_request_creates_log(self):
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Users", headers={"authorization": f"Bearer {self.plain_token}"}
+ f"/scim/v2/{self.config.scim_slug}/Users", headers={"authorization": f"Bearer {self.plain_token}"}
)
assert response.status_code == status.HTTP_200_OK
@@ -57,14 +57,14 @@ class TestSCIMRequestLogCapture(APILicensedTest):
log = logs.first()
assert log is not None
assert log.request_method == "GET"
- assert f"/scim/v2/{self.domain.id}/Users" in log.request_path
+ assert f"/scim/v2/{self.config.scim_slug}/Users" in log.request_path
assert log.response_status == 200
assert log.duration_ms is not None
assert log.duration_ms >= 0
def test_post_request_logs_masked_body(self):
self.client.post(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
data={
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName": "testuser",
@@ -82,7 +82,9 @@ class TestSCIMRequestLogCapture(APILicensedTest):
assert "[email protected]" not in str(log.request_body)
def test_authorization_header_is_fully_masked(self):
- self.client.get(f"/scim/v2/{self.domain.id}/Users", headers={"authorization": f"Bearer {self.plain_token}"})
+ self.client.get(
+ f"/scim/v2/{self.config.scim_slug}/Users", headers={"authorization": f"Bearer {self.plain_token}"}
+ )
log = SCIMRequestLog.objects.filter(identity_provider_config=self.config).first()
assert log is not None
auth_header = log.request_headers.get("Authorization", "")
@@ -91,7 +93,8 @@ class TestSCIMRequestLogCapture(APILicensedTest):
def test_response_body_stored(self):
self.client.get(
- f"/scim/v2/{self.domain.id}/ServiceProviderConfig", headers={"authorization": f"Bearer {self.plain_token}"}
+ f"/scim/v2/{self.config.scim_slug}/ServiceProviderConfig",
+ headers={"authorization": f"Bearer {self.plain_token}"},
)
log = SCIMRequestLog.objects.filter(identity_provider_config=self.config).first()
assert log is not None
@@ -99,7 +102,9 @@ class TestSCIMRequestLogCapture(APILicensedTest):
assert "schemas" in log.response_body
def test_duration_is_tracked(self):
- self.client.get(f"/scim/v2/{self.domain.id}/Users", headers={"authorization": f"Bearer {self.plain_token}"})
+ self.client.get(
+ f"/scim/v2/{self.config.scim_slug}/Users", headers={"authorization": f"Bearer {self.plain_token}"}
+ )
log = SCIMRequestLog.objects.filter(identity_provider_config=self.config).first()
assert log is not None
assert log.duration_ms is not None
diff --git a/ee/api/scim/test/test_users_api.py b/ee/api/scim/test/test_users_api.py
index 1e3fc084b1d4..380ff1ddf332 100644
--- a/ee/api/scim/test/test_users_api.py
+++ b/ee/api/scim/test/test_users_api.py
@@ -47,7 +47,7 @@ class TestSCIMUsersAPI(APILicensedTest):
self.client.credentials(**self.scim_headers)
def test_users_list(self):
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users")
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -89,7 +89,7 @@ class TestSCIMUsersAPI(APILicensedTest):
# Exact match should return only [email protected]
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
{"filter": 'userName eq "[email protected]"'},
)
@@ -115,7 +115,7 @@ class TestSCIMUsersAPI(APILicensedTest):
# Filter for user from other org should return nothing
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
{"filter": 'userName eq "[email protected]"'},
)
@@ -126,7 +126,7 @@ class TestSCIMUsersAPI(APILicensedTest):
def test_users_list_filter_no_match_returns_empty_list(self):
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
{"filter": 'userName eq "[email protected]"'},
)
@@ -139,7 +139,7 @@ class TestSCIMUsersAPI(APILicensedTest):
def test_users_list_filter_unrecognized_returns_empty_list(self):
# Unsupported filter should not return all users; return empty set
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
{"filter": 'name.givenName sw "Eng"'},
)
@@ -159,7 +159,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Users", data=user_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users", data=user_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_201_CREATED
@@ -204,7 +204,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Users", data=user_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users", data=user_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_201_CREATED
@@ -227,7 +227,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Users", data=user_data_first, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users", data=user_data_first, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_201_CREATED
@@ -243,7 +243,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Users", data=user_data_second, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users", data=user_data_second, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_409_CONFLICT
@@ -272,7 +272,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
assert (
self.client.post(
- f"/scim/v2/{self.domain.id}/Users", data=user_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users", data=user_data, content_type="application/scim+json"
).status_code
== status.HTTP_201_CREATED
)
@@ -285,7 +285,7 @@ class TestSCIMUsersAPI(APILicensedTest):
)
response = self.client.post(
- f"/scim/v2/{self.domain.id}/Users", data=user_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users", data=user_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_409_CONFLICT
@@ -307,7 +307,7 @@ class TestSCIMUsersAPI(APILicensedTest):
organization_member=OrganizationMembership.objects.get(user=user, organization=self.organization),
)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users/{user.id}")
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users/{user.id}")
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -340,7 +340,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -372,7 +372,7 @@ class TestSCIMUsersAPI(APILicensedTest):
active=True,
)
- response = self.client.delete(f"/scim/v2/{self.domain.id}/Users/{user.id}")
+ response = self.client.delete(f"/scim/v2/{self.config.scim_slug}/Users/{user.id}")
assert response.status_code == status.HTTP_204_NO_CONTENT
@@ -407,7 +407,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=put_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -454,7 +454,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=put_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -474,7 +474,9 @@ class TestSCIMUsersAPI(APILicensedTest):
fake_user_id = 999999999
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Users/{fake_user_id}", data=put_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{fake_user_id}",
+ data=put_data,
+ content_type="application/scim+json",
)
assert response.status_code == status.HTTP_404_NOT_FOUND, (
@@ -509,7 +511,9 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.put(
- f"/scim/v2/{self.domain.id}/Users/{user_b.id}", data=put_data_conflict, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user_b.id}",
+ data=put_data_conflict,
+ content_type="application/scim+json",
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
@@ -523,7 +527,9 @@ class TestSCIMUsersAPI(APILicensedTest):
fake_user_id = 999999999
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{fake_user_id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{fake_user_id}",
+ data=patch_data,
+ content_type="application/scim+json",
)
assert response.status_code == status.HTTP_404_NOT_FOUND, (
@@ -552,7 +558,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -577,7 +583,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -605,7 +611,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -626,7 +632,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -650,7 +656,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -684,7 +690,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -708,7 +714,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -735,7 +741,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -767,7 +773,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -790,7 +796,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -812,7 +818,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -837,7 +843,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -859,7 +865,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_200_OK
@@ -881,7 +887,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
@@ -902,7 +908,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
@@ -929,7 +935,7 @@ class TestSCIMUsersAPI(APILicensedTest):
def test_users_list_pagination_with_count(self):
self._create_users(5)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users", {"count": "2"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users", {"count": "2"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -941,7 +947,7 @@ class TestSCIMUsersAPI(APILicensedTest):
def test_users_list_pagination_with_start_index(self):
self._create_users(5)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users", {"startIndex": "3", "count": "2"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users", {"startIndex": "3", "count": "2"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -953,7 +959,7 @@ class TestSCIMUsersAPI(APILicensedTest):
def test_users_list_pagination_count_zero(self):
self._create_users(3)
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users", {"count": "0"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users", {"count": "0"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -962,7 +968,7 @@ class TestSCIMUsersAPI(APILicensedTest):
assert data["Resources"] == []
def test_users_list_pagination_start_index_beyond_total(self):
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users", {"startIndex": "999"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users", {"startIndex": "999"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -972,7 +978,7 @@ class TestSCIMUsersAPI(APILicensedTest):
assert data["startIndex"] == 999
def test_users_list_pagination_count_capped_at_max(self):
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users", {"count": "500"})
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users", {"count": "500"})
assert response.status_code == status.HTTP_200_OK
data = response.json()
@@ -988,7 +994,7 @@ class TestSCIMUsersAPI(APILicensedTest):
]
)
def test_users_list_pagination_invalid_values(self, _name: str, params: dict, expected_status: int):
- response = self.client.get(f"/scim/v2/{self.domain.id}/Users", params)
+ response = self.client.get(f"/scim/v2/{self.config.scim_slug}/Users", params)
assert response.status_code == expected_status
def test_users_list_pagination_with_filter(self):
@@ -1003,7 +1009,7 @@ class TestSCIMUsersAPI(APILicensedTest):
)
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
{"filter": 'userName eq "[email protected]"', "count": "1"},
)
@@ -1022,7 +1028,7 @@ class TestSCIMUsersAPI(APILicensedTest):
page_size = 2
while True:
response = self.client.get(
- f"/scim/v2/{self.domain.id}/Users",
+ f"/scim/v2/{self.config.scim_slug}/Users",
{"startIndex": str(start_index), "count": str(page_size)},
)
assert response.status_code == status.HTTP_200_OK
@@ -1065,7 +1071,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
@@ -1107,7 +1113,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{user_b.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{user_b.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
@@ -1137,7 +1143,7 @@ class TestSCIMUsersAPI(APILicensedTest):
}
response = self.client.patch(
- f"/scim/v2/{self.domain.id}/Users/{owner.id}", data=patch_data, content_type="application/scim+json"
+ f"/scim/v2/{self.config.scim_slug}/Users/{owner.id}", data=patch_data, content_type="application/scim+json"
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
diff --git a/ee/api/test/test_authentication.py b/ee/api/test/test_authentication.py
index 988c6287ebe4..39b5450d246d 100644
--- a/ee/api/test/test_authentication.py
+++ b/ee/api/test/test_authentication.py
@@ -603,12 +603,11 @@ class TestEESAMLAuthenticationAPI(APILicensedTest):
self.assertEqual(idp.name, config.saml_relay_state)
def test_relay_state_minted_before_the_move_to_configs_still_resolves(self):
- # A login redirected while SAML routed on domain ids comes back after the switch to config
- # identifiers. The identifier in flight has to keep resolving or the user lands on an error.
self._grant_saml()
config = self.organization_domain.identity_provider_config
assert config is not None
- config.refresh_from_db()
+ config.saml_relay_state = str(self.organization_domain.id)
+ config.save(update_fields=["saml_relay_state"])
auth = object.__new__(MultitenantSAMLAuth)
idp = auth.get_idp(str(self.organization_domain.id))
@@ -1191,12 +1190,13 @@ YotAcSbU3p5bzd11wpyebYHB"""
)
my_config = self.organization_domain.identity_provider_config
assert my_config is not None
- other_domain.identity_provider_config = IdentityProviderConfig.objects.create(
+ other_config = IdentityProviderConfig.objects.create(
organization=other_org,
saml_entity_id=my_config.saml_entity_id,
saml_acs_url=my_config.saml_acs_url,
saml_x509_cert=my_config.saml_x509_cert,
)
+ other_domain.identity_provider_config = other_config
other_domain.save()
response = self.client.get("/login/saml/[email protected]")
@@ -1216,7 +1216,7 @@ YotAcSbU3p5bzd11wpyebYHB"""
"/complete/saml/",
{
"SAMLResponse": saml_response,
- "RelayState": str(other_domain.id),
+ "RelayState": str(other_config.saml_relay_state),
},
follow=False,
format="multipart",
diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.ts
index 71ce7aca0630..1eff49bda79a 100644
--- a/frontend/src/generated/core/api.schemas.ts
+++ b/frontend/src/generated/core/api.schemas.ts
@@ -225,6 +225,8 @@ export interface IdentityProviderConfigApi {
readonly updated_at: string
/** Whether SAML is fully configured on this config. */
readonly has_saml: boolean
+ /** Stable UUID sent as SAML RelayState to route authentication responses to this IdP configuration. */
+ readonly saml_relay_state: string
/**
* SAML IdP entity ID (issuer).
* @maxLength 512
@@ -292,6 +294,8 @@ export interface PatchedIdentityProviderConfigApi {
readonly updated_at?: string
/** Whether SAML is fully configured on this config. */
readonly has_saml?: boolean
+ /** Stable UUID sent as SAML RelayState to route authentication responses to this IdP configuration. */
+ readonly saml_relay_state?: string
/**
* SAML IdP entity ID (issuer).
* @maxLength 512
diff --git a/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureIdJagModal.tsx b/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureIdJagModal.tsx
index 7da9b76cd738..310950055a41 100644
--- a/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureIdJagModal.tsx
+++ b/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureIdJagModal.tsx
@@ -7,11 +7,13 @@ import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonInput } from 'lib/lemon-ui/LemonInput/LemonInput'
import { LemonInputSelect } from 'lib/lemon-ui/LemonInputSelect/LemonInputSelect'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
+import { Spinner } from 'lib/lemon-ui/Spinner'
import { verifiedDomainsLogic } from './verifiedDomainsLogic'
export function ConfigureIdJagModal(): JSX.Element {
- const { configureIdJagModalId, isIdJagConfigSubmitting, idJagConfig } = useValues(verifiedDomainsLogic)
+ const { configureIdJagModalId, configureIdJagModalLoading, isIdJagConfigSubmitting, idJagConfig } =
+ useValues(verifiedDomainsLogic)
const { setConfigureIdJagModalId } = useActions(verifiedDomainsLogic)
const idJagReady = Boolean(idJagConfig.id_jag_issuer_url)
@@ -27,58 +29,72 @@ export function ConfigureIdJagModal(): JSX.Element {
<h3>Configure XAA (ID-JAG)</h3>
</LemonModal.Header>
<LemonModal.Content className="deprecated-space-y-2">
- <LemonField
- name="id_jag_issuer_url"
- label="IdP issuer URL"
- info="The trusted identity provider issuer URL. Must match the iss claim on ID-JAG tokens for users on this domain."
- >
- <LemonInput
- className="ph-ignore-input"
- placeholder="https://idp.example.com"
- autoComplete="off"
- />
- </LemonField>
- <LemonField
- name="id_jag_jwks_url"
- label="JWKS URL (optional)"
- info="Override JWKS discovery. Leave empty to use OIDC discovery at the issuer URL."
- >
- <LemonInput
- className="ph-ignore-input"
- placeholder="https://idp.example.com/.well-known/jwks.json"
- autoComplete="off"
- />
- </LemonField>
- <LemonField
- name="id_jag_allowed_clients"
- label="Allowed client IDs (optional)"
- info="Restrict which client_id values are accepted. Leave empty to allow any client_id."
- >
- {({ value, onChange }) => (
- <LemonInputSelect
- value={value ?? []}
- onChange={onChange}
- placeholder="Add client IDs..."
- mode="multiple"
- allowCustomValues
- options={[]}
- />
- )}
- </LemonField>
- {!idJagReady && (
- <LemonBanner type="info">
- XAA will not be enabled until you enter an IdP issuer URL. You can save partial settings as
- a draft.
- </LemonBanner>
+ {configureIdJagModalLoading ? (
+ <div className="flex min-h-40 items-center justify-center">
+ <Spinner size="large" captureTime />
+ </div>
+ ) : (
+ <>
+ <LemonField
+ name="id_jag_issuer_url"
+ label="IdP issuer URL"
+ info="The trusted identity provider issuer URL. Must match the iss claim on ID-JAG tokens for users on this domain."
+ >
+ <LemonInput
+ className="ph-ignore-input"
+ placeholder="https://idp.example.com"
+ autoComplete="off"
+ />
+ </LemonField>
+ <LemonField
+ name="id_jag_jwks_url"
+ label="JWKS URL (optional)"
+ info="Override JWKS discovery. Leave empty to use OIDC discovery at the issuer URL."
+ >
+ <LemonInput
+ className="ph-ignore-input"
+ placeholder="https://idp.example.com/.well-known/jwks.json"
+ autoComplete="off"
+ />
+ </LemonField>
+ <LemonField
+ name="id_jag_allowed_clients"
+ label="Allowed client IDs (optional)"
+ info="Restrict which client_id values are accepted. Leave empty to allow any client_id."
+ >
+ {({ value, onChange }) => (
+ <LemonInputSelect
+ value={value ?? []}
+ onChange={onChange}
+ placeholder="Add client IDs..."
+ mode="multiple"
+ allowCustomValues
+ options={[]}
+ />
+ )}
+ </LemonField>
+ {!idJagReady && (
+ <LemonBanner type="info">
+ XAA will not be enabled until you enter an IdP issuer URL. You can save partial
+ settings as a draft.
+ </LemonBanner>
+ )}
+ <LemonBanner type="info">
+ Configure your IdP to grant <code>user:read</code> plus the scopes each integration
+ needs (for project-scoped APIs, also <code>organization:read</code> and{' '}
+ <code>project:read</code>). Tokens issued without the required scopes are rejected with
+ an insufficient-scope error.
+ </LemonBanner>
+ </>
)}
- <LemonBanner type="info">
- Configure your IdP to grant <code>user:read</code> plus the scopes each integration needs (for
- project-scoped APIs, also <code>organization:read</code> and <code>project:read</code>). Tokens
- issued without the required scopes are rejected with an insufficient-scope error.
- </LemonBanner>
</LemonModal.Content>
<LemonModal.Footer>
- <LemonButton loading={isIdJagConfigSubmitting} type="primary" htmlType="submit">
+ <LemonButton
+ loading={isIdJagConfigSubmitting}
+ disabled={configureIdJagModalLoading}
+ type="primary"
+ htmlType="submit"
+ >
Save settings
</LemonButton>
</LemonModal.Footer>
diff --git a/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureSAMLModal.tsx b/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureSAMLModal.tsx
index 13fb0f917341..3cc7b2c16a67 100644
--- a/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureSAMLModal.tsx
+++ b/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureSAMLModal.tsx
@@ -10,12 +10,14 @@ import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonInput } from 'lib/lemon-ui/LemonInput/LemonInput'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
import { LemonTextArea } from 'lib/lemon-ui/LemonTextArea/LemonTextArea'
+import { Spinner } from 'lib/lemon-ui/Spinner'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { verifiedDomainsLogic } from './verifiedDomainsLogic'
export function ConfigureSAMLModal(): JSX.Element {
- const { configureSAMLModalId, isSamlConfigSubmitting, samlConfig } = useValues(verifiedDomainsLogic)
+ const { configureSAMLModalId, configureSAMLModalLoading, isSamlConfigSubmitting, samlConfig } =
+ useValues(verifiedDomainsLogic)
const { setConfigureSAMLModalId } = useActions(verifiedDomainsLogic)
const { preflight } = useValues(preflightLogic)
const siteUrl = preflight?.site_url ?? window.location.origin
@@ -34,42 +36,64 @@ export function ConfigureSAMLModal(): JSX.Element {
<h3>Configure SAML authentication and provisioning</h3>
</LemonModal.Header>
<LemonModal.Content className="deprecated-space-y-2">
- <p>
- <Link to="https://posthog.com/docs/data/sso#setting-up-saml" target="_blank" targetBlankIcon>
- Read the docs
- </Link>
- </p>
- <LemonField label="ACS Consumer URL" name="_ACSConsumerUrl">
- <CopyToClipboardInline>{`${siteUrl}/complete/saml/`}</CopyToClipboardInline>
- </LemonField>
- <LemonField label="RelayState" name="_RelayState">
- <CopyToClipboardInline>{configureSAMLModalId || 'unknown'}</CopyToClipboardInline>
- </LemonField>
- <LemonField label="Audience / Entity ID" name="_Audience">
- <CopyToClipboardInline>{siteUrl}</CopyToClipboardInline>
- </LemonField>
- <LemonField name="saml_acs_url" label="SAML ACS URL">
- <LemonInput className="ph-ignore-input" placeholder="Your IdP's ACS or single sign-on URL." />
- </LemonField>
- <LemonField name="saml_entity_id" label="SAML Entity ID">
- <LemonInput className="ph-ignore-input" placeholder="Entity ID provided by your IdP." />
- </LemonField>
- <LemonField name="saml_x509_cert" label="SAML X.509 Certificate">
- <LemonTextArea
- className="ph-ignore-input"
- minRows={10}
- placeholder={`Enter the public certificate of your IdP. Keep all line breaks.\n-----BEGIN CERTIFICATE-----\nMIICVjCCAb+gAwIBAgIBADANBgkqhkiG9w0BAQ0FADBIMQswCQYDVQQGEwJ1czEL\n-----END CERTIFICATE-----`}
- />
- </LemonField>
- {!samlReady && (
- <LemonBanner type="info">
- SAML will not be enabled unless you enter all attributes above. However you can still
- settings as draft.
- </LemonBanner>
+ {configureSAMLModalLoading ? (
+ <div className="flex min-h-40 items-center justify-center">
+ <Spinner size="large" captureTime />
+ </div>
+ ) : (
+ <>
+ <p>
+ <Link
+ to="https://posthog.com/docs/data/sso#setting-up-saml"
+ target="_blank"
+ targetBlankIcon
+ >
+ Read the docs
+ </Link>
+ </p>
+ <LemonField label="ACS Consumer URL" name="_ACSConsumerUrl">
+ <CopyToClipboardInline>{`${siteUrl}/complete/saml/`}</CopyToClipboardInline>
+ </LemonField>
+ <LemonField label="RelayState" name="_RelayState">
+ <CopyToClipboardInline>
+ {samlConfig.saml_relay_state || 'unknown'}
+ </CopyToClipboardInline>
+ </LemonField>
+ <LemonField label="Audience / Entity ID" name="_Audience">
+ <CopyToClipboardInline>{siteUrl}</CopyToClipboardInline>
+ </LemonField>
+ <LemonField name="saml_acs_url" label="SAML ACS URL">
+ <LemonInput
+ className="ph-ignore-input"
+ placeholder="Your IdP's ACS or single sign-on URL."
+ />
+ </LemonField>
+ <LemonField name="saml_entity_id" label="SAML Entity ID">
+ <LemonInput className="ph-ignore-input" placeholder="Entity ID provided by your IdP." />
+ </LemonField>
+ <LemonField name="saml_x509_cert" label="SAML X.509 Certificate">
+ <LemonTextArea
+ className="ph-ignore-input"
+ minRows={10}
+ placeholder={`Enter the public certificate of your IdP. Keep all line breaks.\n-----BEGIN CERTIFICATE-----\nMIICVjCCAb+gAwIBAgIBADANBgkqhkiG9w0BAQ0FADBIMQswCQYDVQQGEwJ1czEL\n-----END CERTIFICATE-----`}
+ />
+ </LemonField>
+ {!samlReady && (
+ <LemonBanner type="info">
+ SAML will not be enabled unless you enter all attributes above. However you can
+ still settings as draft.
+ </LemonBanner>
+ )}
+ </>
)}
</LemonModal.Content>
<LemonModal.Footer>
- <LemonButton loading={isSamlConfigSubmitting} type="primary" htmlType="submit">
+ <LemonButton
+ loading={isSamlConfigSubmitting}
+ disabled={configureSAMLModalLoading}
+ type="primary"
+ htmlType="submit"
+ >
Save settings
</LemonButton>
</LemonModal.Footer>
diff --git a/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureSCIMModal.tsx b/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureSCIMModal.tsx
index 5b48fc3bcd8f..dd7ad9d57e78 100644
--- a/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureSCIMModal.tsx
+++ b/frontend/src/scenes/settings/organization/VerifiedDomains/ConfigureSCIMModal.tsx
@@ -11,6 +11,7 @@ import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
import { LemonLabel } from 'lib/lemon-ui/LemonLabel/LemonLabel'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
import { LemonSwitch } from 'lib/lemon-ui/LemonSwitch/LemonSwitch'
+import { Spinner } from 'lib/lemon-ui/Spinner'
import { verifiedDomainsLogic } from './verifiedDomainsLogic'
@@ -83,55 +84,67 @@ export function ConfigureSCIMModal(): JSX.Element {
<h3>Configure SCIM provisioning</h3>
</LemonModal.Header>
<LemonModal.Content className="space-y-2">
- <p>
- <Link to="https://posthog.com/docs/data/sso#setting-up-scim" target="_blank" targetBlankIcon>
- Read the docs
- </Link>
- </p>
-
- <LemonSwitch
- checked={scimConfig.scim_enabled ?? false}
- onChange={handleToggleScim}
- disabled={scimConfigLoading}
- label="Enable SCIM"
- />
-
- {scimConfig.scim_enabled && (
+ {scimConfigLoading ? (
+ <div className="flex min-h-40 items-center justify-center">
+ <Spinner size="large" captureTime />
+ </div>
+ ) : (
<>
- <div>
- <LemonLabel className="block mb-1">SCIM Base URL</LemonLabel>
- <CopyToClipboardInline description="SCIM base URL">
- {scimConfig.scim_base_url || ''}
- </CopyToClipboardInline>
- </div>
+ <p>
+ <Link
+ to="https://posthog.com/docs/data/sso#setting-up-scim"
+ target="_blank"
+ targetBlankIcon
+ >
+ Read the docs
+ </Link>
+ </p>
- <div>
- <LemonLabel className="block mb-1">Bearer Token</LemonLabel>
- {showToken ? (
- <>
- <CopyToClipboardInline description="Bearer token">
- {scimConfig.scim_bearer_token || ''}
+ <LemonSwitch
+ checked={scimConfig.scim_enabled ?? false}
+ onChange={handleToggleScim}
+ disabled={scimConfigLoading}
+ label="Enable SCIM"
+ />
+
+ {scimConfig.scim_enabled && (
+ <>
+ <div>
+ <LemonLabel className="block mb-1">SCIM Base URL</LemonLabel>
+ <CopyToClipboardInline description="SCIM base URL">
+ {scimConfig.scim_base_url || ''}
</CopyToClipboardInline>
- <LemonBanner type="warning" className="my-2">
- Save this token, it will only be shown once.
- </LemonBanner>
- </>
- ) : (
- <>
- <p className="text-muted">
- The bearer token is only displayed once when generated.
- </p>
- <LemonButton
- type="secondary"
- onClick={handleRegenerateToken}
- icon={<IconRefresh />}
- loading={scimConfigLoading}
- >
- Regenerate token
- </LemonButton>
- </>
- )}
- </div>
+ </div>
+
+ <div>
+ <LemonLabel className="block mb-1">Bearer Token</LemonLabel>
+ {showToken ? (
+ <>
+ <CopyToClipboardInline description="Bearer token">
+ {scimConfig.scim_bearer_token || ''}
+ </CopyToClipboardInline>
+ <LemonBanner type="warning" className="my-2">
+ Save this token, it will only be shown once.
+ </LemonBanner>
+ </>
+ ) : (
+ <>
+ <p className="text-muted">
+ The bearer token is only displayed once when generated.
+ </p>
+ <LemonButton
+ type="secondary"
+ onClick={handleRegenerateToken}
+ icon={<IconRefresh />}
+ loading={scimConfigLoading}
+ >
+ Regenerate token
+ </LemonButton>
+ </>
+ )}
+ </div>
+ </>
+ )}
</>
)}
</LemonModal.Content>
diff --git a/frontend/src/scenes/settings/organization/VerifiedDomains/__snapshots__/verifiedDomainsLogic.test.ts.snap b/frontend/src/scenes/settings/organization/VerifiedDomains/__snapshots__/verifiedDomainsLogic.test.ts.snap
index ec38e9632ded..14e88bcdf740 100644
--- a/frontend/src/scenes/settings/organization/VerifiedDomains/__snapshots__/verifiedDomainsLogic.test.ts.snap
+++ b/frontend/src/scenes/settings/organization/VerifiedDomains/__snapshots__/verifiedDomainsLogic.test.ts.snap
@@ -4,7 +4,9 @@ exports[`verifiedDomainsLogic values has proper defaults 1`] = `
{
"addModalShown": false,
"configureIdJagModalId": null,
+ "configureIdJagModalLoading": false,
"configureSAMLModalId": null,
+ "configureSAMLModalLoading": false,
"configureSCIMModalId": null,
"currentOrganizationId": "ABCD",
"domainBeingVerified": null,
diff --git a/frontend/src/scenes/settings/organization/VerifiedDomains/verifiedDomainsLogic.test.ts b/frontend/src/scenes/settings/organization/VerifiedDomains/verifiedDomainsLogic.test.ts
index 708291c944ac..943b4ef5c8d5 100644
--- a/frontend/src/scenes/settings/organization/VerifiedDomains/verifiedDomainsLogic.test.ts
+++ b/frontend/src/scenes/settings/organization/VerifiedDomains/verifiedDomainsLogic.test.ts
@@ -50,6 +50,23 @@ describe('verifiedDomainsLogic', () => {
is_verified: false,
verified_at: '',
},
+ '/api/organizations/:organization/identity_provider_configs/': {
+ id: '4aa1f0dc-a0ab-490a-9037-14f3358a81bc',
+ name: 'my.posthog.com',
+ saml_relay_state: '6969b120-a0ab-490a-9037-14f3358a81bc',
+ scim_enabled: false,
+ },
+ },
+ patch: {
+ '/api/organizations/:organization/domains/:id/': {
+ id: '8db3b0c2-a0ab-490a-9037-14f3358a81bc',
+ domain: 'my.posthog.com',
+ jit_provisioning_enabled: true,
+ sso_enforcement: 'google-oauth2',
+ is_verified: true,
+ verified_at: '2022-01-01T23:59:59',
+ identity_provider_config: '4aa1f0dc-a0ab-490a-9037-14f3358a81bc',
+ },
},
delete: {
'/api/organizations/:organization/domains/:id/': {},
@@ -91,6 +108,23 @@ describe('verifiedDomainsLogic', () => {
expect(logic.values).toMatchSnapshot()
})
+ it.each(['setConfigureSAMLModalId', 'setConfigureSCIMModalId', 'setConfigureIdJagModalId'] as const)(
+ 'creates and links an IdP config when %s opens',
+ async (openModal) => {
+ await expectLogic(logic).toFinishAllListeners()
+
+ logic.actions[openModal]('8db3b0c2-a0ab-490a-9037-14f3358a81bc')
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.verifiedDomains[0].identity_provider_config).toEqual(
+ '4aa1f0dc-a0ab-490a-9037-14f3358a81bc'
+ )
+ if (openModal === 'setConfigureSAMLModalId') {
+ expect(logic.values.samlConfig.saml_relay_state).toEqual('6969b120-a0ab-490a-9037-14f3358a81bc')
+ }
+ }
+ )
+
it('creates domain correctly', async () => {
await expectLogic(logic).toFinishAllListeners()
logic.actions.addVerifiedDomain('new.posthog.com')
diff --git a/frontend/src/scenes/settings/organization/VerifiedDomains/verifiedDomainsLogic.ts b/frontend/src/scenes/settings/organization/VerifiedDomains/verifiedDomainsLogic.ts
index 42ab9de88f69..2161780fee0a 100644
--- a/frontend/src/scenes/settings/organization/VerifiedDomains/verifiedDomainsLogic.ts
+++ b/frontend/src/scenes/settings/organization/VerifiedDomains/verifiedDomainsLogic.ts
@@ -11,6 +11,7 @@ import { organizationLogic } from 'scenes/organizationLogic'
import { userLogic } from 'scenes/userLogic'
import {
+ domainsPartialUpdate,
identityProviderConfigsCreate,
identityProviderConfigsDestroy,
identityProviderConfigsPartialUpdate,
@@ -26,31 +27,25 @@ import { AvailableFeature, OrganizationDomainType, PaginatedSCIMRequestLogs, Use
* for SAML/SCIM/ID-JAG settings, so all IdP-config CRUD targets it rather than the domain.
* If linking fails, the freshly created config is deleted so we don't leave an orphan behind.
*/
-async function ensureIdpConfigId(organizationId: string, domain: OrganizationDomainType): Promise<string> {
+async function ensureIdpConfig(
+ organizationId: string,
+ domain: OrganizationDomainType,
+ replaceDomain: (domain: OrganizationDomainType) => void
+): Promise<IdentityProviderConfigApi> {
if (domain.identity_provider_config) {
- return domain.identity_provider_config
+ return identityProviderConfigsRetrieve(organizationId, domain.identity_provider_config)
}
const config = await identityProviderConfigsCreate(organizationId, { name: domain.domain })
try {
- await api.update(`api/organizations/${organizationId}/domains/${domain.id}`, {
+ const linkedDomain = await domainsPartialUpdate(organizationId, domain.id, {
identity_provider_config: config.id,
})
+ replaceDomain(linkedDomain as OrganizationDomainType)
} catch (error) {
await identityProviderConfigsDestroy(organizationId, config.id).catch(() => undefined)
throw error
}
- return config.id
-}
-
-/** Fetch the IdP config linked to a domain, or null if none is linked yet. */
-async function fetchLinkedConfig(
- organizationId: string,
- domain: OrganizationDomainType
-): Promise<IdentityProviderConfigApi | null> {
- if (!domain.identity_provider_config) {
- return null
- }
- return identityProviderConfigsRetrieve(organizationId, domain.identity_provider_config)
+ return config
}
/** Re-fetch a single domain and replace it in local state (e.g. after linking/updating its IdP config). */
@@ -70,7 +65,9 @@ export type OrganizationDomainUpdatePayload = Partial<
Pick<OrganizationDomainType, 'id'>
export type SAMLConfigType = Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & { id: string }
+ Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'> & {
+ id: string
+ }
>
export type SCIMConfigType = Partial<
@@ -100,7 +97,9 @@ export interface verifiedDomainsLogicValues {
currentOrganizationId: string // organizationLogic
addModalShown: boolean
configureIdJagModalId: string | null
+ configureIdJagModalLoading: boolean
configureSAMLModalId: string | null
+ configureSAMLModalLoading: boolean
configureSCIMModalId: string | null
domainBeingVerified: OrganizationDomainType | null
idJagConfig: Partial<
@@ -140,7 +139,7 @@ export interface verifiedDomainsLogicValues {
isXAAAuthenticationAvailable: boolean
ownVerifiedDomain: OrganizationDomainType | null
samlConfig: Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'> & {
id: string
}
>
@@ -148,7 +147,10 @@ export interface verifiedDomainsLogicValues {
samlConfigChanged: boolean
samlConfigErrors: DeepPartialMap<
Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>,
@@ -160,7 +162,10 @@ export interface verifiedDomainsLogicValues {
samlConfigTouches: Record<string, boolean>
samlConfigValidationErrors: DeepPartialMap<
Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>,
@@ -376,13 +381,19 @@ export interface verifiedDomainsLogicActions {
}
resetSamlConfig: (
values?: Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>
) => {
values?: Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>
@@ -390,9 +401,15 @@ export interface verifiedDomainsLogicActions {
setConfigureIdJagModalId: (id: string | null) => {
id: string | null
}
+ setConfigureIdJagModalLoading: (loading: boolean) => {
+ loading: boolean
+ }
setConfigureSAMLModalId: (id: string | null) => {
id: string | null
}
+ setConfigureSAMLModalLoading: (loading: boolean) => {
+ loading: boolean
+ }
setConfigureSCIMModalId: (id: string | null) => {
id: string | null
}
@@ -436,7 +453,10 @@ export interface verifiedDomainsLogicActions {
setSamlConfigValues: (
values: DeepPartial<
Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>
@@ -444,7 +464,10 @@ export interface verifiedDomainsLogicActions {
) => {
values: DeepPartial<
Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>
@@ -534,26 +557,38 @@ export interface verifiedDomainsLogicActions {
}
submitSamlConfigRequest: (
samlConfig: Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>
) => {
samlConfig: Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>
}
submitSamlConfigSuccess: (
samlConfig: Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>
) => {
samlConfig: Partial<
- Pick<IdentityProviderConfigApi, 'saml_acs_url' | 'saml_entity_id' | 'saml_x509_cert'> & {
+ Pick<
+ IdentityProviderConfigApi,
+ 'saml_acs_url' | 'saml_entity_id' | 'saml_relay_state' | 'saml_x509_cert'
+ > & {
id: string
}
>
@@ -637,8 +672,10 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
showAddDomainModal: true,
hideAddDomainModal: true,
setConfigureSAMLModalId: (id: string | null) => ({ id }),
+ setConfigureSAMLModalLoading: (loading: boolean) => ({ loading }),
setConfigureSCIMModalId: (id: string | null) => ({ id }),
setConfigureIdJagModalId: (id: string | null) => ({ id }),
+ setConfigureIdJagModalLoading: (loading: boolean) => ({ loading }),
setScimLogsModalId: (id: string | null) => ({ id }),
setScimLogsStatusFilter: (filter: 'all' | 'success' | '4xx' | '5xx') => ({ filter }),
setScimLogsSearch: (search: string) => ({ search }),
@@ -671,6 +708,13 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
setConfigureSAMLModalId: (_, { id }) => id,
},
],
+ configureSAMLModalLoading: [
+ false,
+ {
+ setConfigureSAMLModalId: (_, { id }) => Boolean(id),
+ setConfigureSAMLModalLoading: (_, { loading }) => loading,
+ },
+ ],
configureSCIMModalId: [
null as null | string,
{
@@ -683,6 +727,13 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
setConfigureIdJagModalId: (_, { id }) => id,
},
],
+ configureIdJagModalLoading: [
+ false,
+ {
+ setConfigureIdJagModalId: (_, { id }) => Boolean(id),
+ setConfigureIdJagModalLoading: (_, { loading }) => loading,
+ },
+ ],
scimLogsModalId: [
null as null | string,
{
@@ -775,13 +826,18 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
{
loadScimConfig: async (domainId: string) => {
const domain = values.verifiedDomains.find(({ id }) => id === domainId)
- const config = domain
- ? await fetchLinkedConfig(values.currentOrganizationId as string, domain)
- : null
+ if (!domain) {
+ return { id: domainId, scim_enabled: false, scim_base_url: undefined }
+ }
+ const config = await ensureIdpConfig(
+ values.currentOrganizationId as string,
+ domain,
+ actions.replaceDomain
+ )
return {
id: domainId,
- scim_enabled: config?.scim_enabled ?? false,
- scim_base_url: domain?.scim_base_url,
+ scim_enabled: config.scim_enabled ?? false,
+ scim_base_url: domain.scim_base_url,
}
},
enableScim: async (domainId: string) => {
@@ -790,8 +846,10 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
if (!domain) {
return values.scimConfig
}
- const configId = await ensureIdpConfigId(orgId, domain)
- const config = await identityProviderConfigsPartialUpdate(orgId, configId, { scim_enabled: true })
+ const ensuredConfig = await ensureIdpConfig(orgId, domain, actions.replaceDomain)
+ const config = await identityProviderConfigsPartialUpdate(orgId, ensuredConfig.id, {
+ scim_enabled: true,
+ })
// Refresh the domain so its SCIM base URL and identity_provider_config link are current.
const refreshed = await refreshDomain(orgId, domainId, actions.replaceDomain)
lemonToast.success('SCIM enabled successfully!')
@@ -808,8 +866,10 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
if (!domain) {
return values.scimConfig
}
- const configId = await ensureIdpConfigId(orgId, domain)
- const config = await identityProviderConfigsPartialUpdate(orgId, configId, { scim_enabled: false })
+ const ensuredConfig = await ensureIdpConfig(orgId, domain, actions.replaceDomain)
+ const config = await identityProviderConfigsPartialUpdate(orgId, ensuredConfig.id, {
+ scim_enabled: false,
+ })
const refreshed = await refreshDomain(orgId, domainId, actions.replaceDomain)
lemonToast.success('SCIM disabled successfully!')
return {
@@ -876,13 +936,19 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
return
}
try {
- const config = await fetchLinkedConfig(values.currentOrganizationId as string, domain)
+ const config = await ensureIdpConfig(
+ values.currentOrganizationId as string,
+ domain,
+ actions.replaceDomain
+ )
actions.setSamlConfigValues({
id,
- saml_acs_url: config?.saml_acs_url ?? '',
- saml_entity_id: config?.saml_entity_id ?? '',
- saml_x509_cert: config?.saml_x509_cert ?? '',
+ saml_relay_state: config.saml_relay_state,
+ saml_acs_url: config.saml_acs_url ?? '',
+ saml_entity_id: config.saml_entity_id ?? '',
+ saml_x509_cert: config.saml_x509_cert ?? '',
})
+ actions.setConfigureSAMLModalLoading(false)
} catch {
lemonToast.error('Could not load the SAML configuration for this domain. Please try again.')
actions.setConfigureSAMLModalId(null)
@@ -894,13 +960,18 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
return
}
try {
- const config = await fetchLinkedConfig(values.currentOrganizationId as string, domain)
+ const config = await ensureIdpConfig(
+ values.currentOrganizationId as string,
+ domain,
+ actions.replaceDomain
+ )
actions.setIdJagConfigValues({
id,
- id_jag_issuer_url: config?.id_jag_issuer_url ?? '',
- id_jag_jwks_url: config?.id_jag_jwks_url ?? '',
- id_jag_allowed_clients: config?.id_jag_allowed_clients ?? [],
+ id_jag_issuer_url: config.id_jag_issuer_url ?? '',
+ id_jag_jwks_url: config.id_jag_jwks_url ?? '',
+ id_jag_allowed_clients: config.id_jag_allowed_clients ?? [],
})
+ actions.setConfigureIdJagModalLoading(false)
} catch {
lemonToast.error('Could not load the ID-JAG configuration for this domain. Please try again.')
actions.setConfigureIdJagModalId(null)
@@ -1002,8 +1073,8 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
if (!domain) {
return
}
- const configId = await ensureIdpConfigId(orgId, domain)
- await identityProviderConfigsPartialUpdate(orgId, configId, {
+ const config = await ensureIdpConfig(orgId, domain, actions.replaceDomain)
+ await identityProviderConfigsPartialUpdate(orgId, config.id, {
saml_acs_url,
saml_entity_id,
saml_x509_cert,
@@ -1037,8 +1108,8 @@ export const verifiedDomainsLogic = kea<verifiedDomainsLogicType>([
if (!domain) {
return
}
- const configId = await ensureIdpConfigId(orgId, domain)
- await identityProviderConfigsPartialUpdate(orgId, configId, {
+ const config = await ensureIdpConfig(orgId, domain, actions.replaceDomain)
+ await identityProviderConfigsPartialUpdate(orgId, config.id, {
id_jag_issuer_url: id_jag_issuer_url?.trim() || null,
id_jag_jwks_url: id_jag_jwks_url?.trim() || null,
id_jag_allowed_clients: id_jag_allowed_clients ?? [],
diff --git a/posthog/api/identity_provider_config.py b/posthog/api/identity_provider_config.py
index fcfbd6552f1e..00ed87371c77 100644
--- a/posthog/api/identity_provider_config.py
+++ b/posthog/api/identity_provider_config.py
@@ -31,6 +31,10 @@ def _capture_idp_config_event(
class IdentityProviderConfigSerializer(serializers.ModelSerializer):
+ saml_relay_state = serializers.CharField(
+ read_only=True,
+ help_text="Stable UUID sent as SAML RelayState to route authentication responses to this IdP configuration.",
+ )
scim_bearer_token = serializers.SerializerMethodField(
help_text="Plaintext SCIM bearer token. Only returned once, immediately after SCIM is enabled or the token is regenerated; null otherwise."
)
@@ -56,6 +60,7 @@ class IdentityProviderConfigSerializer(serializers.ModelSerializer):
"created_at",
"updated_at",
"has_saml",
+ "saml_relay_state",
"saml_entity_id",
"saml_acs_url",
"saml_x509_cert",
diff --git a/posthog/api/test/test_identity_provider_config.py b/posthog/api/test/test_identity_provider_config.py
index 240dc22f580d..4b05eb2d4c25 100644
--- a/posthog/api/test/test_identity_provider_config.py
+++ b/posthog/api/test/test_identity_provider_config.py
@@ -45,6 +45,7 @@ class TestIdentityProviderConfigAPI(APIBaseTest):
config = IdentityProviderConfig.objects.get(id=response.json()["id"])
self.assertEqual(config.organization, self.organization)
self.assertEqual(config.saml_entity_id, "entity")
+ self.assertEqual(response.json()["saml_relay_state"], str(config.saml_relay_state))
def test_member_cannot_create_config(self):
self.organization_membership.level = OrganizationMembership.Level.MEMBER
diff --git a/posthog/migrations/1305_alter_identityproviderconfig_saml_relay_state_and_more.py b/posthog/migrations/1305_alter_identityproviderconfig_saml_relay_state_and_more.py
new file mode 100644
index 000000000000..c982a46de81f
--- /dev/null
+++ b/posthog/migrations/1305_alter_identityproviderconfig_saml_relay_state_and_more.py
@@ -0,0 +1,24 @@
+# Generated by Django 5.2.17 on 2026-08-12 11:00
+
+import uuid
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1304_organization_has_active_subscription"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="identityproviderconfig",
+ name="saml_relay_state",
+ field=models.CharField(blank=True, default=uuid.uuid4, max_length=36, null=True, unique=True),
+ ),
+ migrations.AlterField(
+ model_name="identityproviderconfig",
+ name="scim_slug",
+ field=models.CharField(blank=True, default=uuid.uuid4, max_length=36, null=True, unique=True),
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index 0679f7ce6c96..6deaba69dbd4 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1304_organization_has_active_subscription
+1305_alter_identityproviderconfig_saml_relay_state_and_more
diff --git a/posthog/models/identity_provider_config.py b/posthog/models/identity_provider_config.py
index b60ebf8793c2..3b463ff1e7a6 100644
--- a/posthog/models/identity_provider_config.py
+++ b/posthog/models/identity_provider_config.py
@@ -1,8 +1,7 @@
-from collections.abc import Collection
-from typing import Any
+import uuid
from django.contrib.postgres.fields import ArrayField
-from django.db import models, transaction
+from django.db import models
import structlog
@@ -59,10 +58,22 @@ class IdentityProviderConfig(ModelActivityMixin, UUIDModel):
# Round-trips through the IdP as RelayState to route an assertion back to this config, and is
# also the prefix of every `UserSocialAuth.uid` issued through it. Changing the value on a
# config already in use orphans those identities, so it is assigned once and never edited.
- saml_relay_state = models.CharField(max_length=36, blank=True, null=True, unique=True)
+ saml_relay_state = models.CharField(
+ max_length=36,
+ blank=True,
+ null=True,
+ unique=True,
+ default=uuid.uuid4,
+ )
# ---- SCIM attributes ----
- scim_slug = models.CharField(max_length=36, blank=True, null=True, unique=True)
+ scim_slug = models.CharField(
+ max_length=36,
+ blank=True,
+ null=True,
+ unique=True,
+ default=uuid.uuid4,
+ )
scim_enabled = models.BooleanField(default=False)
scim_bearer_token = models.CharField(
max_length=255, blank=True, null=True, help_text="Hashed bearer token for SCIM authentication"
@@ -90,57 +101,12 @@ class IdentityProviderConfig(ModelActivityMixin, UUIDModel):
help_text="Allowed ID-JAG client IDs. Empty list allows any client_id.",
)
- _IDENTIFIER_FIELDS = ("saml_relay_state", "scim_slug")
- _loaded_identifier_values: dict[str, str | None]
-
class Meta:
verbose_name = "identity provider config"
def __str__(self) -> str:
return self.name or str(self.id)
- @classmethod
- def from_db(cls, db: str | None, field_names: Collection[str], values: Collection[Any]) -> "IdentityProviderConfig":
- instance = super().from_db(db, field_names, values)
- instance._loaded_identifier_values = {
- field: getattr(instance, field) for field in cls._IDENTIFIER_FIELDS if field in field_names
- }
- return instance
-
- def save(self, *args: Any, **kwargs: Any) -> None:
- if self._state.adding:
- super().save(*args, **kwargs)
- self._loaded_identifier_values = {field: getattr(self, field) for field in self._IDENTIFIER_FIELDS}
- return
-
- update_fields = kwargs.get("update_fields")
- fields_to_preserve = [
- field
- for field in self._IDENTIFIER_FIELDS
- if getattr(self, field) is None
- and (
- (update_fields is not None and field not in update_fields)
- or (update_fields is None and getattr(self, "_loaded_identifier_values", {}).get(field) is None)
- )
- ]
-
- if fields_to_preserve:
- with transaction.atomic():
- persisted = type(self).objects.select_for_update().values(*fields_to_preserve).get(pk=self.pk)
- for field in fields_to_preserve:
- setattr(self, field, persisted[field])
- super().save(*args, **kwargs)
- else:
- super().save(*args, **kwargs)
-
- saved_identifier_fields = set(fields_to_preserve)
- if update_fields is None:
- saved_identifier_fields.update(self._IDENTIFIER_FIELDS)
- else:
- saved_identifier_fields.update(field for field in self._IDENTIFIER_FIELDS if field in update_fields)
- for field in saved_identifier_fields:
- self._loaded_identifier_values[field] = getattr(self, field)
-
@property
def has_saml(self) -> bool:
"""
diff --git a/posthog/models/organization_domain.py b/posthog/models/organization_domain.py
index 6d48cf44a3b4..cbadb4c87ee0 100644
--- a/posthog/models/organization_domain.py
+++ b/posthog/models/organization_domain.py
@@ -330,19 +330,6 @@ class OrganizationDomain(ModelActivityMixin, UUIDTModel):
identity_provider_config_id=self.identity_provider_config_id,
)
- config = IdentityProviderConfig.objects.select_for_update().get(pk=self.identity_provider_config_id)
- identifier = str(self.pk)
- updates = {field: identifier for field in ("saml_relay_state", "scim_slug") if not getattr(config, field)}
- if updates:
- for field, value in updates.items():
- setattr(config, field, value)
- config.save(update_fields=list(updates))
-
- cached_config = self._state.fields_cache.get("identity_provider_config")
- if cached_config is not None:
- for field, value in updates.items():
- setattr(cached_config, field, value)
-
@property
def is_verified(self) -> bool:
"""
diff --git a/posthog/test/test_identity_provider_config.py b/posthog/test/test_identity_provider_config.py
index 7227381579c7..2f3c39184aac 100644
--- a/posthog/test/test_identity_provider_config.py
+++ b/posthog/test/test_identity_provider_config.py
@@ -1,3 +1,5 @@
+import uuid
+
import pytest
from posthog.test.base import BaseTest
@@ -36,20 +38,28 @@ class TestIdentityProviderConfig(BaseTest):
domain.save()
return config
+ def test_creating_config_populates_uuid_identifiers(self):
+ config = IdentityProviderConfig.objects.create(organization=self.organization)
+
+ assert uuid.UUID(str(config.saml_relay_state))
+ assert uuid.UUID(str(config.scim_slug))
+ assert config.saml_relay_state != config.scim_slug
+
def test_creating_domain_with_idp_config_creates_link(self):
config = IdentityProviderConfig.objects.create(organization=self.organization)
+ identifiers = (str(config.saml_relay_state), str(config.scim_slug))
domain = self._create_domain(identity_provider_config=config)
assert LinkedIdentityProviderConfig.objects.filter(
organization_domain=domain, identity_provider_config=config
).exists()
config.refresh_from_db()
- assert config.saml_relay_state == str(domain.pk)
- assert config.scim_slug == str(domain.pk)
+ assert (config.saml_relay_state, config.scim_slug) == identifiers
def test_updating_domain_idp_config_creates_link(self):
domain = self._create_domain()
config = IdentityProviderConfig.objects.create(organization=self.organization)
+ identifiers = (str(config.saml_relay_state), str(config.scim_slug))
domain.identity_provider_config = config
domain.save()
@@ -57,47 +67,7 @@ class TestIdentityProviderConfig(BaseTest):
organization_domain=domain, identity_provider_config=config
).exists()
config.refresh_from_db()
- assert config.saml_relay_state == str(domain.pk)
- assert config.scim_slug == str(domain.pk)
-
- def test_linking_config_preserves_identifiers_on_stale_partial_save(self):
- config = IdentityProviderConfig.objects.create(organization=self.organization)
- stale_config = IdentityProviderConfig.objects.get(pk=config.pk)
- domain = self._create_domain(identity_provider_config=config)
-
- stale_config.saml_entity_id = "entity-id"
- stale_config.save(update_fields=["saml_entity_id"])
- stale_config.refresh_from_db()
-
- assert stale_config.saml_relay_state == str(domain.pk)
- assert stale_config.scim_slug == str(domain.pk)
-
- def test_linking_config_preserves_identifiers_on_stale_full_save(self):
- config = IdentityProviderConfig.objects.create(organization=self.organization)
- stale_config = IdentityProviderConfig.objects.get(pk=config.pk)
- domain = self._create_domain(identity_provider_config=config)
-
- stale_config.scim_enabled = True
- stale_config.save()
- stale_config.refresh_from_db()
-
- assert stale_config.saml_relay_state == str(domain.pk)
- assert stale_config.scim_slug == str(domain.pk)
-
- def test_explicitly_clearing_identifiers_persists_null(self):
- config = IdentityProviderConfig.objects.create(
- organization=self.organization,
- saml_relay_state="relay-state",
- scim_slug="scim-slug",
- )
-
- config.saml_relay_state = None
- config.scim_slug = None
- config.save()
- config.refresh_from_db()
-
- assert config.saml_relay_state is None
- assert config.scim_slug is None
+ assert (config.saml_relay_state, config.scim_slug) == identifiers
def test_saving_legacy_idp_columns_does_not_create_or_link_config(self):
# The domain<->config dual-write mirror has been removed: writing the legacy underscore
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 44ed9a290263..26bcd83429f9 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -42033,6 +42033,8 @@ export namespace Schemas {
readonly updated_at: string;
/** Whether SAML is fully configured on this config. */
readonly has_saml: boolean;
+ /** Stable UUID sent as SAML RelayState to route authentication responses to this IdP configuration. */
+ readonly saml_relay_state: string;
/**
* SAML IdP entity ID (issuer).
* @maxLength 512
@@ -58103,6 +58105,8 @@ export namespace Schemas {
readonly updated_at?: string;
/** Whether SAML is fully configured on this config. */
readonly has_saml?: boolean;
+ /** Stable UUID sent as SAML RelayState to route authentication responses to this IdP configuration. */
+ readonly saml_relay_state?: string;
/**
* SAML IdP entity ID (issuer).
* @maxLength 512