python-arango 8.3.7__tar.gz → 8.3.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_arango-8.3.8/.agents/skills/python-arango-development/SKILL.md +69 -0
- {python_arango-8.3.7/python_arango.egg-info → python_arango-8.3.8}/PKG-INFO +1 -1
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/connection.py +2 -1
- python_arango-8.3.8/arango/version.py +1 -0
- python_arango-8.3.8/docs/auth.rst +169 -0
- {python_arango-8.3.7 → python_arango-8.3.8/python_arango.egg-info}/PKG-INFO +1 -1
- {python_arango-8.3.7 → python_arango-8.3.8}/python_arango.egg-info/SOURCES.txt +1 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/python_arango.egg-info/scm_file_list.json +1 -0
- python_arango-8.3.8/python_arango.egg-info/scm_version.json +8 -0
- python_arango-8.3.7/arango/version.py +0 -1
- python_arango-8.3.7/docs/auth.rst +0 -117
- python_arango-8.3.7/python_arango.egg-info/scm_version.json +0 -8
- {python_arango-8.3.7 → python_arango-8.3.8}/.circleci/config.yml +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/.github/workflows/codeql.yaml +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/.github/workflows/docs.yaml +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/.github/workflows/pypi.yaml +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/.gitignore +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/.pre-commit-config.yaml +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/.readthedocs.yaml +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/AGENTS.md +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/LICENSE +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/MANIFEST.in +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/README.md +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/__init__.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/api.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/aql.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/backup.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/client.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/cluster.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/collection.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/cursor.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/database.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/errno.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/exceptions.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/executor.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/formatter.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/foxx.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/graph.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/http.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/job.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/pregel.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/py.typed +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/replication.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/request.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/resolver.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/response.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/result.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/typings.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/utils.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/arango/wal.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/Makefile +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/admin.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/analyzer.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/aql.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/async.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/backup.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/batch.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/certificates.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/cluster.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/collection.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/compression.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/conf.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/cursor.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/database.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/document.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/errno.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/errors.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/foxx.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/graph.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/http.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/index.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/indexes.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/logging.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/make.bat +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/overload.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/overview.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/pregel.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/replication.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/requirements.txt +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/schema.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/serializer.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/simple.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/specs.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/static/logo.png +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/task.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/threading.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/transaction.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/user.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/view.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/docs/wal.rst +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/pyproject.toml +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/python_arango.egg-info/dependency_links.txt +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/python_arango.egg-info/requires.txt +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/python_arango.egg-info/top_level.txt +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/setup.cfg +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/setup.py +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/starter.sh +0 -0
- {python_arango-8.3.7 → python_arango-8.3.8}/todo.md +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: python-arango-development
|
|
3
|
+
description: >-
|
|
4
|
+
Maintain and extend python-arango, the ArangoDB Python driver. Use for
|
|
5
|
+
driver features, bug fixes, refactoring, and related tests or documentation,
|
|
6
|
+
rather than application code that uses the driver.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Python driver development
|
|
10
|
+
|
|
11
|
+
Follow the repository's [AGENTS.md](../../../AGENTS.md) for setup, validation
|
|
12
|
+
commands, and contribution rules.
|
|
13
|
+
|
|
14
|
+
Before changing an operation, trace a neighboring method with a similar
|
|
15
|
+
request and response shape. Public API methods usually construct a `Request`,
|
|
16
|
+
define a response handler, and call `self._execute(request, response_handler)`.
|
|
17
|
+
See `arango/api.py`, `arango/request.py`, and the API group being changed.
|
|
18
|
+
Keep request construction and response conversion at the same layer as the
|
|
19
|
+
neighboring operations.
|
|
20
|
+
|
|
21
|
+
Preserve execution through `_execute` when following this pattern. It delegates
|
|
22
|
+
to the configured executor in `arango/executor.py`, supporting default, async,
|
|
23
|
+
batch, and transaction contexts. Calling the connection directly can bypass
|
|
24
|
+
that behavior. Preserve `Result[T]` annotations where applicable: an operation
|
|
25
|
+
can return a value, an async or batch job, or `None`, depending on its context.
|
|
26
|
+
See `arango/result.py` for the shared type.
|
|
27
|
+
|
|
28
|
+
For endpoint or option changes, verify the server HTTP API for the targeted
|
|
29
|
+
ArangoDB versions. Map Python option names to the specified wire names and
|
|
30
|
+
locations: endpoint path, `params` for query parameters, `headers`, or `data`
|
|
31
|
+
for the body. Preserve existing defaults and distinguish omitted options from
|
|
32
|
+
explicit `False`, `0`, or empty values. Where `None` means omission, use
|
|
33
|
+
`is not None` rather than a truthiness check. `normalize_params` in `arango/request.py`
|
|
34
|
+
stringifies supplied values, including `None`; omit such query entries before
|
|
35
|
+
constructing the request. Keep explicit JSON nulls where the body contract
|
|
36
|
+
requires them.
|
|
37
|
+
|
|
38
|
+
Follow the neighboring handler's success checks and response formatting;
|
|
39
|
+
reuse helpers in `arango/formatter.py` where applicable. Preserve Python-facing
|
|
40
|
+
field names, return shapes, and silent-operation results. Handle special
|
|
41
|
+
statuses before the general failure check where required, such as revision
|
|
42
|
+
conflicts. Raise the operation-specific exception from `arango/exceptions.py`
|
|
43
|
+
with `(resp, request)` to retain HTTP and ArangoDB error details. Keep signatures,
|
|
44
|
+
annotations, and Sphinx parameter and return documentation aligned. Cover
|
|
45
|
+
omitted and explicit option values, result conversion, and affected error
|
|
46
|
+
paths in regression tests.
|
|
47
|
+
|
|
48
|
+
Add focused regression coverage in the relevant `tests/test_*.py` module,
|
|
49
|
+
reusing fixtures and helpers from `tests/conftest.py` and `tests/helpers.py`.
|
|
50
|
+
Check the affected request mapping, result, or error behavior; exercise related
|
|
51
|
+
execution contexts when the change affects them.
|
|
52
|
+
|
|
53
|
+
For test selection, inspect fixture dependencies in `tests/conftest.py`.
|
|
54
|
+
Pytest normally connects to ArangoDB and creates test resources during
|
|
55
|
+
configuration, even for database-free tests or collection. Use
|
|
56
|
+
`--skip-arango-setup` only for tests that need no configured database fixtures,
|
|
57
|
+
for example:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
python -m pytest tests/test_request.py --skip-arango-setup
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This flag bypasses setup; it does not make integration tests run offline.
|
|
64
|
+
For server behavior, run the relevant test against a disposable ArangoDB
|
|
65
|
+
instance using AGENTS.md. Match the actual topology: pass `--cluster` for a
|
|
66
|
+
cluster, omit it for a single server. The flag does not start a cluster.
|
|
67
|
+
Check version and capability skips in the selected tests; skipped cases do
|
|
68
|
+
not validate the change. Start with the affected test, expand for changed
|
|
69
|
+
contracts, and report any unverified behavior.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-arango
|
|
3
|
-
Version: 8.3.
|
|
3
|
+
Version: 8.3.8
|
|
4
4
|
Summary: Python Driver for ArangoDB
|
|
5
5
|
Author-email: Joohwan Oh <joohwan.oh@outlook.com>
|
|
6
6
|
Maintainer-email: Joohwan Oh <joohwan.oh@outlook.com>, Alexandru Petenchea <alex.petenchea@gmail.com>, Anthony Mahanna <anthony.mahanna@arangodb.com>
|
|
@@ -407,7 +407,8 @@ class JwtConnection(BaseConnection):
|
|
|
407
407
|
return resp
|
|
408
408
|
|
|
409
409
|
now = int(time.time())
|
|
410
|
-
|
|
410
|
+
has_credentials = self._username is not None and self._password is not None
|
|
411
|
+
if not has_credentials and self._token_exp < now - self.exp_leeway:
|
|
411
412
|
return resp
|
|
412
413
|
|
|
413
414
|
self.refresh_token()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "8.3.8"
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Authentication
|
|
2
|
+
--------------
|
|
3
|
+
|
|
4
|
+
Python-arango supports two HTTP authentication methods: basic and JSON Web
|
|
5
|
+
Tokens (JWT).
|
|
6
|
+
|
|
7
|
+
Basic Authentication
|
|
8
|
+
====================
|
|
9
|
+
|
|
10
|
+
This is python-arango's default authentication method.
|
|
11
|
+
|
|
12
|
+
**Example:**
|
|
13
|
+
|
|
14
|
+
.. testcode::
|
|
15
|
+
from arango import ArangoClient
|
|
16
|
+
|
|
17
|
+
# Initialize the ArangoDB client.
|
|
18
|
+
client = ArangoClient()
|
|
19
|
+
|
|
20
|
+
# Connect to "test" database as root user using basic auth.
|
|
21
|
+
db = client.db('test', username='root', password='passwd')
|
|
22
|
+
|
|
23
|
+
# The authentication method can be given explicitly.
|
|
24
|
+
db = client.db(
|
|
25
|
+
'test',
|
|
26
|
+
username='root',
|
|
27
|
+
password='passwd',
|
|
28
|
+
auth_method='basic'
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
JSON Web Tokens (JWT)
|
|
32
|
+
=====================
|
|
33
|
+
|
|
34
|
+
JWTs are sent in the HTTP ``Authorization`` header as Bearer tokens. Token
|
|
35
|
+
renewal depends on whether the driver obtains tokens using username/password
|
|
36
|
+
or the application supplies them.
|
|
37
|
+
|
|
38
|
+
Driver-managed tokens
|
|
39
|
+
~~~~~~~~~~~~~~~~~~~~~
|
|
40
|
+
|
|
41
|
+
With ``auth_method='jwt'``, the driver obtains an initial token using the
|
|
42
|
+
configured username and password when ``client.db()`` is called. It retains
|
|
43
|
+
those credentials to obtain replacement tokens. If initial acquisition fails,
|
|
44
|
+
``client.db()`` raises an error instead of returning a database wrapper.
|
|
45
|
+
|
|
46
|
+
For each database request, the authentication policy is:
|
|
47
|
+
|
|
48
|
+
1. Send the request with the current token.
|
|
49
|
+
2. If the response has both HTTP status 401 and ArangoDB error code 11, attempt
|
|
50
|
+
to obtain a replacement token using the configured credentials.
|
|
51
|
+
3. If renewal succeeds, retry the original request once with the replacement
|
|
52
|
+
token.
|
|
53
|
+
|
|
54
|
+
* If that retry fails, the application receives the error. The driver does
|
|
55
|
+
not renew the token or retry the request again.
|
|
56
|
+
|
|
57
|
+
4. If obtaining a replacement token fails, the original request is not retried.
|
|
58
|
+
The error from that renewal attempt is raised to the caller.
|
|
59
|
+
|
|
60
|
+
Both the HTTP status and ArangoDB error code must match to trigger renewal.
|
|
61
|
+
Other responses, including HTTP 403, do not trigger JWT renewal or an
|
|
62
|
+
authentication retry. For example, a rejected version request raises
|
|
63
|
+
:class:`arango.exceptions.ServerVersionError`.
|
|
64
|
+
|
|
65
|
+
HTTP 401/error code 11 does not prove that the token expired. The same renewal
|
|
66
|
+
and retry policy applies if the server rejects a locally unexpired token.
|
|
67
|
+
Renewal authenticates the same user and does not grant additional permissions;
|
|
68
|
+
if access is still denied, the retried request fails normally.
|
|
69
|
+
|
|
70
|
+
Renewal is reactive: it happens after a qualifying server rejection, not on a
|
|
71
|
+
timer or proactively before expiration. The driver does not fall back to Basic
|
|
72
|
+
authentication when JWT authentication fails.
|
|
73
|
+
|
|
74
|
+
Keep client and server clocks synchronized because the driver checks token
|
|
75
|
+
expiration when accepting a token.
|
|
76
|
+
|
|
77
|
+
**Example:**
|
|
78
|
+
|
|
79
|
+
.. testcode::
|
|
80
|
+
from arango import ArangoClient
|
|
81
|
+
|
|
82
|
+
# Initialize the ArangoDB client.
|
|
83
|
+
client = ArangoClient()
|
|
84
|
+
|
|
85
|
+
# Connect to "test" database as root user using JWT.
|
|
86
|
+
db = client.db(
|
|
87
|
+
'test',
|
|
88
|
+
username='root',
|
|
89
|
+
password='passwd',
|
|
90
|
+
auth_method='jwt'
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# Manually refresh the token.
|
|
94
|
+
db.conn.refresh_token()
|
|
95
|
+
|
|
96
|
+
Application-managed tokens
|
|
97
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
98
|
+
|
|
99
|
+
Use ``user_token`` or ``superuser_token`` to supply a token obtained outside
|
|
100
|
+
the driver. These tokens are not renewed automatically: the application is
|
|
101
|
+
responsible for obtaining replacements. Supplied username/password and
|
|
102
|
+
``auth_method`` are ignored when either token argument is used, so they cannot
|
|
103
|
+
provide renewal credentials for that connection.
|
|
104
|
+
|
|
105
|
+
``user_token`` is checked for expiration locally when the connection is
|
|
106
|
+
created. ``superuser_token`` is accepted without a local expiry check at
|
|
107
|
+
construction; the server can reject it on the first request. With
|
|
108
|
+
``verify=True``, that first request occurs during ``client.db()`` and a rejected
|
|
109
|
+
token causes :class:`arango.exceptions.ServerConnectionError`.
|
|
110
|
+
|
|
111
|
+
**Example:**
|
|
112
|
+
|
|
113
|
+
.. code-block:: python
|
|
114
|
+
|
|
115
|
+
from calendar import timegm
|
|
116
|
+
from datetime import datetime
|
|
117
|
+
|
|
118
|
+
import jwt
|
|
119
|
+
|
|
120
|
+
from arango import ArangoClient
|
|
121
|
+
|
|
122
|
+
# Initialize the ArangoDB client.
|
|
123
|
+
client = ArangoClient()
|
|
124
|
+
|
|
125
|
+
# Generate the JWT token manually.
|
|
126
|
+
now = timegm(datetime.utcnow().utctimetuple())
|
|
127
|
+
token = jwt.encode(
|
|
128
|
+
payload={
|
|
129
|
+
'iat': now,
|
|
130
|
+
'exp': now + 3600,
|
|
131
|
+
'iss': 'arangodb',
|
|
132
|
+
'server_id': 'client'
|
|
133
|
+
},
|
|
134
|
+
key='secret',
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
# Connect to "test" database as superuser using the token.
|
|
138
|
+
db = client.db('test', superuser_token=token)
|
|
139
|
+
|
|
140
|
+
# Connect to "test" database as user using the token.
|
|
141
|
+
db = client.db('test', user_token=token)
|
|
142
|
+
|
|
143
|
+
Replace an application-managed token using ``db.conn.set_token(new_token)``.
|
|
144
|
+
This changes the token used by the database wrapper and existing collection
|
|
145
|
+
wrappers sharing its connection. Separate connections created by other
|
|
146
|
+
``client.db()`` calls are unaffected. For both user and superuser connections,
|
|
147
|
+
``set_token()`` checks expiration locally and raises
|
|
148
|
+
:class:`arango.exceptions.JWTExpiredError` if the replacement has expired.
|
|
149
|
+
|
|
150
|
+
**Example:**
|
|
151
|
+
|
|
152
|
+
.. code-block:: python
|
|
153
|
+
|
|
154
|
+
from arango import ArangoClient
|
|
155
|
+
|
|
156
|
+
# Initialize the ArangoDB client.
|
|
157
|
+
client = ArangoClient()
|
|
158
|
+
|
|
159
|
+
# Connect to "test" database as a user using the token.
|
|
160
|
+
db = client.db('test', user_token='token')
|
|
161
|
+
|
|
162
|
+
# Set the user token on the connection object.
|
|
163
|
+
db.conn.set_token('new token')
|
|
164
|
+
|
|
165
|
+
# Connect to "test" database as superuser using the token.
|
|
166
|
+
db = client.db('test', superuser_token='superuser token')
|
|
167
|
+
|
|
168
|
+
# Set the user token on the connection object.
|
|
169
|
+
db.conn.set_token('new superuser token')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-arango
|
|
3
|
-
Version: 8.3.
|
|
3
|
+
Version: 8.3.8
|
|
4
4
|
Summary: Python Driver for ArangoDB
|
|
5
5
|
Author-email: Joohwan Oh <joohwan.oh@outlook.com>
|
|
6
6
|
Maintainer-email: Joohwan Oh <joohwan.oh@outlook.com>, Alexandru Petenchea <alex.petenchea@gmail.com>, Anthony Mahanna <anthony.mahanna@arangodb.com>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "8.3.7"
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
Authentication
|
|
2
|
-
--------------
|
|
3
|
-
|
|
4
|
-
Python-arango supports two HTTP authentication methods: basic and JSON Web
|
|
5
|
-
Tokens (JWT).
|
|
6
|
-
|
|
7
|
-
Basic Authentication
|
|
8
|
-
====================
|
|
9
|
-
|
|
10
|
-
This is python-arango's default authentication method.
|
|
11
|
-
|
|
12
|
-
**Example:**
|
|
13
|
-
|
|
14
|
-
.. testcode::
|
|
15
|
-
from arango import ArangoClient
|
|
16
|
-
|
|
17
|
-
# Initialize the ArangoDB client.
|
|
18
|
-
client = ArangoClient()
|
|
19
|
-
|
|
20
|
-
# Connect to "test" database as root user using basic auth.
|
|
21
|
-
db = client.db('test', username='root', password='passwd')
|
|
22
|
-
|
|
23
|
-
# The authentication method can be given explicitly.
|
|
24
|
-
db = client.db(
|
|
25
|
-
'test',
|
|
26
|
-
username='root',
|
|
27
|
-
password='passwd',
|
|
28
|
-
auth_method='basic'
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
JSON Web Tokens (JWT)
|
|
32
|
-
=====================
|
|
33
|
-
|
|
34
|
-
Python-arango automatically obtains JSON web tokens from the server using
|
|
35
|
-
username and password. It also refreshes expired tokens and retries requests.
|
|
36
|
-
The client and server clocks must be synchronized for the automatic refresh
|
|
37
|
-
to work correctly.
|
|
38
|
-
|
|
39
|
-
**Example:**
|
|
40
|
-
|
|
41
|
-
.. testcode::
|
|
42
|
-
from arango import ArangoClient
|
|
43
|
-
|
|
44
|
-
# Initialize the ArangoDB client.
|
|
45
|
-
client = ArangoClient()
|
|
46
|
-
|
|
47
|
-
# Connect to "test" database as root user using JWT.
|
|
48
|
-
db = client.db(
|
|
49
|
-
'test',
|
|
50
|
-
username='root',
|
|
51
|
-
password='passwd',
|
|
52
|
-
auth_method='jwt'
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
# Manually refresh the token.
|
|
56
|
-
db.conn.refresh_token()
|
|
57
|
-
|
|
58
|
-
# Override the token expiry compare leeway in seconds (default: 0) to
|
|
59
|
-
# compensate for out-of-sync clocks between the client and server.
|
|
60
|
-
db.conn.ext_leeway = 2
|
|
61
|
-
|
|
62
|
-
User generated JWT token can be used for user and superuser access.
|
|
63
|
-
|
|
64
|
-
**Example:**
|
|
65
|
-
|
|
66
|
-
.. code-block:: python
|
|
67
|
-
|
|
68
|
-
from calendar import timegm
|
|
69
|
-
from datetime import datetime
|
|
70
|
-
|
|
71
|
-
import jwt
|
|
72
|
-
|
|
73
|
-
from arango import ArangoClient
|
|
74
|
-
|
|
75
|
-
# Initialize the ArangoDB client.
|
|
76
|
-
client = ArangoClient()
|
|
77
|
-
|
|
78
|
-
# Generate the JWT token manually.
|
|
79
|
-
now = timegm(datetime.utcnow().utctimetuple())
|
|
80
|
-
token = jwt.encode(
|
|
81
|
-
payload={
|
|
82
|
-
'iat': now,
|
|
83
|
-
'exp': now + 3600,
|
|
84
|
-
'iss': 'arangodb',
|
|
85
|
-
'server_id': 'client'
|
|
86
|
-
},
|
|
87
|
-
key='secret',
|
|
88
|
-
).decode('utf-8')
|
|
89
|
-
|
|
90
|
-
# Connect to "test" database as superuser using the token.
|
|
91
|
-
db = client.db('test', superuser_token=token)
|
|
92
|
-
|
|
93
|
-
# Connect to "test" database as user using the token.
|
|
94
|
-
db = client.db('test', user_token=token)
|
|
95
|
-
|
|
96
|
-
User and superuser tokens can be set on the connection object as well.
|
|
97
|
-
|
|
98
|
-
**Example:**
|
|
99
|
-
|
|
100
|
-
.. code-block:: python
|
|
101
|
-
|
|
102
|
-
from arango import ArangoClient
|
|
103
|
-
|
|
104
|
-
# Initialize the ArangoDB client.
|
|
105
|
-
client = ArangoClient()
|
|
106
|
-
|
|
107
|
-
# Connect to "test" database as superuser using the token.
|
|
108
|
-
db = client.db('test', user_token='token')
|
|
109
|
-
|
|
110
|
-
# Set the user token on the connection object.
|
|
111
|
-
db.conn.set_token('new token')
|
|
112
|
-
|
|
113
|
-
# Connect to "test" database as superuser using the token.
|
|
114
|
-
db = client.db('test', superuser_token='superuser token')
|
|
115
|
-
|
|
116
|
-
# Set the user token on the connection object.
|
|
117
|
-
db.conn.set_token('new superuser token')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|