-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sso enforcement for invite signup (#25808)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
81d3ffb
commit 40a602a
Showing
16 changed files
with
186 additions
and
52 deletions.
There are no files selected for viewing
Binary file modified
BIN
+258 Bytes
(100%)
frontend/__snapshots__/scenes-other-invitesignup--cloud--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-908 Bytes
(99%)
frontend/__snapshots__/scenes-other-invitesignup--cloud--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+191 Bytes
(100%)
frontend/__snapshots__/scenes-other-invitesignup--cloud-eu--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-636 Bytes
(99%)
frontend/__snapshots__/scenes-other-invitesignup--cloud-eu--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+233 Bytes
(100%)
frontend/__snapshots__/scenes-other-invitesignup--self-hosted--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+268 Bytes
(100%)
frontend/__snapshots__/scenes-other-invitesignup--self-hosted--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+98 KB
frontend/__snapshots__/scenes-other-invitesignup--sso-enforced-google--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+114 KB
frontend/__snapshots__/scenes-other-invitesignup--sso-enforced-google--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+97.4 KB
frontend/__snapshots__/scenes-other-invitesignup--sso-enforced-saml--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+115 KB
frontend/__snapshots__/scenes-other-invitesignup--sso-enforced-saml--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1558,6 +1558,46 @@ def test_cant_claim_expired_invite(self): | |
self.assertEqual(Team.objects.count(), team_count) | ||
self.assertEqual(Organization.objects.count(), org_count) | ||
|
||
def test_api_signup_with_sso_enforced_fails(self): | ||
"""Test that users cannot sign up with email/password when SSO is enforced.""" | ||
|
||
organization = Organization.objects.create(name="Test Org") | ||
organization.available_product_features = [ | ||
{"key": AvailableFeature.SSO_ENFORCEMENT, "name": AvailableFeature.SSO_ENFORCEMENT}, | ||
{"key": AvailableFeature.SAML, "name": AvailableFeature.SAML}, | ||
] | ||
organization.save() | ||
OrganizationDomain.objects.create( | ||
domain="posthog_sss_test.com", organization=organization, sso_enforcement="saml", verified_at=timezone.now() | ||
) | ||
|
||
invite: OrganizationInvite = OrganizationInvite.objects.create( | ||
target_email="test+sso@posthog_sss_test.com", organization=organization | ||
) | ||
|
||
response = self.client.post( | ||
f"/api/signup/{invite.id}/", | ||
{ | ||
"first_name": "Alice", | ||
"password": VALID_TEST_PASSWORD, | ||
}, | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
self.assertEqual( | ||
response.json(), | ||
{ | ||
"type": "validation_error", | ||
"code": "sso_enforced", | ||
"detail": "Sign up with a password is disabled because SSO login is enforced for this domain. Please log in with your SSO credentials.", | ||
"attr": None, | ||
}, | ||
) | ||
|
||
# Verify no user was created and invite was not used | ||
self.assertFalse(User.objects.filter(email="[email protected]").exists()) | ||
self.assertFalse(OrganizationInvite.objects.filter(target_email="[email protected]").exists()) | ||
|
||
# Social signup (use invite) | ||
|
||
def test_api_social_invite_sign_up(self): | ||
|