Skip to content

Commit ca07653

Browse files
authored
Merge pull request #452 from kinde-oss/feat/pre-reg-workflow
Pre-registration workflow docs
2 parents 72f4941 + ac0d86f commit ca07653

File tree

11 files changed

+94
-9
lines changed

11 files changed

+94
-9
lines changed

src/components/APICards.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@
2323
<li
2424
class="relative flex list-none flex-col gap-4 rounded-2xl bg-kinde-grey-50 p-12 dark:bg-kinde-grey-900"
2525
>
26-
<h3>Kinde Frontend API</h3>
26+
<h3>Account API</h3>
2727
<p>
28-
For managing the currently signed-in user, includes getting their profile and revoking tokens
28+
For managing the currently signed-in user, includes e.g their profile, roles, permissions, billing info and revoking tokens
2929
</p>
3030
<p
3131
aria-hidden="true"
3232
class="mt-12 text-inherit underline decoration-inherit underline-offset-[6px] transition-all hover:text-current"
3333
>
34-
Explore the Frontend API reference
34+
Explore the Account API reference
3535
</p>
3636
<a
3737
href="/kinde-apis/frontend/"
3838
class="absolute inset-0 rounded-2xl transition duration-200 hover:ring-2 hover:ring-black focus:border-0 focus:shadow-none focus:ring-2 focus:ring-black focus-visible:overflow-hidden focus-visible:border-none focus-visible:shadow-none focus-visible:outline-black focus-visible:ring-2 focus-visible:ring-black dark:hover:ring-white dark:focus:ring-white dark:focus-visible:outline-white dark:focus-visible:ring-white"
3939
>
40-
<span class="sr-only">Go to the Kinde Frontend API reference docs</span>
40+
<span class="sr-only">Go to the Kinde Account API reference docs</span>
4141
</a>
4242
</li>
4343
</ul>

src/content/docs/workflows/about-workflows/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Develop code in your own repo, and push it to a Kinde workflow, where we execute
1515

1616
Currently, you can use the following triggers:
1717

18+
- [user:pre_registration](/workflows/example-workflows/pre-user-registration-workflow/) - when a user attempts to register an account.
1819
- [user:post_authentication](/workflows/example-workflows/workflow-user-post-auth/) fires after the user has completed single factor authentication (e.g. email + password or Google), and before authorization.
1920
- [m2m:token_generation](/workflows/example-workflows/m2m-token-generation-workflow/) - when a request to the token endpoint is made with an M2M application.
2021
- [user:new_password_provided](/workflows/example-workflows/new-password-provided-workflow/) - when a user requests to create or reset a password.
@@ -34,7 +35,7 @@ We will add more triggers (and allow you to create your own) as we develop the f
3435
## Basic workflow rules
3536

3637
- Workflow actions need to be written in TypeScript or plain JavaScript
37-
- Filenames must end in the word 'Workflow' for Kinde to recognize them as containing workflow code. For example, `MFAWorkflow.ts` or `PreauthorizationWorkflow.jsx`
38+
- Filenames must end in the word 'Workflow' for Kinde to recognize them as containing workflow code. For example, `MFAWorkflow.ts` or `PreauthorizationWorkflow.jsx`
3839
- File extensions should be .ts, .js, .tsx or .jsx
3940
- Each trigger can only have one workflow
4041
- Only Kinde-defined triggers are available (for now)

src/content/docs/workflows/bindings/auth-binding.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Prevent the user from accessing the application.
1818

1919
## Available in workflows
2020

21+
- [user:pre_registration](/workflows/example-workflows/pre-user-registration-workflow/)
2122
- [user:post_authentication](/workflows/example-workflows/workflow-user-post-auth/)
2223
- [user:new_password_provided](/workflows/example-workflows/new-password-provided-workflow/)
2324
- [user:existing_password_provided](/workflows/example-workflows/existing-password-provided-workflow/)

src/content/docs/workflows/bindings/env-binding.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ Secret variables will be redacted in the logs.
2121

2222
## Available in workflows
2323

24+
- [user:pre_registration](/workflows/example-workflows/pre-user-registration-workflow/)
2425
- [user:post_authentication](/workflows/example-workflows/workflow-user-post-auth/)
2526
- [m2m:token_generation](/workflows/example-workflows/m2m-token-generation-workflow/)
2627
- [user:new_password_provided](/workflows/example-workflows/new-password-provided-workflow/)
2728
- [user:existing_password_provided](/workflows/example-workflows/existing-password-provided-workflow/)
2829
- [user:tokens_generation](/workflows/example-workflows/user-token-generation/)
2930
- [user:pre_mfa](/workflows/example-workflows/pre-mfa-workflow/)
31+
- [user:plan_selection](/workflows/example-workflows/plan-selection-workflow/)
32+
- [user:plan_cancellation_request](/workflows/example-workflows/plan-cancellation-request-workflow/)
3033

3134
## Configuration
3235

src/content/docs/workflows/bindings/fetch-binding.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ If you are passing sensitive data we recommend you instead use [kinde.secureFetc
1414

1515
## Available in workflows
1616

17+
- [user:pre_registration](/workflows/example-workflows/pre-user-registration-workflow/)
1718
- [user:post_authentication](/workflows/example-workflows/workflow-user-post-auth/)
1819
- [m2m:token_generation](/workflows/example-workflows/m2m-token-generation-workflow/)
1920
- [user:new_password_provided](/workflows/example-workflows/new-password-provided-workflow/)
2021
- [user:existing_password_provided](/workflows/example-workflows/existing-password-provided-workflow/)
2122
- [user:tokens_generation](/workflows/example-workflows/user-token-generation/)
2223
- [user:pre_mfa](/workflows/example-workflows/pre-mfa-workflow/)
24+
- [user:plan_selection](/workflows/example-workflows/plan-selection-workflow/)
25+
- [user:plan_cancellation_request](/workflows/example-workflows/plan-cancellation-request-workflow/)
2326

2427
## Configuration
2528

src/content/docs/workflows/bindings/secure-fetch-binding.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ The `kinde.secureFetch` binding allows you to make POST requests to external API
1313

1414
## Available in workflows
1515

16+
- [user:pre_registration](/workflows/example-workflows/pre-user-registration-workflow/)
1617
- [user:post_authentication](/workflows/example-workflows/workflow-user-post-auth/)
1718
- [m2m:token_generation](/workflows/example-workflows/m2m-token-generation-workflow/)
1819
- [user:new_password_provided](/workflows/example-workflows/new-password-provided-workflow/)
1920
- [user:existing_password_provided](http://localhost:4321/workflows/example-workflows/existing-password-provided-workflow/)
2021
- [user:tokens_generation](/workflows/example-workflows/user-token-generation/)
2122
- [user:pre_mfa](http://localhost:4321/workflows/example-workflows/pre-mfa-workflow/)
23+
- [user:plan_selection](/workflows/example-workflows/plan-selection-workflow/)
24+
- [user:plan_cancellation_request](/workflows/example-workflows/plan-cancellation-request-workflow/)
2225

2326
## Configuration
2427

src/content/docs/workflows/bindings/url-binding.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ The `url` binding allows you to access the native JavaScript `URLSearchParams` A
1212

1313
## Available in workflows
1414

15+
- [user:pre_registration](/workflows/example-workflows/pre-user-registration-workflow/)
1516
- [user:post_authentication](/workflows/example-workflows/workflow-user-post-auth/)
1617
- [m2m:token_generation](/workflows/example-workflows/m2m-token-generation-workflow/)
1718
- [user:new_password_provided](/workflows/example-workflows/new-password-provided-workflow/)
1819
- [user:existing_password_provided](/workflows/example-workflows/existing-password-provided-workflow/)
1920
- [user:tokens_generation](/workflows/example-workflows/user-token-generation/)
2021
- [user:pre_mfa](/workflows/example-workflows/pre-mfa-workflow/)
22+
- [user:plan_selection](/workflows/example-workflows/plan-selection-workflow/)
23+
- [user:plan_cancellation_request](/workflows/example-workflows/plan-cancellation-request-workflow/)
2124

2225
## Configuration
2326

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
page_id: 69b42223-701c-4707-b961-e52c7cb05399
3+
title: User pre-registration workflow
4+
sidebar:
5+
order: 7
6+
relatedArticles:
7+
- 62fafade-5d33-4f85-9fd2-712c533db3d0
8+
- f499ebb0-d7f5-4244-bf92-6bf0f6082b62
9+
---
10+
11+
Trigger: `user:pre_registration`
12+
13+
This trigger fires after the user has completed single factor authentication (e.g email + password or Google) but before a user record is created in Kinde.
14+
15+
<Aside type="warning">
16+
17+
At this stage the user is not authorized - we have not checked organization access or carried out MFA.
18+
19+
</Aside>
20+
21+
## Example use cases
22+
23+
### IP address checks
24+
25+
Block user registrations from suspicious IP addresses.
26+
27+
### Block disposable email addresses
28+
29+
Refuse disposable email addresses to prevent spam registrations.
30+
31+
## Workflow code
32+
33+
### Sample event object
34+
35+
The main argument provided to your code is the Kinde workflow `event` object which has two keys `request` and `context`. This gives you access to the reason the workflow was triggered and additional relevant datapoints. Here's an example:
36+
37+
```json
38+
{
39+
"request": {
40+
"ip": "***",
41+
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0",
42+
"authUrlParams": {
43+
"state": "b9ea1131f7796a10abe8eac1b48c715575a0ffd349fb9c602e13d824",
44+
"orgCode": "org_12345667",
45+
"clientId": "cad2d86b1ac645e1957889fcb1eff0f9",
46+
"redirectUri": "http://localhost:3000"
47+
}
48+
},
49+
"context": {
50+
"auth": {
51+
"connectionId": "conn_0194ee03c226d48c6858d5a412359ed2"
52+
},
53+
"domains": {
54+
"kindeDomain": "https://newbus.localkinde.me"
55+
},
56+
"workflow": {
57+
"trigger": "user:pre_registration"
58+
},
59+
"application": {
60+
"clientId": "cad2d86b1ac645e1957889fcb1eff0f9"
61+
}
62+
}
63+
}
64+
```
65+
66+
### Example workflows
67+
68+
See examples on GitHub:
69+
70+
[Prevent disposable email sign ups](https://github.com/kinde-starter-kits/workflow-examples/blob/main/preUserRegistration/blockDisposableEmails.ts) - Check the email address against a list of disposable email domains and block the registration if it matches.

src/content/docs/workflows/getting-started/workflow-examples.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You can use this in conjunction with the example files below to create more comp
2323

2424
These can be used as a starting point for your own workflows. You can find them in the [Kinde GitHub repo](https://github.com/kinde-starter-kits/workflow-examples). Either copy the files you need into your existing project or the base template above.
2525

26+
- [Block disposable emails](https://github.com/kinde-starter-kits/workflow-examples/blob/main/preUserRegistration/blockDisposableEmails.ts) - Prevent users from creating accounts with disposable email addresses.
2627
- [Drip feed migration](https://github.com/kinde-starter-kits/workflow-examples/blob/main/existingPassword/dripFeedMigrationWorkflow.ts) - Shows how to check a password against an external database before creating the user in Kinde.
2728
- [Sync passwords to another system](https://github.com/kinde-starter-kits/workflow-examples/blob/main/newPassword/securelySyncPasswordWorkflow.ts) - Use encryption keys to securely keep passwords in sync between systems.
2829
- [Custom password validation](https://github.com/kinde-starter-kits/workflow-examples/blob/main/newPassword/customPasswordValidationWorkflow.ts) - Shows how to validate a password against your own rules.

src/pages/kinde-apis.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import APICards from "@components/APICards.astro";
66
<StarlightPage
77
frontmatter={{
88
title: "Kinde APIs",
9-
description: "Use the Management API for account admin tasks, or the Frontend API for user profile and token management.",
9+
description: "Use the Management API for account admin tasks, or the Account API for current user and token management.",
1010
template: "splash",
1111
editUrl: false,
1212
page_id: "31b91e66-7f86-4fd9-b3c7-b4d0a2a86d6e"

0 commit comments

Comments
 (0)