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!";
|
return "Hello From Baeldung!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/person")
|
@GetMapping("/personInfo")
|
||||||
public ModelAndView person() {
|
public ModelAndView person() {
|
||||||
ModelAndView mav = new ModelAndView("personinfo");
|
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));
|
mav.addObject("person", restOperations.getForObject(personResourceUrl, String.class));
|
||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ security:
|
|||||||
clientId: authserver
|
clientId: authserver
|
||||||
clientSecret: passwordforauthserver
|
clientSecret: passwordforauthserver
|
||||||
resource:
|
resource:
|
||||||
userInfoUri: http://localhost:7070/authserver/user
|
userInfoUri: http://localhost:9000/user
|
||||||
|
|
||||||
person:
|
person:
|
||||||
url: http://localhost:9000/person
|
url: http://localhost:9000/person
|
||||||
@ -27,7 +27,7 @@ zuul:
|
|||||||
url: http://localhost:9000
|
url: http://localhost:9000
|
||||||
user:
|
user:
|
||||||
path: /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,
|
# Make sure the OAuth2 token is only relayed when using the internal API,
|
||||||
# do not pass any authentication to the external API
|
# do not pass any authentication to the external API
|
||||||
|
@ -10,9 +10,9 @@ import com.baeldung.model.Person;
|
|||||||
@RestController
|
@RestController
|
||||||
public class PersonInfoController {
|
public class PersonInfoController {
|
||||||
|
|
||||||
@GetMapping("/personResource")
|
@GetMapping("/person")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN', 'USER')")
|
@PreAuthorize("hasAnyRole('ADMIN', 'USER')")
|
||||||
public @ResponseBody Person personInfo() {
|
public @ResponseBody Person personInfo() {
|
||||||
return new Person("abir", "Dhaka", "Bangladesh", 29, "Male");
|
return new Person("abir", "Dhaka", "Bangladesh", 29, "Male");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ security:
|
|||||||
sessions: NEVER
|
sessions: NEVER
|
||||||
oauth2:
|
oauth2:
|
||||||
resource:
|
resource:
|
||||||
userInfoUri: http://localhost:7070/authserver/user
|
|
||||||
jwt:
|
jwt:
|
||||||
keyValue: |
|
keyValue: |
|
||||||
-----BEGIN PUBLIC KEY-----
|
-----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…
x
Reference in New Issue
Block a user