python-arango-async 1.2.7__tar.gz → 1.2.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_async-1.2.8/.agents/skills/python-arango-async-development/SKILL.md +89 -0
- {python_arango_async-1.2.7/python_arango_async.egg-info → python_arango_async-1.2.8}/PKG-INFO +1 -1
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/client.py +14 -7
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/connection.py +2 -0
- python_arango_async-1.2.8/arangoasync/version.py +1 -0
- python_arango_async-1.2.8/docs/authentication.rst +121 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8/python_arango_async.egg-info}/PKG-INFO +1 -1
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/python_arango_async.egg-info/SOURCES.txt +1 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/python_arango_async.egg-info/scm_file_list.json +1 -0
- python_arango_async-1.2.8/python_arango_async.egg-info/scm_version.json +8 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_connection.py +43 -0
- python_arango_async-1.2.7/arangoasync/version.py +0 -1
- python_arango_async-1.2.7/docs/authentication.rst +0 -117
- python_arango_async-1.2.7/python_arango_async.egg-info/scm_version.json +0 -8
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/.circleci/config.yml +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/.github/workflows/codeql.yaml +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/.github/workflows/docs.yaml +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/.github/workflows/pypi.yaml +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/.gitignore +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/.pre-commit-config.yaml +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/.readthedocs.yaml +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/AGENTS.md +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/LICENSE +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/README.md +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/__init__.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/aql.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/auth.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/backup.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/cluster.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/collection.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/compression.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/cursor.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/database.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/errno.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/exceptions.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/executor.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/foxx.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/graph.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/http.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/job.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/logger.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/replication.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/request.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/resolver.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/response.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/result.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/serialization.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/arangoasync/typings.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/admin.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/analyzer.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/aql.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/async.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/backup.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/certificates.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/cluster.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/collection.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/compression.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/conf.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/cursor.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/database.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/document.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/errno.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/errors.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/foxx.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/graph.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/helpers.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/http.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/index.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/indexes.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/logging.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/migration.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/overview.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/serialization.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/specs.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/static/logo.png +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/task.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/transaction.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/user.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/docs/view.rst +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/pyproject.toml +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/python_arango_async.egg-info/dependency_links.txt +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/python_arango_async.egg-info/requires.txt +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/python_arango_async.egg-info/top_level.txt +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/setup.cfg +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/setup.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/starter.sh +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/__init__.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/conftest.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/helpers.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/static/cluster-3.12.conf +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/static/cluster-4.0.conf +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/static/keyfile +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/static/service.zip +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/static/single-3.12.conf +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/static/single-4.0.conf +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_analyzer.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_aql.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_async.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_backup.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_client.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_cluster.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_collection.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_compression.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_cursor.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_database.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_document.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_foxx.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_graph.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_http.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_imports.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_resolver.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_task.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_transaction.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_typings.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_user.py +0 -0
- {python_arango_async-1.2.7 → python_arango_async-1.2.8}/tests/test_view.py +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: python-arango-async-development
|
|
3
|
+
description: >-
|
|
4
|
+
Maintain and extend python-arango-async, the asyncio ArangoDB Python driver.
|
|
5
|
+
Use for driver features, bug fixes, refactoring, and related tests or
|
|
6
|
+
documentation, rather than application code that uses the driver.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Async 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 synchronous response handler, and call
|
|
17
|
+
`await self._executor.execute(request, response_handler)`.
|
|
18
|
+
See `arangoasync/request.py`, `arangoasync/executor.py`, and the API group
|
|
19
|
+
being changed. Keep request construction and response conversion at the same
|
|
20
|
+
layer as neighboring operations.
|
|
21
|
+
|
|
22
|
+
Preserve executor dispatch. It supports default execution, transactions, and
|
|
23
|
+
ArangoDB background jobs. Calling the connection or HTTP client directly can
|
|
24
|
+
bypass transaction headers and job handling. Preserve `Result[T]` annotations
|
|
25
|
+
where applicable: after awaiting an operation, its result may be `T`,
|
|
26
|
+
`AsyncJob[T]`, or `None`, depending on the execution context.
|
|
27
|
+
|
|
28
|
+
Distinguish asyncio I/O from ArangoDB asynchronous API execution.
|
|
29
|
+
`begin_async_execution()` selects server-side background jobs; it does not
|
|
30
|
+
make an otherwise synchronous driver asynchronous. Follow existing boundaries
|
|
31
|
+
between synchronous wrapper factories and awaited operations rather than
|
|
32
|
+
adding `async` or `await` indiscriminately.
|
|
33
|
+
|
|
34
|
+
For endpoint or option changes, verify the server HTTP API for the targeted
|
|
35
|
+
ArangoDB versions. Map Python option names to the specified wire names and
|
|
36
|
+
locations: endpoint path, `params`, `headers`, or `data`. Preserve existing
|
|
37
|
+
defaults and distinguish omitted options from explicit `False`, `0`, or empty
|
|
38
|
+
values. Where `None` means omission, use `is not None`. `Request.normalized_params()`
|
|
39
|
+
stringifies supplied values, including `None`; omit such query entries before
|
|
40
|
+
constructing the request. Keep explicit JSON nulls where the body requires them.
|
|
41
|
+
|
|
42
|
+
Preserve typed option and response wrappers in `arangoasync/typings.py`.
|
|
43
|
+
Follow neighboring uses of `JsonWrapper`, `.to_dict()`, validation, and typed
|
|
44
|
+
properties rather than replacing wrappers with plain dictionaries. Keep public
|
|
45
|
+
signatures, annotations, Sphinx docstrings, and response shapes aligned.
|
|
46
|
+
|
|
47
|
+
Respect configurable serialization. Inspect whether an operation uses the
|
|
48
|
+
executor's serializer/deserializer for API payloads and metadata, or the
|
|
49
|
+
collection's document serializer/deserializer for user documents. Preserve
|
|
50
|
+
`Collection[T, U, V]` contracts, including distinct single-document and
|
|
51
|
+
multiple-document deserialization results. Do not replace these hooks with
|
|
52
|
+
direct JSON calls or assume custom documents are dictionaries.
|
|
53
|
+
See `arangoasync/serialization.py` and `docs/serialization.rst`.
|
|
54
|
+
|
|
55
|
+
Follow neighboring handlers' success checks and special-status handling.
|
|
56
|
+
Preserve revision-conflict exceptions, missing-resource options, and silent
|
|
57
|
+
results. Raise operation-specific exceptions from `arangoasync/exceptions.py`
|
|
58
|
+
with `(resp, request)` to retain HTTP and ArangoDB error details.
|
|
59
|
+
|
|
60
|
+
For client, transport, cursor, or job changes, preserve awaited cleanup and
|
|
61
|
+
existing async context-manager behavior. Avoid blocking I/O or sleeps in
|
|
62
|
+
coroutines. Keep transport changes compatible with the `HTTPClient` abstraction
|
|
63
|
+
in `arangoasync/http.py`. Inspect connection and resolver behavior before changing
|
|
64
|
+
authentication, host failover, or retries.
|
|
65
|
+
|
|
66
|
+
Cursors use async iteration and retain mutable batch state. Preserve batch
|
|
67
|
+
boundaries, exhaustion behavior, and server-resource cleanup. Cursors obtained
|
|
68
|
+
from background jobs fetch subsequent batches through a non-job executor;
|
|
69
|
+
transaction cursors must retain their transaction context.
|
|
70
|
+
See `arangoasync/aql.py`, `arangoasync/cursor.py`, and `arangoasync/job.py`.
|
|
71
|
+
|
|
72
|
+
Add focused regression coverage in the relevant `tests/test_*.py` module,
|
|
73
|
+
reusing fixtures and helpers from `tests/conftest.py` and `tests/helpers.py`.
|
|
74
|
+
Follow existing `pytest.mark.asyncio` and `pytest_asyncio.fixture` patterns.
|
|
75
|
+
Cover affected request mapping, result conversion, and error behavior;
|
|
76
|
+
exercise related execution contexts when the change affects them.
|
|
77
|
+
|
|
78
|
+
Pytest normally contacts ArangoDB during configuration, even for database-free
|
|
79
|
+
tests or collection. Use `--skip-arango-setup` only for tests whose fixture
|
|
80
|
+
dependencies need no server, for example:
|
|
81
|
+
|
|
82
|
+
python -m pytest tests/test_imports.py tests/test_typings.py --skip-arango-setup
|
|
83
|
+
|
|
84
|
+
This flag bypasses setup; it does not make integration tests run offline.
|
|
85
|
+
For server behavior, use a disposable instance and the commands in AGENTS.md.
|
|
86
|
+
Pass `--cluster` only for an actual cluster; the flag does not start one.
|
|
87
|
+
Check version and capability skips: skipped cases do not validate the change.
|
|
88
|
+
Start with affected tests, expand for changed contracts, and report unverified
|
|
89
|
+
behavior.
|
{python_arango_async-1.2.7/python_arango_async.egg-info → python_arango_async-1.2.8}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-arango-async
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.8
|
|
4
4
|
Summary: Async Python Driver for ArangoDB
|
|
5
5
|
Author-email: Alexandru Petenchea <alexandru.petenchea@arangodb.com>, Anthony Mahanna <anthony.mahanna@arangodb.com>
|
|
6
6
|
Maintainer-email: Alexandru Petenchea <alexandru.petenchea@arangodb.com>, Anthony Mahanna <anthony.mahanna@arangodb.com>
|
|
@@ -163,16 +163,22 @@ class ArangoClient:
|
|
|
163
163
|
- "basic": HTTP authentication.
|
|
164
164
|
Requires the `auth` parameter. The `token` parameter is ignored.
|
|
165
165
|
- "jwt": User JWT authentication.
|
|
166
|
-
At least one of
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
At least one of `auth` or `token` is required.
|
|
167
|
+
Credentials in `auth` allow token acquisition and renewal,
|
|
168
|
+
including when an initial `token` is provided. Without a token,
|
|
169
|
+
acquisition happens on the first request. After HTTP 401,
|
|
170
|
+
a locally expired token triggers renewal and one replay.
|
|
171
|
+
Keep client and server clocks synchronized.
|
|
170
172
|
- "superuser": Superuser JWT authentication.
|
|
171
173
|
The `token` parameter is required. The `auth` parameter is ignored.
|
|
172
|
-
auth (Auth | None): Login information (username and password) or
|
|
173
|
-
access token.
|
|
174
|
-
token (JwtToken | None): JWT token.
|
|
174
|
+
auth (Auth | str | None): Login information (username and password) or
|
|
175
|
+
access token. A string is used as the password with an empty username.
|
|
176
|
+
token (JwtToken | None): Initial JWT token. With `auth_method="jwt"`,
|
|
177
|
+
provide `auth` as well to allow renewal. Without credentials,
|
|
178
|
+
a 401 after local expiration raises `JWTRefreshError`.
|
|
175
179
|
verify (bool): Verify the connection by sending a test request.
|
|
180
|
+
For JWT authentication without an initial token, this also triggers
|
|
181
|
+
acquisition before returning the database wrapper.
|
|
176
182
|
compression (CompressionManager | None): If set, supersedes the
|
|
177
183
|
client-level compression settings.
|
|
178
184
|
serializer (Serializer | None): If set, supersedes the client-level
|
|
@@ -186,6 +192,7 @@ class ArangoClient:
|
|
|
186
192
|
Raises:
|
|
187
193
|
ValueError: If the authentication is invalid.
|
|
188
194
|
ServerConnectionError: If `verify` is `True` and the connection fails.
|
|
195
|
+
JWTRefreshError: If `verify` is `True` and JWT acquisition or renewal fails.
|
|
189
196
|
"""
|
|
190
197
|
connection: Connection
|
|
191
198
|
|
|
@@ -178,6 +178,7 @@ class BaseConnection(ABC):
|
|
|
178
178
|
|
|
179
179
|
if request.prefix_needed:
|
|
180
180
|
request.endpoint = f"{self._db_endpoint}{request.endpoint}"
|
|
181
|
+
request.prefix_needed = False
|
|
181
182
|
host_index = self._host_resolver.get_host_index()
|
|
182
183
|
for tries in range(self._host_resolver.max_tries):
|
|
183
184
|
try:
|
|
@@ -432,6 +433,7 @@ class JwtConnection(BaseConnection):
|
|
|
432
433
|
):
|
|
433
434
|
# If the token has expired, refresh it and retry the request
|
|
434
435
|
await self.refresh_token()
|
|
436
|
+
request.headers["authorization"] = self._auth_header
|
|
435
437
|
resp = await self.process_request(request)
|
|
436
438
|
return resp
|
|
437
439
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.2.8"
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Authentication
|
|
2
|
+
--------------
|
|
3
|
+
|
|
4
|
+
Two HTTP authentication methods are supported out of the box:
|
|
5
|
+
|
|
6
|
+
1. Basic username and password authentication
|
|
7
|
+
2. JSON Web Tokens (JWT)
|
|
8
|
+
|
|
9
|
+
Basic Authentication
|
|
10
|
+
====================
|
|
11
|
+
|
|
12
|
+
This is the default authentication method.
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
|
|
16
|
+
.. code-block:: python
|
|
17
|
+
|
|
18
|
+
from arangoasync import ArangoClient
|
|
19
|
+
from arangoasync.auth import Auth
|
|
20
|
+
|
|
21
|
+
# Initialize the client for ArangoDB.
|
|
22
|
+
async with ArangoClient(hosts="http://localhost:8529") as client:
|
|
23
|
+
auth = Auth(
|
|
24
|
+
username="root",
|
|
25
|
+
password="passwd",
|
|
26
|
+
encoding="utf-8" # Encoding for the password, default is utf-8.
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Connect to "test" database as root user.
|
|
30
|
+
db = await client.db(
|
|
31
|
+
"test", # database name
|
|
32
|
+
auth_method="basic", # use basic authentication (default)
|
|
33
|
+
auth=auth, # authentication details
|
|
34
|
+
verify=True, # verify the connection (optional)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
JSON Web Tokens (JWT)
|
|
38
|
+
=====================
|
|
39
|
+
|
|
40
|
+
JWTs are sent as Bearer tokens in the HTTP ``Authorization`` header.
|
|
41
|
+
Use ``auth_method="jwt"`` with credentials, a token, or both.
|
|
42
|
+
|
|
43
|
+
Tokens with renewal credentials
|
|
44
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
45
|
+
|
|
46
|
+
Provide ``auth`` to allow token acquisition and renewal. Without an initial
|
|
47
|
+
``token``, acquisition happens on the first request; ``verify=True`` triggers
|
|
48
|
+
that request during ``await client.db()``. Providing both ``auth`` and ``token``
|
|
49
|
+
uses the supplied token initially and retains credentials for renewal.
|
|
50
|
+
|
|
51
|
+
For each database request, the renewal policy is:
|
|
52
|
+
|
|
53
|
+
1. Send the request with the current token.
|
|
54
|
+
2. If the response has HTTP status 401 and the token is past its locally
|
|
55
|
+
recorded expiration, obtain a replacement using the retained credentials.
|
|
56
|
+
3. Retry the original request once with the replacement token. A second
|
|
57
|
+
rejection is returned to the operation's response handler without another
|
|
58
|
+
renewal or replay.
|
|
59
|
+
|
|
60
|
+
If acquisition fails, the original request is not replayed and the error
|
|
61
|
+
propagates. Authentication failures during acquisition raise
|
|
62
|
+
:class:`arangoasync.exceptions.JWTRefreshError`.
|
|
63
|
+
|
|
64
|
+
The ArangoDB error code is not checked; other responses do not trigger renewal.
|
|
65
|
+
There is no proactive renewal or Basic authentication fallback.
|
|
66
|
+
Keep client and server clocks synchronized for local expiration checks.
|
|
67
|
+
|
|
68
|
+
.. code-block:: python
|
|
69
|
+
|
|
70
|
+
from arangoasync import ArangoClient
|
|
71
|
+
from arangoasync.auth import Auth
|
|
72
|
+
|
|
73
|
+
async with ArangoClient(hosts="http://localhost:8529") as client:
|
|
74
|
+
db = await client.db(
|
|
75
|
+
"test", auth_method="jwt",
|
|
76
|
+
auth=Auth(username="root", password="passwd"), verify=True
|
|
77
|
+
)
|
|
78
|
+
# Explicit refresh uses the retained credentials.
|
|
79
|
+
await db.connection.refresh_token()
|
|
80
|
+
|
|
81
|
+
Tokens without renewal credentials
|
|
82
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
83
|
+
|
|
84
|
+
Provide ``token`` without ``auth`` when the application supplies replacements.
|
|
85
|
+
Pass a :class:`arangoasync.auth.JwtToken`; constructing one with an expired token
|
|
86
|
+
raises ``jwt.exceptions.ExpiredSignatureError``. A token-only connection receiving
|
|
87
|
+
HTTP 401 after local expiry currently raises
|
|
88
|
+
:class:`arangoasync.exceptions.JWTRefreshError` because it lacks renewal credentials.
|
|
89
|
+
|
|
90
|
+
Replace tokens through ``db.connection.token``. Existing wrappers sharing that
|
|
91
|
+
connection use the replacement on subsequent requests; separate ``client.db()``
|
|
92
|
+
calls remain independent.
|
|
93
|
+
|
|
94
|
+
.. code-block:: python
|
|
95
|
+
|
|
96
|
+
from arangoasync import ArangoClient
|
|
97
|
+
from arangoasync.auth import JwtToken
|
|
98
|
+
|
|
99
|
+
# Token strings come from the application's provider.
|
|
100
|
+
async with ArangoClient(hosts="http://localhost:8529") as client:
|
|
101
|
+
db = await client.db(
|
|
102
|
+
"test", auth_method="jwt", token=JwtToken(encoded_token), verify=True
|
|
103
|
+
)
|
|
104
|
+
db.connection.token = JwtToken(replacement_encoded_token)
|
|
105
|
+
|
|
106
|
+
Superuser tokens
|
|
107
|
+
~~~~~~~~~~~~~~~~
|
|
108
|
+
|
|
109
|
+
Use ``auth_method="superuser"`` with a ``JwtToken``. The driver ignores ``auth``
|
|
110
|
+
and performs no automatic renewal or replay. Token validation and replacement
|
|
111
|
+
work as above. With ``verify=True``, a rejected superuser token raises
|
|
112
|
+
:class:`arangoasync.exceptions.ServerConnectionError` during ``await client.db()``.
|
|
113
|
+
|
|
114
|
+
Within a client context, generate a token using the server's JWT secret:
|
|
115
|
+
|
|
116
|
+
.. code-block:: python
|
|
117
|
+
|
|
118
|
+
token = JwtToken.generate_token("secret")
|
|
119
|
+
db = await client.db(
|
|
120
|
+
"test", auth_method="superuser", token=token, verify=True
|
|
121
|
+
)
|
{python_arango_async-1.2.7 → python_arango_async-1.2.8/python_arango_async.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-arango-async
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.8
|
|
4
4
|
Summary: Async Python Driver for ArangoDB
|
|
5
5
|
Author-email: Alexandru Petenchea <alexandru.petenchea@arangodb.com>, Anthony Mahanna <anthony.mahanna@arangodb.com>
|
|
6
6
|
Maintainer-email: Alexandru Petenchea <alexandru.petenchea@arangodb.com>, Anthony Mahanna <anthony.mahanna@arangodb.com>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import time
|
|
1
2
|
import zlib
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
from unittest.mock import patch
|
|
2
5
|
|
|
6
|
+
import jwt
|
|
3
7
|
import pytest
|
|
4
8
|
|
|
5
9
|
from arangoasync.auth import Auth, JwtToken
|
|
@@ -230,6 +234,45 @@ async def test_JwtConnection_ping_success(
|
|
|
230
234
|
assert connection3.token != connection1.token
|
|
231
235
|
|
|
232
236
|
|
|
237
|
+
@pytest.mark.asyncio
|
|
238
|
+
async def test_JwtConnection_expired_token_recovery(
|
|
239
|
+
client_session, url, sys_db_name, root, password, pytestconfig
|
|
240
|
+
):
|
|
241
|
+
client = AioHTTPClient()
|
|
242
|
+
session = client_session(client, url)
|
|
243
|
+
issued_at = int(time.time()) - 120
|
|
244
|
+
encoded_token = jwt.encode(
|
|
245
|
+
{
|
|
246
|
+
"preferred_username": root,
|
|
247
|
+
"iss": "arangodb",
|
|
248
|
+
"iat": issued_at,
|
|
249
|
+
"exp": issued_at + 60,
|
|
250
|
+
},
|
|
251
|
+
key=pytestconfig.getoption("secret"),
|
|
252
|
+
algorithm="HS256",
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
# Accept the token while valid, then restore the clock before dispatch.
|
|
256
|
+
with patch("jwt.api_jwt.datetime") as clock:
|
|
257
|
+
clock.now.return_value = datetime.fromtimestamp(issued_at, timezone.utc)
|
|
258
|
+
expired_token = JwtToken(encoded_token)
|
|
259
|
+
|
|
260
|
+
assert expired_token.needs_refresh()
|
|
261
|
+
connection = JwtConnection(
|
|
262
|
+
sessions=[session],
|
|
263
|
+
host_resolver=DefaultHostResolver(1),
|
|
264
|
+
http_client=client,
|
|
265
|
+
db_name=sys_db_name,
|
|
266
|
+
auth=Auth(username=root, password=password),
|
|
267
|
+
token=expired_token,
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
# Expect that the token is renewed automatically.
|
|
271
|
+
assert await connection.ping() == 200
|
|
272
|
+
assert connection.token.token != expired_token.token
|
|
273
|
+
assert not connection.token.needs_refresh()
|
|
274
|
+
|
|
275
|
+
|
|
233
276
|
@pytest.mark.asyncio
|
|
234
277
|
async def test_JwtSuperuserConnection_ping_success(
|
|
235
278
|
client_session, url, sys_db_name, token
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.2.7"
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
Authentication
|
|
2
|
-
--------------
|
|
3
|
-
|
|
4
|
-
Two HTTP authentication methods are supported out of the box:
|
|
5
|
-
|
|
6
|
-
1. Basic username and password authentication
|
|
7
|
-
2. JSON Web Tokens (JWT)
|
|
8
|
-
|
|
9
|
-
Basic Authentication
|
|
10
|
-
====================
|
|
11
|
-
|
|
12
|
-
This is the default authentication method.
|
|
13
|
-
|
|
14
|
-
**Example:**
|
|
15
|
-
|
|
16
|
-
.. code-block:: python
|
|
17
|
-
|
|
18
|
-
from arangoasync import ArangoClient
|
|
19
|
-
from arangoasync.auth import Auth
|
|
20
|
-
|
|
21
|
-
# Initialize the client for ArangoDB.
|
|
22
|
-
async with ArangoClient(hosts="http://localhost:8529") as client:
|
|
23
|
-
auth = Auth(
|
|
24
|
-
username="root",
|
|
25
|
-
password="passwd",
|
|
26
|
-
encoding="utf-8" # Encoding for the password, default is utf-8.
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
# Connect to "test" database as root user.
|
|
30
|
-
db = await client.db(
|
|
31
|
-
"test", # database name
|
|
32
|
-
auth_method="basic", # use basic authentication (default)
|
|
33
|
-
auth=auth, # authentication details
|
|
34
|
-
verify=True, # verify the connection (optional)
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
JSON Web Tokens (JWT)
|
|
38
|
-
=====================
|
|
39
|
-
|
|
40
|
-
You can obtain the JWT token from the use server using username and password.
|
|
41
|
-
Upon expiration, the token gets refreshed automatically and requests are retried.
|
|
42
|
-
The client and server clocks must be synchronized for the automatic refresh
|
|
43
|
-
to work correctly.
|
|
44
|
-
|
|
45
|
-
**Example:**
|
|
46
|
-
|
|
47
|
-
.. code-block:: python
|
|
48
|
-
|
|
49
|
-
from arangoasync import ArangoClient
|
|
50
|
-
from arangoasync.auth import Auth
|
|
51
|
-
|
|
52
|
-
# Initialize the client for ArangoDB.
|
|
53
|
-
async with ArangoClient(hosts="http://localhost:8529") as client:
|
|
54
|
-
auth = Auth(username="root", password="passwd")
|
|
55
|
-
|
|
56
|
-
# Successful authentication with auth only
|
|
57
|
-
db = await client.db(
|
|
58
|
-
"test",
|
|
59
|
-
auth_method="jwt",
|
|
60
|
-
auth=auth,
|
|
61
|
-
verify=True,
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
# Now you have the token on hand.
|
|
65
|
-
token = db.connection.token
|
|
66
|
-
|
|
67
|
-
# You can use the token directly.
|
|
68
|
-
db = await client.db("test", auth_method="jwt", token=token, verify=True)
|
|
69
|
-
|
|
70
|
-
# In order to allow the token to be automatically refreshed, you should use both auth and token.
|
|
71
|
-
db = await client.db(
|
|
72
|
-
"test",
|
|
73
|
-
auth_method="jwt",
|
|
74
|
-
auth=auth,
|
|
75
|
-
token=token,
|
|
76
|
-
verify=True,
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
# Force a token refresh.
|
|
80
|
-
await db.connection.refresh_token()
|
|
81
|
-
new_token = db.connection.token
|
|
82
|
-
|
|
83
|
-
# Log in with the first token.
|
|
84
|
-
db2 = await client.db(
|
|
85
|
-
"test",
|
|
86
|
-
auth_method="jwt",
|
|
87
|
-
token=token,
|
|
88
|
-
verify=True,
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
# You can manually set tokens.
|
|
92
|
-
db2.connection.token = new_token
|
|
93
|
-
await db2.connection.ping()
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
If you configured a superuser token, you don't need to provide any credentials.
|
|
97
|
-
|
|
98
|
-
**Example:**
|
|
99
|
-
|
|
100
|
-
.. code-block:: python
|
|
101
|
-
|
|
102
|
-
from arangoasync import ArangoClient
|
|
103
|
-
from arangoasync.auth import JwtToken
|
|
104
|
-
|
|
105
|
-
# Initialize the client for ArangoDB.
|
|
106
|
-
async with ArangoClient(hosts="http://localhost:8529") as client:
|
|
107
|
-
|
|
108
|
-
# Generate a JWT token for authentication. You must know the "secret".
|
|
109
|
-
token = JwtToken.generate_token("secret")
|
|
110
|
-
|
|
111
|
-
# Superuser authentication, no need for the auth parameter.
|
|
112
|
-
db = await client.db(
|
|
113
|
-
"test",
|
|
114
|
-
auth_method="superuser",
|
|
115
|
-
token=token,
|
|
116
|
-
verify=True
|
|
117
|
-
)
|
|
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
|
{python_arango_async-1.2.7 → python_arango_async-1.2.8}/python_arango_async.egg-info/requires.txt
RENAMED
|
File without changes
|
{python_arango_async-1.2.7 → python_arango_async-1.2.8}/python_arango_async.egg-info/top_level.txt
RENAMED
|
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
|