2012-06-20 49 views
0

我需要確保當引用來自遠程域時,Drupal的用戶登錄表單無法登錄。這是一個影響企業接受度的安全漏洞。.htaccess引用重寫規則爲一個漂亮的網址

的路徑是:https://domain.com/user

目前在的.htaccess結束代替規則來要求HTTPS訪問

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

我看了看這個,看規則會如何識別網址,但不知道我將如何對待這種情況,被引薦實現,而且不影響其他規則的HTTPS

回答

1
# if referer not empty 
RewriteCond %{HTTP_REFERER} !^$ 
# and referer doesn't contain domain.com 
RewriteCond %{HTTP_REFERER} !domain\.com 
# and it is a POST request 
RewriteCond %{REQUEST_METHOD} POST [NC] 
# than redirect to current url to remove the POST data and show the default login screen 
RewriteRule ^(user)$ /$1 [R=302,L] 
+1

它並不安全檢查HTTP_REFERER來驗證用戶的LO陽離子。 HTTP_REFERER由客戶端設置,很容易被欺騙。 此外,用戶不能登錄到表單,除非表單由drupal首先生成(表單標記需要設置和匹配),這意味着不會有方法將登錄表單嵌入到另一個網站。 Drupal已經提供了xss-prevention。 – Mixologic