Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Content for OAuth2/OIDC support for Kafka REST proxy #2237

Merged
merged 10 commits into from
Nov 14, 2023
3 changes: 2 additions & 1 deletion _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,10 @@ entries:
entries:
- file: docs/products/kafka/karapace/howto/enable-karapace
- file: docs/products/kafka/karapace/howto/enable-schema-registry-authorization
- file: docs/products/kafka/karapace/howto/enable-kafka-rest-proxy-authorization
- file: docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy
- file: docs/products/kafka/karapace/howto/manage-schema-registry-authorization
- file: docs/products/kafka/karapace/howto/manage-kafka-rest-proxy-authorization


# -------- FLINK --------
- file: docs/products/flink
Expand Down
4 changes: 4 additions & 0 deletions docs/products/kafka/howto/enable-oidc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,7 @@ To enable OAuth2/OIDC authentication for your Aiven for Apache Kafka service usi
For detailed explanations on the OIDC parameters, refer to the :ref:`console-authentication` section above.



See also
--------
- Enable OAuth2/OIDC support for Apache Kafka® REST proxy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Apache Kafka® REST proxy authorization is **disabled** by default on all Aiven

.. seealso::

* :doc:`Enable Apache Kafka® REST proxy authorization via Aiven CLI </docs/products/kafka/karapace/howto/enable-kafka-rest-proxy-authorization>`
* :doc:`Enable OAuth2/OIDC support for Apache Kafka® REST proxy </docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy>`
* :doc:`Manage Apache Kafka® REST proxy authorization <../howto/manage-kafka-rest-proxy-authorization>`


2 changes: 1 addition & 1 deletion docs/products/kafka/karapace/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-----------
* Learn more about :doc:`Karapace schema registry authorization <../karapace/concepts/schema-registry-authorization>` and :doc:`ACLs definition <../karapace/concepts/acl-definition>`.
* Learn more about how to enable :doc:`Karapace schema registry authorization <../karapace/howto/enable-schema-registry-authorization>` and how to :doc:`manage Karapace schema registry authorization <../karapace/howto/manage-schema-registry-authorization>`.
* Learn more about how to enable :doc:`Apache Kafka REST proxy authorization <../karapace/howto/enable-kafka-rest-proxy-authorization>` and how to :doc:`manage Karapace Kafka REST authorization <../karapace/howto/manage-kafka-rest-proxy-authorization>`.
* Learn more about how to enable :doc:`Apache Kafka REST proxy authorization <../karapace/howto/enable-oauth-oidc-kafka-rest-proxy>` and how to :doc:`manage Karapace Kafka REST authorization <../karapace/howto/manage-kafka-rest-proxy-authorization>`.

Check failure on line 10 in docs/products/kafka/karapace/getting-started.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/products/kafka/karapace/getting-started.rst#L10

[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.
Raw output
{"message": "[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.", "location": {"path": "docs/products/kafka/karapace/getting-started.rst", "range": {"start": {"line": 10, "column": 115}}}, "severity": "ERROR"}

Check failure on line 10 in docs/products/kafka/karapace/getting-started.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/products/kafka/karapace/getting-started.rst#L10

[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.
Raw output
{"message": "[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.", "location": {"path": "docs/products/kafka/karapace/getting-started.rst", "range": {"start": {"line": 10, "column": 218}}}, "severity": "ERROR"}

More resources
--------------
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Enable OAuth2/OIDC support for Apache Kafka® REST proxy
========================================================

Secure your Apache Kafka® resources by integrating OAuth 2.0/OpenID Connect (OIDC) with the Karapace REST proxy and enabling REST proxy authorization. This setup ensures that only authorized individuals can manage Apache Kafka resources through both token-based authentication and access control rules.

OAuth2/OIDC token handling
---------------------------

Karapace processes the JSON Web Token (JWT) obtained from the Authorization HTTP header, specifically when employing the Bearer authentication scheme. This allows OAuth2/OIDC credentials to be supplied directly to the REST proxy, which uses the provided token to authorize requests to Apache Kafka. When a Bearer token is presented, Kafka clients configured by Karapace use the SASL OAUTHBEARER mechanism to send the JWT for validation.


Authorization enforcement
----------------------------

In the underlying Aiven for Apache Kafka® service, the default mechanism for authorization, uses the ``sub`` claim from the JWT as the username. This username is then verified against the configured Access Control Lists (ACLs) to authorize user operations on Kafka resources.

While the ``sub`` claim is the default identifier, this setting is configurable. You can specify a different JWT claim for authentication by adjusting the ``kafka.sasl_oauthbearer_sub_claim_name`` parameter. For more information on configuring this, see :ref:`console-authentication`.

To authenticate and authorize a user in Aiven for Apache Kafka, both a service user and an ACL entry describing the permissions are required. The JWT claim value used for authentication must explicitly match the service user in the system. Furthermore, this service user must be associated with an ACL entry that outlines their permissions, ensuring that the identity of the user making the request aligns with both the service user and the ACL entry.



Managing token expiry
------------------------------

With OAuth2/OIDC enabled, Karapace manages Kafka client connections for security and performance. It automatically cleans up idle clients and those with tokens nearing expiration, typically on a 5-minute cycle. This cleanup prevents unauthorized access with expired tokens and clears idle connections.

.. note::
Before your token expires, remove any linked consumers and producers to avoid security issues and service interruptions. After removal, refresh your OAuth2 JWT tokens and reconnect with the new tokens.


Configure OAuth2/OIDC authentication
--------------------------------------------------------------

To establish OAuth2/OIDC authentication for the Karapace REST proxy, complete the following prerequisites and configuration steps:

Prerequisites
```````````````
* :doc:`Aiven for Apache Kafka® </docs/products/kafka/getting-started>` service running with :doc:`OAuth2/OIDC enabled </docs/products/kafka/howto/enable-oidc>`.

Check failure on line 39 in docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst#L39

[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.
Raw output
{"message": "[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.", "location": {"path": "docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst", "range": {"start": {"line": 39, "column": 49}}}, "severity": "ERROR"}

Check failure on line 39 in docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst#L39

[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.
Raw output
{"message": "[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.", "location": {"path": "docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst", "range": {"start": {"line": 39, "column": 136}}}, "severity": "ERROR"}
* :doc:`Karapace schema registry and REST APIs enabled </docs/products/kafka/karapace/howto/enable-karapace>`.

Check failure on line 40 in docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst#L40

[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.
Raw output
{"message": "[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.", "location": {"path": "docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst", "range": {"start": {"line": 40, "column": 72}}}, "severity": "ERROR"}
* Ensure access to an OIDC-compliant provider, such as Auth0, Okta, Google Identity Platform, or Azure.

Configuration via Aiven Console
```````````````````````````````````
1. In `Aiven Console <https://console.aiven.io/>`_, select your project and then choose your Aiven for Apache Kafka® service.
2. On the **Overview** page, scroll down to **Advanced configuration** and select **Configure**.
3. In the **Advanced configuration** screen, select **Add configuration options**.
4. Look for ``kafka_rest_authorization`` parameter and set it to ``True``.

Configuration via Aiven CLI

Check failure on line 50 in docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst#L50

[Aiven.capitalization_headings] 'Configuration via Aiven CLI' should be in sentence case
Raw output
{"message": "[Aiven.capitalization_headings] 'Configuration via Aiven CLI' should be in sentence case", "location": {"path": "docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst", "range": {"start": {"line": 50, "column": 1}}}, "severity": "ERROR"}
`````````````````````````````

To enable REST proxy authorization, use the following command in the Aiven CLI, replacing ``SERVICE_NAME`` with your actual service name:

.. code::

avn service update -c kafka_rest_authorization=true SERVICE_NAME

Disable REST proxy authorization, use:

.. code::

avn service update -c kafka_rest_authorization=false SERVICE_NAME

.. warning::
Enabling Apache Kafka REST proxy authorization can disrupt access for users if the Kafka access control rules have not been configured properly. For more information, see :doc:`Manage Apache Kafka® REST proxy authorization <../howto/manage-kafka-rest-proxy-authorization>`.

Check failure on line 66 in docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst#L66

[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.
Raw output
{"message": "[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.", "location": {"path": "docs/products/kafka/karapace/howto/enable-oauth-oidc-kafka-rest-proxy.rst", "range": {"start": {"line": 66, "column": 245}}}, "severity": "ERROR"}


Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manage Apache Kafka® REST proxy authorization
==============================================

Apache Kafka® REST proxy authorization allows you to use the RESTful interface to connect to Kafka clusters, produce and consume messages easily, and execute administrative activities using Aiven CLI. This feature is disabled by default, and you need to :doc:`enable Apache Kafka REST proxy authorization <../howto/enable-kafka-rest-proxy-authorization>`.
Apache Kafka® REST proxy authorization allows you to use the RESTful interface to connect to Kafka clusters, produce and consume messages easily, and execute administrative activities using Aiven CLI. This feature is disabled by default, and you need to :doc:`enable Apache Kafka REST proxy authorization <../howto/enable-oauth-oidc-kafka-rest-proxy>`.

Check failure on line 4 in docs/products/kafka/karapace/howto/manage-kafka-rest-proxy-authorization.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/products/kafka/karapace/howto/manage-kafka-rest-proxy-authorization.rst#L4

[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.
Raw output
{"message": "[Aiven.common_replacements] Use 'Kafka' instead of 'kafka'.", "location": {"path": "docs/products/kafka/karapace/howto/manage-kafka-rest-proxy-authorization.rst", "range": {"start": {"line": 4, "column": 334}}}, "severity": "ERROR"}

When you enable Apache Kafka REST proxy authorization, Karapace sends the HTTP basic authentication credentials to Apache Kafka®. The authentication and authorization are then performed by Apache Kafka, depending on the ACL defined in Apache Kafka. To configure the ACLs for authorization, see :doc:`Kafka Access Control Lists (ACLs) </docs/products/kafka/concepts/acl>`.

Expand Down
Loading