Skip to content

Commit

Permalink
docs: add adm:pass to URL examples
Browse files Browse the repository at this point in the history
fix #4642
  • Loading branch information
jiahuili430 authored and nickva committed Jun 19, 2023
1 parent be2eecc commit 290ea87
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/docs/src/api/database/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@

.. code-block:: bash
shell> curl http://localhost:5984/pineapple/_security -X PUT -H 'content-type: application/json' -H 'accept: application/json' -d '{"admins":{"names":["superuser"],"roles":["admins"]},"members":{"names": ["user1","user2"],"roles": ["developers"]}}'
shell> curl http://adm:pass@localhost:5984/pineapple/_security -X PUT -H 'content-type: application/json' -H 'accept: application/json' -d '{"admins":{"names":["superuser"],"roles":["admins"]},"members":{"names": ["user1","user2"],"roles": ["developers"]}}'
.. code-block:: http
Expand Down
8 changes: 4 additions & 4 deletions src/docs/src/api/document/attachments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,29 +278,29 @@ database:

.. code-block:: bash
shell> curl -X PUT http://127.0.0.1:5984/test
shell> curl -X PUT http://adm:pass@127.0.0.1:5984/test
{"ok":true}
Then we create a new document and the file attachment in one go:

.. code-block:: bash
shell> curl -X PUT http://127.0.0.1:5984/test/doc/file.txt \
shell> curl -X PUT http://adm:pass@127.0.0.1:5984/test/doc/file.txt \
-H "Content-Type: application/octet-stream" [email protected]
{"ok":true,"id":"doc","rev":"1-287a28fa680ae0c7fb4729bf0c6e0cf2"}
Now we can request the whole file easily:

.. code-block:: bash
shell> curl -X GET http://127.0.0.1:5984/test/doc/file.txt
shell> curl -X GET http://adm:pass@127.0.0.1:5984/test/doc/file.txt
My hovercraft is full of eels!
But say we only want the first 13 bytes:

.. code-block:: bash
shell> curl -X GET http://127.0.0.1:5984/test/doc/file.txt \
shell> curl -X GET http://adm:pass@127.0.0.1:5984/test/doc/file.txt \
-H "Range: bytes=0-12"
My hovercraft
Expand Down
6 changes: 3 additions & 3 deletions src/docs/src/best-practices/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ Here's the worked sample above, using ``curl`` to simulate the form POST.

.. code-block:: bash
$ curl -X PUT localhost:5984/testdb/_design/myddoc -d '{ "updates": { "contactform": "function(doc, req) { ... }" } }'
$ curl -X PUT adm:pass@localhost:5984/testdb/_design/myddoc -d '{ "updates": { "contactform": "function(doc, req) { ... }" } }'
{"ok":true,"id":"_design/myddoc","rev":"1-2a2b0951fcaf7287817573b03bba02ed"}
$ curl --data "name=Lin&[email protected]&message=I Love CouchDB" http://localhost:5984/testdb/_design/myddoc/_update/contactform
$ curl --data "name=Lin&[email protected]&message=I Love CouchDB" http://adm:pass@localhost:5984/testdb/_design/myddoc/_update/contactform
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5984 (#1)
Expand All @@ -139,5 +139,5 @@ Here's the worked sample above, using ``curl`` to simulate the form POST.
* Connection #1 to host localhost left intact
{"success":"ok"}
$ curl http://localhost:5984/testdb/lin\@example.com_2018-04-05T19:51:22.278Z
$ curl http://adm:pass@localhost:5984/testdb/lin\@example.com_2018-04-05T19:51:22.278Z
{"_id":"[email protected]_2018-04-05T19:51:22.278Z","_rev":"1-34483732407fcc6cfc5b60ace48b9da9","name":"Lin","email":"[email protected]","message":"I Love CouchDB"}
4 changes: 2 additions & 2 deletions src/docs/src/best-practices/iso-date.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ simply use ``group_level`` to zoom in on whatever time you wish to use.

.. code-block:: bash
curl -X GET "http://localhost:5984/transactions/_design/widget_count/_view/toss?group_level=1"
curl -X GET "http://adm:pass@localhost:5984/transactions/_design/widget_count/_view/toss?group_level=1"
{"rows":[
{"key":[20],"value":10},
{"key":[21],"value":20}
]}
curl -X GET "http://localhost:5984/transactions/_design/widget_count/_view/toss?group_level=2"
curl -X GET "http://adm:pass@localhost:5984/transactions/_design/widget_count/_view/toss?group_level=2"
{"rows":[
{"key":[20,widget],"value":10},
Expand Down
6 changes: 3 additions & 3 deletions src/docs/src/cluster/sharding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ First, retrieve the database's current metadata:

.. code-block:: bash
$ curl http://localhost/_node/_local/_dbs/{name}
$ curl http://adm:pass@localhost:5984/_node/_local/_dbs/{name}
{
"_id": "{name}",
"_rev": "1-e13fb7e79af3b3107ed62925058bfa3a",
Expand Down Expand Up @@ -532,7 +532,7 @@ Now you can ``PUT`` this new metadata:

.. code-block:: bash
$ curl -X PUT http://localhost/_node/_local/_dbs/{name} -d '{...}'
$ curl -X PUT http://adm:pass@localhost:5984/_node/_local/_dbs/{name} -d '{...}'
.. _cluster/sharding/sync:

Expand Down Expand Up @@ -643,7 +643,7 @@ Do this for all of the nodes in your cluster. For example:

.. code-block:: bash
$ curl -X PUT http://localhost/_node/_local/_nodes/{node-name} \
$ curl -X PUT http://adm:pass@localhost:5984/_node/_local/_nodes/{node-name} \
-d '{ \
"_id": "{node-name}",
"_rev": "{rev}",
Expand Down
6 changes: 3 additions & 3 deletions src/docs/src/config/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Alternatively, configuration parameters can be set via the
:ref:`HTTP API <api/config>`. This API allows changing CouchDB configuration
on-the-fly without requiring a server restart::

curl -X PUT http://localhost:5984/_node/<name@host>/_config/uuids/algorithm -d '"random"'
curl -X PUT http://adm:pass@localhost:5984/_node/<name@host>/_config/uuids/algorithm -d '"random"'

The old parameter's value is returned in the response::

Expand All @@ -161,7 +161,7 @@ You should be careful changing configuration via the HTTP API since it's
possible to make CouchDB unreachable, for example, by changing the
:option:`chttpd/bind_address`::

curl -X PUT http://localhost:5984/_node/<name@host>/_config/chttpd/bind_address -d '"10.10.0.128"'
curl -X PUT http://adm:pass@localhost:5984/_node/<name@host>/_config/chttpd/bind_address -d '"10.10.0.128"'

If you make a typo or the specified IP address is not available from your
network, CouchDB will be unreachable. The only way to resolve this will be
Expand All @@ -182,4 +182,4 @@ cluster, as a convenience, you can use the literal string ``_local`` in place
of the node name, to interact with the local node's configuration. For
example::

curl -X PUT http://localhost:5984/_node/_local/_config/uuids/algorithm -d '"random"'
curl -X PUT http://adm:pass@localhost:5984/_node/_local/_config/uuids/algorithm -d '"random"'
2 changes: 1 addition & 1 deletion src/docs/src/ddocs/views/collation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ You can demonstrate the collation sequence for 7-bit ASCII characters like this:
require 'restclient'
require 'json'
DB="http://127.0.0.1:5984/collator"
DB="http://adm:pass@127.0.0.1:5984/collator"
RestClient.delete DB rescue nil
RestClient.put "#{DB}",""
Expand Down
4 changes: 2 additions & 2 deletions src/docs/src/ddocs/views/pagination.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Paging
To get the first five rows from the view result, you use the ``?limit=5``
query parameter::

curl -X GET http://127.0.0.1:5984/artists/_design/artists/_view/by-name?limit=5
curl -X GET 'http://adm:pass@127.0.0.1:5984/artists/_design/artists/_view/by-name?limit=5'

The result:

Expand All @@ -156,7 +156,7 @@ we can determine if there are more pages to display. We also know by the
So we query CouchDB with::

curl -X GET 'http://127.0.0.1:5984/artists/_design/artists/_view/by-name?limit=5&skip=5'
curl -X GET 'http://adm:pass@127.0.0.1:5984/artists/_design/artists/_view/by-name?limit=5&skip=5'

Note we have to use ``'`` (single quotes) to escape the ``&`` character that is
special to the shell we execute curl in.
Expand Down
14 changes: 7 additions & 7 deletions src/docs/src/intro/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ easy to make)::

Now we can use the database `albums-replica` as a replication target::

curl -X POST http://adm:pass@127.0.0.1:5984/_replicate \
-d '{"source":"http://adm:pass@127.0.0.1:5984/albums","target":"http://adm:pass@127.0.0.1:5984/albums-replica"}' \
curl -X POST http://admin:password@127.0.0.1:5984/_replicate \
-d '{"source":"http://admin:password@127.0.0.1:5984/albums","target":"http://admin:password@127.0.0.1:5984/albums-replica"}' \
-H "Content-Type: application/json"

.. note::
Expand Down Expand Up @@ -681,8 +681,8 @@ and target members of our replication request are actually links (like in
HTML) and so far we've seen links relative to the server we're working on
(hence local). You can also specify a remote database as the target::

curl -X POST http://adm:pass@127.0.0.1:5984/_replicate \
-d '{"source":"http://adm:pass@127.0.0.1:5984/albums","target":"http://user:[email protected]:5984/albums-replica"}' \
curl -X POST http://admin:password@127.0.0.1:5984/_replicate \
-d '{"source":"http://admin:password@127.0.0.1:5984/albums","target":"http://user:[email protected]:5984/albums-replica"}' \
-H "Content-Type:application/json"

Using a *local source* and a *remote target* database is called *push
Expand All @@ -700,14 +700,14 @@ You can also use a *remote source* and a *local target* to do a *pull
replication*. This is great for getting the latest changes from a server that
is used by others::

curl -X POST http://adm:pass@127.0.0.1:5984/_replicate \
-d '{"source":"http://user:[email protected]:5984/albums-replica","target":"http://adm:pass@127.0.0.1:5984/albums"}' \
curl -X POST http://admin:password@127.0.0.1:5984/_replicate \
-d '{"source":"http://user:[email protected]:5984/albums-replica","target":"http://admin:password@127.0.0.1:5984/albums"}' \
-H "Content-Type:application/json"

Finally, you can run remote replication, which is mostly useful for management
operations::

curl -X POST http://adm:pass@127.0.0.1:5984/_replicate \
curl -X POST http://admin:password@127.0.0.1:5984/_replicate \
-d '{"source":"http://user:[email protected]:5984/albums","target":"http://user:[email protected]:5984/albums-replica"}' \
-H "Content-Type: application/json"

Expand Down
16 changes: 8 additions & 8 deletions src/docs/src/intro/curl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ to get the database information:

.. code-block:: bash
shell> curl http://admin:password@127.0.0.1:5984
shell> curl http://127.0.0.1:5984
This returns the database information (formatted in the output below for
clarity):
Expand Down Expand Up @@ -65,13 +65,13 @@ clarity):

.. code-block:: bash
shell> curl -X PUT 'http://127.0.0.1:5984/demo/doc' -d '{"motto": "I love gnomes"}'
shell> curl -X PUT 'http://adm:pass@127.0.0.1:5984/demo/doc' -d '{"motto": "I love gnomes"}'
you should replace it with:

.. code-blocK:: bash
.. code-block:: bash
shell> curl -X PUT "http://127.0.0.1:5984/demo/doc" -d "{""motto"": ""I love gnomes""}"
shell> curl -X PUT "http://adm:pass@127.0.0.1:5984/demo/doc" -d "{""motto"": ""I love gnomes""}"
If you prefer, ``^"`` and ``\"`` may be used to escape the double-quote
character in quoted strings instead.
Expand All @@ -82,15 +82,15 @@ URL you send using a PUT request:

.. code-block:: bash
shell> curl -X PUT http://user:[email protected]:5984/demo
shell> curl -X PUT http://adm:[email protected]:5984/demo
{"ok":true}
But to obtain the database information you use a ``GET`` request (with
the return information formatted for clarity):

.. code-block:: bash
shell> curl -X GET http://user:[email protected]:5984/demo
shell> curl -X GET http://adm:[email protected]:5984/demo
{
"compact_running" : false,
"doc_count" : 0,
Expand Down Expand Up @@ -120,7 +120,7 @@ submit a simple document to the ``demo`` database:
.. code-block:: bash
shell> curl -H 'Content-Type: application/json' \
-X POST http://user:[email protected]:5984/demo \
-X POST http://adm:[email protected]:5984/demo \
-d '{"company": "Example, Inc."}'
{"ok":true,"id":"8843faaf0b831d364278331bc3001bd8",
"rev":"1-33b9fbce46930280dab37d672bbc8bb9"}
Expand All @@ -133,7 +133,7 @@ that was returned:

.. code-block:: bash
shell> curl -X GET http://user:[email protected]:5984/demo/8843faaf0b831d364278331bc3001bd8
shell> curl -X GET http://adm:[email protected]:5984/demo/8843faaf0b831d364278331bc3001bd8
{"_id":"8843faaf0b831d364278331bc3001bd8",
"_rev":"1-33b9fbce46930280dab37d672bbc8bb9",
"company":"Example, Inc."}
Expand Down
8 changes: 4 additions & 4 deletions src/docs/src/intro/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ Creating a new user is a very trivial operation. You just need to do a
:method:`PUT` request with the user's data to CouchDB. Let's create a user with
login `jan` and password `apple`::

curl -X PUT http://localhost:5984/_users/org.couchdb.user:jan \
curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:jan \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"name": "jan", "password": "apple", "roles": [], "type": "user"}'
Expand Down Expand Up @@ -394,7 +394,7 @@ Summarizing the above process - we need to get the document's content, add
the ``password`` field with the new password in plain text and then store the
JSON result to the authentication database. ::

curl -X GET http://localhost:5984/_users/org.couchdb.user:jan
curl -X GET http://admin:password@localhost:5984/_users/org.couchdb.user:jan

.. code-block:: javascript
Expand All @@ -413,7 +413,7 @@ JSON result to the authentication database. ::
Here is our user's document. We may strip hashes from the stored document to
reduce the amount of posted data::

curl -X PUT http://localhost:5984/_users/org.couchdb.user:jan \
curl -X PUT http://admin:password@localhost:5984/_users/org.couchdb.user:jan \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "If-Match: 1-e0ebfb84005b920488fc7a8cc5470cc0" \
Expand Down Expand Up @@ -504,7 +504,7 @@ The database is now secured against anonymous reads and writes::
You declared user "jan" as a member in this database, so he is able to read and
write normal documents::

> curl -u jan:apple http://localhost:5984/mydatabase/
> curl -u jan:orange http://localhost:5984/mydatabase/

.. code-block:: javascript
Expand Down
10 changes: 5 additions & 5 deletions src/docs/src/maintenance/compaction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Compaction can be manually triggered per database and runs as a background
task. To start it for specific database there is need to send HTTP
:post:`/{db}/_compact` sub-resource of the target database::

curl -H "Content-Type: application/json" -X POST http://localhost:5984/my_db/_compact
curl -H "Content-Type: application/json" -X POST http://adm:pass@localhost:5984/my_db/_compact

On success, HTTP status :statuscode:`202` is returned immediately:

Expand Down Expand Up @@ -271,7 +271,7 @@ for the request. If you don't, you will be aware about with HTTP status
When the compaction is successful started and running it is possible to get
information about it via :ref:`database information resource <api/db>`::

curl http://localhost:5984/my_db
curl http://adm:pass@localhost:5984/my_db

.. code-block:: http
Expand Down Expand Up @@ -303,7 +303,7 @@ Note that ``compact_running`` field is ``true`` indicating that compaction
is actually running. To track the compaction progress you may query the
:get:`_active_tasks </_active_tasks>` resource::

curl http://localhost:5984/_active_tasks
curl http://adm:pass@localhost:5984/_active_tasks

.. code-block:: http
Expand Down Expand Up @@ -351,7 +351,7 @@ per `design document`. To start their compaction, send the HTTP
.. code-block:: bash
curl -H "Content-Type: application/json" -X POST http://localhost:5984/dbname/_compact/ddoc-name
curl -H "Content-Type: application/json" -X POST http://adm:pass@localhost:5984/dbname/_compact/ddoc-name
.. code-block:: javascript
Expand All @@ -372,7 +372,7 @@ When you change a view, old indexes remain on disk. To clean up all outdated
view indexes (files named after the MD5 representation of views, that does not
exist anymore) you can trigger a :ref:`view cleanup <api/db/view_cleanup>`::

curl -H "Content-Type: application/json" -X POST http://localhost:5984/dbname/_view_cleanup
curl -H "Content-Type: application/json" -X POST http://adm:pass@localhost:5984/dbname/_view_cleanup

.. code-block:: javascript
Expand Down
Loading

0 comments on commit 290ea87

Please sign in to comment.