Skip to content

Commit a7fd59a

Browse files
Cloud native authentication support plugins.
1 parent a366371 commit a7fd59a

22 files changed

+1100
-217
lines changed

doc/src/api_manual/connect_params.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ ConnectParams Methods
6464
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
6565
driver_name=oracledb.defaults.driver_name, use_sni=None, \
6666
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
67-
handle=None)
67+
extra_auth_params=None, handle=None)
6868

6969
Sets the values for one or more of the parameters of a ConnectParams
7070
object.
7171

7272
.. versionchanged:: 3.0.0
7373

74-
The ``use_sni``, ``thick_mode_dsn_passthrough``, and ``instance_name``
75-
parameters were added.
74+
The ``use_sni``, ``thick_mode_dsn_passthrough``, ``extra_auth_params``
75+
and ``instance_name`` parameters were added.
7676

7777
.. versionchanged:: 2.5.0
7878

@@ -242,6 +242,17 @@ ConnectParams Attributes
242242

243243
This attribute is only supported in python-oracledb Thick mode.
244244

245+
.. attribute:: ConnectParams.extra_auth_params
246+
247+
This read-only attribute is a dictionary containing the configuration
248+
parameters necessary for Oracle Database authentication using
249+
:ref:`Azure <azurecloudnativeauthplugin>` or
250+
:ref:` <ocicloudnativeauthplugin>` cloud native authentication plugins.
251+
252+
This attribute is supported in both python-oracledb Thin and Thick modes.
253+
254+
.. versionadded:: 3.0.0
255+
245256
.. attribute:: ConnectParams.host
246257

247258
This read-only attribute is a string that returns the name or IP address of

doc/src/api_manual/module.rst

Lines changed: 120 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Oracledb Methods
5454
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
5555
driver_name=oracledb.defaults.driver_name, use_sni=False, \
5656
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
57-
handle=0)
57+
extra_auth_params=None, handle=0)
5858

5959
Constructor for creating a connection to the database. Returns a
6060
:ref:`Connection Object <connobj>`. All parameters are optional and can be
@@ -408,6 +408,13 @@ Oracledb Methods
408408
python-oracledb Thick mode. The default value is the value of
409409
:attr:`defaults.thick_mode_dsn_passthrough`.
410410

411+
The ``extra_auth_params`` parameter is expected to be a dictionary
412+
containing the configuration parameters necessary for Oracle Database
413+
authentication using :ref:`Azure <azurecloudnativeauthplugin>` or
414+
:ref:`OCI <ocicloudnativeauthplugin>` cloud native authentication plugins.
415+
This value is used in both the python-oracledb Thin and Thick modes. See
416+
:ref:`tokenauth`.
417+
411418
If the ``handle`` parameter is specified, it must be of type OCISvcCtx\*
412419
and is only of use when embedding Python in an application (like
413420
PowerBuilder) which has already made the connection. The connection thus
@@ -418,9 +425,10 @@ Oracledb Methods
418425

419426
.. versionchanged:: 3.0.0
420427

421-
The ``pool_alias``, ``instance_name``, ``use_sni``, and
422-
``thick_mode_dsn_passthrough`` parameters were added. The ``pool``
423-
parameter was deprecated. Use :meth:`ConnectionPool.acquire()` instead.
428+
The ``pool_alias``, ``instance_name``, ``use_sni``,
429+
``thick_mode_dsn_passthrough`` and ``extra_auth_params`` parameters
430+
were added. The ``pool`` parameter was deprecated: use
431+
:meth:`ConnectionPool.acquire()` instead.
424432

425433
.. versionchanged:: 2.5.0
426434

@@ -467,7 +475,7 @@ Oracledb Methods
467475
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
468476
driver_name=oracledb.defaults.driver_name, use_sni=False, \
469477
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
470-
handle=0)
478+
extra_auth_params=None, handle=0)
471479

472480
Constructor for creating a connection to the database. Returns an
473481
:ref:`AsyncConnection Object <asyncconnobj>`. All parameters are optional
@@ -747,15 +755,22 @@ Oracledb Methods
747755
is used in both the python-oracledb Thin and Thick modes. The default is
748756
the value of :attr:`defaults.driver_name`.
749757

758+
The ``extra_auth_params`` parameter is expected to be a dictionary
759+
containing the configuration parameters necessary for Oracle Database
760+
authentication using :ref:`Azure <azurecloudnativeauthplugin>` or
761+
:ref:`OCI <ocicloudnativeauthplugin>` cloud native authentication plugins.
762+
This value is used in both the python-oracledb Thin and Thick modes. See
763+
:ref:`tokenauth`.
764+
750765
The ``thick_mode_dsn_passthrough`` and ``handle`` parameters are ignored in
751766
python-oracledb Thin mode.
752767

753768
.. versionchanged:: 3.0.0
754769

755-
The ``pool_alias``, ``instance_name``, ``use_sni``, and
756-
``thick_mode_dsn_passthrough`` parameters were added. The ``pool``
757-
parameter was deprecated. Use :meth:`AsyncConnectionPool.acquire()`
758-
instead.
770+
The ``pool_alias``, ``instance_name``, ``use_sni``,
771+
``thick_mode_dsn_passthrough`` and ``extra_auth_params`` parameters
772+
were added. The ``pool`` parameter was deprecated: use
773+
:meth:`AsyncConnectionPool.acquire()` instead.
759774

760775
.. versionchanged:: 2.5.0
761776

@@ -800,7 +815,7 @@ Oracledb Methods
800815
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
801816
driver_name=oracledb.defaults.driver_name, use_sni=False, \
802817
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
803-
handle=0)
818+
extra_auth_params=None, handle=0)
804819

805820
Contains all the parameters that can be used to establish a connection to
806821
the database.
@@ -1108,15 +1123,22 @@ Oracledb Methods
11081123
python-oracledb Thick mode. The default value is the value of
11091124
:attr:`defaults.thick_mode_dsn_passthrough`.
11101125

1126+
The ``extra_auth_params`` parameter is expected to be a dictionary
1127+
containing the configuration parameters necessary for Oracle Database
1128+
authentication using :ref:`Azure <azurecloudnativeauthplugin>` or
1129+
:ref:`OCI <ocicloudnativeauthplugin>` cloud native authentication plugins.
1130+
This value is used in both the python-oracledb Thin and Thick modes. See
1131+
:ref:`tokenauth`.
1132+
11111133
The ``handle`` parameter is expected to be an integer which represents a
11121134
pointer to a valid service context handle. This value is only used in the
11131135
python-oracledb Thick mode. It should be used with extreme caution. The
11141136
default value is *0*.
11151137

11161138
.. versionchanged:: 3.0.0
11171139

1118-
The ``use_sni``, ``thick_mode_dsn_passthrough``, and ``instance_name``
1119-
parameters were added.
1140+
The ``instance_name``, ``use_sni``, ``thick_mode_dsn_passthrough`` and
1141+
``extra_auth_params`` parameters were added.
11201142

11211143
.. versionchanged:: 2.5.0
11221144

@@ -1174,7 +1196,7 @@ Oracledb Methods
11741196
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
11751197
driver_name=oracledb.defaults.driver_name, use_sni=False, \
11761198
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
1177-
handle=0)
1199+
extra_auth_params=None, handle=0)
11781200

11791201
Creates a connection pool with the supplied parameters and returns the
11801202
:ref:`ConnectionPool object <connpool>` for the pool. See :ref:`Connection
@@ -1603,6 +1625,13 @@ Oracledb Methods
16031625
python-oracledb Thick mode. The default value is
16041626
:attr:`defaults.thick_mode_dsn_passthrough`.
16051627

1628+
The ``extra_auth_params`` parameter is expected to be a dictionary
1629+
containing the configuration parameters necessary for Oracle Database
1630+
authentication using :ref:`Azure <azurecloudnativeauthplugin>` or
1631+
:ref:`OCI <ocicloudnativeauthplugin>` cloud native authentication plugins.
1632+
This value is used in both the python-oracledb Thin and Thick modes. See
1633+
:ref:`tokenauth`.
1634+
16061635
If the ``handle`` parameter is specified, it must be of type OCISvcCtx\*
16071636
and is only of use when embedding Python in an application (like
16081637
PowerBuilder) which has already made the connection. The connection thus
@@ -1613,8 +1642,9 @@ Oracledb Methods
16131642

16141643
.. versionchanged:: 3.0.0
16151644

1616-
The ``pool_alias``, ``instance_name``, ``use_sni``, and
1617-
``thick_mode_dsn_passthrough`` parameters were added.
1645+
The ``pool_alias``, ``instance_name``, ``use_sni``,
1646+
``thick_mode_dsn_passthrough`` and ``extra_auth_params`` parameters
1647+
were added.
16181648

16191649
.. versionchanged:: 2.5.0
16201650

@@ -1666,7 +1696,7 @@ Oracledb Methods
16661696
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
16671697
driver_name=oracledb.defaults.driver_name, use_sni=False, \
16681698
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
1669-
handle=0)
1699+
extra_auth_params=None, handle=0)
16701700

16711701
Creates a connection pool with the supplied parameters and returns the
16721702
:ref:`AsyncConnectionPool object <asyncconnpoolobj>` for the pool.
@@ -2005,13 +2035,21 @@ Oracledb Methods
20052035
is used in both the python-oracledb Thin and Thick modes. The default is
20062036
the value of :attr:`defaults.driver_name`.
20072037

2038+
The ``extra_auth_params`` parameter is expected to be a dictionary
2039+
containing the configuration parameters necessary for Oracle Database
2040+
authentication using :ref:`Azure <azurecloudnativeauthplugin>` or
2041+
:ref:`OCI <ocicloudnativeauthplugin>` cloud native authentication plugins.
2042+
This value is used in both the python-oracledb Thin and Thick modes. See
2043+
:ref:`tokenauth`.
2044+
20082045
The ``handle`` and ``thick_mode_dsn_passthrough`` parameters are ignored in
20092046
python-oracledb Thin mode.
20102047

20112048
.. versionchanged:: 3.0.0
20122049

2013-
The ``pool_alias``, ``instance_name``, ``use_sni``, and
2014-
``thick_mode_dsn_passthrough`` parameters were added.
2050+
The ``pool_alias``, ``instance_name``, ``use_sni``,
2051+
``thick_mode_dsn_passthrough`` and ``extra_auth_params`` parameters
2052+
were added.
20152053

20162054
.. versionchanged:: 2.5.0
20172055

@@ -2230,7 +2268,7 @@ Oracledb Methods
22302268
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
22312269
driver_name=oracledb.defaults.driver_name, use_sni=False, \
22322270
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
2233-
handle=0)
2271+
extra_auth_params=None, handle=0)
22342272

22352273
Creates and returns a :ref:`PoolParams Object <poolparam>`. The object
22362274
can be passed to :meth:`oracledb.create_pool()`.
@@ -2602,15 +2640,22 @@ Oracledb Methods
26022640
python-oracledb Thick mode. The default value is
26032641
:attr:`defualts.thick_mode_dsn_passthrough`.
26042642

2643+
The ``extra_auth_params`` parameter is expected to be a dictionary
2644+
containing the configuration parameters necessary for Oracle Database
2645+
authentication using :ref:`Azure <azurecloudnativeauthplugin>` or
2646+
:ref:`OCI <ocicloudnativeauthplugin>` cloud native authentication plugins.
2647+
This value is used in both the python-oracledb Thin and Thick modes. See
2648+
:ref:`tokenauth`.
2649+
26052650
The ``handle`` parameter is expected to be an integer which represents a
26062651
pointer to a valid service context handle. This value is only used in the
26072652
python-oracledb Thick mode. It should be used with extreme caution. The
26082653
default value is *0*.
26092654

26102655
.. versionchanged:: 3.0.0
26112656

2612-
The ``use_sni``, ``thick_mode_dsn_passthrough``, and ``instance_name``
2613-
parameters were added.
2657+
The ``use_sni``, ``instance_name``, ``thick_mode_dsn_passthrough``,
2658+
``extra_auth_params`` and ``instance_name`` parameters were added.
26142659

26152660
.. versionchanged:: 2.5.0
26162661

@@ -2651,6 +2696,22 @@ Oracledb Methods
26512696

26522697
.. versionadded:: 3.0.0
26532698

2699+
.. function:: register_params_hook(hook_function)
2700+
2701+
Registers a user hook function that will be called internally by
2702+
python-oracledb prior to connection or pool creation. The hook function
2703+
accepts a copy of the parameters that will be used to create the pool or
2704+
standalone connection and may modify them. For example, the cloud native
2705+
authentication plugins modify the "access_token" parameter with a function
2706+
that will acquire the token using information found in the
2707+
"extra_auth_parms" parameter.
2708+
2709+
.. note::
2710+
2711+
This method is an extension to the DB API definition.
2712+
2713+
.. versionadded:: 3.0.0
2714+
26542715
.. function:: register_password_type(password_type, hook_function)
26552716

26562717
Registers a user hook function that will be called internally by
@@ -2778,6 +2839,17 @@ Oracledb Methods
27782839
(number of seconds since the epoch; see the documentation of the standard
27792840
Python time module for details).
27802841

2842+
.. function:: unregister_params_hook(hook_function)
2843+
2844+
Unregisters a user function that was earlier registered with a call to
2845+
:meth:`oracledb.register_params_hook()`.
2846+
2847+
.. note::
2848+
2849+
This method is an extension to the DB API definition.
2850+
2851+
.. versionadded:: 3.0.0
2852+
27812853

27822854
.. _interval_ym:
27832855

@@ -4424,3 +4496,30 @@ will use to connect to Oracle Database. See :ref:`importconfigazureplugin`
44244496
for more information.
44254497

44264498
.. versionadded:: 3.0.0
4499+
4500+
.. _ocicloudnativeauthplugin:
4501+
4502+
Oracle Cloud Infrastructure (OCI) Cloud Native Authentication Plugin
4503+
--------------------------------------------------------------------
4504+
4505+
``oci_tokens`` is a plugin that uses the Oracle Cloud Infrastructure (OCI)
4506+
Software Development Kit (SDK) to generate access tokens when authenticating
4507+
with OCI Identity and Access Management (IAM) token-based authentication.
4508+
Importing this plugin defines and
4509+
:meth:`registers <oracledb.register_params_hook()>`, the built-in hook function
4510+
that generates OCI IAM access tokens. See :ref:`cloudnativeauthoci`.
4511+
4512+
.. versionadded:: 3.0.0
4513+
4514+
.. _azurecloudnativeauthplugin:
4515+
4516+
Azure Cloud Native Authentication Plugin
4517+
----------------------------------------
4518+
4519+
``azure_tokens`` is a plugin that uses the Microsoft Authentication Library
4520+
(MSAL) to generate access tokens when authenticating with OAuth 2.0 token-based
4521+
authentication. Importing this plugin defines and
4522+
:meth:`registers <oracledb.register_params_hook()>`, the built-in hook function
4523+
that generates OAuth2 access tokens. See :ref:`cloudnativeauthoauth`.
4524+
4525+
.. versionadded:: 3.0.0

doc/src/api_manual/pool_params.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ PoolParams Methods
5353
terminal=oracledb.defaults.terminal, osuser=oracledb.defaults.osuser, \
5454
driver_name=oracledb.defaults.driver_name, use_sni=None, \
5555
thick_mode_dsn_passthrough=oracledb.defaults.thick_mode_dsn_passthrough, \
56-
handle=None)
56+
extra_auth_params=None, handle=None)
5757

5858
Sets one or more of the parameters.
5959

6060
.. versionchanged:: 3.0.0
6161

62-
The ``use_sni``, ``thick_mode_dsn_passthrough``, and
63-
``instance_name`` parameters were added.
62+
The ``use_sni``, ``thick_mode_dsn_passthrough``,
63+
``extra_auth_params`` and ``instance_name`` parameters were added.
6464

6565
.. versionchanged:: 2.5.0
6666

doc/src/release_notes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ Common Changes
108108
#) Added :meth:`oracledb.register_password_type()` to allow users to register
109109
a function that will be called when a password is supplied as a dictionary
110110
containing the key "type".
111+
#) Added :ref:`cloud native authentication <tokenauth>` support through the
112+
integration of Oracle Cloud Infrastructure (OCI) SDK and Azure SDK.
113+
#) Added parameter ``extra_auth_params`` to :meth:`oracledb.connect()`,
114+
:meth:`oracledb.connect_async()`, :meth:`oracledb.create_pool()`,
115+
and :meth:`oracledb.create_pool_async()` which is used to specify the
116+
configuration parameters required for cloud native authentication.
117+
#) Added :meth:`oracledb.register_params_hook()` and
118+
:meth:`oracledb.unregister_params_hook()` which allow users to register or
119+
unregister a function that manipulates the parameters used for creating
120+
pools or standalone connections. See
121+
:ref:`oci_tokens <ocicloudnativeauthplugin>` and
122+
:ref:`azure_tokens <azurecloudnativeauthplugin>` plugins which make use of
123+
this functionality.
111124
#) Added attributes :attr:`DbObjectAttribute.precision`,
112125
:attr:`DbObjectAttribute.scale`, and :attr:`DbObjectAttribute.max_size` that
113126
provide additional metadata about

0 commit comments

Comments
 (0)