Skip to content

Commit afe252c

Browse files
ci-stytchStytch Codegen Bot
andauthored
Add Organization Consent Management settings (#267)
Co-authored-by: Stytch Codegen Bot <[email protected]>
1 parent d7f30fe commit afe252c

File tree

6 files changed

+125
-13
lines changed

6 files changed

+125
-13
lines changed

stytch/b2b/api/discovery_organizations.py

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
from typing import Any, Dict, List, Optional, Union
1010

11-
from stytch.b2b.models.discovery_organizations import CreateResponse, ListResponse
11+
from stytch.b2b.models.discovery_organizations import (
12+
CreateRequestFirstPartyConnectedAppsAllowedType,
13+
CreateRequestThirdPartyConnectedAppsAllowedType,
14+
CreateResponse,
15+
ListResponse,
16+
)
1217
from stytch.b2b.models.organizations import EmailImplicitRoleAssignment
1318
from stytch.core.api_base import ApiBase
1419
from stytch.core.http.client import AsyncClient, SyncClient
@@ -45,6 +50,14 @@ def create(
4550
allowed_mfa_methods: Optional[List[str]] = None,
4651
oauth_tenant_jit_provisioning: Optional[str] = None,
4752
allowed_oauth_tenants: Optional[Dict[str, Any]] = None,
53+
first_party_connected_apps_allowed_type: Optional[
54+
Union[CreateRequestFirstPartyConnectedAppsAllowedType, str]
55+
] = None,
56+
allowed_first_party_connected_apps: Optional[List[str]] = None,
57+
third_party_connected_apps_allowed_type: Optional[
58+
Union[CreateRequestThirdPartyConnectedAppsAllowedType, str]
59+
] = None,
60+
allowed_third_party_connected_apps: Optional[List[str]] = None,
4861
) -> CreateResponse:
4962
"""This endpoint allows you to exchange the `intermediate_session_token` returned when the user successfully completes a authentication flow to create a new
5063
[Organization](https://stytch.com/docs/b2b/api/organization-object) and [Member](https://stytch.com/docs/b2b/api/member-object) and log the user in. If the user wants to log into an existing Organization, use the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) instead.
@@ -143,6 +156,24 @@ def create(
143156
`NOT_ALLOWED` – disable JIT provisioning by OAuth Tenant.
144157
145158
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
159+
- first_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy towards first party Connected Apps. The accepted values are:
160+
161+
`ALL_ALLOWED` – any first party Connected App in the Project is permitted for use by Members.
162+
163+
`RESTRICTED` – only first party Connected Apps with IDs in `allowed_first_party_connected_apps` can be used by Members.
164+
165+
`NOT_ALLOWED` – no first party Connected Apps are permitted.
166+
167+
- allowed_first_party_connected_apps: An array of first party Connected App IDs that are allowed for the Organization. Only used when the Organization's `first_party_connected_apps_allowed_type` is `RESTRICTED`.
168+
- third_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy towards third party Connected Apps. The accepted values are:
169+
170+
`ALL_ALLOWED` – any third party Connected App in the Project is permitted for use by Members.
171+
172+
`RESTRICTED` – only third party Connected Apps with IDs in `allowed_first_party_connected_apps` can be used by Members.
173+
174+
`NOT_ALLOWED` – no third party Connected Apps are permitted.
175+
176+
- allowed_third_party_connected_apps: An array of third party Connected App IDs that are allowed for the Organization. Only used when the Organization's `third_party_connected_apps_allowed_type` is `RESTRICTED`.
146177
""" # noqa
147178
headers: Dict[str, str] = {}
148179
data: Dict[str, Any] = {
@@ -187,6 +218,22 @@ def create(
187218
data["oauth_tenant_jit_provisioning"] = oauth_tenant_jit_provisioning
188219
if allowed_oauth_tenants is not None:
189220
data["allowed_oauth_tenants"] = allowed_oauth_tenants
221+
if first_party_connected_apps_allowed_type is not None:
222+
data["first_party_connected_apps_allowed_type"] = (
223+
first_party_connected_apps_allowed_type
224+
)
225+
if allowed_first_party_connected_apps is not None:
226+
data["allowed_first_party_connected_apps"] = (
227+
allowed_first_party_connected_apps
228+
)
229+
if third_party_connected_apps_allowed_type is not None:
230+
data["third_party_connected_apps_allowed_type"] = (
231+
third_party_connected_apps_allowed_type
232+
)
233+
if allowed_third_party_connected_apps is not None:
234+
data["allowed_third_party_connected_apps"] = (
235+
allowed_third_party_connected_apps
236+
)
190237

191238
url = self.api_base.url_for("/v1/b2b/discovery/organizations/create", data)
192239
res = self.sync_client.post(url, data, headers)
@@ -215,6 +262,14 @@ async def create_async(
215262
allowed_mfa_methods: Optional[List[str]] = None,
216263
oauth_tenant_jit_provisioning: Optional[str] = None,
217264
allowed_oauth_tenants: Optional[Dict[str, Any]] = None,
265+
first_party_connected_apps_allowed_type: Optional[
266+
CreateRequestFirstPartyConnectedAppsAllowedType
267+
] = None,
268+
allowed_first_party_connected_apps: Optional[List[str]] = None,
269+
third_party_connected_apps_allowed_type: Optional[
270+
CreateRequestThirdPartyConnectedAppsAllowedType
271+
] = None,
272+
allowed_third_party_connected_apps: Optional[List[str]] = None,
218273
) -> CreateResponse:
219274
"""This endpoint allows you to exchange the `intermediate_session_token` returned when the user successfully completes a authentication flow to create a new
220275
[Organization](https://stytch.com/docs/b2b/api/organization-object) and [Member](https://stytch.com/docs/b2b/api/member-object) and log the user in. If the user wants to log into an existing Organization, use the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) instead.
@@ -313,6 +368,24 @@ async def create_async(
313368
`NOT_ALLOWED` – disable JIT provisioning by OAuth Tenant.
314369
315370
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
371+
- first_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy towards first party Connected Apps. The accepted values are:
372+
373+
`ALL_ALLOWED` – any first party Connected App in the Project is permitted for use by Members.
374+
375+
`RESTRICTED` – only first party Connected Apps with IDs in `allowed_first_party_connected_apps` can be used by Members.
376+
377+
`NOT_ALLOWED` – no first party Connected Apps are permitted.
378+
379+
- allowed_first_party_connected_apps: An array of first party Connected App IDs that are allowed for the Organization. Only used when the Organization's `first_party_connected_apps_allowed_type` is `RESTRICTED`.
380+
- third_party_connected_apps_allowed_type: The authentication setting that sets the Organization's policy towards third party Connected Apps. The accepted values are:
381+
382+
`ALL_ALLOWED` – any third party Connected App in the Project is permitted for use by Members.
383+
384+
`RESTRICTED` – only third party Connected Apps with IDs in `allowed_first_party_connected_apps` can be used by Members.
385+
386+
`NOT_ALLOWED` – no third party Connected Apps are permitted.
387+
388+
- allowed_third_party_connected_apps: An array of third party Connected App IDs that are allowed for the Organization. Only used when the Organization's `third_party_connected_apps_allowed_type` is `RESTRICTED`.
316389
""" # noqa
317390
headers: Dict[str, str] = {}
318391
data: Dict[str, Any] = {
@@ -357,6 +430,22 @@ async def create_async(
357430
data["oauth_tenant_jit_provisioning"] = oauth_tenant_jit_provisioning
358431
if allowed_oauth_tenants is not None:
359432
data["allowed_oauth_tenants"] = allowed_oauth_tenants
433+
if first_party_connected_apps_allowed_type is not None:
434+
data["first_party_connected_apps_allowed_type"] = (
435+
first_party_connected_apps_allowed_type
436+
)
437+
if allowed_first_party_connected_apps is not None:
438+
data["allowed_first_party_connected_apps"] = (
439+
allowed_first_party_connected_apps
440+
)
441+
if third_party_connected_apps_allowed_type is not None:
442+
data["third_party_connected_apps_allowed_type"] = (
443+
third_party_connected_apps_allowed_type
444+
)
445+
if allowed_third_party_connected_apps is not None:
446+
data["allowed_third_party_connected_apps"] = (
447+
allowed_third_party_connected_apps
448+
)
360449

361450
url = self.api_base.url_for("/v1/b2b/discovery/organizations/create", data)
362451
res = await self.async_client.post(url, data, headers)

stytch/b2b/api/organizations_members.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ def create(
918918
for complete field behavior details.
919919
- create_member_as_pending: Flag for whether or not to save a Member as `pending` or `active` in Stytch. It defaults to false. If true, new Members will be created with status `pending` in Stytch's backend. Their status will remain `pending` and they will continue to receive signup email templates for every Email Magic Link until that Member authenticates and becomes `active`. If false, new Members will be created with status `active`.
920920
- is_breakglass: Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings. A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures. Refer to the [Organization object](organization-object) and its `auth_methods` and `allowed_auth_methods` fields for more details.
921-
- mfa_phone_number: The Member's phone number. A Member may only have one phone number.
921+
- mfa_phone_number: The Member's phone number. A Member may only have one phone number. The phone number should be in E.164 format (i.e. +1XXXXXXXXXX).
922922
- mfa_enrolled: Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
923923
- roles: Roles to explicitly assign to this Member. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
924924
for more information about role assignment.
@@ -983,7 +983,7 @@ async def create_async(
983983
for complete field behavior details.
984984
- create_member_as_pending: Flag for whether or not to save a Member as `pending` or `active` in Stytch. It defaults to false. If true, new Members will be created with status `pending` in Stytch's backend. Their status will remain `pending` and they will continue to receive signup email templates for every Email Magic Link until that Member authenticates and becomes `active`. If false, new Members will be created with status `active`.
985985
- is_breakglass: Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings. A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures. Refer to the [Organization object](organization-object) and its `auth_methods` and `allowed_auth_methods` fields for more details.
986-
- mfa_phone_number: The Member's phone number. A Member may only have one phone number.
986+
- mfa_phone_number: The Member's phone number. A Member may only have one phone number. The phone number should be in E.164 format (i.e. +1XXXXXXXXXX).
987987
- mfa_enrolled: Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
988988
- roles: Roles to explicitly assign to this Member. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
989989
for more information about role assignment.

stytch/b2b/api/passwords.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,13 @@ def migrate(
140140
set_phone_number_verified: Optional[bool] = None,
141141
external_id: Optional[str] = None,
142142
) -> MigrateResponse:
143-
"""Adds an existing password to a member's email that doesn't have a password yet. We support migrating members from passwords stored with bcrypt, scrypt, argon2, MD-5, SHA-1, and PBKDF2. This endpoint has a rate limit of 100 requests per second.
143+
"""Adds an existing password to a Member's email that doesn't have a password yet.
144144
145-
The member's email will be marked as verified when you use this endpoint. If you are using **cross-organization passwords**, call this method separately for each `organization_id` associated with the given `email_address` to ensure the email is verified across all of their organizations.
145+
We support migrating members from passwords stored with bcrypt, scrypt, argon2, MD-5, SHA-1, and PBKDF2. This endpoint has a rate limit of 100 requests per second.
146+
147+
The Member's email will be marked as verified when you use this endpoint.
148+
149+
If you are using **cross-organization passwords**, i.e. allowing an end user to share the same password across all of their Organizations, call this method separately for each `organization_id` associated with the given `email_address` to ensure the password is set across all of their Organizations.
146150
147151
Fields:
148152
- email_address: The email address of the Member.
@@ -170,8 +174,9 @@ def migrate(
170174
- preserve_existing_sessions: Whether to preserve existing sessions when explicit Roles that are revoked are also implicitly assigned
171175
by SSO connection or SSO group. Defaults to `false` - that is, existing Member Sessions that contain SSO
172176
authentication factors with the affected SSO connection IDs will be revoked.
173-
- mfa_phone_number: (no documentation yet)
174-
- set_phone_number_verified: (no documentation yet)
177+
- mfa_phone_number: The Member's phone number. A Member may only have one phone number. The phone number should be in E.164 format (i.e. +1XXXXXXXXXX).
178+
- set_phone_number_verified: Whether to set the user's phone number as verified. This is a dangerous field. This flag should only be set if you can attest that
179+
the user owns the phone number in question.
175180
- external_id: If a new member is created, this will set an identifier that can be used in API calls wherever a member_id is expected. This is a string consisting of alphanumeric, `.`, `_`, `-`, or `|` characters with a maximum length of 128 characters. External IDs must be unique within an organization, but may be reused across different organizations in the same project. Note that if a member already exists, this field will be ignored.
176181
""" # noqa
177182
headers: Dict[str, str] = {}
@@ -248,9 +253,13 @@ async def migrate_async(
248253
set_phone_number_verified: Optional[bool] = None,
249254
external_id: Optional[str] = None,
250255
) -> MigrateResponse:
251-
"""Adds an existing password to a member's email that doesn't have a password yet. We support migrating members from passwords stored with bcrypt, scrypt, argon2, MD-5, SHA-1, and PBKDF2. This endpoint has a rate limit of 100 requests per second.
256+
"""Adds an existing password to a Member's email that doesn't have a password yet.
257+
258+
We support migrating members from passwords stored with bcrypt, scrypt, argon2, MD-5, SHA-1, and PBKDF2. This endpoint has a rate limit of 100 requests per second.
259+
260+
The Member's email will be marked as verified when you use this endpoint.
252261
253-
The member's email will be marked as verified when you use this endpoint. If you are using **cross-organization passwords**, call this method separately for each `organization_id` associated with the given `email_address` to ensure the email is verified across all of their organizations.
262+
If you are using **cross-organization passwords**, i.e. allowing an end user to share the same password across all of their Organizations, call this method separately for each `organization_id` associated with the given `email_address` to ensure the password is set across all of their Organizations.
254263
255264
Fields:
256265
- email_address: The email address of the Member.
@@ -278,8 +287,9 @@ async def migrate_async(
278287
- preserve_existing_sessions: Whether to preserve existing sessions when explicit Roles that are revoked are also implicitly assigned
279288
by SSO connection or SSO group. Defaults to `false` - that is, existing Member Sessions that contain SSO
280289
authentication factors with the affected SSO connection IDs will be revoked.
281-
- mfa_phone_number: (no documentation yet)
282-
- set_phone_number_verified: (no documentation yet)
290+
- mfa_phone_number: The Member's phone number. A Member may only have one phone number. The phone number should be in E.164 format (i.e. +1XXXXXXXXXX).
291+
- set_phone_number_verified: Whether to set the user's phone number as verified. This is a dangerous field. This flag should only be set if you can attest that
292+
the user owns the phone number in question.
283293
- external_id: If a new member is created, this will set an identifier that can be used in API calls wherever a member_id is expected. This is a string consisting of alphanumeric, `.`, `_`, `-`, or `|` characters with a maximum length of 128 characters. External IDs must be unique within an organization, but may be reused across different organizations in the same project. Note that if a member already exists, this field will be ignored.
284294
""" # noqa
285295
headers: Dict[str, str] = {}

stytch/b2b/models/discovery_organizations.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from __future__ import annotations
88

9+
import enum
910
from typing import List, Optional
1011

1112
from stytch.b2b.models.discovery import DiscoveredOrganization
@@ -15,6 +16,18 @@
1516
from stytch.core.response_base import ResponseBase
1617

1718

19+
class CreateRequestFirstPartyConnectedAppsAllowedType(str, enum.Enum):
20+
ALL_ALLOWED = "ALL_ALLOWED"
21+
RESTRICTED = "RESTRICTED"
22+
NOT_ALLOWED = "NOT_ALLOWED"
23+
24+
25+
class CreateRequestThirdPartyConnectedAppsAllowedType(str, enum.Enum):
26+
ALL_ALLOWED = "ALL_ALLOWED"
27+
RESTRICTED = "RESTRICTED"
28+
NOT_ALLOWED = "NOT_ALLOWED"
29+
30+
1831
class CreateResponse(ResponseBase):
1932
"""Response type for `Organizations.create`.
2033
Fields:

stytch/b2b/models/organizations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ class Member(pydantic.BaseModel):
540540
541541
- is_locked: (no documentation yet)
542542
- mfa_enrolled: Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
543-
- mfa_phone_number: The Member's phone number. A Member may only have one phone number.
543+
- mfa_phone_number: The Member's phone number. A Member may only have one phone number. The phone number should be in E.164 format (i.e. +1XXXXXXXXXX).
544544
- default_mfa_method: (no documentation yet)
545545
- roles: Explicit or implicit Roles assigned to this Member, along with details about the role assignment source.
546546
See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.

stytch/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "13.8.0"
1+
__version__ = "13.9.0"

0 commit comments

Comments
 (0)