diff --git a/db/migrations/20232402024000_add_auth_url_for_oauth2_to_dataset_table.php b/db/migrations/20232402024000_add_auth_url_for_oauth2_to_dataset_table.php new file mode 100644 index 0000000000..10bd48057c --- /dev/null +++ b/db/migrations/20232402024000_add_auth_url_for_oauth2_to_dataset_table.php @@ -0,0 +1,50 @@ +. + */ + +use Phinx\Migration\AbstractMigration; + +/** + * Add display venue metadata + * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace + */ + +class AddAuthUrlForOauth2ToDatasetTable extends AbstractMigration +{ + /** @inheritDoc */ + public function change() + { + // Add new column + $this->table('dataset') + ->addColumn('oauth2Url', 'string', ['after' => 'authentication', 'limit' => 1024, 'default' => null, 'null' => true]) + ->addColumn('oauth2Client', 'string', ['after' => 'oauth2Url', 'limit' => 1024, 'default' => null, 'null' => true]) + ->addColumn('oauth2ClientSecret', 'string', ['after' => 'oauth2Client', 'limit' => 1024, 'default' => null, 'null' => true]) + ->addColumn('oauth2GrantType', 'enum', ['values' => ['client_credentials', 'authorization_code'], 'default' => null, 'null' => true]) + ->save(); + + // Modify the existing 'authentication' column to add the 'oauth2' value + $tableName = 'dataset'; + $columnName = 'authentication'; + $newValues = "'none', 'plain', 'basic', 'digest', 'bearer', 'ntlm', 'oauth2'"; + + $this->execute("ALTER TABLE `$tableName` CHANGE `$columnName` `$columnName` ENUM($newValues) DEFAULT NULL"); + } +} diff --git a/db/migrations/20232902024000_extend_dataset_password_column_length.php b/db/migrations/20232902024000_extend_dataset_password_column_length.php new file mode 100644 index 0000000000..14c77ac68b --- /dev/null +++ b/db/migrations/20232902024000_extend_dataset_password_column_length.php @@ -0,0 +1,32 @@ +. + */ + +use Phinx\Migration\AbstractMigration; + +class ExtendDatasetPasswordColumnLength extends AbstractMigration +{ + public function change(): void + { + // Updating the password column to accept much longer tokens for the Bearer method + $this->execute("ALTER TABLE `dataset` MODIFY `password` VARCHAR(1024)"); + } +} diff --git a/lib/Controller/DataSet.php b/lib/Controller/DataSet.php index c97bb2c91e..c003ff799b 100644 --- a/lib/Controller/DataSet.php +++ b/lib/Controller/DataSet.php @@ -88,6 +88,9 @@ public function getDataSetFactory() public function displayPage(Request $request, Response $response) { $this->getState()->template = 'dataset-page'; + $this->getState()->setData([ + 'users' => $this->userFactory->query(), + ]); return $this->render($request, $response); } @@ -423,6 +426,34 @@ public function addForm(Request $request, Response $response) * required=false * ), * @SWG\Parameter( + * name="oauth2Url", + * in="formData", + * description="Oauth2.0 Authorization Token Endpoint", + * type="string", + * required=false + * ), + * @SWG\Parameter( + * name="oauth2Client", + * in="formData", + * description="Oauth2.0 Client ID", + * type="string", + * required=false + * ), + * @SWG\Parameter( + * name="oauth2ClientSecret", + * in="formData", + * description="Oauth2.0 Client Secret", + * type="string", + * required=false + * ), + * @SWG\Parameter( + * name="oauth2GrantType", + * in="formData", + * description="Oauth2.0 Grant Type Requested client_credentials|authorization_code", + * type="string", + * required=false + * ), + * @SWG\Parameter( * name="customHeaders", * in="formData", * description="Comma separated string of custom HTTP headers", @@ -581,6 +612,10 @@ public function add(Request $request, Response $response) $dataSet->username = $sanitizedParams->getString('username'); $dataSet->password = $sanitizedParams->getString('password'); $dataSet->customHeaders = $sanitizedParams->getString('customHeaders'); + $dataSet->oauth2Url = $sanitizedParams->getString('oauth2Url'); + $dataSet->oauth2Client = $sanitizedParams->getString('oauth2Client'); + $dataSet->oauth2ClientSecret = $sanitizedParams->getString('oauth2ClientSecret'); + $dataSet->oauth2GrantType = $sanitizedParams->getString('oauth2GrantType'); $dataSet->userAgent = $sanitizedParams->getString('userAgent'); $dataSet->refreshRate = $sanitizedParams->getInt('refreshRate'); $dataSet->clearRate = $sanitizedParams->getInt('clearRate'); @@ -748,6 +783,34 @@ public function editForm(Request $request, Response $response, $id) * required=false * ), * @SWG\Parameter( + * name="oauth2Url", + * in="formData", + * description="Oauth2.0 Authorization Token Endpoint", + * type="string", + * required=false + * ), + * @SWG\Parameter( + * name="oauth2Client", + * in="formData", + * description="Oauth2.0 Client ID", + * type="string", + * required=false + * ), + * @SWG\Parameter( + * name="oauth2ClientSecret", + * in="formData", + * description="Oauth2.0 Client Secret", + * type="string", + * required=false + * ), + * @SWG\Parameter( + * name="oauth2GrantType", + * in="formData", + * description="Oauth2.0 Grant Type Requested client_credentials|authorization_code", + * type="string", + * required=false + * ), + * @SWG\Parameter( * name="customHeaders", * in="formData", * description="Comma separated string of custom HTTP headers", @@ -890,6 +953,10 @@ public function edit(Request $request, Response $response, $id) $dataSet->username = $sanitizedParams->getString('username'); $dataSet->password = $sanitizedParams->getString('password'); $dataSet->customHeaders = $sanitizedParams->getString('customHeaders'); + $dataSet->oauth2Url = $sanitizedParams->getString('oauth2Url'); + $dataSet->oauth2Client = $sanitizedParams->getString('oauth2Client'); + $dataSet->oauth2ClientSecret = $sanitizedParams->getString('oauth2ClientSecret'); + $dataSet->oauth2GrantType = $sanitizedParams->getString('oauth2GrantType'); $dataSet->userAgent = $sanitizedParams->getString('userAgent'); $dataSet->refreshRate = $sanitizedParams->getInt('refreshRate'); $dataSet->clearRate = $sanitizedParams->getInt('clearRate'); @@ -1420,9 +1487,24 @@ public function testRemoteRequest(Request $request, Response $response) $dataSet->authentication = $sanitizedParams->getString('authentication'); $dataSet->username = $sanitizedParams->getString('username'); $dataSet->password = $sanitizedParams->getString('password'); + $dataSet->customHeaders = $sanitizedParams->getString('customHeaders'); + $dataSet->oauth2Url = $sanitizedParams->getString('oauth2Url'); + $dataSet->oauth2Client = $sanitizedParams->getString('oauth2Client'); + $dataSet->oauth2ClientSecret = $sanitizedParams->getString('oauth2ClientSecret'); + $dataSet->oauth2GrantType = $sanitizedParams->getString('oauth2GrantType'); + $dataSet->userAgent = $sanitizedParams->getString('userAgent'); + $dataSet->refreshRate = $sanitizedParams->getInt('refreshRate'); + $dataSet->clearRate = $sanitizedParams->getInt('clearRate'); + $dataSet->truncateOnEmpty = $sanitizedParams->getCheckbox('truncateOnEmpty'); + $dataSet->runsAfter = $sanitizedParams->getInt('runsAfter'); $dataSet->dataRoot = $sanitizedParams->getString('dataRoot'); + $dataSet->summarize = $sanitizedParams->getString('summarize'); + $dataSet->summarizeField = $sanitizedParams->getString('summarizeField'); $dataSet->sourceId = $sanitizedParams->getInt('sourceId'); $dataSet->ignoreFirstRow = $sanitizedParams->getCheckbox('ignoreFirstRow'); + $dataSet->rowLimit = $sanitizedParams->getInt('rowLimit'); + $dataSet->limitPolicy = $sanitizedParams->getString('limitPolicy') ?? 'stop'; + $dataSet->csvSeparator = ($dataSet->sourceId === 2) ? $sanitizedParams->getString('csvSeparator') ?? ',' : null; // Set this DataSet as active. $dataSet->setActive(); @@ -1571,3 +1653,4 @@ public function clearCache(Request $request, Response $response, $id) return $this->render($request, $response); } } + diff --git a/lib/Entity/DataSet.php b/lib/Entity/DataSet.php index 26239e9bd7..85a4cdec11 100644 --- a/lib/Entity/DataSet.php +++ b/lib/Entity/DataSet.php @@ -1,6 +1,6 @@ heading == $heading) { // Formula column? if ($column->dataSetColumnTypeId == 2) { - $select .= str_replace( - Sql::DISALLOWED_KEYWORDS, - '', - htmlspecialchars_decode($column->formula, ENT_QUOTES) - ) . ' AS `' . $column->heading . '`,'; - } else { + $select .= str_replace($this->blackList, '', htmlspecialchars_decode($column->formula, ENT_QUOTES)) . ' AS `' . $column->heading . '`,'; + } + else { $select .= '`' . $column->heading . '`,'; } $found = true; @@ -521,20 +544,15 @@ public function getData($filterBy = [], $options = []) // Formula column? if ($column->dataSetColumnTypeId == 2) { // Is this a client side column? - if (str_starts_with($column->formula, '$')) { + if (substr($column->formula, 0, 1) === '$') { $clientSideFormula[] = $column; continue; } - $formula = str_ireplace( - Sql::DISALLOWED_KEYWORDS, - '', - htmlspecialchars_decode($column->formula, ENT_QUOTES) - ); + $formula = str_ireplace($this->blackList, '', htmlspecialchars_decode($column->formula, ENT_QUOTES)); $formula = str_replace('[DisplayId]', $displayId, $formula); - $heading = str_replace('[DisplayGeoLocation]', $displayGeoLocation, $formula) - . ' AS `' . $column->heading . '`'; + $heading = str_replace('[DisplayGeoLocation]', $displayGeoLocation, $formula) . ' AS `' . $column->heading . '`'; } else { $heading = '`' . $column->heading . '`'; } @@ -550,7 +568,7 @@ public function getData($filterBy = [], $options = []) if ($filter != '') { // Support display filtering. $filter = str_replace('[DisplayId]', $displayId, $filter); - $filter = str_ireplace(Sql::DISALLOWED_KEYWORDS, '', $filter); + $filter = str_ireplace($this->blackList, '', $filter); $body .= ' AND ' . $filter; } @@ -1008,8 +1026,8 @@ private function add() // Insert the extra columns we expect for a remote DataSet if ($this->isRemote === 1) { - $columns .= ', `method`, `uri`, `postData`, `authentication`, `username`, `password`, `customHeaders`, `userAgent`, `refreshRate`, `clearRate`, `truncateOnEmpty`, `runsAfter`, `dataRoot`, `lastSync`, `summarize`, `summarizeField`, `sourceId`, `ignoreFirstRow`, `rowLimit`, `limitPolicy`, `csvSeparator`'; - $values .= ', :method, :uri, :postData, :authentication, :username, :password, :customHeaders, :userAgent, :refreshRate, :clearRate, :truncateOnEmpty, :runsAfter, :dataRoot, :lastSync, :summarize, :summarizeField, :sourceId, :ignoreFirstRow, :rowLimit, :limitPolicy, :csvSeparator'; + $columns .= ', `method`, `uri`, `postData`, `authentication`, `username`, `password`, `oauth2Url`, `oauth2Client`, `oauth2ClientSecret`, `oauth2GrantType`, `customHeaders`, `userAgent`, `refreshRate`, `clearRate`, `truncateOnEmpty`, `runsAfter`, `dataRoot`, `lastSync`, `summarize`, `summarizeField`, `sourceId`, `ignoreFirstRow`, `rowLimit`, `limitPolicy`, `csvSeparator`'; + $values .= ', :method, :uri, :postData, :authentication, :username, :password, :oauth2Url, :oauth2Client, :oauth2ClientSecret, :oauth2GrantType, :customHeaders, :userAgent, :refreshRate, :clearRate, :truncateOnEmpty, :runsAfter, :dataRoot, :lastSync, :summarize, :summarizeField, :sourceId, :ignoreFirstRow, :rowLimit, :limitPolicy, :csvSeparator'; $params['method'] = $this->method; $params['uri'] = $this->uri; @@ -1017,6 +1035,10 @@ private function add() $params['authentication'] = $this->authentication; $params['username'] = $this->username; $params['password'] = $this->password; + $params['oauth2Url'] = $this->oauth2Url; + $params['oauth2Client'] = $this->oauth2Client; + $params['oauth2ClientSecret'] = $this->oauth2ClientSecret; + $params['oauth2GrantType'] = $this->oauth2GrantType; $params['customHeaders'] = $this->customHeaders; $params['userAgent'] = $this->userAgent; $params['refreshRate'] = $this->refreshRate; @@ -1061,7 +1083,7 @@ private function edit() ]; if ($this->isRemote) { - $sql .= ', method = :method, uri = :uri, postData = :postData, authentication = :authentication, `username` = :username, `password` = :password, `customHeaders` = :customHeaders, `userAgent` = :userAgent, refreshRate = :refreshRate, clearRate = :clearRate, truncateOnEmpty = :truncateOnEmpty, runsAfter = :runsAfter, `dataRoot` = :dataRoot, `summarize` = :summarize, `summarizeField` = :summarizeField, `sourceId` = :sourceId, `ignoreFirstRow` = :ignoreFirstRow , `rowLimit` = :rowLimit, `limitPolicy` = :limitPolicy, `csvSeparator` = :csvSeparator '; + $sql .= ', method = :method, uri = :uri, postData = :postData, authentication = :authentication, `username` = :username, `password` = :password, `oauth2Url` = :oauth2Url, `oauth2Client` = :oauth2Client, `oauth2ClientSecret` = :oauth2ClientSecret, `oauth2GrantType` = :oauth2GrantType, `customHeaders` = :customHeaders, `userAgent` = :userAgent, refreshRate = :refreshRate, clearRate = :clearRate, truncateOnEmpty = :truncateOnEmpty, runsAfter = :runsAfter, `dataRoot` = :dataRoot, `summarize` = :summarize, `summarizeField` = :summarizeField, `sourceId` = :sourceId, `ignoreFirstRow` = :ignoreFirstRow , `rowLimit` = :rowLimit, `limitPolicy` = :limitPolicy, `csvSeparator` = :csvSeparator '; $params['method'] = $this->method; $params['uri'] = $this->uri; @@ -1069,6 +1091,10 @@ private function edit() $params['authentication'] = $this->authentication; $params['username'] = $this->username; $params['password'] = $this->password; + $params['oauth2Url'] = $this->oauth2Url; + $params['oauth2Client'] = $this->oauth2Client; + $params['oauth2ClientSecret'] = $this->oauth2ClientSecret; + $params['oauth2GrantType'] = $this->oauth2GrantType; $params['customHeaders'] = $this->customHeaders; $params['userAgent'] = $this->userAgent; $params['refreshRate'] = $this->refreshRate; @@ -1228,3 +1254,4 @@ public function clearCache() $this->pool->deleteItem('/dataset/cache/' . $this->dataSetId); } } + diff --git a/lib/Factory/DataSetFactory.php b/lib/Factory/DataSetFactory.php index 7140e257fc..277c681f28 100644 --- a/lib/Factory/DataSetFactory.php +++ b/lib/Factory/DataSetFactory.php @@ -206,6 +206,10 @@ public function query($sortOrder = null, $filterBy = []) dataset.`uri`, dataset.`postData`, dataset.`authentication`, + dataset.`oauth2Url`, + dataset.`oauth2Client`, + dataset.`oauth2ClientSecret`, + dataset.`oauth2GrantType`, dataset.`username`, dataset.`password`, dataset.`customHeaders`, @@ -347,7 +351,7 @@ public function callRemoteService(DataSet $dataSet, DataSet $dependant = null, $ $result->entries = []; $result->number = 0; $result->isEligibleToTruncate = false; - + // Getting all dependant values if needed // just an empty array if we don't have a dependent $values = [ @@ -359,7 +363,7 @@ public function callRemoteService(DataSet $dataSet, DataSet $dependant = null, $ $values = $dependant->getData(); } - + // Fetching data for every field in the dependant dataSet foreach ($values as $options) { // Make some request params to provide to the HTTP client @@ -372,6 +376,32 @@ public function callRemoteService(DataSet $dataSet, DataSet $dependant = null, $ $requestParams['auth'] = [$dataSet->username, $dataSet->password]; break; + case 'oauth2': + // Check if we have all of the required parameters + if (empty($dataSet->oauth2Url) || empty($dataSet->oauth2Client || empty($dataSet->oauth2ClientSecret) || empty($dataset->oauth2GrantType))) { + throw new InvalidArgumentException('Oauth2.0 configuration for dataset ' . $dataSet->dataSet . ' is incorrect'); + } + + // Obtain Access Token for OAuth 2.0 + $tokenResponse = $client->post($dataSet->oauth2Url, [ + 'form_params' => [ + 'grant_type' => $dataSet->oauth2GrantType, + 'client_id' => $dataSet->oauth2Client, + 'client_secret' => $dataSet->oauth2ClientSecret, + ] + ]); + + if ($tokenResponse->getStatusCode() != 200) { + throw new InvalidArgumentException('Failed to obtain access token for ' . $dataSet->dataSet . ' OAuth 2.0 endpoint: ' . $dataSet->oauth2Url); + } + + $tokenData = json_decode($tokenResponse->getBody(), true); + $accessToken = $tokenData['access_token']; + + // Add the access token to the request headers + $requestParams['headers']['Authorization'] = 'Bearer ' . $accessToken; + break; + case 'digest': $requestParams['auth'] = [$dataSet->username, $dataSet->password, 'digest']; break; @@ -534,7 +564,7 @@ function ($v) use ($dataSet) { throw new InvalidArgumentException(__('Unable to get Data for %s because %s.', $dataSet->dataSet, $requestException->getMessage()), 'dataSetId'); } } - + return $result; } @@ -888,3 +918,4 @@ public function processCsvEntries(DataSet $dataSet, \stdClass $results, $save = } } } + diff --git a/views/dataset-form-add.twig b/views/dataset-form-add.twig index b2f9c6fd14..ae8f6a68c5 100644 --- a/views/dataset-form-add.twig +++ b/views/dataset-form-add.twig @@ -29,6 +29,7 @@ {% endblock %} {% block formButtons %} + {% trans "Help" %}, XiboHelpRender("{{ help }}") {% trans "Cancel" %}, XiboDialogClose() {% trans "Save" %}, $("#dataSetAddForm").submit() {% endblock %} @@ -116,12 +117,14 @@ {% set auth_digest %}{% trans "Digest" %}{% endset %} {% set auth_ntlm %}{% trans "NTLM" %}{% endset %} {% set auth_bearer %}{% trans "Bearer" %}{% endset %} + {% set auth_oauth2 %}{% trans "Oauth2.0" %}{% endset %} {% set options = [ { typeid: "none", type: auth_none }, { typeid: "basic", type: auth_basic }, { typeid: "digest", type: auth_digest }, { typeid: "ntlm", type: auth_ntlm }, - { typeid: "bearer", type: auth_bearer } + { typeid: "bearer", type: auth_bearer }, + { typeid: "oauth2", type: auth_oauth2 } ] %} {{ forms.dropdown("authentication", "single", title, "", options, "typeid", "type", helpText) }} @@ -140,6 +143,30 @@ {% set title %}{% trans "User Agent" %}{% endset %} {% set helpText %}{% trans "Optionally set specific User Agent for this request, provide only the value, relevant header will be added automatically" %}{% endset %} {{ forms.input("userAgent", title, "", helpText) }} + + {% set title %}{% trans "Oauth2.0 Authentication URL" %}{% endset %} + {% set helpText %}{% trans "This will need to be a url ending in access_token" %}{% endset %} + {{ forms.input("oauth2Url", title, dataset.oauth2Url, helpText, "auth-field-oauth2-url", "") }} + + {% set title %}{% trans "Oauth2.0 Grant Type" %}{% endset %} + {% set helpText %}{% trans "Set the grant type requested" %}{% endset %} + {% set oauth2_grant_client_credentials %}{% trans "client_credentials" %}{% endset %} + {% set oauth2_grant_authorization_code %}{% trans "authorization_code" %}{% endset %} + {% set options = [ + { typeid: "client_credentials", type: oauth2_grant_client_credentials }, + { typeid: "authorization_code", type: oauth2_grant_authorization_code } + ] %} +
+ {{ forms.dropdown("oauth2GrantType", "single", title, dataSet.oauth2GrantType, options, "typeid", "type", helpText) }} +
+ + {% set title %}{% trans "Oauth2.0 Client ID" %}{% endset %} + {% set helpText %}{% trans "Please provide the Client ID" %}{% endset %} + {{ forms.input("oauth2Client", title, dataSet.oauth2Client, helpText, "auth-field-oauth2-client-id", "") }} + + {% set title %}{% trans "Oauth2.0 Client Secret" %}{% endset %} + {% set helpText %}{% trans "Please provide the Client Secret" %}{% endset %} + {{ forms.input("oauth2ClientSecret", title, dataSet.oauth2ClientSecret, helpText, "auth-field-oauth2-client-secret", "") }}
@@ -291,4 +318,4 @@
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/views/dataset-form-edit.twig b/views/dataset-form-edit.twig index 16d02a83ef..4a1acc88be 100644 --- a/views/dataset-form-edit.twig +++ b/views/dataset-form-edit.twig @@ -29,6 +29,7 @@ {% endblock %} {% block formButtons %} + {% trans "Help" %}, XiboHelpRender("{{ help }}") {% trans "Cancel" %}, XiboDialogClose() {% trans "Save" %}, $("#dataSetEditForm").submit() {% endblock %} @@ -127,12 +128,14 @@ {% set auth_digest %}{% trans "Digest" %}{% endset %} {% set auth_ntlm %}{% trans "NTLM" %}{% endset %} {% set auth_bearer %}{% trans "Bearer" %}{% endset %} + {% set auth_oauth2 %}{% trans "Oauth2.0" %}{% endset %} {% set options = [ { typeid: "none", type: auth_none }, { typeid: "basic", type: auth_basic }, { typeid: "digest", type: auth_digest }, { typeid: "ntlm", type: auth_ntlm }, - { typeid: "bearer", type: auth_bearer } + { typeid: "bearer", type: auth_bearer }, + { typeid: "oauth2", type: auth_oauth2 } ] %} {{ forms.dropdown("authentication", "single", title, dataSet.authentication, options, "typeid", "type", helpText) }} @@ -151,6 +154,29 @@ {% set title %}{% trans "User Agent" %}{% endset %} {% set helpText %}{% trans "Optionally set specific User Agent for this request, provide only the value, relevant header will be added automatically" %}{% endset %} {{ forms.input("userAgent", title, dataSet.userAgent, helpText) }} + + {% set title %}{% trans "Oauth2.0 Authentication URL" %}{% endset %} + {% set helpText %}{% trans "This will need to be a url ending in access_token" %}{% endset %} + {{ forms.input("oauth2Url", title, dataSet.oauth2Url, helpText, "auth-field-oauth2-url", "") }} + + {% set title %}{% trans "Oauth2.0 Grant Type" %}{% endset %} + {% set helpText %}{% trans "Set the grant type requested" %}{% endset %} + {% set oauth2_grant_client_credentials %}{% trans "client_credentials" %}{% endset %} + {% set oauth2_grant_authorization_code %}{% trans "authorization_code" %}{% endset %} + {% set options = [ + { typeid: "client_credentials", type: oauth2_grant_client_credentials }, + { typeid: "authorization_code", type: oauth2_grant_authorization_code } + ] %} +
+ {{ forms.dropdown("oauth2GrantType", "single", title, dataSet.oauth2GrantType, options, "typeid", "type", helpText) }} +
+ {% set title %}{% trans "Oauth2.0 Client ID" %}{% endset %} + {% set helpText %}{% trans "Please provide the Client ID" %}{% endset %} + {{ forms.input("oauth2Client", title, dataSet.oauth2Client, helpText, "auth-field-oauth2-client-id", "") }} + + {% set title %}{% trans "Oauth2.0 Client Secret" %}{% endset %} + {% set helpText %}{% trans "Please provide the Client Secret" %}{% endset %} + {{ forms.input("oauth2ClientSecret", title, dataSet.oauth2ClientSecret, helpText, "auth-field-oauth2-client-secret", "") }}
@@ -302,4 +328,4 @@
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/views/dataset-page.twig b/views/dataset-page.twig index decf019367..55235af446 100644 --- a/views/dataset-page.twig +++ b/views/dataset-page.twig @@ -224,6 +224,13 @@ table.ajax.reload(); XiboDialogClose(); } + }, + help: { + label: "{% trans "Help" %}", + className: "default btn-bb-help", + callback: function() { + XiboHelpRender("{{ helpService.link("dataset") }}#Importing_from_CSV_file"); + } } } }).on('shown.bs.modal', function() { @@ -354,16 +361,39 @@ var authentication = $(dialog).find("#authentication").val(); var $authFieldUserName = $(dialog).find(".auth-field-username"); var $authFieldPassword = $(dialog).find(".auth-field-password"); + var $oauth2FieldUrl = $(dialog).find(".auth-field-oauth2-url"); + var $oauth2FieldClientId = $(dialog).find(".auth-field-oauth2-client-id"); + var $oauth2FieldClientSecret = $(dialog).find(".auth-field-oauth2-client-secret"); + var $oauth2FieldGrantType = $(dialog).find(".auth-field-oauth2-grant-type"); if (authentication === "none") { $authFieldUserName.addClass("d-none"); $authFieldPassword.addClass("d-none"); + $oauth2FieldUrl.addClass("d-none"); + $oauth2FieldClientId.addClass("d-none"); + $oauth2FieldClientSecret.addClass("d-none"); + $oauth2FieldGrantType.addClass("d-none"); } else if (authentication === "bearer") { $authFieldUserName.addClass("d-none"); + $oauth2FieldUrl.addClass("d-none"); + $oauth2FieldClientId.addClass("d-none"); + $oauth2FieldClientSecret.addClass("d-none"); + $oauth2FieldGrantType.addClass("d-none"); $authFieldPassword.removeClass("d-none"); + } else if (authentication === "oauth2") { + $authFieldUserName.addClass("d-none"); + $authFieldPassword.addClass("d-none"); + $oauth2FieldUrl.removeClass("d-none"); + $oauth2FieldClientId.removeClass("d-none"); + $oauth2FieldClientSecret.removeClass("d-none"); + $oauth2FieldGrantType.removeClass("d-none"); } else { $authFieldUserName.removeClass("d-none"); $authFieldPassword.removeClass("d-none"); + $oauth2FieldUrl.addClass("d-none"); + $oauth2FieldClientId.addClass("d-none"); + $oauth2FieldClientSecret.addClass("d-none"); + $oauth2FieldGrantType.addClass("d-none"); } } @@ -529,4 +559,4 @@ {% endverbatim %} -{% endblock %} \ No newline at end of file +{% endblock %}