diff --git a/spring-cloud/spring-cloud-security/auth-client/src/main/java/com/baeldung/controller/CloudSiteController.java b/spring-cloud/spring-cloud-security/auth-client/src/main/java/com/baeldung/controller/CloudSiteController.java index b6bfd0bcf6..c77a5e02c5 100644 --- a/spring-cloud/spring-cloud-security/auth-client/src/main/java/com/baeldung/controller/CloudSiteController.java +++ b/spring-cloud/spring-cloud-security/auth-client/src/main/java/com/baeldung/controller/CloudSiteController.java @@ -19,10 +19,10 @@ public class CloudSiteController { return "Hello From Baeldung!"; } - @GetMapping("/person") + @GetMapping("/personInfo") public ModelAndView person() { ModelAndView mav = new ModelAndView("personinfo"); - String personResourceUrl = "http://localhost:9000/personResource"; + String personResourceUrl = "http://localhost:9000/person"; mav.addObject("person", restOperations.getForObject(personResourceUrl, String.class)); return mav; } diff --git a/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.yml b/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.yml index 06a950d270..2a758faeae 100644 --- a/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.yml +++ b/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.yml @@ -13,7 +13,7 @@ security: clientId: authserver clientSecret: passwordforauthserver resource: - userInfoUri: http://localhost:7070/authserver/user + userInfoUri: http://localhost:9000/user person: url: http://localhost:9000/person @@ -27,7 +27,7 @@ zuul: url: http://localhost:9000 user: path: /user/** - url: http://localhost:7070/authserver/user + url: http://localhost:9000/user # Make sure the OAuth2 token is only relayed when using the internal API, # do not pass any authentication to the external API diff --git a/spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/controller/PersonInfoController.java b/spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/controller/PersonInfoController.java index 9e5420da5a..1958c0ebb8 100644 --- a/spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/controller/PersonInfoController.java +++ b/spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/controller/PersonInfoController.java @@ -10,9 +10,9 @@ import com.baeldung.model.Person; @RestController public class PersonInfoController { - @GetMapping("/personResource") + @GetMapping("/person") @PreAuthorize("hasAnyRole('ADMIN', 'USER')") public @ResponseBody Person personInfo() { return new Person("abir", "Dhaka", "Bangladesh", 29, "Male"); - } -} \ No newline at end of file + } +} diff --git a/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/controller/ResourceController.java b/spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/controller/ResourceController.java similarity index 100% rename from spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/controller/ResourceController.java rename to spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/controller/ResourceController.java diff --git a/spring-cloud/spring-cloud-security/auth-resource/src/main/resources/application.yml b/spring-cloud/spring-cloud-security/auth-resource/src/main/resources/application.yml index 20a3313a60..52e02ba41b 100644 --- a/spring-cloud/spring-cloud-security/auth-resource/src/main/resources/application.yml +++ b/spring-cloud/spring-cloud-security/auth-resource/src/main/resources/application.yml @@ -8,7 +8,6 @@ security: sessions: NEVER oauth2: resource: - userInfoUri: http://localhost:7070/authserver/user jwt: keyValue: | -----BEGIN PUBLIC KEY----- diff --git a/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/ResourceServerConfigurer.java b/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/ResourceServerConfigurer.java deleted file mode 100644 index f97544dc59..0000000000 --- a/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/ResourceServerConfigurer.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; -import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; - -/** - * Our configuration for the OAuth2 User Info Resource Server. - */ -@Configuration -@EnableResourceServer -public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter { - @Override - public void configure(HttpSecurity http) throws Exception { - http.antMatcher("/user") - .authorizeRequests() - .anyRequest() - .authenticated(); - } -}