Skip to content

Commit 136e163

Browse files
author
Stytch Codegen Bot
committed
feat: Add Connected App CRUD PRs
1 parent afe252c commit 136e163

24 files changed

+795
-34
lines changed

stytch/b2b/api/impersonation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def authenticate(
2828
"""Authenticate an impersonation token to impersonate a. This endpoint requires an impersonation token that is not expired or previously used.
2929
A Stytch session will be created for the impersonated member with a 60 minute duration. Impersonated sessions cannot be extended.
3030
31-
Prior to this step, you can generate an impersonation token by visiting the Stytch dashboard, viewing a member, and clicking the `Impersonate Member` button.
31+
Prior to this step, you can generate an impersonation token by visiting the Stytch Dashboard, viewing a member, and clicking the `Impersonate Member` button.
3232
3333
Fields:
3434
- impersonation_token: The User Impersonation token to authenticate.
@@ -49,7 +49,7 @@ async def authenticate_async(
4949
"""Authenticate an impersonation token to impersonate a. This endpoint requires an impersonation token that is not expired or previously used.
5050
A Stytch session will be created for the impersonated member with a 60 minute duration. Impersonated sessions cannot be extended.
5151
52-
Prior to this step, you can generate an impersonation token by visiting the Stytch dashboard, viewing a member, and clicking the `Impersonate Member` button.
52+
Prior to this step, you can generate an impersonation token by visiting the Stytch Dashboard, viewing a member, and clicking the `Impersonate Member` button.
5353
5454
Fields:
5555
- impersonation_token: The User Impersonation token to authenticate.

stytch/b2b/api/passwords.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@ def strength_check(
6565
) -> StrengthCheckResponse:
6666
"""This API allows you to check whether the user’s provided password is valid, and to provide feedback to the user on how to increase the strength of their password.
6767
68-
This endpoint adapts to your Project's password strength configuration. If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are considered valid if they meet the requirements that you've set with Stytch. You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
68+
This endpoint adapts to your Project's password strength configuration.
69+
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid if the strength score is >= 3.
70+
If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are considered valid if they meet the requirements that you've set with Stytch.
71+
You may update your password strength configuration on the [Passwords Policy page](https://stytch.com/dashboard/password-strength-config) in the Stytch Dashboard.
6972
7073
## Password feedback
71-
The zxcvbn_feedback and luds_feedback objects contains relevant fields for you to relay feedback to users that failed to create a strong enough password.
74+
The `zxcvbn_feedback` and `luds_feedback` objects contains relevant fields for you to relay feedback to users that failed to create a strong enough password.
7275
7376
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the feedback object will contain warning and suggestions for any password that does not meet the [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy) strength requirements. You can return these strings directly to the user to help them craft a strong password.
7477
@@ -96,10 +99,13 @@ async def strength_check_async(
9699
) -> StrengthCheckResponse:
97100
"""This API allows you to check whether the user’s provided password is valid, and to provide feedback to the user on how to increase the strength of their password.
98101
99-
This endpoint adapts to your Project's password strength configuration. If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are considered valid if they meet the requirements that you've set with Stytch. You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
102+
This endpoint adapts to your Project's password strength configuration.
103+
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid if the strength score is >= 3.
104+
If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are considered valid if they meet the requirements that you've set with Stytch.
105+
You may update your password strength configuration on the [Passwords Policy page](https://stytch.com/dashboard/password-strength-config) in the Stytch Dashboard.
100106
101107
## Password feedback
102-
The zxcvbn_feedback and luds_feedback objects contains relevant fields for you to relay feedback to users that failed to create a strong enough password.
108+
The `zxcvbn_feedback` and `luds_feedback` objects contains relevant fields for you to relay feedback to users that failed to create a strong enough password.
103109
104110
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the feedback object will contain warning and suggestions for any password that does not meet the [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy) strength requirements. You can return these strings directly to the user to help them craft a strong password.
105111

stytch/b2b/api/passwords_discovery_email.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def reset_start(
4141
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
4242
if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are
4343
considered valid if they meet the requirements that you've set with Stytch.
44-
You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
44+
You may update your password strength configuration on the [Passwords Policy page](https://stytch.com/dashboard/password-strength-config) in the Stytch Dashboard.
4545
4646
Fields:
4747
- email_address: The email address of the Member to start the email reset process for.
@@ -107,7 +107,7 @@ async def reset_start_async(
107107
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
108108
if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are
109109
considered valid if they meet the requirements that you've set with Stytch.
110-
You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
110+
You may update your password strength configuration on the [Passwords Policy page](https://stytch.com/dashboard/password-strength-config) in the Stytch Dashboard.
111111
112112
Fields:
113113
- email_address: The email address of the Member to start the email reset process for.

stytch/b2b/api/passwords_email.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def reset_start(
4646
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
4747
if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are
4848
considered valid if they meet the requirements that you've set with Stytch.
49-
You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
49+
You may update your password strength configuration on the [Passwords Policy page](https://stytch.com/dashboard/password-strength-config) in the Stytch Dashboard.
5050
5151
Fields:
5252
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value. You may also use the organization_slug here as a convenience.
@@ -114,7 +114,7 @@ async def reset_start_async(
114114
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
115115
if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are
116116
considered valid if they meet the requirements that you've set with Stytch.
117-
You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
117+
You may update your password strength configuration on the [Passwords Policy page](https://stytch.com/dashboard/password-strength-config) in the Stytch Dashboard.
118118
119119
Fields:
120120
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value. You may also use the organization_slug here as a convenience.

stytch/b2b/api/passwords_existing_password.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def reset(
4242
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
4343
if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are
4444
considered valid if they meet the requirements that you've set with Stytch.
45-
You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
45+
You may update your password strength configuration on the [Passwords Policy page](https://stytch.com/dashboard/password-strength-config) in the Stytch Dashboard.
4646
4747
If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
4848
The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA step and acquire a full member session.
@@ -122,7 +122,7 @@ async def reset_async(
122122
If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
123123
if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are
124124
considered valid if they meet the requirements that you've set with Stytch.
125-
You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
125+
You may update your password strength configuration on the [Passwords Policy page](https://stytch.com/dashboard/password-strength-config) in the Stytch Dashboard.
126126
127127
If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
128128
The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA step and acquire a full member session.

stytch/b2b/api/rbac.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def policy(
2828
2929
When using the backend SDKs, the RBAC Policy will be cached to allow for local evaluations, eliminating the need for an extra request to Stytch. The policy will be refreshed if an authorization check is requested and the RBAC policy was last updated more than 5 minutes ago.
3030
31-
Resources and Roles can be created and managed within the [Dashboard](https://stytch.com/docs/dashboard/rbac). Additionally, [Role assignment](https://stytch.com/docs/b2b/guides/rbac/role-assignment) can be programmatically managed through certain Stytch API endpoints.
31+
Resources and Roles can be created and managed within the [RBAC page](https://stytch.com/docs/dashboard/rbac) in the Dashboard.
32+
Additionally, [Role assignment](https://stytch.com/docs/b2b/guides/rbac/role-assignment) can be programmatically managed through certain Stytch API endpoints.
3233
3334
Check out the [RBAC overview](https://stytch.com/docs/b2b/guides/rbac/overview) to learn more about Stytch's RBAC permissioning model.
3435
@@ -48,7 +49,8 @@ async def policy_async(
4849
4950
When using the backend SDKs, the RBAC Policy will be cached to allow for local evaluations, eliminating the need for an extra request to Stytch. The policy will be refreshed if an authorization check is requested and the RBAC policy was last updated more than 5 minutes ago.
5051
51-
Resources and Roles can be created and managed within the [Dashboard](https://stytch.com/docs/dashboard/rbac). Additionally, [Role assignment](https://stytch.com/docs/b2b/guides/rbac/role-assignment) can be programmatically managed through certain Stytch API endpoints.
52+
Resources and Roles can be created and managed within the [RBAC page](https://stytch.com/docs/dashboard/rbac) in the Dashboard.
53+
Additionally, [Role assignment](https://stytch.com/docs/b2b/guides/rbac/role-assignment) can be programmatically managed through certain Stytch API endpoints.
5254
5355
Check out the [RBAC overview](https://stytch.com/docs/b2b/guides/rbac/overview) to learn more about Stytch's RBAC permissioning model.
5456

stytch/b2b/api/sessions.py

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import jwt
1212

1313
from stytch.b2b.models.sessions import (
14+
AttestResponse,
1415
AuthenticateJWTLocalResponse,
1516
AuthenticateResponse,
1617
AuthorizationCheck,
@@ -532,14 +533,75 @@ async def exchange_access_token_async(
532533
res = await self.async_client.post(url, data, headers)
533534
return ExchangeAccessTokenResponse.from_json(res.response.status, res.json)
534535

536+
def attest(
537+
self,
538+
organization_id: str,
539+
profile_id: str,
540+
token: str,
541+
session_duration_minutes: Optional[int] = None,
542+
session_custom_claims: Optional[Dict[str, Any]] = None,
543+
session_token: Optional[str] = None,
544+
session_jwt: Optional[str] = None,
545+
) -> AttestResponse:
546+
headers: Dict[str, str] = {}
547+
data: Dict[str, Any] = {
548+
"organization_id": organization_id,
549+
"profile_id": profile_id,
550+
"token": token,
551+
}
552+
if session_duration_minutes is not None:
553+
data["session_duration_minutes"] = session_duration_minutes
554+
if session_custom_claims is not None:
555+
data["session_custom_claims"] = session_custom_claims
556+
if session_token is not None:
557+
data["session_token"] = session_token
558+
if session_jwt is not None:
559+
data["session_jwt"] = session_jwt
560+
561+
url = self.api_base.url_for("/v1/b2b/sessions/attest", data)
562+
res = self.sync_client.post(url, data, headers)
563+
return AttestResponse.from_json(res.response.status_code, res.json)
564+
565+
async def attest_async(
566+
self,
567+
organization_id: str,
568+
profile_id: str,
569+
token: str,
570+
session_duration_minutes: Optional[int] = None,
571+
session_custom_claims: Optional[Dict[str, Any]] = None,
572+
session_token: Optional[str] = None,
573+
session_jwt: Optional[str] = None,
574+
) -> AttestResponse:
575+
headers: Dict[str, str] = {}
576+
data: Dict[str, Any] = {
577+
"organization_id": organization_id,
578+
"profile_id": profile_id,
579+
"token": token,
580+
}
581+
if session_duration_minutes is not None:
582+
data["session_duration_minutes"] = session_duration_minutes
583+
if session_custom_claims is not None:
584+
data["session_custom_claims"] = session_custom_claims
585+
if session_token is not None:
586+
data["session_token"] = session_token
587+
if session_jwt is not None:
588+
data["session_jwt"] = session_jwt
589+
590+
url = self.api_base.url_for("/v1/b2b/sessions/attest", data)
591+
res = await self.async_client.post(url, data, headers)
592+
return AttestResponse.from_json(res.response.status, res.json)
593+
535594
def migrate(
536595
self,
537596
session_token: str,
538597
organization_id: str,
539598
session_duration_minutes: Optional[int] = None,
540599
session_custom_claims: Optional[Dict[str, Any]] = None,
541600
) -> MigrateResponse:
542-
"""Migrate a session from an external OIDC compliant endpoint. Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. If the response contains a valid email address, Stytch will attempt to match that email address with an existing in your and create a Stytch Session. You will need to create the member before using this endpoint.
601+
"""Migrate a session from an external OIDC compliant endpoint.
602+
Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. <!-- FIXME more specific dashboard link-->
603+
If the response contains a valid email address, Stytch will attempt to match that email address with an existing in your and create a Stytch Session.
604+
You will need to create the member before using this endpoint.
543605
544606
Fields:
545607
- session_token: The authorization token Stytch will pass in to the external userinfo endpoint.
@@ -580,7 +642,10 @@ async def migrate_async(
580642
session_duration_minutes: Optional[int] = None,
581643
session_custom_claims: Optional[Dict[str, Any]] = None,
582644
) -> MigrateResponse:
583-
"""Migrate a session from an external OIDC compliant endpoint. Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. If the response contains a valid email address, Stytch will attempt to match that email address with an existing in your and create a Stytch Session. You will need to create the member before using this endpoint.
645+
"""Migrate a session from an external OIDC compliant endpoint.
646+
Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. <!-- FIXME more specific dashboard link-->
647+
If the response contains a valid email address, Stytch will attempt to match that email address with an existing in your and create a Stytch Session.
648+
You will need to create the member before using this endpoint.
584649
585650
Fields:
586651
- session_token: The authorization token Stytch will pass in to the external userinfo endpoint.

stytch/b2b/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from stytch.b2b.api.sessions import Sessions
2525
from stytch.b2b.api.sso import SSO
2626
from stytch.b2b.api.totps import TOTPs
27+
from stytch.consumer.api.connected_apps import ConnectedApp
2728
from stytch.consumer.api.fraud import Fraud
2829
from stytch.consumer.api.m2m import M2M
2930
from stytch.consumer.api.project import Project
@@ -66,6 +67,11 @@ def __init__(
6667
)
6768
)
6869

70+
self.connected_app = ConnectedApp(
71+
api_base=self.api_base,
72+
sync_client=self.sync_client,
73+
async_client=self.async_client,
74+
)
6975
self.discovery = Discovery(
7076
api_base=self.api_base,
7177
sync_client=self.sync_client,

0 commit comments

Comments
 (0)