org.springdoc.demo.resource.web.controller.UserInfoController Maven / Gradle / Ivy
package org.springdoc.demo.resource.web.controller;
import java.util.Collections;
import java.util.Map;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserInfoController {
@GetMapping("/user/info")
@SecurityRequirement(name = "security_auth")
public Map getUserInfo(@AuthenticationPrincipal Jwt principal) {
return Collections.singletonMap("user_name", principal.getClaimAsString("preferred_username"));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy