mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-28 01:52:16 +00:00
## Todos for release - [x] Configure Env in docs project on vercel - [x] Configure Root Path in the docs project on vercel - [ ] Remove old CSP https://github.com/zitadel/website/pull/1592 ## What we did This pull request migrates the project documentation from the old `docs/` directory to the new `apps/docs/` directory, introduces a new documentation system built with Next.js and Fumadocs, and updates all relevant references, configuration files, and documentation to reflect this change. It also adds new configuration and ignore files for the new documentation app, updates CI and linting to exclude the new docs from certain checks, and revises the contributing guidelines accordingly. **Documentation System Migration and New Docs App** * Migrated all documentation from `docs/` to `apps/docs/`, and updated all references in `README.md`, `CONTRIBUTING.md`, and other files to point to the new location. [[1]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L585-L640) [[2]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L660-R607) [[3]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L740-R687) [[4]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L2-R3) [[5]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L30-R30) * Added a new Next.js/Fumadocs-based documentation app under `apps/docs/`, including core app files, layouts, routing, search API, and a comprehensive `README.md` with development and contribution instructions. [[1]](diffhunk://#diff-5a1b07344a2c1b4d3f37b23ff1388b62cd9f57dea3c1cd23d8a0412b7602b132R1-R74) [[2]](diffhunk://#diff-462b9ad1eabbb7d1c29bb9c36e4931eb180fd7190900e6d2babf8f4d66ad1c28R1-R39) [[3]](diffhunk://#diff-e16ae25660ded787b10ac35dea96d5ecaacf895dae0afc8a9bd4382dc79a8c87R1-R7) [apps/docs/app/[[...slug]]/layout.tsxR1-R81](diffhunk://#diff-59e08acde4e805b7aeccef1dcf98f1d71dfc550777e6b9402085cee0e9fa4e0aR1-R81), [apps/docs/app/[[...slug]]/page.tsxR1-R79](diffhunk://#diff-e5df3f80d0fa01e12d63d81f29c57a9d14e846c78fd3beabb2ef768e38fd9580R1-R79), [[4]](diffhunk://#diff-389b34918e040cacaa87cd7201ffa462cc2b0b716736f537e3d3c660ac69353bR1-R7) [[5]](diffhunk://#diff-d3b03416d1c457b19f1c27b26f2db741412df841b875c26ccadc36e4522247f4R1-R29) [[6]](diffhunk://#diff-c8fb8339570a5305809be7c618e14705fd86390dc278e6ce8ba224a7bc8b0c3cR1-R25) **Configuration and Tooling Updates** * Updated `.github/workflows/codeql.yml`, `.golangci.yaml`, and `.github/dependabot.yml` to properly handle the new docs app: excluded `apps/docs` from certain checks, added npm dependency updates for the docs app, and excluded generated content. [[1]](diffhunk://#diff-12783128521e452af0cfac94b99b8d250413c516ec71fe6d97dbea666ff7ba27L8-R14) [[2]](diffhunk://#diff-9917ddc9f1c3304218f7269265b746d997c5c0615478177b5fceecd33ef47cb5R5-R6) [[3]](diffhunk://#diff-9917ddc9f1c3304218f7269265b746d997c5c0615478177b5fceecd33ef47cb5R126-R129) [[4]](diffhunk://#diff-dd4fbda47e51f1e35defb9275a9cd9c212ecde0b870cba89ddaaae65c5f3cd28R89-R106) * Updated `.devcontainer/devcontainer.json` to use the latest Go 1.25.3 version for consistency. **Licensing and Miscellaneous** * Added `apps/docs/` to the list of licensed directories in `LICENSING.md`. These changes ensure the documentation is now maintained in a modern, scalable system and all project tooling is updated to support the new structure. --------- Co-authored-by: Federico Coppede <[email protected]>
241 lines
8.6 KiB
Plaintext
241 lines
8.6 KiB
Plaintext
---
|
|
title: Verify Payload Integrity
|
|
---
|
|
|
|
import JSONCode from "./go/json.go";
|
|
import JWTCode from "./go/jwt.go";
|
|
import JWECode from "./go/jwe.go";
|
|
import CodeBlock from "@/components/docusaurus/code-block";
|
|
|
|
This guide shows you how to verify the integrity of the received data on your target.
|
|
There are three options available, which will be demonstrated in the following sections.
|
|
The examples are based on the request action, but the same principles apply to other action types as well.
|
|
|
|
## Prerequisites
|
|
|
|
Before you start, make sure you have everything set up correctly.
|
|
|
|
- You need to be at least a ZITADEL [_IAM_OWNER_](/guides/manage/console/managers)
|
|
|
|
<Callout type="info">
|
|
Note that this guide assumes that ZITADEL is running on the same machine as the target and can be reached via `localhost`.
|
|
In case you are using a different setup, you need to adjust the target URL accordingly and will need to make sure that the target is reachable from ZITADEL.
|
|
</Callout>
|
|
|
|
## Payload and Validation Types
|
|
|
|
ZITADEL supports the following three types of payload in actions:
|
|
- **JSON**: The payload is sent as JSON in the request body. Additionally, a signature header is sent to validate the payload.
|
|
This is the simplest form of payload and validation and doesn't require any additional calls to validate the payload. It's also the default type,
|
|
which will be used if no type is specified.
|
|
- **JWT**: The payload is sent as a JSON Web Token (JWT) in the request body. The JWT is signed with the signing key of the instance.
|
|
This allows you to validate the payload by verifying the signature of the JWT using the signing key managed though the webkeys endpoint of the ZITADEL instance,
|
|
which allows for easier key rotation and management. Additionally, it's the base for the JWE type, in case you need to encrypt the payload for certain use cases.
|
|
- **JWE**: The payload is sent as encrypted JSON Web Token (JWE) in the request body. The JWT is additionally encrypted with the public key provided by you.
|
|
This allows you to validate and decrypt the payload by verifying the signature of the JWT using the signing key managed though the webkeys endpoint of the ZITADEL instance,
|
|
and decrypting the payload using your private key. This is the most secure form of payload and validation, but requires additional setup to provide the public key to ZITADEL.
|
|
This type is recommended if the payload contains sensitive information that should not be exposed to any intermediaries.
|
|
|
|
## Create target
|
|
|
|
We'll start the endpoint on port '8090' and if we want to use it as webhook, the target can be created as follows:
|
|
|
|
See [Create a target](/apis/resources/action_service_v2/action-service-create-target) for more detailed information.
|
|
|
|
Specify the `payloadType` according to the implementation you want to test: `PAYLOAD_TYPE_JSON`, `PAYLOAD_TYPE_JWT`, or `PAYLOAD_TYPE_JWE`.
|
|
|
|
```shell
|
|
curl -L -X POST 'https://${CUSTOM_DOMAIN}/v2/actions/targets' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Bearer <TOKEN>' \
|
|
--data-raw '{
|
|
"name": "local webhook",
|
|
"restWebhook": {
|
|
"interruptOnError": true
|
|
},
|
|
"endpoint": "http://localhost:8090/webhook",
|
|
"timeout": "10s",
|
|
"payloadType": "PAYLOAD_TYPE_JSON"
|
|
}'
|
|
```
|
|
|
|
Example response after creating the target:
|
|
```json
|
|
{
|
|
"id": "344649040681500814",
|
|
"creationDate": "2025-10-31T15:00:36.432595dZ",
|
|
"signingKey": "somekey"
|
|
}
|
|
```
|
|
Save the returned ID to set in the execution. If you're intending to use the `PAYLOAD_TYPE_JSON`, additionally store the `signingKey` and use it in the example above.
|
|
|
|
### JWE Specific Setup
|
|
|
|
If you are using the `PAYLOAD_TYPE_JWE`, you need to provide a public key to ZITADEL so that it can encrypt the payload.
|
|
|
|
Create a public/private key pair. You can use the following command to generate an RSA key pair:
|
|
```shell
|
|
openssl genpkey -algorithm RSA -outform PEM -out private_key.pem -pkeyopt rsa_keygen_bits:2048
|
|
openssl rsa -pubout -in private_key.pem -out public_key.pem
|
|
```
|
|
|
|
Then upload the public key to ZITADEL using the following command. Replace `<TargetID>` with the ID of the target you created earlier.
|
|
Use the base64 encoded content of the `public_key.pem` file as the value for `publicKey`.
|
|
```shell
|
|
curl -L -X POST 'https://${CUSTOM_DOMAIN}/v2/actions/targets/<TargetID>/publickeys' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Bearer <TOKEN>' \
|
|
--data-raw '{
|
|
"publicKey": "<base64 encoded contents of public_key.pem>"
|
|
}'
|
|
```
|
|
|
|
Be sure to also activate the public key for the target using the returned `<KeyID>` from the previous request:
|
|
```shell
|
|
curl -L -X PUT 'https://${CUSTOM_DOMAIN}/v2/actions/targets/<TargetID>/publickeys/<KeyID>/activate' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Bearer <TOKEN>'
|
|
```
|
|
|
|
## Set execution
|
|
|
|
To configure ZITADEL to call the target when an API endpoint is called, you need to set an execution and define the request
|
|
condition.
|
|
|
|
See [Set an execution](/apis/resources/action_service_v2/action-service-set-execution) for more detailed information.
|
|
|
|
```shell
|
|
curl -L -X PUT 'https://${CUSTOM_DOMAIN}/v2/actions/executions' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Bearer <TOKEN>' \
|
|
--data-raw '{
|
|
"condition": {
|
|
"request": {
|
|
"method": "/zitadel.user.v2.UserService/CreateUser"
|
|
}
|
|
},
|
|
"targets": [
|
|
"<TargetID returned>"
|
|
]
|
|
}'
|
|
```
|
|
|
|
## Start example target
|
|
|
|
To test the actions feature, you need to create a target that will be called when an API endpoint is called.
|
|
You will need to implement a listener that can receive HTTP requests.
|
|
For this example, we will use a simple Go HTTP server that will print the received request to standard output.
|
|
As mentioned before, this validation can and should be applied to any target implementation.
|
|
|
|
<Tabs>
|
|
<Tab value="JSON">
|
|
<CodeBlock language="go">{JSONCode}</CodeBlock>
|
|
</Tab>
|
|
<Tab value="JWT">
|
|
<CodeBlock language="go">{JWTCode}</CodeBlock>
|
|
</Tab>
|
|
<Tab value="JWE">
|
|
<CodeBlock language="go">{JWECode}</CodeBlock>
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
<Callout type="info">
|
|
The example above runs only on your local machine (`localhost`).
|
|
To test it with Zitadel, you must make your listener reachable from the internet.
|
|
You can do this by using **Webhook.site** (see [Creating a Listener with Webhook.site](./webhook-site-setup)).
|
|
</Callout>
|
|
|
|
## Example call
|
|
|
|
Now that you have set up the target and execution, you can test it by creating a user through the Management Console UI or
|
|
by calling the ZITADEL API to create a human user.
|
|
|
|
```shell
|
|
curl -L -X POST 'https://${CUSTOM_DOMAIN}/v2/users/new' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Bearer <TOKEN>' \
|
|
--data-raw '{
|
|
"organizationId": "344648897353810062",
|
|
"human":
|
|
{
|
|
"profile":
|
|
{
|
|
"givenName": "Minnie",
|
|
"familyName": "Mouse",
|
|
"nickName": "Mini",
|
|
"displayName": "Minnie Mouse",
|
|
"preferredLanguage": "en",
|
|
"gender": "GENDER_FEMALE"
|
|
},
|
|
"email":
|
|
{
|
|
"email": "[email protected]"
|
|
}
|
|
}
|
|
}'
|
|
```
|
|
|
|
Your server should now print out something like the following. Check out
|
|
the [Sent information Request](./usage#sent-information-request) payload description.
|
|
|
|
```json
|
|
{
|
|
"fullMethod": "/zitadel.user.v2.UserService/CreateUser",
|
|
"instanceID": "344648897353744526",
|
|
"orgID": "344648897353810062",
|
|
"projectID": "344648897353875598",
|
|
"userID": "344648897354465422",
|
|
"request":
|
|
{
|
|
"organizationId": "344648897353810062",
|
|
"human":
|
|
{
|
|
"profile":
|
|
{
|
|
"givenName": "Minnie",
|
|
"familyName": "Mouse",
|
|
"nickName": "Mini",
|
|
"displayName": "Minnie Mouse",
|
|
"preferredLanguage": "en",
|
|
"gender": "GENDER_FEMALE"
|
|
},
|
|
"email":
|
|
{
|
|
"email": "[email protected]"
|
|
}
|
|
}
|
|
},
|
|
"headers":
|
|
{
|
|
"Content-Type":
|
|
[
|
|
"application/grpc"
|
|
],
|
|
"Host":
|
|
[
|
|
"localhost:8080"
|
|
],
|
|
"X-Forwarded-For":
|
|
[
|
|
"::1"
|
|
],
|
|
"X-Forwarded-Host":
|
|
[
|
|
"localhost:8080"
|
|
]
|
|
}
|
|
}
|
|
```
|
|
|
|
## Conclusion
|
|
|
|
You have successfully set up a target and verified the payload integrity for request actions using your preferred payload type.
|
|
You can now extend this setup to other action types and integrate it into your workflows as needed.
|
|
Selecting the appropriate payload type ensures that your data is transmitted securely and can be validated effectively on the receiving end.
|
|
Find more information about the actions feature in the [API documentation](/concepts/features/actions_v2).
|