parent
221c33f558
commit
19f06284cd
|
@ -16,7 +16,6 @@
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
@ -29,8 +28,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
public class OAuth2ResourceServerController {
|
public class OAuth2ResourceServerController {
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String index(@AuthenticationPrincipal OAuth2AuthenticatedPrincipal principal) {
|
public String index(@AuthenticationPrincipal(expression="subject") String subject) {
|
||||||
return String.format("Hello, %s!", (String) principal.getAttribute("sub"));
|
return String.format("Hello, %s!", subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/message")
|
@GetMapping("/message")
|
||||||
|
|
Loading…
Reference in New Issue