From 955e38ccc903158b17c5098aae8680036640e48f Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 5 Nov 2024 15:28:32 +0000 Subject: [PATCH 01/30] Bump version to 0.1.15 --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 6a8bbce0..c194b787 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -13,7 +13,7 @@ The OpenConnector Nextcloud app provides a ESB-framework to work together in an - 🆓 Map and translate API calls ]]> - 0.1.14 + 0.1.15 agpl integration Conduction From f88aeb5e402f61f9ede2334bc335f5033ad9c6bd Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 6 Nov 2024 16:37:09 +0100 Subject: [PATCH 02/30] Authentication documentatio --- docs/authentication.md | 80 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 docs/authentication.md diff --git a/docs/authentication.md b/docs/authentication.md new file mode 100644 index 00000000..0f0a4ea0 --- /dev/null +++ b/docs/authentication.md @@ -0,0 +1,80 @@ +# Authentication on sources + +In order to authenticate on other sources there are possibilities based upon the way the source expects autentication parameters. +These parameters can be set in the source configuration. For example, if the source expects an API key in the headers, we can set the parameter `headers.Authorization` with the API key as value. + +Usually, sources tend to use dynamic authorization parameters in order to prevent the same authentication parameter from being used by adversaries that catch a call and deduce the parameter. + +At the moment, OpenConnector supports two dynamic authentication methods, OAuth and JWT Bearers. + +## OAuth + +To use OAuth we put in our Authorization header the following value: +```twig +Bearer {{ oauthToken(source) }} +``` +This will impose an OAuth 2.0 access token after `Bearer` if the field `authenticationConfig` contains correct values. +OpenConnector supports the OAuth 2.0 protocol with client credentials and password credentials as grant_types. + +>[!NOTE] +> TODO: How to add authenticationConfig parameters in frontend + +When using OAuth, OpenConnector supports the following parameters: + +### Standard parameters +- `grant_type`: The type of grant we have to use at the source. Supported are `client_credentials` and `password` +- `scope`: The scope(s) needed to perform the requests we want to do in the API. +- `tokenUrl`: The URL used to fetch the actual access token. Usually this url can be recognised by its path ending on `/oauth/token` +- `authentication`: Location of the credentials, either `body` for credentials included in the request body, or `basic_auth` when the credentials have to be sent as a basic_auth header. _[!warning] Only used when `grant_type` is `client_credentials`_ +- `client_id`: The client id of the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ +- `client_secret`: The secret for the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ +- `username`: The username for the OAuth client _[!note] Only used when `grant_type` is `password`_ +- `password`: The password for the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ +- +This results in the following example: +```json +{ + "grant_type": "client_credentials", + "scope": "api", + "authentication": "body", + "tokenUrl": "https://example.com/oauth/token", + "client_id": "test-client", + "client_secret": "some secret value" +} +``` +### Custom parameters + +> [!warning] Custom parameters are currently in beta, it is not recommended to use them in production environments. + +At the moment, OpenConnector is tested with the following custom parameters: + +- `client_assertion_type`, only meaningful at the moment when value is set to `urn:ietf:params:oauth:client-assertion-type:jwt-bearer`. When this is set (for Microsoft authentications) the following fields are needed to generate the `client-assertion`-field +- - `private_key`: The base64 encoded private key of the certificate uploaded to Microsoft. +- - `x5t`: The base64 encoded sha1 fingerprint of the uploaded certificate, generated by running the following command: +```bash +echo $(openssl x509 -in certificate.crt -fingerprint -noout) | sed 's/SHA1 Fingerprint=//g' | sed 's/://g' | xxd -r -ps | base64`) +``` +- - `payload`: The payload of the JWT generated as `client_assertion`, this can contain Twig variables to render, for example to set timestamps in the JWT payload. + +## JWT Bearer + +A second supported way of using dynamic authentication is setting a JWT Bearer. This means setting a header or query parameter with a JWT token. + +This can for example be used by setting an Authorization header with the following value: +```twig +Bearer {{ jwtToken(source) }} +``` + +This will impose a JWT token after the bearer. For this, the `authenticationConfig` field of the source needs to contain the following fields: +- `algorithm`: The algorithm that should be used to generate the JWT. Supported are `HS256`, `HS384` and `HS512` for HMAC algorithms, `RS256`, `RS384`, `RS512` and `PS256` for RSA algorithms. +- `secret`: The secret used for the JWT. This can either be a HMAC shared secret, or a RSA private key in base64 encoding. +- `payload`: The payload of your JWT, json_encoded. + +This results in the following example for the `authenticationConfig` parameter in i.e. an OpenZaak source. +```json +{ + "algorithm": "HS256", + "secret": "YOUR_256BIT_(32BYTE)_HMAC_SECRET", + "payload": "{\"iss\":\"my_zgw_client\",\"iat\":{{ 'now'|date('U') }},\"client_id\":\"my_zgw_client\",\"user_id\":\"my_zgw_client\",\"user_representation\":\"me@company.com\",\"aud\":\"my_zgw_client\"}" +} +``` From 07673c412610c5ecfb06d3d4130f08f8fd7d973a Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 6 Nov 2024 16:39:46 +0100 Subject: [PATCH 03/30] MD fix --- docs/authentication.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/docs/authentication.md b/docs/authentication.md index 0f0a4ea0..243ada2f 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -22,15 +22,15 @@ OpenConnector supports the OAuth 2.0 protocol with client credentials and passwo When using OAuth, OpenConnector supports the following parameters: ### Standard parameters -- `grant_type`: The type of grant we have to use at the source. Supported are `client_credentials` and `password` -- `scope`: The scope(s) needed to perform the requests we want to do in the API. -- `tokenUrl`: The URL used to fetch the actual access token. Usually this url can be recognised by its path ending on `/oauth/token` -- `authentication`: Location of the credentials, either `body` for credentials included in the request body, or `basic_auth` when the credentials have to be sent as a basic_auth header. _[!warning] Only used when `grant_type` is `client_credentials`_ -- `client_id`: The client id of the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ -- `client_secret`: The secret for the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ -- `username`: The username for the OAuth client _[!note] Only used when `grant_type` is `password`_ -- `password`: The password for the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ -- +* `grant_type`: The type of grant we have to use at the source. Supported are `client_credentials` and `password` +* `scope`: The scope(s) needed to perform the requests we want to do in the API. +* `tokenUrl`: The URL used to fetch the actual access token. Usually this url can be recognised by its path ending on `/oauth/token` +* `authentication`: Location of the credentials, either `body` for credentials included in the request body, or `basic_auth` when the credentials have to be sent as a basic_auth header. _[!warning] Only used when `grant_type` is `client_credentials`_ +* `client_id`: The client id of the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ +* `client_secret`: The secret for the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ +* `username`: The username for the OAuth client _[!note] Only used when `grant_type` is `password`_ +* `password`: The password for the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ + This results in the following example: ```json { @@ -48,13 +48,15 @@ This results in the following example: At the moment, OpenConnector is tested with the following custom parameters: -- `client_assertion_type`, only meaningful at the moment when value is set to `urn:ietf:params:oauth:client-assertion-type:jwt-bearer`. When this is set (for Microsoft authentications) the following fields are needed to generate the `client-assertion`-field -- - `private_key`: The base64 encoded private key of the certificate uploaded to Microsoft. -- - `x5t`: The base64 encoded sha1 fingerprint of the uploaded certificate, generated by running the following command: -```bash -echo $(openssl x509 -in certificate.crt -fingerprint -noout) | sed 's/SHA1 Fingerprint=//g' | sed 's/://g' | xxd -r -ps | base64`) -``` -- - `payload`: The payload of the JWT generated as `client_assertion`, this can contain Twig variables to render, for example to set timestamps in the JWT payload. +* `client_assertion_type`, only meaningful at the moment when value is set to `urn:ietf:params:oauth:client-assertion-type:jwt-bearer`. When this is set (for Microsoft authentications) the following fields are needed to generate the `client-assertion`-field + - `private_key`: The base64 encoded private key of the certificate uploaded to Microsoft. + - `x5t`: The base64 encoded sha1 fingerprint of the uploaded certificate, generated by running the following command: + + ```bash + echo $(openssl x509 -in certificate.crt -fingerprint -noout) | sed 's/SHA1 Fingerprint=//g' | sed 's/://g' | xxd -r -ps | base64`) + ``` + + - `payload`: The payload of the JWT generated as `client_assertion`, this can contain Twig variables to render, for example to set timestamps in the JWT payload. ## JWT Bearer @@ -66,9 +68,9 @@ Bearer {{ jwtToken(source) }} ``` This will impose a JWT token after the bearer. For this, the `authenticationConfig` field of the source needs to contain the following fields: -- `algorithm`: The algorithm that should be used to generate the JWT. Supported are `HS256`, `HS384` and `HS512` for HMAC algorithms, `RS256`, `RS384`, `RS512` and `PS256` for RSA algorithms. -- `secret`: The secret used for the JWT. This can either be a HMAC shared secret, or a RSA private key in base64 encoding. -- `payload`: The payload of your JWT, json_encoded. +* `algorithm`: The algorithm that should be used to generate the JWT. Supported are `HS256`, `HS384` and `HS512` for HMAC algorithms, `RS256`, `RS384`, `RS512` and `PS256` for RSA algorithms. +* `secret`: The secret used for the JWT. This can either be a HMAC shared secret, or a RSA private key in base64 encoding. +* `payload`: The payload of your JWT, json_encoded. This results in the following example for the `authenticationConfig` parameter in i.e. an OpenZaak source. ```json From 3109c2ab8bc4e6f000cf26dab9fbe493bd965643 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 6 Nov 2024 16:40:46 +0100 Subject: [PATCH 04/30] Fix MD warnings and notes --- docs/authentication.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/authentication.md b/docs/authentication.md index 243ada2f..e1d0639f 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -26,10 +26,10 @@ When using OAuth, OpenConnector supports the following parameters: * `scope`: The scope(s) needed to perform the requests we want to do in the API. * `tokenUrl`: The URL used to fetch the actual access token. Usually this url can be recognised by its path ending on `/oauth/token` * `authentication`: Location of the credentials, either `body` for credentials included in the request body, or `basic_auth` when the credentials have to be sent as a basic_auth header. _[!warning] Only used when `grant_type` is `client_credentials`_ -* `client_id`: The client id of the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ -* `client_secret`: The secret for the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ -* `username`: The username for the OAuth client _[!note] Only used when `grant_type` is `password`_ -* `password`: The password for the OAuth client _[!note] Only used when `grant_type` is `client_credentials`_ +* `client_id`: The client id of the OAuth client _[!NOTE] Only used when `grant_type` is `client_credentials`_ +* `client_secret`: The secret for the OAuth client _[!NOTE] Only used when `grant_type` is `client_credentials`_ +* `username`: The username for the OAuth client _[!NOTE] Only used when `grant_type` is `password`_ +* `password`: The password for the OAuth client _[!NOTE] Only used when `grant_type` is `client_credentials`_ This results in the following example: ```json @@ -44,7 +44,7 @@ This results in the following example: ``` ### Custom parameters -> [!warning] Custom parameters are currently in beta, it is not recommended to use them in production environments. +> [!WARNING] Custom parameters are currently in beta, it is not recommended to use them in production environments. At the moment, OpenConnector is tested with the following custom parameters: From c46bc7f9fd2ee8001f9d3c7554f54ef2a94bd9bb Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 6 Nov 2024 16:43:49 +0100 Subject: [PATCH 05/30] Some more MD changes --- docs/authentication.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/authentication.md b/docs/authentication.md index e1d0639f..be0a0884 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -26,10 +26,18 @@ When using OAuth, OpenConnector supports the following parameters: * `scope`: The scope(s) needed to perform the requests we want to do in the API. * `tokenUrl`: The URL used to fetch the actual access token. Usually this url can be recognised by its path ending on `/oauth/token` * `authentication`: Location of the credentials, either `body` for credentials included in the request body, or `basic_auth` when the credentials have to be sent as a basic_auth header. _[!warning] Only used when `grant_type` is `client_credentials`_ -* `client_id`: The client id of the OAuth client _[!NOTE] Only used when `grant_type` is `client_credentials`_ -* `client_secret`: The secret for the OAuth client _[!NOTE] Only used when `grant_type` is `client_credentials`_ -* `username`: The username for the OAuth client _[!NOTE] Only used when `grant_type` is `password`_ -* `password`: The password for the OAuth client _[!NOTE] Only used when `grant_type` is `client_credentials`_ +* `client_id`: The client id of the OAuth client + > [!NOTE] + > Only used when `grant_type` is `client_credentials` +* `client_secret`: The secret for the OAuth client + > [!NOTE] + > Only used when `grant_type` is `client_credentials` +* `username`: The username for the OAuth client + > [!NOTE] + > Only used when `grant_type` is `password` +* `password`: The password for the OAuth client + > [!NOTE] + > Only used when `grant_type` is `client_credentials` This results in the following example: ```json @@ -44,7 +52,8 @@ This results in the following example: ``` ### Custom parameters -> [!WARNING] Custom parameters are currently in beta, it is not recommended to use them in production environments. +> [!WARNING] +> Custom parameters are currently in beta, it is not recommended to use them in production environments. At the moment, OpenConnector is tested with the following custom parameters: From 7080c7ef3dbe9e73ed30de662082bdf852a7b409 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Wed, 6 Nov 2024 16:47:19 +0100 Subject: [PATCH 06/30] Remove notes, correct one of the notes --- docs/authentication.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/authentication.md b/docs/authentication.md index be0a0884..d3bb7632 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -25,19 +25,16 @@ When using OAuth, OpenConnector supports the following parameters: * `grant_type`: The type of grant we have to use at the source. Supported are `client_credentials` and `password` * `scope`: The scope(s) needed to perform the requests we want to do in the API. * `tokenUrl`: The URL used to fetch the actual access token. Usually this url can be recognised by its path ending on `/oauth/token` -* `authentication`: Location of the credentials, either `body` for credentials included in the request body, or `basic_auth` when the credentials have to be sent as a basic_auth header. _[!warning] Only used when `grant_type` is `client_credentials`_ -* `client_id`: The client id of the OAuth client - > [!NOTE] +* `authentication`: Location of the credentials, either `body` for credentials included in the request body, or `basic_auth` when the credentials have to be sent as a basic_auth header. + > Only used when `grant_type` is `client_credentials` +* `client_id`: The client id of the OAuth client > Only used when `grant_type` is `client_credentials` * `client_secret`: The secret for the OAuth client - > [!NOTE] > Only used when `grant_type` is `client_credentials` * `username`: The username for the OAuth client - > [!NOTE] > Only used when `grant_type` is `password` * `password`: The password for the OAuth client - > [!NOTE] - > Only used when `grant_type` is `client_credentials` + > Only used when `grant_type` is `password` This results in the following example: ```json From 5177e54d9fa339f1ce0f625a2421eb5602ee6e18 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 12 Nov 2024 14:55:26 +0000 Subject: [PATCH 07/30] Bump version to 0.1.16 --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index c194b787..260f2fe6 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -13,7 +13,7 @@ The OpenConnector Nextcloud app provides a ESB-framework to work together in an - 🆓 Map and translate API calls ]]> - 0.1.15 + 0.1.16 agpl integration Conduction From d0fbe5df248dd7c3f2f8bd0d0f42e302c54117b5 Mon Sep 17 00:00:00 2001 From: Thijn Date: Thu, 14 Nov 2024 16:20:23 +0100 Subject: [PATCH 08/30] finished source config and target config key-value pairs --- .../synchronization/synchronization.ts | 8 +- .../synchronization/synchronization.types.ts | 4 +- src/modals/Modals.vue | 12 ++ .../DeleteSynchronizationSourceConfig.vue | 127 +++++++++++++++ .../EditSynchronizationSourceConfig.vue | 152 ++++++++++++++++++ .../DeleteSynchronizationTargetConfig.vue | 127 +++++++++++++++ .../EditSynchronizationTargetConfig.vue | 152 ++++++++++++++++++ src/store/modules/synchronization.js | 50 +++--- .../SynchronizationDetails.vue | 91 ++++++++++- 9 files changed, 692 insertions(+), 31 deletions(-) create mode 100644 src/modals/SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue create mode 100644 src/modals/SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue create mode 100644 src/modals/SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue create mode 100644 src/modals/SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue diff --git a/src/entities/synchronization/synchronization.ts b/src/entities/synchronization/synchronization.ts index 700367e5..c9bac364 100644 --- a/src/entities/synchronization/synchronization.ts +++ b/src/entities/synchronization/synchronization.ts @@ -12,7 +12,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati public sourceType: string public sourceHash: string public sourceTargetMapping: string - public sourceConfig: object + public sourceConfig: Record public sourceLastChanged: string public sourceLastChecked: string public sourceLastSynced: string @@ -20,7 +20,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati public targetType: string public targetHash: string public targetSourceMapping: string - public targetConfig: object + public targetConfig: Record public targetLastChanged: string public targetLastChecked: string public targetLastSynced: string @@ -64,7 +64,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati sourceType: z.string(), sourceHash: z.string(), sourceTargetMapping: z.string(), - sourceConfig: z.object({}), + sourceConfig: z.record(z.string(), z.string()), sourceLastChanged: z.string(), sourceLastChecked: z.string(), sourceLastSynced: z.string(), @@ -72,7 +72,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati targetType: z.string(), targetHash: z.string(), targetSourceMapping: z.string(), - targetConfig: z.object({}), + targetConfig: z.record(z.string(), z.string()), targetLastChanged: z.string(), targetLastChecked: z.string(), targetLastSynced: z.string(), diff --git a/src/entities/synchronization/synchronization.types.ts b/src/entities/synchronization/synchronization.types.ts index e2e59bfd..7dcf47a1 100644 --- a/src/entities/synchronization/synchronization.types.ts +++ b/src/entities/synchronization/synchronization.types.ts @@ -6,7 +6,7 @@ export type TSynchronization = { sourceType: string sourceHash: string sourceTargetMapping: string - sourceConfig: object + sourceConfig: Record sourceLastChanged: string sourceLastChecked: string sourceLastSynced: string @@ -14,7 +14,7 @@ export type TSynchronization = { targetType: string targetHash: string targetSourceMapping: string - targetConfig: object + targetConfig: Record targetLastChanged: string targetLastChecked: string targetLastSynced: string diff --git a/src/modals/Modals.vue b/src/modals/Modals.vue index 8b6165f6..337b4675 100644 --- a/src/modals/Modals.vue +++ b/src/modals/Modals.vue @@ -34,6 +34,10 @@ import { navigationStore } from '../store/store.js' + + + + @@ -68,6 +72,10 @@ import DeleteMappingCast from './mappingCast/DeleteMappingCast.vue' import ViewJobLog from './Log/ViewJobLog.vue' import ViewSynchronizationLog from './Log/ViewSynchronizationLog.vue' import ViewSynchronizationContract from './Log/ViewSynchronizationContract.vue' +import EditSynchronizationSourceConfig from './SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue' +import DeleteSynchronizationSourceConfig from './SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue' +import EditSynchronizationTargetConfig from './SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue' +import DeleteSynchronizationTargetConfig from './SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue' export default { name: 'Modals', @@ -102,6 +110,10 @@ export default { ViewJobLog, ViewSynchronizationLog, ViewSynchronizationContract, + EditSynchronizationSourceConfig, + DeleteSynchronizationSourceConfig, + EditSynchronizationTargetConfig, + DeleteSynchronizationTargetConfig, }, setup() { return { diff --git a/src/modals/SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue b/src/modals/SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue new file mode 100644 index 00000000..fb95139d --- /dev/null +++ b/src/modals/SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue @@ -0,0 +1,127 @@ + + + + + + + diff --git a/src/modals/SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue b/src/modals/SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue new file mode 100644 index 00000000..ea113058 --- /dev/null +++ b/src/modals/SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/modals/SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue b/src/modals/SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue new file mode 100644 index 00000000..1541c217 --- /dev/null +++ b/src/modals/SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue @@ -0,0 +1,127 @@ + + + + + + + diff --git a/src/modals/SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue b/src/modals/SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue new file mode 100644 index 00000000..621638e2 --- /dev/null +++ b/src/modals/SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/store/modules/synchronization.js b/src/store/modules/synchronization.js index 75c966e5..797e7258 100644 --- a/src/store/modules/synchronization.js +++ b/src/store/modules/synchronization.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ import { defineStore } from 'pinia' import { Synchronization } from '../../entities/index.js' @@ -9,26 +8,36 @@ export const useSynchronizationStore = defineStore('synchronization', { synchronizationContracts: [], synchronizationTest: null, synchronizationLogs: [], + synchronizationSourceConfigKey: null, + synchronizationTargetConfigKey: null, }), actions: { setSynchronizationItem(synchronizationItem) { this.synchronizationItem = synchronizationItem && new Synchronization(synchronizationItem) - console.log('Active synchronization item set to ' + synchronizationItem) + console.info('Active synchronization item set to ' + synchronizationItem) }, setSynchronizationList(synchronizationList) { this.synchronizationList = synchronizationList.map( (synchronizationItem) => new Synchronization(synchronizationItem), ) - console.log('Synchronization list set to ' + synchronizationList.length + ' items') + console.info('Synchronization list set to ' + synchronizationList.length + ' items') }, setSynchronizationContracts(synchronizationContracts) { this.synchronizationContracts = synchronizationContracts - console.log('Synchronization contracts set to ' + synchronizationContracts?.length + ' items') + console.info('Synchronization contracts set to ' + synchronizationContracts?.length + ' items') }, setSynchronizationLogs(synchronizationLogs) { this.synchronizationLogs = synchronizationLogs - console.log('Synchronization logs set to ' + synchronizationLogs?.length + ' items') + console.info('Synchronization logs set to ' + synchronizationLogs?.length + ' items') + }, + setSynchronizationSourceConfigKey(key) { + this.synchronizationSourceConfigKey = key + console.info('Synchronization source config key set to ' + key) + }, + setSynchronizationTargetConfigKey(key) { + this.synchronizationTargetConfigKey = key + console.info('Synchronization target config key set to ' + key) }, /* istanbul ignore next */ // ignore this for Jest until moved into a service @@ -127,7 +136,7 @@ export const useSynchronizationStore = defineStore('synchronization', { throw new Error('No synchronization item to delete') } - console.log('Deleting synchronization...') + console.info('Deleting synchronization...') const endpoint = `/index.php/apps/openconnector/api/synchronizations/${this.synchronizationItem.id}` @@ -143,12 +152,12 @@ export const useSynchronizationStore = defineStore('synchronization', { }) }, // Create or save a synchronization from store - saveSynchronization(synchronizationItem) { + async saveSynchronization(synchronizationItem) { if (!synchronizationItem) { throw new Error('No synchronization item to save') } - console.log('Saving synchronization...') + console.info('Saving synchronization...') const isNewSynchronization = !synchronizationItem?.id const endpoint = isNewSynchronization @@ -156,7 +165,7 @@ export const useSynchronizationStore = defineStore('synchronization', { : `/index.php/apps/openconnector/api/synchronizations/${synchronizationItem.id}` const method = isNewSynchronization ? 'POST' : 'PUT' - return fetch( + const response = await fetch( endpoint, { method, @@ -166,17 +175,16 @@ export const useSynchronizationStore = defineStore('synchronization', { body: JSON.stringify(synchronizationItem), }, ) - .then((response) => response.json()) - .then((data) => { - this.setSynchronizationItem(data) - console.log('Synchronization saved') - this.refreshSynchronizationList() - }) - .catch((err) => { - console.error('Error saving synchronization:', err) - throw err - }) + console.info('Synchronization saved') + + const data = await response.json() + const entity = new Synchronization(data) + + this.setSynchronizationItem(entity) + this.refreshSynchronizationList() + + return { response, data, entity } }, // Test a synchronization async testSynchronization() { @@ -184,7 +192,7 @@ export const useSynchronizationStore = defineStore('synchronization', { throw new Error('No synchronization item to test') } - console.log('Testing synchronization...') + console.info('Testing synchronization...') const endpoint = `/index.php/apps/openconnector/api/synchronizations-test/${this.synchronizationItem.id}` @@ -198,7 +206,7 @@ export const useSynchronizationStore = defineStore('synchronization', { const data = await response.json() this.synchronizationTest = data - console.log('Synchronization tested') + console.info('Synchronization tested') this.refreshSynchronizationLogs() return { response, data } diff --git a/src/views/Synchronization/SynchronizationDetails.vue b/src/views/Synchronization/SynchronizationDetails.vue index c2920f2c..34af78bd 100644 --- a/src/views/Synchronization/SynchronizationDetails.vue +++ b/src/views/Synchronization/SynchronizationDetails.vue @@ -21,6 +21,18 @@ import { synchronizationStore, navigationStore, logStore } from '../../store/sto Edit + + + Add Source Config + + + + Add Target Config +