|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +/** |
| 5 | + * Authentication strategies for Azure Event Hubs Kafka support in Spring Cloud Azure. |
| 6 | + * |
| 7 | + * <h2>Overview</h2> |
| 8 | + * This package contains authentication strategy implementations for configuring Kafka clients |
| 9 | + * to connect to Azure Event Hubs using different authentication methods. |
| 10 | + * |
| 11 | + * <h2>Architecture</h2> |
| 12 | + * The authentication configuration uses the Strategy pattern to support different authentication methods: |
| 13 | + * <ul> |
| 14 | + * <li>{@link com.azure.spring.cloud.autoconfigure.implementation.kafka.authentication.KafkaAuthenticationStrategy} - |
| 15 | + * The strategy interface that defines how authentication should be applied</li> |
| 16 | + * <li>{@link com.azure.spring.cloud.autoconfigure.implementation.kafka.authentication.KafkaOAuth2AuthenticationStrategy} - |
| 17 | + * Implementation for OAuth2 authentication using Microsoft Entra ID</li> |
| 18 | + * </ul> |
| 19 | + * |
| 20 | + * <h2>Supported Authentication Methods</h2> |
| 21 | + * |
| 22 | + * <h3>OAuth2 Authentication (Microsoft Entra ID)</h3> |
| 23 | + * The {@code KafkaOAuth2AuthenticationStrategy} configures SASL/OAUTHBEARER authentication |
| 24 | + * for connecting to Azure Event Hubs using Microsoft Entra ID credentials. |
| 25 | + * |
| 26 | + * <p><b>Configuration Requirements:</b></p> |
| 27 | + * <ul> |
| 28 | + * <li>Bootstrap server must be an Event Hubs namespace endpoint (ends with :9093)</li> |
| 29 | + * <li>Security protocol should be SASL_SSL (or not configured)</li> |
| 30 | + * <li>SASL mechanism should be OAUTHBEARER (or not configured)</li> |
| 31 | + * </ul> |
| 32 | + * |
| 33 | + * <p><b>Properties Configured:</b></p> |
| 34 | + * <ul> |
| 35 | + * <li>{@code security.protocol} = SASL_SSL</li> |
| 36 | + * <li>{@code sasl.mechanism} = OAUTHBEARER</li> |
| 37 | + * <li>{@code sasl.jaas.config} = JAAS configuration with Azure credentials</li> |
| 38 | + * <li>{@code sasl.login.callback.handler.class} = KafkaOAuth2AuthenticateCallbackHandler</li> |
| 39 | + * </ul> |
| 40 | + * |
| 41 | + * <h2>Usage</h2> |
| 42 | + * The authentication strategies are used automatically by the Kafka bean post processors: |
| 43 | + * <ul> |
| 44 | + * <li>{@code KafkaPropertiesBeanPostProcessor} - For Spring Boot Kafka auto-configuration</li> |
| 45 | + * <li>{@code KafkaBinderConfigurationPropertiesBeanPostProcessor} - For Spring Cloud Stream Kafka binder</li> |
| 46 | + * </ul> |
| 47 | + * |
| 48 | + * <h2>Example Configuration</h2> |
| 49 | + * <pre>{@code |
| 50 | + * spring.kafka.bootstrap-servers=mynamespace.servicebus.windows.net:9093 |
| 51 | + * spring.cloud.azure.credential.client-id=<client-id> |
| 52 | + * spring.cloud.azure.credential.client-secret=<client-secret> |
| 53 | + * spring.cloud.azure.profile.tenant-id=<tenant-id> |
| 54 | + * }</pre> |
| 55 | + * |
| 56 | + * @since 6.1.0 |
| 57 | + */ |
| 58 | +package com.azure.spring.cloud.autoconfigure.implementation.kafka.authentication; |
0 commit comments