在我们的asp.net核心应用程序中,我需要对IIS 8.0服务器进行AJAX调用。
服务器URL受CA SiteMinder SSO保护。

当我使用AJAX发出Get请求时,我得到了所需的响应。但是相反,无论何时发出“放置”或“发布”请求,我都会收到302响应,并显示表明SiteMinder正在请求凭据的URL。

我认为,只要通过SiteMinder对用户进行身份验证,那么从同一浏览器会话向同一域发出的请求就不会明确要求用户凭据。

据我所知,即使已对用户进行身份验证并且将请求(PUT和POST)发送到同一域,SiteMinder仍在请求用户凭据。
CA SiteMinder提供了一个cookie(HttpOnly),我相信该cookie用于验证对服务器的请求。我可以确认SiteMinder cookie是否包含在请求标头中。

我的问题是,为什么SiteMinder对GET和POST / Put请求的处理方式有所不同?还是有什么方法可以使我使用XHR使用Siteminder进行POST / PUT请求工作(而无需从SiteMinder获得重定向)?

这是发出XHR请求的功能的链接。



function fixRecords() {
	_buildingId = ($("input:hidden[id='buildingIdModal']").val());
    _roomNo = $("#roomNoModal").val();
      if ((_roomNo === "" || _roomNo == null) && _suggestedRoomNo) {
          _roomNo = document.getElementById("roomNoModal").value;
     }
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (this.readyState == 4 && this.status.toString() == 200) {
            var message = "Record updated sucessfully.";
            var jsonResponse = JSON.parse(this.responseText);
            console.log(jsonResponse);
            _roomNo = jsonResponse.roomNo;
            _buildingId = jsonResponse.building;
            _runId = jsonResponse.runId;
            var _prevRoomId = _roomId;
            _roomId = jsonResponse.roomId;
            _recId = jsonResponse.recordId;
            message = jsonResponse.comment;
            _valid = jsonResponse.valid;
            _suggestion = '<div class="glyphicon glyphicon-alert text-info">' + jsonResponse.suggestion+'</div>';
            _suggestedRoomId = jsonResponse.suggestedRoomId;
            _suggestedRoomNo = jsonResponse.suggestedRoomNo;
            var _protocol = jsonResponse.protocol;
            var _invAcct = jsonResponse.account;
            var _pi = jsonResponse.pi;
			displayInformationInFixModal(message + _suggestion, null);
            $('#fixModal').on('show.bs.modal', inflateModal(message, _buildingId, _cageId, _roomId, _roomNo, _recId, _runId, _frequencyId, _frequencyType, _valid, _suggestedRoomId, _suggestedRoom, _suggestion, _protocol, _pi, _invAcct));
            $('#fixModal').modal('show').on("hide", function () {
                $('#fixModal').modal('hide');
            });
            //document.write(this.responseText);
        }
        $('#showLoadingImage').modal('hide');
        return false;
     };
     if (_roomNo == null || _roomNo.trim()===''|| _roomNo==="Room Num Unknown") {
         alert("Please enter a valid Room No.");
         var message = "Please enter a valid Room No.";
         $('#fixModal').on('show.bs.modal', populateModalMessage(message));
         $('#fixModal').modal('show').on("hide", function () {
             $('#fixModal').modal('hide');
         });
     }
	if (_recId <=0) {
		xhttp.open("POST", "/FileUploads/InsertFixRecordToDB?BuildingId=" + _buildingId );
        }
    else {
		xhttp.open("PUT", "/FileUploads/FixARecord?BuildingId=" + _buildingId );
        }
        $('#showLoadingImage').modal('show');
        $('#showLoadingImage').css('zIndex', 1500);
        xhttp.send();
    }

最佳答案

如果SiteMinder cookie是HttpOnly,那么ajax引擎将不会明确发送它。这就是HttpOnly的意思。

另外,SiteMinder(现在称为CA SSO)肯定可以区分不同的HTTP方法,因此SiteMinder规则对于GET POST和PUT可以有所不同。您的SiteMinder管理员将需要检查适用于您的应用程序的规则,以确保它们明确涵盖了GET POST和PUT(尤其是通常不包括PUT)。

HTH!

09-20 23:20