spring-security问题记录
生活随笔
收集整理的這篇文章主要介紹了
spring-security问题记录
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
一、錯誤信息
- Could not decode JSON for additional information: BaseClientDetails
根據(jù)錯消息定位到 JdbcClientDetailsService.java 這個類,查看源碼可以知道查出的數(shù)據(jù)中有一個空數(shù)據(jù)轉(zhuǎn)json報(bào)錯
查看數(shù)據(jù)庫果然 additional_information 字段都是空的。然后在數(shù)據(jù)庫中先添加了測試字符串,發(fā)現(xiàn)還是報(bào)同樣的錯誤。
最后百度+google終于在網(wǎng)址找到了下面這兩篇文章。
1.根據(jù)這篇文章里的介紹這是一個預(yù)留的字段 https://blog.csdn.net/u011676300/article/details/84390988
二、錯誤信息
{"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)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mybatis-plusspringbo
- 下一篇: spring-security问题记录-