2016-11-29 49 views
0

我嘗試找到導致基本登錄對話框訪問受保護的端點時提示的原因。 我們落後於SSL並使用Taffy REST框架。Taffy基本登錄提示出現

HTTP基本登錄我指的是這樣https://www.httpwatch.com/httpgallery/authentication/#showExample10 (點擊 「顯示圖片」 按鈕)

我們onTaffyRequest代碼

function onTaffyRequest(verb, cfc, requestArguments, mimeExt, headers, methodMetadata, matchedURI){ 

      //get username and password 
      structAuth = structnew(); 

      structAuth = getBasicAuthCredentials(); 

      structAuth.authenticated = false; 
      local.status = "forbidden"; 



      /*<!--- Get request from ColdFusion page contenxt. --->*/ 
      objRequest = GetPageContext().GetRequest(); 
      /*<!--- Get requested URL from request object. --->*/ 
      requestArguments.strUrl = objRequest.GetRequestUrl().Append(
       "?" & objRequest.GetQueryString() 
      ).ToString(); 


      /* CATCH NO BASIC auth*/    
      //if username is blank return false 
      if (structAuth.username is ""){ 
       return representationOf(local.status).withStatus(401); 
      } 

      //check invalid password 
      if(structAuth.password is ""){ 
       return representationOf(local.status).withStatus(401); 
      }  


      return true; 
     } 

是對objRequest = GetPageContext()。的GetRequest ();使登錄提示出現?

回答

0

如果你刪除了objRequest = GetPageContext().GetRequest()位,它是否仍然給你基本的認證提示?

我懷疑你的API所在的目錄中可能有一個.htaccess文件,該文件通過Apache(或者,如果使用IIS,你需要通過IIS進行基本身份驗證)請求基本身份驗證,並顯示登錄提示。

這是一個服務器級別的對話框,不太可能是您通過代碼想到的東西。

+0

我曾嘗試刪除objRequest = GetPageContext()。GetRequest(),並且沒有出現提示。我很困惑GetPageContext()。GetRequest()能夠帶來基本登錄提示 – Vlad