OAuth2用密码模式授权返回错误信息为Full authentication is required to access this resource

Blade 已结 2 10430
风缘
风缘 剑童 2019-04-24 14:15
悬赏:3

操作步骤:image.png所有服务都已经启动,按照开发手册里面的方式使用密码模式授权image.png

设置headers里的内容

image.png

设置body里面的内容

提交返回

image.png

2条回答
  •  smallchill
    smallchill (最佳回答者)
    2019-04-24 15:16

    1.Authorization的值设置成 Basic c3dvcmQ6c3dvcmRfc2VjcmV0

    image.png

    2.查看gateway、auth、user、system控制台是否有错误信息


    3.检查下redis链接是否都连接成功,并且执行flushdb命令


    4.前往blade-user服务的UserServiceImpluserInfo方法,进行断点调试查看是否报错


    5.前往blade-auth服务的BladeUserDetailsServiceImpl方法,进行断点调试查看是否报错

    4 讨论(1)
  • 2020-07-03 14:32

    image.png




    handleSpringSecurityException(HttpServletRequest requestHttpServletResponse responseFilterChain chainRuntimeException exception) IOExceptionServletException {
        (exception AuthenticationException) {
            .logger.debug(exception).sendStartAuthentication(requestresponsechain(AuthenticationException)exception)} (exception AccessDeniedException) {
            Authentication authentication = SecurityContextHolder.getContext().getAuthentication()(!.authenticationTrustResolver.isAnonymous(authentication) && !.authenticationTrustResolver.isRememberMe(authentication)) {
                .logger.debug(exception).accessDeniedHandler.handle(requestresponse(AccessDeniedException)exception)} {
                .logger.debug(+ (.authenticationTrustResolver.isAnonymous(authentication) ? : ) + exception).sendStartAuthentication(requestresponsechainInsufficientAuthenticationException(.messages.getMessage()))}
        }
    
    }



    此问题的代码报错位置。



    最后的解决方案(版本: 2.4.0.RELEASE):  

    这个依赖, 不可以加到blade-oauth 项目中去。 

            <dependency>

                <groupId>org.springblade</groupId>

                <artifactId>blade-core-secure</artifactId>

            </dependency>


    4 讨论(0)
提交回复