官术网_书友最值得收藏!

Time for action — checking to make sure the database is secure

Your _users database should be secure, so that only admins can read or alter the structure of the database. Let's quickly test this:

  1. Open Terminal.
  2. Try to read the user document again by running the following command. Again, replace your_username with the username of the service admin that you just created:
    curl localhost:5984/_users/org.couchdb.user:your_username 
    
  3. Terminal will respond with the following:
    {"error":"unauthorized","reason":"You are not authorized to access this db."} 
    

What just happened?

With the CouchDB instance out of Admin Party mode, the authentication module stepped in to make sure that anonymous users couldn't read the database.

Note

We'll add more security to the databases down the road, but this is one of the simplest ways to add security to a database.

If you were to play around with the command line again, you would be restricted by doing anything with the _users database, but you would also notice that the test-db database is operating just as it was before, perfect! That's exactly what we wanted. You might be asking how do I access the _users database through the command line, now that security is enabled? You have to show that you are an admin by passing your credentials to the RESTful JSON API.

主站蜘蛛池模板: 昭苏县| 青浦区| 扶余县| 南开区| 凤台县| 武隆县| 秀山| 九台市| 鄢陵县| 武宣县| 道孚县| 台中县| 易门县| 陇西县| 乌恰县| 尖扎县| 封开县| 富阳市| 阿鲁科尔沁旗| 蒙山县| 新乡县| 洞口县| 枞阳县| 额敏县| 兴宁市| 凌源市| 陆川县| 遂平县| 翼城县| 饶平县| 奎屯市| 商河县| 白银市| 巨野县| 奇台县| 崇义县| 大荔县| 沁水县| 奉贤区| 阜南县| 廉江市|