Skip to content

Commit 5238238

Browse files
authored
Mature feature: mTLS (#1118)
1 parent 3313018 commit 5238238

File tree

16 files changed

+67
-164
lines changed

16 files changed

+67
-164
lines changed

docs/source/api.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,16 +653,13 @@ Specify a client certificate or certificate provider for mutual TLS (mTLS) authe
653653
This setting does not have any effect if ``encrypted`` is set to ``False``
654654
(and the URI scheme is ``bolt://`` or ``neo4j://``) or a custom ``ssl_context`` is configured.
655655

656-
**This is a preview** (see :ref:`filter-warnings-ref`).
657-
It might be changed without following the deprecation policy.
658-
See also
659-
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
660-
661656
:Type: :class:`.ClientCertificate`, :class:`.ClientCertificateProvider` or :data:`None`.
662657
:Default: :data:`None`
663658

664659
.. versionadded:: 5.19
665660

661+
.. versionchanged:: 5.27 Stabilized from preview.
662+
666663
.. autoclass:: neo4j.auth_management.ClientCertificate
667664
:members:
668665

docs/source/async_api.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,13 @@ Specify a client certificate or certificate provider for mutual TLS (mTLS) authe
446446
This setting does not have any effect if ``encrypted`` is set to ``False``
447447
(and the URI scheme is ``bolt://`` or ``neo4j://``) or a custom ``ssl_context`` is configured.
448448

449-
**This is a preview** (see :ref:`filter-warnings-ref`).
450-
It might be changed without following the deprecation policy.
451-
See also
452-
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
453-
454449
:Type: :class:`.ClientCertificate`, :class:`.AsyncClientCertificateProvider` or :data:`None`.
455450
:Default: :data:`None`
456451

457452
.. versionadded:: 5.19
458453

454+
.. versionchanged:: 5.27 Stabilized from preview.
455+
459456
.. autoclass:: neo4j.auth_management.AsyncClientCertificateProvider
460457
:members:
461458

src/neo4j/_async/auth_management.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
expiring_auth_has_expired,
3232
ExpiringAuth,
3333
)
34-
from .._meta import preview
3534

3635

3736
if t.TYPE_CHECKING:
@@ -331,12 +330,6 @@ class AsyncRotatingClientCertificateProvider(AsyncClientCertificateProvider):
331330
From that point on, the new certificate will be used for all new
332331
connections until :meth:`update_certificate` is called again and so on.
333332
334-
**This is a preview** (see :ref:`filter-warnings-ref`).
335-
It might be changed without following the deprecation policy.
336-
337-
See also
338-
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
339-
340333
Example::
341334
342335
from neo4j import AsyncGraphDatabase
@@ -386,6 +379,8 @@ class AsyncRotatingClientCertificateProvider(AsyncClientCertificateProvider):
386379
implementation internal. This entails removing the possibility to
387380
directly instantiate this class. Please use the factory method
388381
:meth:`.AsyncClientCertificateProviders.rotating` instead.
382+
383+
.. versionchanged:: 5.27 Stabilized from preview.
389384
"""
390385

391386
@abc.abstractmethod
@@ -414,17 +409,12 @@ class AsyncClientCertificateProviders:
414409
"""
415410
A collection of :class:`.AsyncClientCertificateProvider` factories.
416411
417-
**This is a preview** (see :ref:`filter-warnings-ref`).
418-
It might be changed without following the deprecation policy.
419-
420-
See also
421-
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
422-
423412
.. versionadded:: 5.19
413+
414+
.. versionchanged:: 5.27 Stabilized from preview.
424415
"""
425416

426417
@staticmethod
427-
@preview("Mutual TLS is a preview feature.")
428418
def static(cert: ClientCertificate) -> AsyncClientCertificateProvider:
429419
"""
430420
Create a static client certificate provider.
@@ -435,7 +425,6 @@ def static(cert: ClientCertificate) -> AsyncClientCertificateProvider:
435425
return _AsyncStaticClientCertificateProvider(cert)
436426

437427
@staticmethod
438-
@preview("Mutual TLS is a preview feature.")
439428
def rotating(
440429
initial_cert: ClientCertificate,
441430
) -> AsyncRotatingClientCertificateProvider:

src/neo4j/_async/driver.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ def driver(
213213
config["client_certificate"] = (
214214
_AsyncStaticClientCertificateProvider(client_certificate)
215215
)
216-
if client_certificate is not None:
217-
preview_warn("Mutual TLS is a preview feature.", stack_level=2)
218216

219217
# TODO: 6.0 - remove "trust" config option
220218
if "trust" in config and config["trust"] not in {

src/neo4j/_auth_management.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import typing as t
2222
from dataclasses import dataclass
2323

24-
from ._meta import preview
25-
2624

2725
if t.TYPE_CHECKING:
2826
from os import PathLike
@@ -215,7 +213,6 @@ async def handle_security_exception(
215213
...
216214

217215

218-
@preview("Mutual TLS is a preview feature.")
219216
@dataclass
220217
class ClientCertificate:
221218
"""
@@ -224,13 +221,9 @@ class ClientCertificate:
224221
The attributes are the same as the arguments to
225222
:meth:`ssl.SSLContext.load_cert_chain()`.
226223
227-
**This is a preview** (see :ref:`filter-warnings-ref`).
228-
It might be changed without following the deprecation policy.
229-
230-
See also
231-
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
232-
233224
.. versionadded:: 5.19
225+
226+
.. versionchanged:: 5.27 Stabilized from preview.
234227
"""
235228

236229
certfile: str | bytes | PathLike[str] | PathLike[bytes]
@@ -267,13 +260,9 @@ class ClientCertificateProvider(_Protocol, metaclass=abc.ABCMeta):
267260
The provider **must not** interact with the driver in any way as this
268261
can cause deadlocks and undefined behaviour.
269262
270-
**This is a preview** (see :ref:`filter-warnings-ref`).
271-
It might be changed without following the deprecation policy.
272-
273-
See also
274-
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
275-
276263
.. versionadded:: 5.19
264+
265+
.. versionchanged:: 5.27 Stabilized from preview.
277266
"""
278267

279268
@abc.abstractmethod
@@ -300,17 +289,13 @@ class AsyncClientCertificateProvider(_Protocol, metaclass=abc.ABCMeta):
300289
The package provides some default implementations of this class in
301290
:class:`.AsyncClientCertificateProviders` for convenience.
302291
303-
**This is a preview** (see :ref:`filter-warnings-ref`).
304-
It might be changed without following the deprecation policy.
305-
306-
See also
307-
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
308-
309292
.. seealso::
310293
:class:`.ClientCertificateProvider`,
311294
:class:`.AsyncClientCertificateProviders`
312295
313296
.. versionadded:: 5.19
297+
298+
.. versionchanged:: 5.27 Stabilized from preview.
314299
"""
315300

316301
@abc.abstractmethod

src/neo4j/_sync/auth_management.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
expiring_auth_has_expired,
3232
ExpiringAuth,
3333
)
34-
from .._meta import preview
3534

3635

3736
if t.TYPE_CHECKING:
@@ -331,12 +330,6 @@ class RotatingClientCertificateProvider(ClientCertificateProvider):
331330
From that point on, the new certificate will be used for all new
332331
connections until :meth:`update_certificate` is called again and so on.
333332
334-
**This is a preview** (see :ref:`filter-warnings-ref`).
335-
It might be changed without following the deprecation policy.
336-
337-
See also
338-
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
339-
340333
Example::
341334
342335
from neo4j import GraphDatabase
@@ -386,6 +379,8 @@ class RotatingClientCertificateProvider(ClientCertificateProvider):
386379
implementation internal. This entails removing the possibility to
387380
directly instantiate this class. Please use the factory method
388381
:meth:`.ClientCertificateProviders.rotating` instead.
382+
383+
.. versionchanged:: 5.27 Stabilized from preview.
389384
"""
390385

391386
@abc.abstractmethod
@@ -414,17 +409,12 @@ class ClientCertificateProviders:
414409
"""
415410
A collection of :class:`.ClientCertificateProvider` factories.
416411
417-
**This is a preview** (see :ref:`filter-warnings-ref`).
418-
It might be changed without following the deprecation policy.
419-
420-
See also
421-
https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
422-
423412
.. versionadded:: 5.19
413+
414+
.. versionchanged:: 5.27 Stabilized from preview.
424415
"""
425416

426417
@staticmethod
427-
@preview("Mutual TLS is a preview feature.")
428418
def static(cert: ClientCertificate) -> ClientCertificateProvider:
429419
"""
430420
Create a static client certificate provider.
@@ -435,7 +425,6 @@ def static(cert: ClientCertificate) -> ClientCertificateProvider:
435425
return _StaticClientCertificateProvider(cert)
436426

437427
@staticmethod
438-
@preview("Mutual TLS is a preview feature.")
439428
def rotating(
440429
initial_cert: ClientCertificate,
441430
) -> RotatingClientCertificateProvider:

src/neo4j/_sync/driver.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ def driver(
212212
config["client_certificate"] = (
213213
_StaticClientCertificateProvider(client_certificate)
214214
)
215-
if client_certificate is not None:
216-
preview_warn("Mutual TLS is a preview feature.", stack_level=2)
217215

218216
# TODO: 6.0 - remove "trust" config option
219217
if "trust" in config and config["trust"] not in {

testkitbackend/_async/requests.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,10 @@ async def new_driver(backend, data):
174174
client_cert_provider_id
175175
]
176176
data.mark_item_as_read_if_equals("clientCertificate", None)
177-
expected_warnings.append(
178-
(neo4j.PreviewWarning, r"Mutual TLS is a preview feature\.")
179-
)
180177
else:
181178
client_cert = fromtestkit.to_client_cert(data, "clientCertificate")
182179
if client_cert is not None:
183180
kwargs["client_certificate"] = client_cert
184-
expected_warnings.append(
185-
(neo4j.PreviewWarning, r"Mutual TLS is a preview feature\.")
186-
)
187181
if data["resolverRegistered"] or data["domainNameResolverRegistered"]:
188182
kwargs["resolver"] = resolution_func(
189183
backend,

testkitbackend/_sync/requests.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,10 @@ def new_driver(backend, data):
174174
client_cert_provider_id
175175
]
176176
data.mark_item_as_read_if_equals("clientCertificate", None)
177-
expected_warnings.append(
178-
(neo4j.PreviewWarning, r"Mutual TLS is a preview feature\.")
179-
)
180177
else:
181178
client_cert = fromtestkit.to_client_cert(data, "clientCertificate")
182179
if client_cert is not None:
183180
kwargs["client_certificate"] = client_cert
184-
expected_warnings.append(
185-
(neo4j.PreviewWarning, r"Mutual TLS is a preview feature\.")
186-
)
187181
if data["resolverRegistered"] or data["domainNameResolverRegistered"]:
188182
kwargs["resolver"] = resolution_func(
189183
backend,

testkitbackend/fromtestkit.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
)
4040

4141
from ._preview_imports import NotificationDisabledClassification
42-
from ._warning_check import warnings_check
4342

4443

4544
def to_cypher_and_params(data):
@@ -222,12 +221,9 @@ def to_client_cert(data, key) -> ClientCertificate | None:
222221
return None
223222
data[key].mark_item_as_read_if_equals("name", "ClientCertificate")
224223
cert_data = data[key]["data"]
225-
with warnings_check(
226-
((neo4j.PreviewWarning, r"Mutual TLS is a preview feature\."),)
227-
):
228-
return ClientCertificate(
229-
cert_data["certfile"], cert_data["keyfile"], cert_data["password"]
230-
)
224+
return ClientCertificate(
225+
cert_data["certfile"], cert_data["keyfile"], cert_data["password"]
226+
)
231227

232228

233229
def set_notifications_config(config, data):

0 commit comments

Comments
 (0)