move user endpoint (#3730)
* move user endpoint * formatting * formatting * formatting * formatting * change url name * Update PersonInfoController.java * Update PersonInfoController.java
This commit is contained in:
parent
76d7e9c49b
commit
07111d1edc
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ security:
|
|||
sessions: NEVER
|
||||
oauth2:
|
||||
resource:
|
||||
userInfoUri: http://localhost:7070/authserver/user
|
||||
jwt:
|
||||
keyValue: |
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue