Skip to content

Commit

Permalink
preserve basic auth credentials when reloading from http to https...
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed May 2, 2024
1 parent c3e6a2b commit c7dc857
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
29 changes: 22 additions & 7 deletions app/assets/javascripts/controllers/wizardModal.js
Expand Up @@ -20,6 +20,8 @@ angular.module('QuepidApp')
$uibModalInstance.dismiss('cancel');
};

$scope.shouldCreateNewSearchEndpointDefaultToOpen = false;
$scope.shouldExistingSearchEndpointDefaultToOpen = false;
$scope.searchEndpoints = [];
$scope.isStaticCollapsed = true;
$scope.addedStaticQueries = false;
Expand Down Expand Up @@ -115,6 +117,9 @@ angular.module('QuepidApp')
if (angular.isDefined($location.search().apiMethod)){
$scope.pendingWizardSettings.apiMethod = $location.search().apiMethod;
}
if (angular.isDefined($location.search().basicAuthCredential)){
$scope.pendingWizardSettings.basicAuthCredential = $location.search().basicAuthCredential;
}
$scope.reset();
};

Expand Down Expand Up @@ -190,13 +195,18 @@ angular.module('QuepidApp')
$scope.pendingWizardSettings.searchEndpointId = null;
};

// do we need to have the wizard be open?


if (angular.isDefined($location.search().searchEngine)) {
$scope.shouldCreateNewSearchEndpointDefaultToOpen = true;
}
else {
$scope.shouldCreateNewSearchEndpointDefaultToOpen = false;
}
// Changing http(s), so we should be open.
if (angular.isDefined($location.search().existingSearchEndpoint)) {
// We were on the Existing Search Endpoint
$scope.shouldExistingSearchEndpointDefaultToOpen = true;
}
else {
$scope.shouldCreateNewSearchEndpointDefaultToOpen = true;
}
}


$scope.validate = validate;
Expand Down Expand Up @@ -430,7 +440,12 @@ angular.module('QuepidApp')
$scope.quepidUrlToSwitchTo = resultsTuple[0];
$scope.protocolToSwitchTo = resultsTuple[1];

$scope.quepidUrlToSwitchTo = $scope.quepidUrlToSwitchTo + '?searchEngine=' + $scope.pendingWizardSettings.searchEngine + '&searchUrl=' + $scope.pendingWizardSettings.searchUrl + '&showWizard=true&caseName=' + $scope.pendingWizardSettings.caseName + '&apiMethod=' + $scope.pendingWizardSettings.apiMethod;
$scope.quepidUrlToSwitchTo = $scope.quepidUrlToSwitchTo + '?showWizard=true' +
'&searchEngine=' + $scope.pendingWizardSettings.searchEngine +
'&searchUrl=' + $scope.pendingWizardSettings.searchUrl +
'&caseName=' + $scope.pendingWizardSettings.caseName +
'&apiMethod=' + $scope.pendingWizardSettings.apiMethod +
'&basicAuthCredential=' + $scope.pendingWizardSettings.basicAuthCredential;
}
}
}
Expand Down
18 changes: 15 additions & 3 deletions app/assets/templates/views/wizardModal.html
Expand Up @@ -29,7 +29,6 @@ <h2>Name Your Case!</h2>
<wz-step title="Endpoint" id="step-three">
<h2>What Search Endpoint do you want to connect to?</h2>
<div>
shouldCreateNewSearchEndpointBeOpen{{shouldCreateNewSearchEndpointBeOpen}}
<uib-accordion>
<div uib-accordion-group class="panel-default" heading="Create a new Search Endpoint"
is-open="shouldCreateNewSearchEndpointDefaultToOpen"
Expand Down Expand Up @@ -379,7 +378,7 @@ <h2>CSV</h2>


</div>
<div uib-accordion-group class="panel-default" heading="Use an existing Search Endpoint" >
<div uib-accordion-group class="panel-default" heading="Use an existing Search Endpoint" is-open="shouldExistingSearchEndpointDefaultToOpen">
<div class="row">
<div class="alert alert-warning" role="alert" ng-if="listSearchEndpoints().length === 0">
You do not have any Search Endpoints created yet.
Expand All @@ -399,14 +398,27 @@ <h2>CSV</h2>
</p>
</div>
<div ng-if="urlValid" class="alert alert-success">Quepid can search this! Hit 'Continue' to keep working through setup.</div>
<div ng-show="showTLSChangeWarning" class="alert alert-warning">
<span>
You have specified a search endpoint url that is on a different protocol ( <code>{{protocolToSwitchTo}}</code> ) than Quepid is running,
and this triggers your browser to prevent communciation with the search endpoint. Option 1: Reload Quepid to run on the correct protocol
or Option 2: Proxy the requests THROUGH the Quepid server.
</span>
</div>
<div class="row" style="margin-top: 50px;">

<div class="pull-right">
<button class="btn btn-primary pull-right continue" ng-click="validate()" ng-disabled="pendingWizardSettings.searchEndpointId == null">Continue</button>
<button class="btn btn-primary pull-right continue" ng-show="!showTLSChangeWarning" ng-click="validate()" ng-disabled="pendingWizardSettings.searchEndpointId == null">Continue</button>

<button class="btn btn-danger" ng-show="urlInvalid && !showTLSChangeWarning" ng-click="skipValidation()" ng-disabled="validating">
<span ng-hide="validating">Skip Validation</span>
</button>

<span ng-show="showTLSChangeWarning">
<a href="{{quepidUrlToSwitchTo}}&existingSearchEndpoint=true" class="btn btn-primary form-control">
<span class="glyphicon glyphicon-refresh"></span> Reload Quepid in <code>{{protocolToSwitchTo}}</code> Protocol
</a>
</span>
</div>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/core_controller.rb
Expand Up @@ -53,9 +53,10 @@ def populate_from_params
if params[:searchEngine].present?

search_endpoint_params = {
search_engine: params[:searchEngine],
endpoint_url: params[:searchUrl],
api_method: params[:apiMethod],
search_engine: params[:searchEngine],
endpoint_url: params[:searchUrl],
api_method: params[:apiMethod],
basic_auth_credential: params[:basicAuthCredential],

}
search_endpoint = SearchEndpoint.find_or_create_by search_endpoint_params
Expand Down

0 comments on commit c7dc857

Please sign in to comment.