一、错误信息

  • Could not decode JSON for additional information: BaseClientDetails
2019-12-03 22:18:37.239  WARN 19120 --- [nio-8100-exec-4] o.s.s.o.p.c.JdbcClientDetailsService     : Could not decode JSON for additional information: BaseClientDetails [clientId=c1, clientSecret=$2a$10$NlBC84MVb7F95EXYTXwLneXgCca6/GipyWR5NHm8K0203bSQMLpvm, scope=[ROLE_ADMIN, ROLE_USER, ROLE_API], resourceIds=[res1], authorizedGrantTypes=[client_credentials, password, authorization_code, implicit, refresh_token], registeredRedirectUris=[http://www.baidu.com], authorities=[], accessTokenValiditySeconds=7200, refreshTokenValiditySeconds=259200, additionalInformation={}]

java.io.EOFException: No content to map to Object due to end of input
at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2775) ~[jackson-mapper-asl-1.9.13.jar:1.9.13]
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2718) ~[jackson-mapper-asl-1.9.13.jar:1.9.13]
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863) ~[jackson-mapper-asl-1.9.13.jar:1.9.13]
at org.springframework.security.oauth2.provider.client.JdbcClientDetailsService$JacksonMapper.read(`JdbcClientDetailsService.java:309`) ~[spring-security-oauth2-2.3.4.RELEASE.jar:na]
at org.springframework.security.oauth2.provider.client.JdbcClientDetailsService$ClientDetailsRowMapper.mapRow(JdbcClientDetailsService.java:268) [spring-security-oauth2-2.3.4.RELEASE.jar:na]
at org.springframework.security.oauth2.provider.client.JdbcClientDetailsService$ClientDetailsRowMapper.mapRow(JdbcClientDetailsService.java:251) [spring-security-oauth2-2.3.4.RELEASE.jar:na]
at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:94) [spring-jdbc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:61) [spring-jdbc-5.1.10.RELEASE.jar:5.1.10.RELEASE]

根据错消息定位到 JdbcClientDetailsService.java 这个类,查看源码可以知道查出的数据中有一个空数据转json报错

查看数据库果然 additional_information 字段都是空的。然后在数据库中先添加了测试字符串,发现还是报同样的错误。

最后百度+google终于在网址找到了下面这两篇文章。

1.根据这篇文章里的介绍这是一个预留的字段 https://blog.csdn.net/u011676300/article/details/84390988

  1. Spring OAuth2:无法从ClientDetailsS​​ervice获取其他信息

二、错误信息

{"error":"method_not_allowed","error_description":"Request method 'GET' not supported"}

原因:security 默认只支持post方式获取token,如果需要实用get方式的话需要修改security的配置

@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.authenticationManager(authenticationManager)
.tokenServices(tokenService())
.authorizationCodeServices(authorizationCodeServices())
.allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST);// 默认只能通过post
}

三、重定向问题

当使用授权码认证模式的话,通过zuul网关访问:`http://localhost:8111/security/oauth/authorize?client_id=c1&response_type=code`,会重定向到
认证服务器的ip和端口

解决:

zuul:
routes:
# 添加代理投
add-proxy-headers: true
# 此处解决后端服务重定向导致用户浏览的 host 变成 后端服务的 host 问题
add-host-header: true

加上之后,ip和端口就不会改为认证服务器的地址 http://localhost:8111/security/oauth/authorize?client_id=c1&response_type=code

spring-security问题记录的更多相关文章

  1. spring security实现记录用户登录时间等信息

    目录 spring security实现记录用户登录时间等信息 一.原理分析 二.实现方式 2.1 自定义AuthenticationSuccessHandler实现类 2.2 在spring-sec ...

  2. Spring Security调研记录【七】--核心模型与实现

    网上有非常多关于Spring Security文章中,都觉得Spring Security(相对于shiro)过于复杂,个人觉得复杂的是Spring Security的官方文档而不是Spring Se ...

  3. Spring Security 学习记录

    一.核心拦截器详细说明 1.WebAsyncManagerIntegrationFilter 根据请求封装获取WebAsyncManager 从WebAsyncManager获取/注册Security ...

  4. SPRING SECURITY JAVA配置:Web Security

    在前一篇,我已经介绍了Spring Security Java配置,也概括的介绍了一下这个项目方方面面.在这篇文章中,我们来看一看一个简单的基于web security配置的例子.之后我们再来作更多的 ...

  5. Spring Security的使用

    spring security使用目的:验证,授权,攻击防护. 原理:创建大量的filter和interceptor来进行请求的验证和拦截,以此来达到安全的效果. Spring Security主要包 ...

  6. spring security简介与使用

    目录 spring security 新建一个springboot项目 添加spring security 登录 使用默认用户和随机生成的密码登录 使用yaml文件定义的用户名.密码登录 使用代码中指 ...

  7. Activiti7 与 Spring Boot 及 Spring Security 整合 踩坑记录

    1.  前言 实话实说,网上关于Activiti的教程千篇一律,有参考价值的不多.很多都是老早以前写的,基本都是直接照搬官方提供的示例,要么就是用单元测试跑一下,要么排除Spring Security ...

  8. 【OAuth2.0】Spring Security OAuth2.0篇之初识

    不吐不快 因为项目需求开始接触OAuth2.0授权协议.断断续续接触了有两周左右的时间.不得不吐槽的,依然是自己的学习习惯问题,总是着急想了解一切,习惯性地钻牛角尖去理解小的细节,而不是从宏观上去掌握 ...

  9. Spring Security笔记:自定义Login/Logout Filter、AuthenticationProvider、AuthenticationToken

    在前面的学习中,配置文件中的<http>...</http>都是采用的auto-config="true"这种自动配置模式,根据Spring Securit ...

  10. 浅谈spring security 403机制

    403就是access denied ,就是请求拒绝,因为权限不足 三种权限级别 一.无权限访问 <security:http security="none" pattern ...

随机推荐

  1. jenkins 邮箱通知设置

    https://blog.csdn.net/boonya/article/details/77335074 https://blog.csdn.net/lovedingd/article/detail ...

  2. React Native 之导航栏

    一定要参考官网: https://reactnavigation.org/docs/en/getting-started.html 代码来自慕课网:https://www.imooc.com/cour ...

  3. mybatis时间范围查询

    <if test="excStartTime!=null and excStartTime!=''"> <![CDATA[ and DATE_FORMAT(dl. ...

  4. PHP开发工具PHP基础教程

        PHP开发 工具PHP基础教程,以下是兄弟连PHP培训小编整理: PHP IDE PHP IDE也不少,主要从几个方面进行筛选: 跨平台(能够同时在windows,mac或者ubuntu上面运 ...

  5. UOJ37. 【清华集训2014】主旋律

    http://uoj.ac/problem/37 题解 题目是让我们求出有多少个边集可以使这张图强连通. 先补集转化一下,求这张图不强连通的方案数. 我们考虑这样的图缩完点之后的情况,既然不强连通,那 ...

  6. Linux 设置端口转发

    ps -ef | grep 10020     --查询10020端口是否被使用kill -9 86971     --结束使用10020端口的进程 ssh -C -f -N -g -L 18889: ...

  7. 双边滤波Matlab代码

    %简单地说: %A为给定图像,归一化到[,]的矩阵 %W为双边滤波器(核)的边长/ %定义域方差σd记为SIGMA(),值域方差σr记为SIGMA() %%%%%%%%%%%%%%%%%%%%%%%% ...

  8. 解决RHEL6 vncserver 启动 could not open default font 'fixed'错误.

    https://blog.csdn.net/silencegll/article/details/51320629

  9. Wowza 4.5 修改 manager 端口号

    //编辑下面的文件, 搜索8088 有两处,改为想要的端口号即可 vim /usr/local/WowzaStreamingEngine/manager/bin/startmgr.sh // 重启服务 ...

  10. leetcode-mid-Linked list- 116. Populating Next Right Pointers in Each Node

    mycode   93.97% """ # Definition for a Node. class Node(object): def __init__(self, v ...