File tree Expand file tree Collapse file tree 4 files changed +29
-18
lines changed
authentication-common/src/main/java/com/microservice/authentication/autoconfigure
kotlin-service/src/main/kotlin/com/microservice/kotlin/config
person-service/src/main/java/com/microservice/person
user-service/src/main/java/com/microservice/user Expand file tree Collapse file tree 4 files changed +29
-18
lines changed Original file line number Diff line number Diff line change 2828
2929import org .springframework .beans .BeansException ;
3030import org .springframework .beans .factory .ObjectProvider ;
31- import org .springframework .beans .factory .annotation .Value ;
3231import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
3332import org .springframework .boot .autoconfigure .security .oauth2 .resource .JwtAccessTokenConverterConfigurer ;
3433import org .springframework .boot .context .properties .EnableConfigurationProperties ;
@@ -162,8 +161,7 @@ public OAuth2AccessToken enhance(
162161 return converter ;
163162 }
164163
165- @ Profile ("prod" )
166- @ ConditionalOnMissingBean
164+ @ Profile ("auth" )
167165 @ Bean
168166 KeyPair getKeyPair (AuthenticationProperties authenticationProperties ) throws Exception {
169167 AuthenticationProperties .Jwt jwt = authenticationProperties .getJwt ();
@@ -204,28 +202,13 @@ private String removeBeginEnd(String pem) {
204202 return pem .trim ();
205203 }
206204
207- @ Primary
208- @ Profile ("prod" )
209- @ ConditionalOnMissingBean (KeyPair .class )
210- @ Bean
211- RSAPublicKey publicKeyStore (@ Value ("${com.microservice.authentication.jwt.publicKeyStore}" ) RSAPublicKey key ) {
212- return key ;
213- }
214-
215205 @ Profile ("prod" )
216206 @ ConditionalOnMissingBean
217207 @ Bean
218208 RSAPublicKey publicKey (KeyPair keyPair ) {
219209 return (RSAPublicKey ) keyPair .getPublic ();
220210 }
221211
222- @ Profile ("prod" )
223- @ ConditionalOnMissingBean (KeyPair .class )
224- @ Bean
225- RSAPublicKey publicKey (@ Value ("${com.microservice.authentication.jwt.key-store}" ) RSAPublicKey key ) {
226- return key ;
227- }
228-
229212 @ Bean
230213 UserDetailsService sharedAuthenticationService (AuthenticationCommonRepository authenticationCommonRepository ) {
231214 return new SharedAuthenticationServiceImpl (authenticationCommonRepository );
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import org.springframework.boot.info.GitProperties
1616import org.springframework.context.annotation.Bean
1717import org.springframework.context.annotation.Configuration
1818import org.springframework.context.annotation.Primary
19+ import org.springframework.context.annotation.Profile
1920import org.springframework.core.Ordered
2021import org.springframework.core.annotation.Order
2122import org.springframework.core.convert.support.DefaultConversionService
@@ -28,6 +29,7 @@ import org.springframework.data.util.TypeInformation
2829import org.springframework.util.Assert
2930import org.springframework.util.MultiValueMap
3031import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean
32+ import java.security.interfaces.RSAPublicKey
3133import java.util.*
3234import java.util.stream.IntStream
3335
@@ -73,6 +75,13 @@ class ServiceConfiguration {
7375 }
7476 }
7577
78+ @Primary
79+ @Profile(" prod" )
80+ @Bean
81+ fun publicKeyStore (@Value(" \$ {com.microservice.authentication.jwt.publicKeyStore}" ) key : RSAPublicKey ? ): RSAPublicKey ? {
82+ return key
83+ }
84+
7685 @ConditionalOnMissingBean
7786 @Bean
7887 fun querydslPredicateBuilderCustomizer (querydslBindingsFactory : QuerydslBindingsFactory ): QuerydslPredicateBuilderCustomizer ? {
Original file line number Diff line number Diff line change 11package com .microservice .person ;
22
33import java .lang .annotation .Annotation ;
4+ import java .security .interfaces .RSAPublicKey ;
45import java .time .ZoneId ;
56import java .util .Collection ;
67import java .util .List ;
3940import org .springframework .context .annotation .Bean ;
4041import org .springframework .context .annotation .Configuration ;
4142import org .springframework .context .annotation .Primary ;
43+ import org .springframework .context .annotation .Profile ;
4244import org .springframework .core .Ordered ;
4345import org .springframework .core .annotation .Order ;
4446import org .springframework .core .convert .support .DefaultConversionService ;
@@ -80,6 +82,13 @@ public void addViewControllers(ViewControllerRegistry registry) {
8082 registry .addRedirectViewController ("/swagger/swagger-ui.html" , "/swagger-ui.html" );
8183 }
8284
85+ @ Primary
86+ @ Profile ("prod" )
87+ @ Bean
88+ RSAPublicKey publicKeyStore (@ Value ("${com.microservice.authentication.jwt.publicKeyStore}" ) RSAPublicKey key ) {
89+ return key ;
90+ }
91+
8392 @ Configuration
8493 @ ConditionalOnProperty (prefix = "kafka.local.test" , name = "enabled" , havingValue = "true" )
8594 class KafkaTestConfiguration {
Original file line number Diff line number Diff line change 11package com .microservice .user ;
22
3+ import java .security .interfaces .RSAPublicKey ;
34import java .util .Collection ;
45import java .util .List ;
56import java .util .Map ;
910import com .querydsl .core .BooleanBuilder ;
1011import com .querydsl .core .types .Predicate ;
1112
13+ import org .springframework .beans .factory .annotation .Value ;
1214import org .springframework .boot .SpringApplication ;
1315import org .springframework .boot .autoconfigure .SpringBootApplication ;
1416import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
1517import org .springframework .boot .info .BuildProperties ;
1618import org .springframework .context .annotation .Bean ;
1719import org .springframework .context .annotation .Primary ;
20+ import org .springframework .context .annotation .Profile ;
1821import org .springframework .core .convert .support .DefaultConversionService ;
1922import org .springframework .data .mongodb .core .mapping .event .ValidatingMongoEventListener ;
2023import org .springframework .data .querydsl .binding .PathInformation ;
@@ -57,6 +60,13 @@ BuildProperties buildProperties() {
5760 return new BuildProperties (new Properties ());
5861 }
5962
63+ @ Primary
64+ @ Profile ("prod" )
65+ @ Bean
66+ RSAPublicKey publicKeyStore (@ Value ("${com.microservice.authentication.jwt.publicKeyStore}" ) RSAPublicKey key ) {
67+ return key ;
68+ }
69+
6070 @ ConditionalOnMissingBean
6171 @ Bean
6272 QuerydslPredicateBuilderCustomizer querydslPredicateBuilderCustomizer (QuerydslBindingsFactory querydslBindingsFactory ) {
You can’t perform that action at this time.
0 commit comments