Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Disable ResourceServerTokenRelayAutoConfiguration when property secur… #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration;
import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices;
import org.springframework.cloud.security.oauth2.client.ResourceServerTokenRelayAutoConfiguration.ConditionalOnNoClientCredentialsInResourceServer;
import org.springframework.cloud.security.oauth2.client.ResourceServerTokenRelayAutoConfiguration.ConditionalOnOAuth2ClientInResourceServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
Expand Down Expand Up @@ -62,6 +60,7 @@
*/
@Configuration
@AutoConfigureAfter(OAuth2AutoConfiguration.class)
@ConditionalOnNoClientCredentialsInResourceServer
@ConditionalOnOAuth2ClientInResourceServer
@ConditionalOnClass(ResourceServerConfiguration.class)
@ConditionalOnWebApplication
Expand Down Expand Up @@ -121,4 +120,24 @@ static class Client {

}

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Conditional(NoClientCredentialsCondition.class)
@interface ConditionalOnNoClientCredentialsInResourceServer {

}

private static class NoClientCredentialsCondition extends NoneNestedConditions {

NoClientCredentialsCondition() {
super(ConfigurationPhase.PARSE_CONFIGURATION);
}

@ConditionalOnProperty(prefix = "security.oauth2.client", name = "grant-type", havingValue = "client_credentials", matchIfMissing = false)
static class ClientCredentialsActivated {
}

}

}