You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by am...@apache.org on 2019/05/28 11:19:33 UTC

[ambari] branch branch-2.7 updated: AMBARI-25175. Start, Stop, Service Check and other request actions using PUT/POST from Ambari UI do not respond when tried via Knox TP (amagyar) (#2842) (#2990)

This is an automated email from the ASF dual-hosted git repository.

amagyar pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new cdf6b9e  AMBARI-25175. Start, Stop, Service Check and other request actions using PUT/POST from Ambari UI do not respond when tried via Knox TP (amagyar) (#2842) (#2990)
cdf6b9e is described below

commit cdf6b9e0d8a9766563b5e1c5ca05386728b51858
Author: Attila Magyar <am...@hortonworks.com>
AuthorDate: Tue May 28 13:19:26 2019 +0200

    AMBARI-25175. Start, Stop, Service Check and other request actions using PUT/POST from Ambari UI do not respond when tried via Knox TP (amagyar) (#2842) (#2990)
    
    * AMBARI-25175. Start, Stop, Service Check and other request actions using PUT/POST from Ambari UI do not respond when tried via Knox TP (amagyar) (#2842)
    
    * AMBARI-25175. Start, Stop, Service Check and other request actions using PUT/POST from Ambari UI do not respond when tried via Knox TP (amagyar) (#2842)
---
 .../java/org/apache/ambari/server/api/services/RequestFactory.java    | 2 ++
 ambari-server/src/test/python/ldap-password.dat                       | 2 +-
 ambari-web/app/utils/ajax/ajax.js                                     | 4 ++++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestFactory.java
index a26518d..dec4990 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestFactory.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.UriInfo;
 
+import org.apache.ambari.server.api.predicate.QueryLexer;
 import org.apache.ambari.server.api.resources.ResourceDefinition;
 import org.apache.ambari.server.api.resources.ResourceInstance;
 
@@ -154,6 +155,7 @@ public class RequestFactory {
    */
   private boolean applyDirectives(Request.Type requestType, RequestBody body, UriInfo uriInfo, ResourceInstance resource) {
     Map<String, String> queryParameters = getQueryParameters(uriInfo, body);
+    queryParameters.remove(QueryLexer.QUERY_DOAS); // KNOX appends a doAs parameter to every request. Ignore this as it's neither a query predicate nor a directive.
     Map<String, String> requestInfoProperties;
     boolean allDirectivesApplicable = true;
     if (!queryParameters.isEmpty()) {
diff --git a/ambari-server/src/test/python/ldap-password.dat b/ambari-server/src/test/python/ldap-password.dat
index 7aa311a..c7589bd 100644
--- a/ambari-server/src/test/python/ldap-password.dat
+++ b/ambari-server/src/test/python/ldap-password.dat
@@ -1 +1 @@
-password
\ No newline at end of file
+${alias=ambari.ldap.manager.password}
\ No newline at end of file
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 3d9fc7e..12e12b1 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -3275,6 +3275,10 @@ var formatRequest = function (data) {
   if (this.format) {
     jQuery.extend(opt, this.format(data, opt));
   }
+  if (!('headers' in opt && 'Content-Type' in opt.headers)) {
+    // With the default www-url-form-encoded Content-Type KNOX would corrupt the json content.
+    opt.headers['Content-Type'] = 'text/plain';
+  }
   var statusCode = jQuery.extend({}, require('data/statusCodes'));
   statusCode['404'] = function () {
     console.log("Error code 404: URI not found. -> " + opt.url);