Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update terminology from credentialfree to passwordless. #30788

Merged
merged 16 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sdk/boms/spring-cloud-azure-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
saragluna marked this conversation as resolved.
Show resolved Hide resolved
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.6.0-beta.1</version> <!-- {x-version-update;jdbc_com.azure:azure-identity;external_dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-spring-data-cosmos</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package com.azure.spring.cloud.autoconfigure.implementation.kafka;

import com.azure.spring.cloud.autoconfigure.context.AzureGlobalProperties;
import com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties;
import com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties;
import com.azure.spring.cloud.service.implementation.kafka.KafkaOAuth2AuthenticateCallbackHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -13,7 +13,7 @@
import java.util.HashMap;
import java.util.Map;

import static com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreePropertiesUtils.convertConfigMapToAzureProperties;
import static com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessPropertiesUtils.convertConfigMapToAzureProperties;
import static com.azure.spring.cloud.core.implementation.util.AzurePropertiesUtils.copyPropertiesIgnoreNull;
import static org.apache.kafka.clients.CommonClientConfigs.SECURITY_PROTOCOL_CONFIG;
import static org.apache.kafka.common.config.SaslConfigs.SASL_JAAS_CONFIG;
Expand Down Expand Up @@ -93,18 +93,18 @@ public static void logConfigureOAuthProperties() {
}

/**
* Build {@link AzureCredentialFreeProperties} from Kafka custom properties and {@link AzureGlobalProperties}.
* Build {@link AzurePasswordlessProperties} from Kafka custom properties and {@link AzureGlobalProperties}.
*
* @param kafkaProperties the kafka custom property map
* @param azureGlobalProperties Azure global properties
* @return a {@link AzureCredentialFreeProperties}
* @return a {@link AzurePasswordlessProperties}
*/
public static AzureCredentialFreeProperties buildAzureProperties(Map<String, Object> kafkaProperties,
AzureGlobalProperties azureGlobalProperties) {
AzureCredentialFreeProperties azureCredentialFreeProperties = new AzureCredentialFreeProperties();
copyPropertiesIgnoreNull(azureGlobalProperties.getProfile(), azureCredentialFreeProperties.getProfile());
copyPropertiesIgnoreNull(azureGlobalProperties.getCredential(), azureCredentialFreeProperties.getCredential());
convertConfigMapToAzureProperties(kafkaProperties, azureCredentialFreeProperties);
return azureCredentialFreeProperties;
public static AzurePasswordlessProperties buildAzureProperties(Map<String, Object> kafkaProperties,
AzureGlobalProperties azureGlobalProperties) {
AzurePasswordlessProperties azurePasswordlessProperties = new AzurePasswordlessProperties();
copyPropertiesIgnoreNull(azureGlobalProperties.getProfile(), azurePasswordlessProperties.getProfile());
copyPropertiesIgnoreNull(azureGlobalProperties.getCredential(), azurePasswordlessProperties.getCredential());
convertConfigMapToAzureProperties(kafkaProperties, azurePasswordlessProperties);
return azurePasswordlessProperties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.azure.spring.cloud.autoconfigure.implementation.jdbc.DatabaseType;
import com.azure.spring.cloud.autoconfigure.implementation.jdbc.JdbcConnectionString;
import com.azure.spring.cloud.core.implementation.credential.resolver.AzureTokenCredentialResolver;
import com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties;
import com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties;
import com.azure.spring.cloud.service.implementation.identity.credential.provider.SpringTokenCredentialProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -24,7 +24,7 @@
import java.util.HashMap;
import java.util.Map;

import static com.azure.spring.cloud.service.implementation.identity.credential.provider.SpringTokenCredentialProvider.CREDENTIAL_FREE_TOKEN_BEAN_NAME;
import static com.azure.spring.cloud.service.implementation.identity.credential.provider.SpringTokenCredentialProvider.PASSWORDLESS_TOKEN_BEAN_NAME;
saragluna marked this conversation as resolved.
Show resolved Hide resolved


/**
Expand All @@ -44,10 +44,10 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro
if (bean instanceof DataSourceProperties) {
DataSourceProperties dataSourceProperties = (DataSourceProperties) bean;

AzureCredentialFreeProperties properties = Binder.get(environment)
.bindOrCreate(SPRING_CLOUD_AZURE_DATASOURCE_PREFIX, AzureCredentialFreeProperties.class);
if (!properties.isCredentialFreeEnabled()) {
LOGGER.debug("Feature credential free is not enabled, skip enhancing jdbc url.");
AzurePasswordlessProperties properties = Binder.get(environment)
.bindOrCreate(SPRING_CLOUD_AZURE_DATASOURCE_PREFIX, AzurePasswordlessProperties.class);
if (!properties.isPasswordlessEnabled()) {
LOGGER.debug("Feature passwordless authentication is not enabled, skip enhancing jdbc url.");
return bean;
}

Expand Down Expand Up @@ -89,15 +89,15 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro
return bean;
}

private Map<String, String> buildEnhancedProperties(DatabaseType databaseType, AzureCredentialFreeProperties properties) {
private Map<String, String> buildEnhancedProperties(DatabaseType databaseType, AzurePasswordlessProperties properties) {
Map<String, String> result = new HashMap<>();
AzureTokenCredentialResolver resolver = applicationContext.getBean(AzureTokenCredentialResolver.class);
TokenCredential tokenCredential = resolver.resolve(properties);

if (tokenCredential != null) {
LOGGER.debug("Add SpringTokenCredentialProvider as the default token credential provider.");
AuthProperty.TOKEN_CREDENTIAL_BEAN_NAME.setProperty(result, CREDENTIAL_FREE_TOKEN_BEAN_NAME);
applicationContext.registerBean(CREDENTIAL_FREE_TOKEN_BEAN_NAME, TokenCredential.class, () -> tokenCredential);
AuthProperty.TOKEN_CREDENTIAL_BEAN_NAME.setProperty(result, PASSWORDLESS_TOKEN_BEAN_NAME);
applicationContext.registerBean(PASSWORDLESS_TOKEN_BEAN_NAME, TokenCredential.class, () -> tokenCredential);
}

AuthProperty.TOKEN_CREDENTIAL_PROVIDER_CLASS_NAME.setProperty(result, SPRING_TOKEN_CREDENTIAL_PROVIDER_CLASS_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.azure.core.credential.TokenCredential;
import com.azure.spring.cloud.autoconfigure.context.AzureGlobalProperties;
import com.azure.spring.cloud.core.implementation.credential.resolver.AzureTokenCredentialResolver;
import com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties;
import com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties;
import org.apache.kafka.common.message.ApiVersionsRequestData;
import org.apache.kafka.common.requests.ApiVersionsRequest;

Expand Down Expand Up @@ -77,16 +77,16 @@ DefaultKafkaProducerFactoryCustomizer azureOAuth2KafkaProducerFactoryCustomizer(

private void configureOAuth2Properties(Map<String, Object> updateConfigs, Map<String, Object> sourceKafkaProperties) {
if (needConfigureSaslOAuth(sourceKafkaProperties)) {
AzureCredentialFreeProperties azureCredentialFreeProperties = buildAzureProperties(sourceKafkaProperties,
AzurePasswordlessProperties azurePasswordlessProperties = buildAzureProperties(sourceKafkaProperties,
azureGlobalProperties);
updateConfigs.put(AZURE_TOKEN_CREDENTIAL, resolveSpringCloudAzureTokenCredential(azureCredentialFreeProperties));
updateConfigs.put(AZURE_TOKEN_CREDENTIAL, resolveSpringCloudAzureTokenCredential(azurePasswordlessProperties));
updateConfigs.putAll(KAFKA_OAUTH_CONFIGS);
logConfigureOAuthProperties();
}
}

private TokenCredential resolveSpringCloudAzureTokenCredential(AzureCredentialFreeProperties azureCredentialFreeProperties) {
TokenCredential tokenCredential = tokenCredentialResolver.resolve(azureCredentialFreeProperties);
private TokenCredential resolveSpringCloudAzureTokenCredential(AzurePasswordlessProperties azurePasswordlessProperties) {
TokenCredential tokenCredential = tokenCredentialResolver.resolve(azurePasswordlessProperties);
return tokenCredential == null ? defaultTokenCredential : tokenCredential;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package com.azure.spring.cloud.autoconfigure.kafka;

import com.azure.spring.cloud.autoconfigure.context.AzureGlobalProperties;
import com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties;
import com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
Expand All @@ -14,7 +14,7 @@
import static com.azure.spring.cloud.autoconfigure.implementation.kafka.AzureKafkaAutoconfigurationUtils.buildAzureProperties;
import static com.azure.spring.cloud.autoconfigure.implementation.kafka.AzureKafkaAutoconfigurationUtils.configureOAuthProperties;
import static com.azure.spring.cloud.autoconfigure.implementation.kafka.AzureKafkaAutoconfigurationUtils.needConfigureSaslOAuth;
import static com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreePropertiesUtils.convertAzurePropertiesToConfigMap;
import static com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessPropertiesUtils.convertAzurePropertiesToConfigMap;
import static org.springframework.cloud.stream.binder.kafka.provisioning.KafkaTopicProvisioner.normalalizeBootPropsWithBinder;

/**
Expand Down Expand Up @@ -54,9 +54,9 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro

private void configureKafkaBinderProperties(Map<String, Object> mergedConfiguration, Map<String, String> sourceProperties) {
if (needConfigureSaslOAuth(mergedConfiguration)) {
AzureCredentialFreeProperties azureCredentialFreeProperties =
AzurePasswordlessProperties azurePasswordlessProperties =
buildAzureProperties(mergedConfiguration, azureGlobalProperties);
convertAzurePropertiesToConfigMap(azureCredentialFreeProperties, sourceProperties);
convertAzurePropertiesToConfigMap(azurePasswordlessProperties, sourceProperties);
configureOAuthProperties(sourceProperties);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1464,62 +1464,62 @@
"name": "spring.datasource.azure.credential.client-id",
"type": "java.lang.String",
"description": "Client ID to use when performing service principal authentication with Azure.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties"
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties"
},
{
"name": "spring.datasource.azure.credential.client-secret",
"type": "java.lang.String",
"description": "Client secret to use when performing service principal authentication with Azure.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties"
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties"
},
{
"name": "spring.datasource.azure.credential.client-certificate-password",
"type": "java.lang.String",
"description": "Password of the certificate file.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties"
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties"
},
{
"name": "spring.datasource.azure.credential.client-certificate-path",
"type": "java.lang.String",
"description": "Path of a PEM certificate file to use when performing service principal authentication with Azure.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties"
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties"
},
{
"name": "spring.datasource.azure.credential.username",
"type": "java.lang.String",
"description": "Username to use when performing username\/password authentication with Azure.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties"
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties"
},
{
"name": "spring.datasource.azure.credential.password",
"type": "java.lang.String",
"description": "Password to use when performing username\/password authentication with Azure.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties"
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties"
},
{
"name": "spring.datasource.azure.credential.managed-identity-enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable managed identity to authenticate with Azure. If true and the client-id is set, will use the client ID as user assigned managed identity client ID.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties",
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties",
"defaultValue": false
},
{
"name": "spring.datasource.azure.profile.environment.active-directory-endpoint",
"type": "java.lang.String",
"description": "The Azure Active Directory endpoint to connect to.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties"
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties"
},
{
"name": "spring.datasource.azure.profile.tenant-id",
"type": "java.lang.String",
"description": "Tenant ID for Azure resources.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties"
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties"
},
{
"name": "spring.datasource.azure.profile.cloud-type",
"type": "java.lang.String",
"description": "Name of the Azure cloud to connect to.",
"sourceType": "com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties"
"sourceType": "com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties"
}
],
"hints": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.azure.spring.cloud.autoconfigure.context.AzureGlobalPropertiesAutoConfiguration;
import com.azure.spring.cloud.autoconfigure.context.AzureTokenCredentialAutoConfiguration;
import com.azure.spring.cloud.autoconfigure.implementation.jdbc.SpringTokenCredentialProviderContextProvider;
import com.azure.spring.cloud.service.implementation.credentialfree.AzureCredentialFreeProperties;
import com.azure.spring.cloud.service.implementation.passwordless.AzurePasswordlessProperties;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
Expand All @@ -32,7 +32,7 @@ abstract class AbstractJdbcPropertiesBeanPostProcessorTest {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(AzureJdbcAutoConfiguration.class,
DataSourceProperties.class,
AzureCredentialFreeProperties.class,
AzurePasswordlessProperties.class,
AzureGlobalPropertiesAutoConfiguration.class,
AzureTokenCredentialAutoConfiguration.class));

Expand Down Expand Up @@ -108,7 +108,7 @@ private void assertBootPropertiesConfigureCorrectly(AssertableApplicationContext
assertThat(context).hasSingleBean(SpringTokenCredentialProviderContextProvider.class);

ConfigurableEnvironment environment = context.getEnvironment();
AzureCredentialFreeProperties properties = Binder.get(environment).bindOrCreate(SPRING_CLOUD_AZURE_DATASOURCE_PREFIX, AzureCredentialFreeProperties.class);
AzurePasswordlessProperties properties = Binder.get(environment).bindOrCreate(SPRING_CLOUD_AZURE_DATASOURCE_PREFIX, AzurePasswordlessProperties.class);

assertNotEquals("azure-client-id", properties.getCredential().getClientId());
assertEquals("fake-jdbc-client-id", properties.getCredential().getClientId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MySqlAzureJdbcAutoConfigurationTest extends AbstractAzureJdbcAutoConfigura
= AuthProperty.TOKEN_CREDENTIAL_PROVIDER_CLASS_NAME.getPropertyKey() + "=" + SpringTokenCredentialProvider.class.getName();

private static final String AUTHPROPERTY_CREDENTIAL_BEAN_NAME
= AuthProperty.TOKEN_CREDENTIAL_BEAN_NAME.getPropertyKey() + "=" + "credentialFreeTokenCredential";
= AuthProperty.TOKEN_CREDENTIAL_BEAN_NAME.getPropertyKey() + "=" + "passwordlessTokenCredential";

@Override
void pluginNotOnClassPath() {
Expand Down Expand Up @@ -66,7 +66,7 @@ void enhanceUrlWithDefaultCredential() {

this.contextRunner
.withPropertyValues("spring.datasource.url = " + connectionString)
.withPropertyValues("spring.datasource.azure.credentialFreeEnabled = " + true)
.withPropertyValues("spring.datasource.azure.passwordlessEnabled = " + true)
.run((context) -> {
DataSourceProperties dataSourceProperties = context.getBean(DataSourceProperties.class);

Expand All @@ -87,7 +87,7 @@ void enhanceUrlWithCustomCredential() {

this.contextRunner
.withPropertyValues("spring.datasource.url = " + connectionString)
.withPropertyValues("spring.datasource.azure.credentialFreeEnabled = " + true)
.withPropertyValues("spring.datasource.azure.passwordlessEnabled = " + true)
.withPropertyValues("spring.datasource.azure.profile.tenantId = " + "fake-tenantId")
.withPropertyValues("spring.datasource.azure.credential.clientSecret = " + "fake-clientSecret")
.withPropertyValues("spring.datasource.azure.credential.clientId = " + "fake-clientId")
Expand Down
Loading