Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit 35f59b2

Browse files
gjaldonkxepal
authored andcommitted
Grammar fixes in security section
This closes #3 Signed-off-by: Alexander Shorin <[email protected]>
1 parent 5718b70 commit 35f59b2

File tree

1 file changed

+69
-79
lines changed

1 file changed

+69
-79
lines changed

src/intro/security.rst

Lines changed: 69 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -260,46 +260,42 @@ with the timeout (in seconds) setting in the :ref:`couch_httpd_auth
260260
Authentication Database
261261
=======================
262262

263-
You may already note, that CouchDB administrators are defined within config file
264-
and you now wondering does regular users are also stored there. No, they don't.
265-
CouchDB has special `authentication database` -- ``_users`` by default -- that
266-
stores all registered users as JSON documents.
263+
You may already note that CouchDB administrators are defined within the config
264+
file and are wondering if regular users are also stored there. No, they are not.
265+
CouchDB has a special `authentication database`, named ``_users`` by default,
266+
that stores all registered users as JSON documents.
267267

268-
CouchDB uses special database (called ``_users`` by default) to store
269-
information about registered users. This is a `system database` -- this means
270-
that while it shares common :ref:`database API <api/database>`, there are some
271-
special security-related constraints applied and used agreements on documents
272-
structure. So how `authentication database` is different from others?
268+
This special database is a `system database`, this means that while it shares
269+
the common :ref:`database API <api/database>`, there are some
270+
special security-related constraints applied. Below is listed how the
271+
`authentication database` is different from the other databases.
273272

274273
- Only administrators may browse list of all documents
275274
(:get:`GET /_users/_all_docs </{db}/_all_docs>`)
276-
- Only administrators may listen :ref:`changes feed
275+
- Only administrators may listen to :ref:`changes feed
277276
<changes>` (:get:`GET /_users/_changes </{db}/_changes>`)
278277
- Only administrators may execute design functions like :ref:`views <viewfun>`,
279278
:ref:`shows <showfun>` and :ref:`others <ddocs>`
280-
- Only administrators may :method:`GET`, :method:`PUT` or :method:`DELETE`
281-
any document (to be honest, that they always can do)
282-
- There is special design document ``_auth`` that cannot be modified
283-
- Every document (of course, except `design documents`) represents registered
279+
- There is a special design document ``_auth`` that cannot be modified
280+
- Every document except the `design documents` represent registered
284281
CouchDB users and belong to them
285282
- Users may only access (:get:`GET /_users/org.couchdb.user:Jan
286283
</{db}/{docid}>`) or modify (:put:`PUT /_users/org.couchdb.user:Jan
287-
</{db}/{docid}>`) documents that they owns
284+
</{db}/{docid}>`) documents that they own
288285

289-
These draconian rules are reasonable: CouchDB cares about user's personal
290-
information and doesn't discloses it for everyone. Often, users documents are
291-
contains not only system information like `login`, `password hash` and `roles`,
292-
but also sensitive personal information like: real name, email, phone, special
293-
internal identifications and more - this is not right information that you
286+
These draconian rules are necessary since CouchDB cares about its users'
287+
personal information and takes not to disclose it to just anyone. Often, user
288+
documents contain system information like `login`, `password hash` and `roles`,
289+
apart from sensitive personal information like: real name, email, phone, special
290+
internal identifications and more. This is not information that you
294291
want to share with the World.
295292

296293

297294
Users Documents
298295
===============
299296

300-
Each CouchDB user is stored in document format. These documents are contains
301-
several *mandatory* fields, that CouchDB handles for correct authentication
302-
process:
297+
Each CouchDB user is stored in document format. These documents contain
298+
several *mandatory* fields, that CouchDB needs for authentication:
303299

304300
- **_id** (*string*): Document ID. Contains user's login with special prefix
305301
:ref:`org.couchdb.user`
@@ -317,37 +313,37 @@ process:
317313
- **salt** (*string*): Hash salt. Used for ``simple`` `password_scheme`
318314
- **type** (*string*): Document type. Constantly have value ``user``
319315

320-
Additionally, you may specify any custom fields that are relates to the target
321-
user. This is good place to store user's private information because only the
316+
Additionally, you may specify any custom fields that relate to the target
317+
user. This is a good place to store user's private information because only the
322318
target user and CouchDB administrators may browse it.
323319

324320
.. _org.couchdb.user:
325321

326322
Why ``org.couchdb.user:`` prefix?
327323
---------------------------------
328324

329-
The reason to have special prefix before user's login name is to have
330-
namespaces which users are belongs to. This prefix is designed to prevent
331-
replication conflicts when you'll try to merge two `_user` databases or more.
325+
The reason there is a special prefix before a user's login name is to have
326+
namespaces that users belong to. This prefix is designed to prevent
327+
replication conflicts when you try merging two `_user` databases or more.
332328

333-
For current CouchDB releases, all users are belongs to the same
334-
``org.couchdb.user`` namespace and this cannot be changed, but we'd made
335-
such design decision for future releases.
329+
For current CouchDB releases, all users belong to the same
330+
``org.couchdb.user`` namespace and this cannot be changed. This may be changed
331+
in future releases.
336332

337333

338334
Creating New User
339335
=================
340336

341-
Creating new user is a very trivial operation. You need just to send single
342-
:method:`PUT` request with user's data to CouchDB. Let's create user with login
343-
`jan` and password `apple`::
337+
Creating a new user is a very trivial operation. You just need to do a
338+
:method:`PUT` request with user's data to CouchDB. Let's create a user with
339+
login `jan` and password `apple`::
344340

345341
curl -X PUT http://localhost:5984/_users/org.couchdb.user:jan \
346342
-H "Accept: application/json" \
347343
-H "Content-Type: application/json" \
348344
-d '{"name": "jan", "password": "apple", "roles": [], "type": "user"}'
349345

350-
This `curl` command will produce next HTTP request:
346+
This `curl` command will produce the following HTTP request:
351347

352348
.. code-block:: http
353349
@@ -373,8 +369,8 @@ And CouchDB responds with:
373369
374370
{"ok":true,"id":"org.couchdb.user:jan","rev":"1-e0ebfb84005b920488fc7a8cc5470cc0"}
375371
376-
Document successfully created what also means that user `jan` have created too!
377-
Let's check is this true::
372+
The document was successfully created! The user `jan` should now exist in our
373+
database. Let's check if this is true::
378374

379375
curl -X POST http://localhost:5984/_session -d 'name=jan&password=apple'
380376

@@ -384,9 +380,9 @@ CouchDB should respond with:
384380
385381
{"ok":true,"name":"jan","roles":[]}
386382
387-
Which means that username was recognized and password's hash matches with stored
388-
one. If we specify wrong login and/or password, CouchDB will notify us with
389-
the next error message:
383+
This means that the username was recognized and the password's hash matches
384+
with the stored one. If we specify an incorrect login and/or password, CouchDB
385+
will notify us with the following error message:
390386

391387
.. code-block:: javascript
392388
@@ -396,21 +392,16 @@ the next error message:
396392
Password Changing
397393
=================
398394

399-
This is quite common situation: user had forgot their password, it was leaked
400-
somehow (via copy-paste, screenshot, or by typing in wrong chat window) or
401-
something else. Let's change password for our user `jan`.
395+
Let's define what is password changing from the point of view of CouchDB and
396+
the authentication database. Since "users" are "documents", this operation is
397+
just updating the document with a special field ``password`` which contains
398+
the *plain text password*. Scared? No need to be, the authentication database
399+
has a special internal hook on document update which looks for this field and
400+
replaces it with the *secured hash* depending on the chosen ``password_scheme``.
402401

403-
First of all, let's define what is the password changing from the point of
404-
CouchDB and the authentication database. Since "users" are "documents", this
405-
operation is nothing, but updating the document with special field ``password``
406-
which contains the *plain text password*. Scared? No need to: the authentication
407-
database has special internal hook on document update which looks for this
408-
field and replaces it with the *secured hash*, depending on chosen
409-
``password_scheme``.
410-
411-
Summarizing above, we need to get document content, add ``password`` field
412-
with new plain text password value and store JSON result to the authentication
413-
database.
402+
Summarizing the above process - we need to get the document's content, add
403+
the ``password`` field with the new password in plain text and then store the
404+
JSON result to the authentication database.
414405

415406
::
416407

@@ -430,8 +421,8 @@ database.
430421
"type": "user"
431422
}
432423
433-
Here is our user's document. We may strip hashes from stored document to reduce
434-
amount of posted data::
424+
Here is our user's document. We may strip hashes from the stored document to reduce
425+
the amount of posted data::
435426

436427
curl -X PUT http://localhost:5984/_users/org.couchdb.user:jan \
437428
-H "Accept: application/json" \
@@ -443,7 +434,7 @@ amount of posted data::
443434
444435
{"ok":true,"id":"org.couchdb.user:jan","rev":"2-ed293d3a0ae09f0c624f10538ef33c6f"}
445436
446-
Updated! Now let's check that password was really changed::
437+
Updated! Now let's check that the password was really changed::
447438

448439
curl -X POST http://localhost:5984/_session -d 'name=jan&password=apple'
449440

@@ -465,11 +456,12 @@ CouchDB should respond with:
465456
466457
{"ok":true,"name":"jan","roles":[]}
467458
468-
Hooray! You may wonder why so complex: need to retrieve user's document, add
469-
special field to it, post it back - where is one big button that changes the
470-
password without worry about document's content? Actually, :ref:`Futon
471-
<intro/futon>` has such at the right bottom corner if you have logged in -
472-
all implementation details are hidden from your sight.
459+
Hooray! You may wonder why this was so complex - we need to retrieve user's
460+
document, add a special field to it, post it back - where is that one big
461+
button that changes the password without worrying about the document's content?
462+
Actually, :ref:`Futon <intro/futon>` has one such thing at the bottom right
463+
corner if are logged in. Using that will hide all the implementation details
464+
described above and keep it real simple for you.
473465

474466
.. note::
475467

@@ -482,47 +474,45 @@ Users Public Information
482474

483475
.. versionadded:: 1.4
484476

485-
Sometimes users *wants* to share some information with the World. For instance,
477+
Sometimes users *want* to share some information with the world. For instance,
486478
their contact email to let other users get in touch with them. To solve this
487-
problem, but still keep sensitive and private information secured there is
488-
special :ref:`configuration <config>` option :config:option:`public_fields
489-
<couch_httpd_auth/public_fields>`. In this options you may define comma
490-
separated list of users document fields that will be publicity available.
479+
problem, but still keep sensitive and private information secured, there is
480+
a special :ref:`configuration <config>` option :config:option:`public_fields
481+
<couch_httpd_auth/public_fields>`. In this option you may define
482+
a comma-separated lis of users document fields that will be publicly available.
491483

492-
Normally, if you request any user's document and you're not administrator or
493-
this document owner, CouchDB will respond with :statuscode:`404`::
484+
Normally, if you request a user document and you're not an administrator or
485+
document's owner, CouchDB will respond with :statuscode:`404`::
494486

495487
curl http://localhost:5984/_users/org.couchdb.user:robert
496488

497489
.. code-block:: javascript
498490
499491
{"error":"not_found","reason":"missing"}
500492
501-
This response is constant for both cases when user exists or not exists - by
493+
This response is constant for both cases when user exists or doesn't exist for
502494
security reasons.
503495

504-
Now let's share field ``name``. First, setup the ``public_fields`` configuration
505-
option. Remember, that this action requires administrator's privileges and
506-
the next command will ask for password for user `admin`, assuming that they are
507-
the server administrator::
496+
Now let's share the field ``name``. First, setup the ``public_fields``
497+
configuration option. Remember, that this action requires administrator
498+
privileges. The next command will prompt you for user `admin`'s password:
508499

509500
curl -X PUT http://localhost:5984/_config/couch_http_auth/public_fields \
510501
-H "Content-Type: application/json" \
511502
-d '"name"' \
512503
-u admin
513504

514-
What have changed? Let's check Robert's document once again::
505+
What has changed? Let's check Robert's document once again::
515506

516507
curl http://localhost:5984/_users/org.couchdb.user:robert
517508

518509
.. code-block:: javascript
519510
520511
{"_id":"org.couchdb.user:robert","_rev":"6-869e2d3cbd8b081f9419f190438ecbe7","name":"robert"}
521512
522-
Good news! Now we may read field ``name`` from *every user's document without
523-
need to be an administrator*. That's important note: don't publish sensitive
524-
information, especially without user's acknowledge - they may not like such
525-
actions from your side.
513+
Good news! Now, we may read the field ``name`` in *every user document without
514+
needing to be an administrator*. Keep in mind though not to publish sensitive
515+
information, especially without user's consent!
526516

527517

528518
==============

0 commit comments

Comments
 (0)