Skip to content

Commit 7efce48

Browse files
Merge pull request #402 from kinde-oss/Feat/workflow-docs
Big update to workflow docs by @DaveOrDead. New topics, updated section, more examples, generally awesome.
2 parents 518a3c0 + b97aa84 commit 7efce48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2545
-2418
lines changed

package-lock.json

Lines changed: 1053 additions & 1721 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/docs/authenticate/auth-guides/pass-params-idp.mdx

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ relatedArticles:
1212
You can pass provider-specific parameters to an Identity Provider (IdP) during authentication. These are also known as 'upstream params'. The values your pass can either be static per connection or dynamic per user.
1313

1414
There's a number of reason why you might want to use upstream params:
15+
1516
- to create a smoother sign in experience - by passing the email through
1617
- to offer an account switcher (such as the Google account switcher) during sign in
1718

18-
Upstream params are available for OAuth 2.0 connections, e.g. [social connections](/authenticate/social-sign-in/add-social-sign-in/), [Entra ID OAuth 2.0 enterprise connection](/authenticate/enterprise-connections/azure/), and as part of [advanced configurations](/authenticate/enterprise-connections/advanced-saml-configurations/) in SAML connections.
19+
Upstream params are available for OAuth 2.0 connections, e.g. [social connections](/authenticate/social-sign-in/add-social-sign-in/), [Entra ID OAuth 2.0 enterprise connection](/authenticate/enterprise-connections/azure/), and as part of [advanced configurations](/authenticate/enterprise-connections/advanced-saml-configurations/) in SAML connections.
1920

2021
## Limitations
2122

@@ -31,28 +32,26 @@ The Upstream parameter field accepts JSON and the structure is as follows:
3132

3233
```json
3334
{
34-
"<param_name_to_pass>": {
35+
"<param_name_to_pass>": {
3536
"value": "<your_hardcoded_value>"
3637
}
3738
}
38-
3939
```
4040

4141
Replace `<param_name_to_pass>` with the name of the parameter you wish to pass upstream to the IDP.
4242
Replace `<your_hardcoded_value>` with the value of the parameter you wish to pass upstream.
4343

4444
### Example: Force the google account selector to display on sign in
4545

46-
If you want Google to always show the account selector even if the user is already logged in with a Google account, pass the `prompt=select_account` parameter from Kinde.
46+
If you want Google to always show the account selector even if the user is already logged in with a Google account, pass the `prompt=select_account` parameter from Kinde.
4747
This is how that would look:
4848

4949
```json
5050
{
51-
"prompt": {
51+
"prompt": {
5252
"value": "select_account"
5353
}
5454
}
55-
5655
```
5756

5857
Now, when your user clicks on the Google button and Kinde creates the URL to redirect to Google, it will append`&prompt=select_account`.
@@ -65,34 +64,34 @@ This is the structure.
6564

6665
```json
6766
{
68-
"<param_name_to_pass>": {
67+
"<param_name_to_pass>": {
6968
"alias": "<dynamic_param_name>"
7069
}
7170
}
72-
7371
```
7472

7573
The `alias` keyword tells Kinde which parameter from your auth url to use, and the value to pass upstream to the IDP.
7674

7775
Here is an example where we provide `login_hint` as part of the auth URL, where the email [`&[email protected]`](mailto:&[email protected]) is included on the URL.
7876

7977
```html
80-
https://<your_kinde_sudomain>.kinde.com/oauth2/auth
81-
?response_type=code
82-
&client_id=<your_kinde_client_id>
83-
&redirect_uri=<your_app_redirect_url>
84-
&scope=openid%20profile%20email
85-
&state=abc
86-
78+
https://<your_kinde_subdomain
79+
>.kinde.com/oauth2/auth ?response_type=code &client_id=<your_kinde_client_id>
80+
&redirect_uri=<your_app_redirect_url>
81+
&scope=openid%20profile%20email &state=abc
82+
&[email protected]</your_app_redirect_url
83+
></your_kinde_client_id
84+
></your_kinde_subdomain
85+
>
8786
```
8887

8988
In this case both Kinde and the IDP use the parameter name `login_hint` so the configuration is the same on both sides:
9089
Add this to the connection configuration:
9190

92-
}
91+
}
9392
}
9493

95-
```
94+
````
9695
9796
In this case we are saying pass the `login_hint` parameter upstream to the IDP with the value Kinde received in the `login_hint` auth url param. So `&[email protected]` would be passed on to the provider.
9897
@@ -104,7 +103,7 @@ Where the `alias` becomes especially powerful is when you want to re-map a param
104103
"alias": "login_hint"
105104
}
106105
}
107-
```
106+
````
108107

109108
In this case we are saying pass the `username` parameter upstream to the IDP with the value Kinde received in the `login_hint` auth url param. We remap the email value from `login_hint` to `username` and the parameter `&[email protected]` would be passed on to the IDP.
110109

@@ -118,9 +117,9 @@ If the user enters `[email protected]` in the Kinde email field with the followi
118117

119118
```json
120119
{
121-
"login_hint": {
122-
"alias": "login_hint"
123-
}
120+
"login_hint": {
121+
"alias": "login_hint"
122+
}
124123
}
125124
```
126125

@@ -130,14 +129,13 @@ You can send multple parameters this way and mix-and-match between dynamic and s
130129

131130
```json
132131
{
133-
"prompt": {
134-
"value": "login"
135-
},
136-
"username": {
137-
"alias": "login_hint"
138-
}
132+
"prompt": {
133+
"value": "login"
134+
},
135+
"username": {
136+
"alias": "login_hint"
137+
}
139138
}
140-
141139
```
142140

143141
This would result in `&prompt=login&[email protected]`

src/content/docs/authenticate/custom-configurations/redirect-users.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Because it is just a string, you can leverage it to store additional information
6464
3. When you redirect your user to Kinde to complete the authentication flow, include the random string as the `state` param:
6565

6666
```jsx
67-
https://<your_kinde_sudomain>.kinde.com/oauth2/auth
67+
https://<your_kinde_subdomain>.kinde.com/oauth2/auth
6868
?response_type=code
6969
&client_id=<your_kinde_client_id>
7070
&redirect_uri=<your_app_redirect_url>

src/content/docs/build/set-up-options/sync-git-code.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To use workflows and other BYO code features, you need to sync your git-stored c
1212

1313
## Change the git repo
1414

15-
If you are connecting your repo to Kinde for the first time, see [Connect your workflows repo and branch](/workflows/about-workflows/connect-repo-for-workflows/)
15+
If you are connecting your repo to Kinde for the first time, see [Connect your workflows repo and branch](/workflows/getting-started/connect-repo-for-workflows/)
1616

1717
1. Go to **Settings > Git repo**.
1818
2. Select **Change repo**
@@ -22,7 +22,7 @@ If you are connecting your repo to Kinde for the first time, see [Connect your w
2222

2323
## Preview workflow code
2424

25-
If you are on an eligible plan, we recommend enabling code preview for your workflow. This lets you [test deployed code](/workflows/manage-workflows/preview-workflows/) before you make it live for customers.
25+
If you are on an eligible plan, we recommend enabling code preview for your workflow. This lets you [test deployed code](/workflows/testing/preview-workflows/) before you make it live for customers.
2626

2727
1. Go to **Settings > Git repo**.
2828
2. Select the **Enable preview mode** option.

src/content/docs/developer-tools/about/using-kinde-without-an-sdk.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ You will need to use this redirect URL in the following step.
4646
Your users must be redirected from your product to Kinde to sign up or sign in securely. The redirect URL on your product side would look like the following:
4747

4848
```markdown
49-
https://<your_kinde_sudomain>.kinde.com/oauth2/auth
49+
https://<your_kinde_subdomain>.kinde.com/oauth2/auth
5050
?response_type=code
5151
&client_id=<your_kinde_client_id>
5252
&redirect_uri=<your_app_redirect_url>
@@ -61,6 +61,7 @@ Kinde supports all the standard OAuth 2 request parameters as well as a few addi
6161
Kinde also supports the PKCE extension, in which case the `code_challenge` and `code_challenge_method` parameters are also required. This is recommended for mobile apps and single page applications (SPAs).
6262

6363
## Handling successful auth for desktop and mobile apps
64+
6465
If you offer mobile and desktop apps, as well as access through a browser, you'll need to handle the post-authentication browser state. Rather than leaving a hanging screen, you can show users a success page. To do this, add the `is_use_auth_success_page` parameter to the authorization URL. See the [Request prameters](/developer-tools/about/using-kinde-without-an-sdk/#request-parameters) section below.
6566

6667
## Handling the callback
@@ -84,7 +85,7 @@ client_id=<your_kinde_client_id>
8485
&client_secret=<your_kinde_client_secret>
8586
&grant_type=authorization_code
8687
&redirect_uri=<your_app_redirect_url>
87-
&code=<CALLBACK_AUTHORIZATION_CODE>
88+
&code=<CALLBACK_AUTHORIZATION_CODE>
8889
```
8990

9091
Make sure you replace the `<values>` with your own credentials.

src/content/docs/get-started/guides/byo-code.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
page_id: 5c7de06d-f065-4a8a-81cb-f6914ee374f7
3-
title: Bring your own project and code to Kinde
3+
title: Connect existing code base to Kinde
44
sidebar:
55
order: 3
66
relatedArticles:

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ title: About workflows
44
sidebar:
55
order: 1
66
relatedArticles:
7-
- d672fca7-6c6a-49f8-85c9-6e86ce99f440
8-
- 8554d648-fc2f-4ef9-aaa9-4f27b3c05205
7+
- b5a147ac-c189-40b5-8300-b518dd353f91
8+
- a49abb3b-467f-4b4c-aba2-07ec360b3f19
99
- d360c480-49a8-47d3-b178-1abd34ae669f
1010
---
1111

12-
In Kinde, workflows exist to give you (almost) unlimited power over how Kinde works for you.
12+
In Kinde, workflows exist to give you (almost) unlimited power over how Kinde works for you.
1313

14-
Develop code in your own repo, and push it to a Kinde workflow, where we execute it in ways that you define, triggered by Kinde events.
14+
Develop code in your own repo, and push it to a Kinde workflow, where we execute it in ways that you define, triggered by Kinde events.
1515

1616
Currently, you can use the following triggers:
1717

18-
- `user:post_authentication` fires after the user has completed single factor authentication (e.g. email + password or Google), and before authorization.
19-
- `m2m:token_generation` - when a request to the token endpoint is made with an M2M application.
20-
- `user:new_password_provided` - when a user requests to create or reset a password.
21-
- `user:existing_password_provided` - when a user hasn’t signed in, but they have requested to sign in and given their current password.
22-
- `user:tokens_generation` - An ID or access token is generated after authentication or refresh token request.
23-
- `user:pre_mfa` - where the user has completed single factor authentication (e.g. email + password or Google) and determined which organization (if any) they are trying to access. This trigger is only available to customers on a Kinde Scale plan.
18+
- [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.
19+
- [m2m:token_generation](/workflows/example-workflows/m2m-token-generation-workflow/) - when a request to the token endpoint is made with an M2M application.
20+
- [user:new_password_provided](/workflows/example-workflows/new-password-provided-workflow/) - when a user requests to create or reset a password.
21+
- [user:existing_password_provided](/workflows/example-workflows/existing-password-provided-workflow/) - when a user hasn’t signed in, but they have requested to sign in and given their current password.
22+
- [user:token_generation](/workflows/example-workflows/user-token-generation/) - An ID or access token is generated after authentication or refresh token request.
23+
- [user:pre_mfa](/workflows/example-workflows/pre-mfa-workflow/) - where the user has completed single factor authentication (e.g. email + password or Google) and determined which organization (if any) they are trying to access. This trigger is only available to customers on a Kinde Scale plan.
2424

2525
We will add more triggers (and allow you to create your own) as we develop the feature.
2626

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
page_id: a5c850c0-0251-44ea-adef-73606694ace3
3+
title: kinde.accessToken
4+
sidebar:
5+
order: 2
6+
relatedArticles:
7+
- d170e5f0-c6c0-4323-90c9-1d722c837384
8+
- 5917da0f-24f0-48df-a387-aca03ce1fe7a
9+
---
10+
11+
The `kinde.accessToken` binding lets you modify access tokens for the current user. When you add custom claims, they are included in the access token returned to the client.
12+
13+
## Methods
14+
15+
### `setCustomClaim(name: string, value: any): void`
16+
17+
Adds a custom claim to the access token. The claim will be available when the token is returned to the client.
18+
19+
## Available in workflows
20+
21+
- [user:tokens_generation](/workflows/example-workflows/user-token-generation/)
22+
23+
## Configuration
24+
25+
```js
26+
export const workflowSettings = {
27+
// ...other settings
28+
bindings: {"kinde.accessToken": {}}
29+
};
30+
```
31+
32+
## Usage
33+
34+
### Using the Kinde infrastructure library (recommended)
35+
36+
The [Kinde infrastructure library](https://github.com/kinde-oss/infrastructure) provides type-safe access token modification:
37+
38+
```js
39+
import { accessTokenCustomClaims } from "@kinde/infrastructure";
40+
41+
export default async function (event: onUserTokenGeneratedEvent) {
42+
const accessToken = accessTokenCustomClaims<{
43+
hello: string;
44+
ipAddress: string;
45+
}>();
46+
47+
accessToken.hello = "Hello there!";
48+
accessToken.ipAddress = event.request.ip;
49+
};
50+
```
51+
52+
### Using the low-level API
53+
54+
If you're not using the infrastructure library, you can modify the access token directly:
55+
56+
```js
57+
kinde.accessToken.setCustomClaim("hello", "Hello there!");
58+
kinde.accessToken.setCustomClaim("ipAddress", event.request.ip);
59+
```
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
page_id: 2b401ba2-b802-4939-b86f-d5e28eb4559b
3+
title: kinde.auth
4+
sidebar:
5+
order: 3
6+
relatedArticles:
7+
- d170e5f0-c6c0-4323-90c9-1d722c837384
8+
- 5917da0f-24f0-48df-a387-aca03ce1fe7a
9+
---
10+
11+
The `kinde.auth` binding affects the auth flow.
12+
13+
## Methods
14+
15+
### `denyAccess(reason: string): void`
16+
17+
Prevent the user from accessing the application.
18+
19+
## Available in workflows
20+
21+
- [user:post_authentication](/workflows/example-workflows/workflow-user-post-auth/)
22+
- [user:new_password_provided](/workflows/example-workflows/new-password-provided-workflow/)
23+
- [user:existing_password_provided](/workflows/example-workflows/existing-password-provided-workflow/)
24+
- [user:tokens_generation](/workflows/example-workflows/user-token-generation/)
25+
- [user:pre_mfa](/workflows/example-workflows/pre-mfa-workflow/)
26+
27+
## Configuration
28+
29+
```js
30+
export const workflowSettings = {
31+
// ...other settings
32+
bindings: {"kinde.auth": {}}
33+
};
34+
```
35+
36+
## Usage
37+
38+
### Using the Kinde infrastructure library (recommended)
39+
40+
The [Kinde infrastructure library](https://github.com/kinde-oss/infrastructure) provides a type-safe helper:
41+
42+
```js
43+
import { denyAccess } from "@kinde/infrastructure";
44+
45+
export default async function (event: onUserTokenGeneratedEvent) {
46+
if (event.request.ip.startsWith("192")) {
47+
denyAccess("You are not allowed to access this resource");
48+
}
49+
}
50+
```
51+
52+
### Using the low-level API
53+
54+
If you're not using the infrastructure library, you can call the underlying API directly:
55+
56+
```js
57+
kinde.auth.denyAccess("You are not allowed to access this resource");
58+
```

0 commit comments

Comments
 (0)