diff --git a/airflow/providers/jdbc/CHANGELOG.rst b/airflow/providers/jdbc/CHANGELOG.rst index bdb5fef2201d3..e3d87ab88adc7 100644 --- a/airflow/providers/jdbc/CHANGELOG.rst +++ b/airflow/providers/jdbc/CHANGELOG.rst @@ -74,9 +74,9 @@ Breaking changes To configure driver parameters (driver path and driver class), you can use the following methods: 1. Supply them as constructor arguments when instantiating the hook. -2. Set the "driver_path" and/or "driver_class" parameters in the "hook_params" dictionary when creating the hook using SQL operators. -3. Set the "driver_path" and/or "driver_class" extra in the connection and correspondingly enable the "allow_driver_path_in_extra" and/or "allow_driver_class_in_extra" options in the "providers.jdbc" section of the Airflow configuration. -4. Patch the "JdbcHook.default_driver_path" and/or "JdbcHook.default_driver_class" values in the "local_settings.py" file. +2. Set the ``driver_path`` and/or ``driver_class`` parameters in the ``hook_params`` dictionary when creating the hook using SQL operators. +3. Set the ``driver_path`` and/or ``driver_class`` extra in the connection and correspondingly enable the ``allow_driver_path_in_extra`` and/or ``allow_driver_class_in_extra`` options in the ``providers.jdbc`` section of the Airflow configuration. +4. Patch the ``JdbcHook.default_driver_path`` and/or ``JdbcHook.default_driver_class`` values in the ``local_settings.py`` file. * ``Restrict direct usage of driver params via extras for JDBC connection (#31849)`` diff --git a/airflow/providers/jdbc/hooks/jdbc.py b/airflow/providers/jdbc/hooks/jdbc.py index 7ed9129792e82..35267319afe71 100644 --- a/airflow/providers/jdbc/hooks/jdbc.py +++ b/airflow/providers/jdbc/hooks/jdbc.py @@ -44,7 +44,7 @@ class JdbcHook(DbApiHook): configuration, you should make sure that you trust the users who can edit connections in the UI to not use it maliciously. 4. Patch the ``JdbcHook.default_driver_path`` and/or ``JdbcHook.default_driver_class`` values in the - "local_settings.py" file. + ``local_settings.py`` file. See :doc:`/connections/jdbc` for full documentation. diff --git a/airflow/providers/jdbc/provider.yaml b/airflow/providers/jdbc/provider.yaml index 4a7b18cdae30a..8948dfeb50270 100644 --- a/airflow/providers/jdbc/provider.yaml +++ b/airflow/providers/jdbc/provider.yaml @@ -64,7 +64,29 @@ hooks: python-modules: - airflow.providers.jdbc.hooks.jdbc - connection-types: - hook-class-name: airflow.providers.jdbc.hooks.jdbc.JdbcHook connection-type: jdbc + +config: + providers.jdbc: + description: This section applies for the JDBC provider and connection type. + options: + allow_driver_path_in_extra: + description: | + Whether to allow using ``driver_path`` set in the connection's ``extra`` field. If set to False, + ``driver_path`` will be ignored. If enabling this functionality, you should make sure that you + trust the users who can edit connections to not use it maliciously. + version_added: "4.0.0" + type: boolean + example: ~ + default: "False" + allow_driver_class_in_extra: + description: | + Whether to allow using ``driver_class`` set in the connection's ``extra`` field. If set to False, + ``driver_class`` will be ignored. If enabling this functionality, you should make sure that you + trust the users who can edit connections to not use it maliciously. + version_added: "4.0.0" + type: boolean + example: ~ + default: "False" diff --git a/docs/apache-airflow-providers-jdbc/configurations-ref.rst b/docs/apache-airflow-providers-jdbc/configurations-ref.rst new file mode 100644 index 0000000000000..5885c9d91b6e8 --- /dev/null +++ b/docs/apache-airflow-providers-jdbc/configurations-ref.rst @@ -0,0 +1,18 @@ + .. Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + .. http://www.apache.org/licenses/LICENSE-2.0 + + .. Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +.. include:: ../exts/includes/providers-configurations-ref.rst diff --git a/docs/apache-airflow-providers-jdbc/index.rst b/docs/apache-airflow-providers-jdbc/index.rst index b2a04d9169f11..118bd02cbb351 100644 --- a/docs/apache-airflow-providers-jdbc/index.rst +++ b/docs/apache-airflow-providers-jdbc/index.rst @@ -34,8 +34,9 @@ :maxdepth: 1 :caption: Guides - Operators + Configuration Connection types + Operators .. toctree:: :hidden: