日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

spring-security问题记录

發(fā)布時間:2024/9/15 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 spring-security问题记录 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

一、錯誤信息

  • 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 inputat 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]

根據(jù)錯消息定位到 JdbcClientDetailsService.java 這個類,查看源碼可以知道查出的數(shù)據(jù)中有一個空數(shù)據(jù)轉(zhuǎn)json報錯

查看數(shù)據(jù)庫果然 additional_information 字段都是空的。然后在數(shù)據(jù)庫中先添加了測試字符串,發(fā)現(xiàn)還是報同樣的錯誤。

最后百度+google終于在網(wǎng)址找到了下面這兩篇文章。

1.根據(jù)這篇文章里的介紹這是一個預(yù)留的字段 https://blog.csdn.net/u011676300/article/details/84390988

  • Spring OAuth2:無法從ClientDetailsS??ervice獲取其他信息
  • 二、錯誤信息

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

    原因:security 默認(rèn)只支持post方式獲取token,如果需要實(shí)用get方式的話需要修改security的配置

    @Overridepublic void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {endpoints.authenticationManager(authenticationManager).tokenServices(tokenService()).authorizationCodeServices(authorizationCodeServices()).allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST);// 默認(rèn)只能通過post}

    三、重定向問題

    當(dāng)使用授權(quán)碼認(rèn)證模式的話,通過zuul網(wǎng)關(guān)訪問:`http://localhost:8111/security/oauth/authorize?client_id=c1&response_type=code`,會重定向到 認(rèn)證服務(wù)器的ip和端口

    解決:

    zuul:routes:# 添加代理投add-proxy-headers: true# 此處解決后端服務(wù)重定向?qū)е掠脩魹g覽的 host 變成 后端服務(wù)的 host 問題add-host-header: true

    加上之后,ip和端口就不會改為認(rèn)證服務(wù)器的地址 http://localhost:8111/security/oauth/authorize?client_id=c1&response_type=code

    總結(jié)

    以上是生活随笔為你收集整理的spring-security问题记录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。