我正在使用 spring security oauth2 批准页面,当我授权请求时,该页面会作为“post”发送到“/oauth/authorize”(AuthorizationEndpoint 类中的approveOrDeny 方法),但是此服务的参数之一为 null,这将是“主要”。
spring oauth 页面,当我点击授权时 (/image/aCIKZ.jpg)
有人知道为什么这个参数(Principalprincipal)为空吗?
这是 spring 方法,其主体为 null
public View approveOrDeny(@RequestParam Map<String, String> approvalParameters, Map<String, ?> model,
SessionStatus sessionStatus, Principal principal) {
if (!(principal instanceof Authentication)) {
sessionStatus.setComplete();
throw new InsufficientAuthenticationException(
"User must be authenticated with Spring Security before authorizing an access token.");
}
...
...
最佳答案
我发现了问题,我有一个扩展 DefaultRedirectResolver 的类,并且在我调用的重写方法中resolveRedirect SecurityContextHolder.clearContext()
只需删除 SecurityContextHolder.clearContext() 即可填充主体。
关于java - 确认 oauth2 批准流程后,service/oauth/authorize 中的主体为空(approveR Deny 中的 http post),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58450340/