Skip to content

Commit c6af8fc

Browse files
ci-stytchStytch Codegen Botbgier-stytch
authored
Consumer RBAC Release (#114)
* Consumer RBAC Release * Add in the organization slug --------- Co-authored-by: Stytch Codegen Bot <support@stytch.com> Co-authored-by: Brandon Gier <bgier@stytch.com>
1 parent becd1f4 commit c6af8fc

22 files changed

Lines changed: 613 additions & 121 deletions

File tree

stytch/src/main/kotlin/com/stytch/java/b2b/api/organizations/Organizations.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public interface Organizations {
4848
/**
4949
* Creates an Organization. An `organization_name` and a unique `organization_slug` are required.
5050
*
51-
* By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED`, and `mfa_policy` will be set to
52-
* `OPTIONAL` if no Organization authentication settings are explicitly defined in the request.
51+
* If no Organization authentication setting parameters are passed in, `email_invites` will default to `ALL_ALLOWED` so
52+
* that the Organization has a way to add Members. Otherwise, `email_invites` will default to `NOT_ALLOWED`.
5353
*
5454
* *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn
5555
* more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
@@ -59,8 +59,8 @@ public interface Organizations {
5959
/**
6060
* Creates an Organization. An `organization_name` and a unique `organization_slug` are required.
6161
*
62-
* By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED`, and `mfa_policy` will be set to
63-
* `OPTIONAL` if no Organization authentication settings are explicitly defined in the request.
62+
* If no Organization authentication setting parameters are passed in, `email_invites` will default to `ALL_ALLOWED` so
63+
* that the Organization has a way to add Members. Otherwise, `email_invites` will default to `NOT_ALLOWED`.
6464
*
6565
* *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn
6666
* more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
@@ -73,8 +73,8 @@ public interface Organizations {
7373
/**
7474
* Creates an Organization. An `organization_name` and a unique `organization_slug` are required.
7575
*
76-
* By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED`, and `mfa_policy` will be set to
77-
* `OPTIONAL` if no Organization authentication settings are explicitly defined in the request.
76+
* If no Organization authentication setting parameters are passed in, `email_invites` will default to `ALL_ALLOWED` so
77+
* that the Organization has a way to add Members. Otherwise, `email_invites` will default to `NOT_ALLOWED`.
7878
*
7979
* *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn
8080
* more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.

stytch/src/main/kotlin/com/stytch/java/b2b/api/organizationsmembers/OrganizationsMembers.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ public interface Members {
433433
* The member will receive an Email Magic Link that expires in 5 minutes. If they do not verify their new email address in
434434
* that timeframe, the email
435435
* will be freed up for other members to use.
436+
*
437+
* The Magic Link will redirect to your `login_redirect_url` (or the configured default if one isn't provided), and you
438+
* should invoke the [Authenticate Magic Link](https://stytch.com/docs/b2b/api/authenticate-magic-link) endpoint as normal
439+
* to complete the flow.
436440
*/
437441
public suspend fun startEmailUpdate(
438442
data: StartEmailUpdateRequest,
@@ -452,6 +456,10 @@ public interface Members {
452456
* The member will receive an Email Magic Link that expires in 5 minutes. If they do not verify their new email address in
453457
* that timeframe, the email
454458
* will be freed up for other members to use.
459+
*
460+
* The Magic Link will redirect to your `login_redirect_url` (or the configured default if one isn't provided), and you
461+
* should invoke the [Authenticate Magic Link](https://stytch.com/docs/b2b/api/authenticate-magic-link) endpoint as normal
462+
* to complete the flow.
455463
*/
456464
public fun startEmailUpdate(
457465
data: StartEmailUpdateRequest,
@@ -472,6 +480,10 @@ public interface Members {
472480
* The member will receive an Email Magic Link that expires in 5 minutes. If they do not verify their new email address in
473481
* that timeframe, the email
474482
* will be freed up for other members to use.
483+
*
484+
* The Magic Link will redirect to your `login_redirect_url` (or the configured default if one isn't provided), and you
485+
* should invoke the [Authenticate Magic Link](https://stytch.com/docs/b2b/api/authenticate-magic-link) endpoint as normal
486+
* to complete the flow.
475487
*/
476488
public fun startEmailUpdateCompletable(
477489
data: StartEmailUpdateRequest,

stytch/src/main/kotlin/com/stytch/java/b2b/api/otpsms/OTPSms.kt

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ public interface Sms {
4343
* their phone number. In that case, this endpoint should only be used for subsequent authentication events, such as
4444
* prompting a Member for an OTP again after a period of inactivity.
4545
*
46-
* Passing an intermediate session token, session token, or session JWT is not required, but if passed must match the
47-
* Member ID passed.
46+
* If the Member already has an active MFA factor, then passing an intermediate session token, session token, or session
47+
* JWT with the existing MFA factor on it is required to prevent bypassing MFA.
48+
*
49+
* Otherwise, passing an intermediate session token, session token, or session JWT is not required, but if passed must
50+
* match the `member_id` passed.
4851
*
4952
* ### Cost to send SMS OTP
5053
* Before configuring SMS or WhatsApp OTPs, please review how Stytch
@@ -56,8 +59,9 @@ public interface Sms {
5659
*
5760
* __Note:__ SMS to phone numbers outside of the US and Canada is disabled by default for customers who did not use SMS
5861
* prior to October 2023. If you're interested in sending international SMS, please add those countries to your Project's
59-
* allowlist via [the API](https://stytch.com/docs/workspace-management/pwa/country-code-allowlist-object), and
60-
* [add credit card details](https://stytch.com/docs/dashboard/settings/billing) to your account.
62+
* allowlist via the [Dashboard](https://stytch.com/dashboard/country-code-allowlists) or
63+
* [Programmatic Workspace Actions](https://stytch.com/docs/workspace-management/pwa/set-allowed-country-codes), and
64+
* [add credit card details](https://stytch.com/dashboard/settings/billing) to your account.
6165
*/
6266
public suspend fun send(data: SendRequest): StytchResult<SendResponse>
6367

@@ -81,8 +85,11 @@ public interface Sms {
8185
* their phone number. In that case, this endpoint should only be used for subsequent authentication events, such as
8286
* prompting a Member for an OTP again after a period of inactivity.
8387
*
84-
* Passing an intermediate session token, session token, or session JWT is not required, but if passed must match the
85-
* Member ID passed.
88+
* If the Member already has an active MFA factor, then passing an intermediate session token, session token, or session
89+
* JWT with the existing MFA factor on it is required to prevent bypassing MFA.
90+
*
91+
* Otherwise, passing an intermediate session token, session token, or session JWT is not required, but if passed must
92+
* match the `member_id` passed.
8693
*
8794
* ### Cost to send SMS OTP
8895
* Before configuring SMS or WhatsApp OTPs, please review how Stytch
@@ -94,8 +101,9 @@ public interface Sms {
94101
*
95102
* __Note:__ SMS to phone numbers outside of the US and Canada is disabled by default for customers who did not use SMS
96103
* prior to October 2023. If you're interested in sending international SMS, please add those countries to your Project's
97-
* allowlist via [the API](https://stytch.com/docs/workspace-management/pwa/country-code-allowlist-object), and
98-
* [add credit card details](https://stytch.com/docs/dashboard/settings/billing) to your account.
104+
* allowlist via the [Dashboard](https://stytch.com/dashboard/country-code-allowlists) or
105+
* [Programmatic Workspace Actions](https://stytch.com/docs/workspace-management/pwa/set-allowed-country-codes), and
106+
* [add credit card details](https://stytch.com/dashboard/settings/billing) to your account.
99107
*/
100108
public fun send(
101109
data: SendRequest,
@@ -122,8 +130,11 @@ public interface Sms {
122130
* their phone number. In that case, this endpoint should only be used for subsequent authentication events, such as
123131
* prompting a Member for an OTP again after a period of inactivity.
124132
*
125-
* Passing an intermediate session token, session token, or session JWT is not required, but if passed must match the
126-
* Member ID passed.
133+
* If the Member already has an active MFA factor, then passing an intermediate session token, session token, or session
134+
* JWT with the existing MFA factor on it is required to prevent bypassing MFA.
135+
*
136+
* Otherwise, passing an intermediate session token, session token, or session JWT is not required, but if passed must
137+
* match the `member_id` passed.
127138
*
128139
* ### Cost to send SMS OTP
129140
* Before configuring SMS or WhatsApp OTPs, please review how Stytch
@@ -135,8 +146,9 @@ public interface Sms {
135146
*
136147
* __Note:__ SMS to phone numbers outside of the US and Canada is disabled by default for customers who did not use SMS
137148
* prior to October 2023. If you're interested in sending international SMS, please add those countries to your Project's
138-
* allowlist via [the API](https://stytch.com/docs/workspace-management/pwa/country-code-allowlist-object), and
139-
* [add credit card details](https://stytch.com/docs/dashboard/settings/billing) to your account.
149+
* allowlist via the [Dashboard](https://stytch.com/dashboard/country-code-allowlists) or
150+
* [Programmatic Workspace Actions](https://stytch.com/docs/workspace-management/pwa/set-allowed-country-codes), and
151+
* [add credit card details](https://stytch.com/dashboard/settings/billing) to your account.
140152
*/
141153
public fun sendCompletable(data: SendRequest): CompletableFuture<StytchResult<SendResponse>>
142154

stytch/src/main/kotlin/com/stytch/java/b2b/api/rbac/RBAC.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public interface RBAC {
3131
* extra request to Stytch. The policy will be refreshed if an authorization check is requested and the RBAC policy was
3232
* last updated more than 5 minutes ago.
3333
*
34-
* Resources and Roles can be created and managed within the [RBAC page](https://stytch.com/docs/dashboard/rbac) in the
34+
* Resources and Roles can be created and managed within the [RBAC page](https://stytch.com/dashboard/rbac) in the
3535
* Dashboard.
3636
* Additionally, [Role assignment](https://stytch.com/docs/b2b/guides/rbac/role-assignment) can be programmatically
3737
* managed through certain Stytch API endpoints.
@@ -49,7 +49,7 @@ public interface RBAC {
4949
* extra request to Stytch. The policy will be refreshed if an authorization check is requested and the RBAC policy was
5050
* last updated more than 5 minutes ago.
5151
*
52-
* Resources and Roles can be created and managed within the [RBAC page](https://stytch.com/docs/dashboard/rbac) in the
52+
* Resources and Roles can be created and managed within the [RBAC page](https://stytch.com/dashboard/rbac) in the
5353
* Dashboard.
5454
* Additionally, [Role assignment](https://stytch.com/docs/b2b/guides/rbac/role-assignment) can be programmatically
5555
* managed through certain Stytch API endpoints.
@@ -70,7 +70,7 @@ public interface RBAC {
7070
* extra request to Stytch. The policy will be refreshed if an authorization check is requested and the RBAC policy was
7171
* last updated more than 5 minutes ago.
7272
*
73-
* Resources and Roles can be created and managed within the [RBAC page](https://stytch.com/docs/dashboard/rbac) in the
73+
* Resources and Roles can be created and managed within the [RBAC page](https://stytch.com/dashboard/rbac) in the
7474
* Dashboard.
7575
* Additionally, [Role assignment](https://stytch.com/docs/b2b/guides/rbac/role-assignment) can be programmatically
7676
* managed through certain Stytch API endpoints.

stytch/src/main/kotlin/com/stytch/java/b2b/api/sessions/Sessions.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,15 @@ public interface Sessions {
315315

316316
/**
317317
* Exchange an auth token issued by a trusted identity provider for a Stytch session. You must first register a Trusted
318-
* Auth Token profile in the Stytch dashboard [here](https://stytch.com/docs/dashboard/trusted-auth-tokens). If a session
318+
* Auth Token profile in the Stytch dashboard [here](https://stytch.com/dashboard/trusted-auth-tokens). If a session
319319
* token or session JWT is provided, it will add the trusted auth token as an authentication factor to the existing
320320
* session.
321321
*/
322322
public suspend fun attest(data: AttestRequest): StytchResult<AttestResponse>
323323

324324
/**
325325
* Exchange an auth token issued by a trusted identity provider for a Stytch session. You must first register a Trusted
326-
* Auth Token profile in the Stytch dashboard [here](https://stytch.com/docs/dashboard/trusted-auth-tokens). If a session
326+
* Auth Token profile in the Stytch dashboard [here](https://stytch.com/dashboard/trusted-auth-tokens). If a session
327327
* token or session JWT is provided, it will add the trusted auth token as an authentication factor to the existing
328328
* session.
329329
*/
@@ -334,7 +334,7 @@ public interface Sessions {
334334

335335
/**
336336
* Exchange an auth token issued by a trusted identity provider for a Stytch session. You must first register a Trusted
337-
* Auth Token profile in the Stytch dashboard [here](https://stytch.com/docs/dashboard/trusted-auth-tokens). If a session
337+
* Auth Token profile in the Stytch dashboard [here](https://stytch.com/dashboard/trusted-auth-tokens). If a session
338338
* token or session JWT is provided, it will add the trusted auth token as an authentication factor to the existing
339339
* session.
340340
*/
@@ -343,8 +343,7 @@ public interface Sessions {
343343
/**
344344
* Migrate a session from an external OIDC compliant endpoint.
345345
* Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the
346-
* [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. <!-- FIXME more
347-
* specific dashboard link-->
346+
* [Dashboard](https://stytch.com/dashboard/migrations), and then perform a lookup using the `session_token`.
348347
* If the response contains a valid email address, Stytch will attempt to match that email address with an existing Member
349348
* in your Organization and create a Stytch Session.
350349
* You will need to create the member before using this endpoint.
@@ -354,8 +353,7 @@ public interface Sessions {
354353
/**
355354
* Migrate a session from an external OIDC compliant endpoint.
356355
* Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the
357-
* [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. <!-- FIXME more
358-
* specific dashboard link-->
356+
* [Dashboard](https://stytch.com/dashboard/migrations), and then perform a lookup using the `session_token`.
359357
* If the response contains a valid email address, Stytch will attempt to match that email address with an existing Member
360358
* in your Organization and create a Stytch Session.
361359
* You will need to create the member before using this endpoint.
@@ -368,8 +366,7 @@ public interface Sessions {
368366
/**
369367
* Migrate a session from an external OIDC compliant endpoint.
370368
* Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the
371-
* [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. <!-- FIXME more
372-
* specific dashboard link-->
369+
* [Dashboard](https://stytch.com/dashboard/migrations), and then perform a lookup using the `session_token`.
373370
* If the response contains a valid email address, Stytch will attempt to match that email address with an existing Member
374371
* in your Organization and create a Stytch Session.
375372
* You will need to create the member before using this endpoint.
@@ -823,6 +820,7 @@ internal class SessionsImpl(
823820
} ?: throw JWTException.JwtMissingClaims
824821
val orgSessionClaims = jwtClaims.payload.claimsMap["https://stytch.com/organization"] as? Map<*, *>
825822
val organizationId = orgSessionClaims?.get("organization_id") as String
823+
val organizationSlug = orgSessionClaims?.get("slug") as String
826824
if (authorizationCheck != null) {
827825
if (stytchSessionClaim.roles == null) {
828826
throw JWTException.MissingRolesClaim
@@ -846,6 +844,7 @@ internal class SessionsImpl(
846844
expiresAt = Instant.parse(stytchSessionClaim.expiresAt),
847845
customClaims = jwtClaims.customClaims,
848846
roles = stytchSessionClaim.roles ?: emptyList(),
847+
organizationSlug = organizationSlug,
849848
),
850849
)
851850
} catch (e: JWTException.JwtTooOld) {

stytch/src/main/kotlin/com/stytch/java/b2b/api/totps/TOTPs.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,23 @@ public interface TOTPs {
2929
* Create a new TOTP instance for a Member. The Member can use the authenticator application of their choice to scan the
3030
* QR code or enter the secret.
3131
*
32-
* Passing an intermediate session token, session token, or session JWT is not required, but if passed must match the
33-
* Member ID passed.
32+
* If the Member already has an active MFA factor, then passing an intermediate session token, session token, or session
33+
* JWT with the existing MFA factor on it is required to prevent bypassing MFA.
34+
*
35+
* Otherwise, passing an intermediate session token, session token, or session JWT is not required, but if passed must
36+
* match the `member_id` passed.
3437
*/
3538
public suspend fun create(data: CreateRequest): StytchResult<CreateResponse>
3639

3740
/**
3841
* Create a new TOTP instance for a Member. The Member can use the authenticator application of their choice to scan the
3942
* QR code or enter the secret.
4043
*
41-
* Passing an intermediate session token, session token, or session JWT is not required, but if passed must match the
42-
* Member ID passed.
44+
* If the Member already has an active MFA factor, then passing an intermediate session token, session token, or session
45+
* JWT with the existing MFA factor on it is required to prevent bypassing MFA.
46+
*
47+
* Otherwise, passing an intermediate session token, session token, or session JWT is not required, but if passed must
48+
* match the `member_id` passed.
4349
*/
4450
public fun create(
4551
data: CreateRequest,
@@ -50,8 +56,11 @@ public interface TOTPs {
5056
* Create a new TOTP instance for a Member. The Member can use the authenticator application of their choice to scan the
5157
* QR code or enter the secret.
5258
*
53-
* Passing an intermediate session token, session token, or session JWT is not required, but if passed must match the
54-
* Member ID passed.
59+
* If the Member already has an active MFA factor, then passing an intermediate session token, session token, or session
60+
* JWT with the existing MFA factor on it is required to prevent bypassing MFA.
61+
*
62+
* Otherwise, passing an intermediate session token, session token, or session JWT is not required, but if passed must
63+
* match the `member_id` passed.
5564
*/
5665
public fun createCompletable(data: CreateRequest): CompletableFuture<StytchResult<CreateResponse>>
5766

0 commit comments

Comments
 (0)