feat: V2 alpha import and export of organizations (#3798)

* feat(import): add functionality to import data into an instance

* feat(import): move import to admin api and additional checks for nil pointer

* fix(export): export implementation with filtered members and grants

* fix: export and import implementation

* fix: add possibility to export hashed passwords with the user

* fix(import): import with structure of v1 and v2

* docs: add v1 proto

* fix(import): check im imported user is already existing

* fix(import): add otp import function

* fix(import): add external idps, domains, custom text and messages

* fix(import): correct usage of default values from login policy

* fix(export): fix renaming of add project function

* fix(import): move checks for unit tests

* expect filter

* fix(import): move checks for unit tests

* fix(import): move checks for unit tests

* fix(import): produce prerelease from branch

* fix(import): correctly use provided user id for machine user imports

* fix(import): corrected otp import and added guide for export and import

* fix: import verified and primary domains

* fix(import): add reading from gcs, s3 and localfile with tracing

* fix(import): gcs and s3, file size correction and error logging

* Delete docker-compose.yml

* fix(import): progress logging and count of resources

* fix(import): progress logging and count of resources

* log subscription

* fix(import): incorporate review

* fix(import): incorporate review

* docs: add suggestion for import

Co-authored-by: Fabi <[email protected]>

* fix(import): add verification otp event and handling of deleted but existing users

Co-authored-by: Livio Amstutz <[email protected]>
Co-authored-by: Fabienne <[email protected]>
Co-authored-by: Silvan <[email protected]>
Co-authored-by: Fabi <[email protected]>
This commit is contained in:
Stefan Benz
2022-07-28 13:42:35 +00:00
committed by GitHub
co-authored by Fabi Livio Amstutz Fabienne Silvan
parent d620126aab
commit bc9a85daf3
51 changed files with 4430 additions and 648 deletions
+129
View File
@@ -0,0 +1,129 @@
---
title: Export and import with ZITADEL
---
## Export from V1 to Import into V2
To migrate from ZITADEL V1 to V2 the API provides you with a possibility to export all resources which are under your organizations.
Currently, this doesn't include the following points:
* Global policies
* IAM members
* Global IDPs
* Global second/multi factors
* Machine keys
* PAT's
* Application keys
Which results in that if you want to import, and you have no defined organization-specific custom policies, the experience for your users will not be exactly like in your old instance.
```suggestion
::note Note that the ressources will be migrated without the event stream. This means that you will not have the audit trail for the imported objects.
*** With this export and import the current audit trail is not included, the resources will be newly created ***
### Export from V1 to import into V2 directly
***To use this requests you have to have an access token with enough permissions to export and import.***
To export all necessary data you only have to use one request, as an example:
```bash
curl --request POST \
--url {your_domain}/admin/v1/export \
--header 'Authorization: Bearer XXXX' \
--header 'Content-Type: application/json' \
--data '{
"org_ids": [ "70669144072186707", "70671105999825752" ],
"excluded_org_ids": [ ],
"with_passwords": true,
"with_otp": true
"timeout": "30s",
"response_output": true,
}' -o export.json
```
* "org_ids": to select which organizations should be exported
* "excluded_org_ids": to exclude several organization, if for example no organizations are selected
* "with_passwords": to include the hashed_passwords of the users in the export
* "with_otp": to include the OTP-code of the users in the export
* "timeout": timeout of the call to export the data
* "response_output": to output the export as response to the call
***To import the exported data into you new instance, you have to have an already existing instance on a ZITADEL V2, with all desired configuration and global resources.***
Then as an example you can use one request for the import:
```bash
curl --request POST \
--url {your_domain}/admin/v1/import \
--header 'Authorization: Bearer XXXX' \
--header 'Content-Type: application/json' \
--data '{
"data_orgsv1": '$(cat export.json)'
}'
```
## Export from V1 to Import into V2 thorugh GCS
***To use this requests you have to have an access token with enough permissions to export and import.***
***The used serviceaccount has to have at least the role "Storage Object Creator" to create objects on GCS***
To export all necessary data you only have to use one request which results in a file in your GCS, as an example:
```bash
curl --request POST \
--url {your_domain}/admin/v1/export \
--header 'Authorization: Bearer XXXX' \
--header 'Content-Type: application/json' \
--data ' "{
"org_ids": [ "70669144072186707", "70671105999825752" ],
"excluded_org_ids": [ ],
"with_passwords": true,
"with_otp": true,
"timeout": "10m",
"gcs_output": {
"path": "export.json",
"bucket": "caos-zitadel-exports",
"serviceaccount_json": "XXXX"
}' -o export.json
```
* "org_ids": to select which organizations should be exported
* "excluded_org_ids": to exclude several organization, if for example no organizations are selected
* "with_passwords": to include the hashed_passwords of the users in the export
* "with_otp": to include the OTP-code of the users in the export
* "timeout": timeout for the call to export the data
* "gcs_output": to write a file into GCS as output to the call
* "path": path to the output file on GCS
* "bucket": used bucket for output on GCS
* "serviceaccount_json": base64-encoded serviceaccount.json used to output the file on GCS
***To import the exported data into you new instance, you have to have an already existing instance on a ZITADEL V2, with all desired configuration and global resources.***
***The used serviceaccount has to have at least the role "Storage Object Viewer" to create objects on GCS***
Then as an example you can use one request for the import:
```bash
curl --request POST \
--url {your_domain}/admin/v1/import \
--header 'Authorization: Bearer XXXX' \
--header 'Content-Type: application/json' \
--data '{
"timeout": "10m",
"data_orgsv1_gcs": {
"path": "export.json",
"bucket": "caos-zitadel-exports",
"serviceaccount_json": "XXXX"
}
}'
```
* "timeout": timeout for the import task
* "data_orgsv1_gcs": to read the export from GCS directly
* "path": path to the exported file on GCS
* "bucket": used bucket to read from GCS
* "serviceaccount_json": base64-encoded serviceaccount.json used to read the file from GCS