Skip to content

Commit

Permalink
Merge pull request #3067 from jcantrill/1614255
Browse files Browse the repository at this point in the history
No longer post token for kibana
  • Loading branch information
openshift-merge-robot authored Aug 30, 2018
2 parents 5b005aa + d922cc2 commit e83dbde
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 150 deletions.
18 changes: 1 addition & 17 deletions app/scripts/directives/logViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,23 +434,10 @@ angular.module('openshiftConsole')
if(!(projectName && containerName && name && url)) {
return;
}

// 3 things needed:
// - kibanaAuthUrl to authorize user
// - access_token
// - kibanaArchiveUrl for the final destination once auth'd
angular.extend($scope, {
kibanaAuthUrl: $sce.trustAsResourceUrl(URI(url)
.segment('auth').segment('token')
.normalizePathname().toString()),
access_token: AuthService.UserStore().getToken()
});

$scope.$watchGroup(['context.project.metadata.name', 'options.container', 'name'], function() {
angular.extend($scope, {
// The archive URL violates angular's built in same origin policy.
// Need to explicitly tell it to trust this location or it will throw errors.
kibanaArchiveUrl: $sce.trustAsResourceUrl(logLinks.archiveUri({
baseURL: url,
namespace: $scope.context.project.metadata.name,
namespaceUid: $scope.context.project.metadata.uid,
podname: name,
Expand All @@ -461,9 +448,6 @@ angular.module('openshiftConsole')
});
});




// PUBLIC API ----------------------------------------------------

this.cacheScrollableNode = function(node) {
Expand Down
7 changes: 6 additions & 1 deletion app/scripts/services/logLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ angular.module('openshiftConsole')

// broken up for readability:
var template = _.template([
"/#/discover?",
"<%= baseURL %>#/discover?",
"_g=(",
"time:(",
"from:now-1w,",
Expand Down Expand Up @@ -76,6 +76,11 @@ angular.module('openshiftConsole')
var archiveUri = function(opts, prefix) {
prefix = prefix || 'project.' + opts.namespace + '.' + opts.namespaceUid;
opts.index = prefix + '.*';

if (opts.baseURL.substr(-1) !== '/') {
opts.baseURL += '/';
}

return template(opts);
};

Expand Down
10 changes: 2 additions & 8 deletions app/views/directives/logs/_log-viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
extension-name="log-links"
extension-types="link dom"
extension-args="[object, options]"></span>
<span ng-if="kibanaAuthUrl">
<form
action="{{kibanaAuthUrl}}"
method="POST">
<input type="hidden" name="redirect" value="{{kibanaArchiveUrl}}">
<input type="hidden" name="access_token" value="{{access_token}}">
<button class="btn btn-link">View Archive</button>
</form>
<span ng-if="kibanaArchiveUrl">
<a href="{{kibanaArchiveUrl}}">View Archive</a>
<span ng-if="state && state !== 'empty'" class="action-divider">|</span>
</span>
<span ng-if="canSave && state && state !== 'empty'">
Expand Down
Loading

0 comments on commit e83dbde

Please sign in to comment.