spring redis http会话在从azure ad graph api登录重定向时创建新会话

qhhrdooz  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(200)

我正在使用azure ad graph api登录,在登录时应用程序重定向到azure ad graph api以获取令牌,并从azure ad graph api再次重定向到应用程序,此时它创建新会话而不是使用现有会话,有人能提供从azure ad graph api重定向时如何使用现有会话的解决方案吗

@GetMapping(value = "/sso/login")
    public void loginSSO(final HttpServletRequest request) {
       request.getSession(); // Session X
}

@PostMapping(value = "/sso/redirect")
    public void redirectSSO(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
        request.getSession(); // Session Y

        // Authenticate User from Azure AD, do some process(logging) and add Authentication object to SecurityContextHolderv
        response.sendRedirect(request.getContextPath() + "/"); // Redirected but have old session
}

@GetMapping(value = "/", produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView index(final HttpServletRequest request) {
    request.getSession(false).getAttribute("userId"); // gets null
}

注意:如果我们禁用springredis会话,它将按预期工作

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题