weathermap 插件 editor.php 的安全性問題

最近剛部署完 CactiEZ+weathermap+nagios+npc的整合,發現一個問題,weathermap下的editor.php文件是任何人都能訪問的,並能修改氣象圖,以下圖。php


經過google的搜索相關的信息,從Weathermap的網站看到,editor.php是沒有作驗證的,任何人均可以修改你的氣象圖配置文件的。但其網站也提供了一個解決方法,以下html


weathermap官網說明:http://www.network-weathermap.com/manual/latest/pages/install-cacti-editor.html ios


<Directory /var/www/html/plugins/weathermap>
   <Files editor.php>
            Order Deny,Allow
            Deny from all
            Allow from127.0.0.1
        </Files>
</Directory>

apache的配置文件末尾加上上面的代碼,這樣就能夠解決問題了。可是不久後你就會發現,本身想要修改氣象圖的時候,卻沒有權限訪問的,以下圖apache





呵呵,是否是很鬱悶呢,還得修改apache的配置文件?其實不用,若是咱們用.htaccess的驗證方法,就能夠徹底避免這個問題的發生了。瀏覽器

首先咱們在/var/www/html/plugins/weathermap下建立一個驗證文件安全


htpasswd -cb /var/www/html/plugins/weathermap/.htpasswd cacti catiuser

其中cacti是用戶名,cactiuser是密碼ide

建立好驗證文件後,在apache的配置文件末尾加上以下的代碼網站


<Directory/var/www/html/plugins/weathermap>
 <Files editor.php>
 AuthType Basic
 AuthName "Please input your username and password."
 AuthUserFile /var/www/html/plugins/weathermap/.htpasswd
 require valid-user     
 </Files>
</Directory>

這裏大概說明一下上面的字段的意思。ui

AuthType指令選擇了對用戶實施認證的方法,最經常使用的是由mod_auth提供的Basic。很重要的必須認識到的一點是,Basic認證方法並不加密來自用戶瀏覽器的密碼,所以,不該該用於高度敏感的數據。Apache在最近的版本中還有另外一種更安全的認證方法,即由mod_auth_digest提供的AuthType Digest
AuthName指令設置了使用認證的領域,它起兩個做用,首先,此領域說明會出如今顯示給用戶的密碼提問對話框中,其次,也幫助客戶端程序肯定應該輸入哪一個密碼。

AuthUserFile指令設置了密碼文件,也就是剛纔咱們已經用htpasswd創建的。
google

require valid-user表示針對/var/www/html/plugins/weathermap/.htpasswd設置的全部用戶生效。若是隻想對.htpasswd裏面設置的一個用戶生效,可使用requier user Username1


好了,設置完上面內容,從新啓動一下apache

再訪問http://xxxx.com/plugins/weathermap/editor.php的時候,就會提示你輸入用戶名和密碼了。以下圖


相關文章
相關標籤/搜索