[英]How does one block direct browser access of client side include files in angularjs?
在angularjs應用程序中,當用戶在其Web瀏覽器中鍵入mydomain.com
時,將提供index.html
頁面。 但是該頁面具有客戶端包含頁面,包括index_firstinclude.html
。 但是該應用程序存在一個漏洞,因為如果任何用戶(或網絡爬蟲蜘蛛機器人)在瀏覽器中鍵入mydomain.com/index_firstinclude.html
都可以看到意外的內容。 這可能會導致自動鏈接到來自搜索引擎和其他網站的意外的包含URL。 如果他們在瀏覽器中鍵入mydomain.com/index_firstinclude.html
,如何確保用戶看不到index_firstinclude.html
的內容?
這是index.html
:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="resources/css/my.css">
</head>
<body ng-app="myApp">
<script src="js/lib/angular.js"></script>
<script type="text/javascript" src="myController.js"></script>
<div ng-controller="myController">
<table width=100%>
<tr>
<td align="center">
<div ng-include="'index_firstinclude.html'"></div>
</td>
</tr>
</table>
</div>
</body>
</html>
在您的代碼示例中,您將index_firstinclude.html包含在您的主頁中,因此,網站訪問者和處理javascript網站的那些漫游器都可以看到它的內容。 您可以通過配置Web服務器來禁用為特定的用戶代理加載任何指定的文件。 另外,如果某些頁面僅包含授權用戶的內容,則可以為它們提供服務器端授權檢查。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.