Update Opaque Token Sample

Issue gh-6489
This commit is contained in:
Josh Cummings 2020-07-09 14:36:46 -06:00
parent 221c33f558
commit 19f06284cd
No known key found for this signature in database
GPG Key ID: 49EF60DD7FF83443
1 changed files with 2 additions and 3 deletions

View File

@ -16,7 +16,6 @@
package sample;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -29,8 +28,8 @@ import org.springframework.web.bind.annotation.RestController;
public class OAuth2ResourceServerController {
@GetMapping("/")
public String index(@AuthenticationPrincipal OAuth2AuthenticatedPrincipal principal) {
return String.format("Hello, %s!", (String) principal.getAttribute("sub"));
public String index(@AuthenticationPrincipal(expression="subject") String subject) {
return String.format("Hello, %s!", subject);
}
@GetMapping("/message")