Skip to content

Commit

Permalink
Change azure active directory related property from "azure.activedire…
Browse files Browse the repository at this point in the history
…ctory.*" to "spring.cloud.azure.active-directory.*" (#25434)
  • Loading branch information
Rujun Chen authored Nov 17, 2021
1 parent f952243 commit 1c251a1
Show file tree
Hide file tree
Showing 25 changed files with 184 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public ConditionOutcome getMatchOutcome(final ConditionContext context,
*/
private static AADB2CProperties getAADB2CProperties(ConditionContext context) {
return Binder.get(context.getEnvironment())
.bind("azure.activedirectory.b2c", AADB2CProperties.class)
.bind("spring.cloud.azure.active-directory.b2c", AADB2CProperties.class)
.orElse(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class AADB2CProperties implements InitializingBean {

public static final String DEFAULT_LOGOUT_SUCCESS_URL = "http://localhost:8080/login";

public static final String PREFIX = "azure.activedirectory.b2c";
public static final String PREFIX = "spring.cloud.azure.active-directory.b2c";

private static final String TENANT_NAME_PART_REGEX = "([A-Za-z0-9]+\\.)";

Expand Down Expand Up @@ -188,7 +188,7 @@ public void setTenant(String tenant) {
*/
@DeprecatedConfigurationProperty(
reason = "Configuration updated to baseUri",
replacement = "azure.activedirectory.b2c.base-uri")
replacement = "spring.cloud.azure.active-directory.b2c.base-uri")
public String getTenant() {
if (StringUtils.hasText(baseUri)) {
Matcher matcher = Pattern.compile(TENANT_NAME_PART_REGEX).matcher(baseUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
ConditionMessage.Builder message = ConditionMessage.forCondition("AAD Application Client Condition");
AADAuthenticationProperties properties =
Binder.get(context.getEnvironment())
.bind("azure.activedirectory", AADAuthenticationProperties.class)
.bind("spring.cloud.azure.active-directory", AADAuthenticationProperties.class)
.orElse(null);
if (properties == null) {
return ConditionOutcome.noMatch(
message.notAvailable("AAD authorization properties(azure.activedirectory" + ".xxx)"));
message.notAvailable("AAD authorization properties(spring.cloud.azure.active-directory" + ".xxx)"));
}

if (!StringUtils.hasText(properties.getClientId())) {
return ConditionOutcome.noMatch(message.didNotFind("azure.activedirectory.client-id").atAll());
return ConditionOutcome.noMatch(message.didNotFind("spring.cloud.azure.active-directory.client-id").atAll());
}

// Bind properties will not execute AADAuthenticationProperties#afterPropertiesSet()
Expand All @@ -46,6 +46,6 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
message.because("Resource server does not need client registration."));
}
return ConditionOutcome.match(
message.foundExactly("azure.activedirectory.application-type=" + applicationType));
message.foundExactly("spring.cloud.azure.active-directory.application-type=" + applicationType));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
ConditionMessage.Builder message = ConditionMessage.forCondition("AAD Resource Server Condition");
AADAuthenticationProperties properties =
Binder.get(context.getEnvironment())
.bind("azure.activedirectory", AADAuthenticationProperties.class)
.bind("spring.cloud.azure.active-directory", AADAuthenticationProperties.class)
.orElse(null);
if (properties == null) {
return ConditionOutcome.noMatch(message.notAvailable("aad authorization properties"));
Expand All @@ -37,9 +37,9 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
.orElseGet(AADApplicationType::inferApplicationTypeByDependencies);
if (applicationType == null || applicationType == WEB_APPLICATION) {
return ConditionOutcome.noMatch(
message.because("azure.activedirectory.application-type=" + applicationType));
message.because("spring.cloud.azure.active-directory.application-type=" + applicationType));
}
return ConditionOutcome.match(
message.foundExactly("azure.activedirectory.application-type=" + applicationType));
message.foundExactly("spring.cloud.azure.active-directory.application-type=" + applicationType));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
ConditionMessage.Builder message = ConditionMessage.forCondition("AAD Web Application Condition");
AADAuthenticationProperties properties =
Binder.get(context.getEnvironment())
.bind("azure.activedirectory", AADAuthenticationProperties.class)
.bind("spring.cloud.azure.active-directory", AADAuthenticationProperties.class)
.orElse(null);
if (properties == null) {
return ConditionOutcome.noMatch(message.notAvailable("aad authorization properties"));
Expand All @@ -45,9 +45,9 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
|| applicationType == RESOURCE_SERVER
|| applicationType == RESOURCE_SERVER_WITH_OBO) {
return ConditionOutcome.noMatch(
message.because("azure.activedirectory.application-type=" + applicationType));
message.because("spring.cloud.azure.active-directory.application-type=" + applicationType));
}
return ConditionOutcome.match(
message.foundExactly("azure.activedirectory.application-type=" + applicationType));
message.foundExactly("spring.cloud.azure.active-directory.application-type=" + applicationType));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
/**
* {@link EnableAutoConfiguration Auto-configuration} for Azure Active Authentication filters.
* <p>
* The configuration will not be activated if no {@literal azure.activedirectory.client-id} property provided.
* The configuration will not be activated if no {@literal spring.cloud.azure.active-directory.client-id} property provided.
* <p>
* A stateless filter {@link AADAppRoleStatelessAuthenticationFilter} will be auto-configured by specifying {@literal
* azure.activedirectory.session-stateless=true}. Otherwise, {@link AADAuthenticationFilter} will be configured.
* spring.cloud.azure.active-directory.session-stateless=true}. Otherwise, {@link AADAuthenticationFilter} will be configured.
*/
@Configuration
@ConditionalOnWebApplication
Expand All @@ -39,7 +39,7 @@
@ConditionalOnProperty(prefix = AADAuthenticationFilterAutoConfiguration.PROPERTY_PREFIX, value = { "client-id" })
@EnableConfigurationProperties({ AADAuthenticationProperties.class })
public class AADAuthenticationFilterAutoConfiguration {
public static final String PROPERTY_PREFIX = "azure.activedirectory";
public static final String PROPERTY_PREFIX = "spring.cloud.azure.active-directory";
private static final Logger LOG = LoggerFactory.getLogger(AADAuthenticationProperties.class);

private final AADAuthenticationProperties properties;
Expand All @@ -57,7 +57,7 @@ public AADAuthenticationFilterAutoConfiguration(AADAuthenticationProperties prop
*/
@Bean
@ConditionalOnMissingBean(AADAuthenticationFilter.class)
@ConditionalOnExpression("${azure.activedirectory.session-stateless:false} == false")
@ConditionalOnExpression("${spring.cloud.azure.active-directory.session-stateless:false} == false")
// client-id and client-secret used to: get graphApiToken -> groups
@ConditionalOnProperty(prefix = PROPERTY_PREFIX, value = { "client-id", "client-secret" })
public AADAuthenticationFilter azureADJwtTokenFilter() {
Expand All @@ -72,7 +72,7 @@ public AADAuthenticationFilter azureADJwtTokenFilter() {

@Bean
@ConditionalOnMissingBean(AADAppRoleStatelessAuthenticationFilter.class)
@ConditionalOnExpression("${azure.activedirectory.session-stateless:false} == true")
@ConditionalOnExpression("${spring.cloud.azure.active-directory.session-stateless:false} == true")
// client-id used to: userPrincipalManager.getValidator
@ConditionalOnProperty(prefix = PROPERTY_PREFIX, value = { "client-id" })
public AADAppRoleStatelessAuthenticationFilter azureADStatelessAuthFilter(ResourceRetriever resourceRetriever) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


/**
* Manage all AAD OAuth2 clients configured by property "azure.activedirectory.xxx".
* Manage all AAD OAuth2 clients configured by property "spring.cloud.azure.active-directory.xxx".
* Do extra works:
* 1. Make "azure" client's scope contains all "azure_delegated" clients' scope.
* This scope is used to request authorize code.
Expand Down
Loading

0 comments on commit 1c251a1

Please sign in to comment.