<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                * * [功能簡介](#功能簡介) * [sso對接](#sso對接) * [服務端配置](#服務端配置) * [客戶端配置](#客戶端配置) * [單點登錄測試用例](#單點登錄測試用例) * [鎖定應用](#鎖定應用) * [正常應用](#正常應用) * [問題總結](#問題總結) * [報錯二:](#報錯二) * [測試用例](#測試用例) ## 一、功能簡介 auth-sso是一個單點功能,這個系統是`auth-sever`的一個客戶端服務。 ## 二、sso對接 auth-sso應與auth-server的對接。 ### [](#服務端配置)服務端配置 ![image](https://s3.ax1x.com/2020/12/15/rK3R7F.png?ynotemdtimestamp=1608128738913) ### [](#客戶端配置)客戶端配置 > 在客戶端應有一個客戶端秘鑰的配置: auth-sso中`application.yml`的配置內容為: ~~~ security: ignored: /,/favicon.ico,/home.html,/dashboard.html,/js/**,/css/**,/webjars/** sessions: ALWAYS user: password: 123456 oauth2: sso: login-path: /dashboard/login client: client-id: owen client-secret: owen user-authorization-uri: http://127.0.0.1:9200/api-auth/oauth/authorize #直接配置認證中心端口(http://127.0.0.1:9200/oauth/authorize),也可以配置網關端口 access-token-uri: http://127.0.0.1:9200/api-auth/oauth/token #直接配置認證中心端口(http://127.0.0.1:9200/oauth/authorize),也可以配置網關端口 resource: # user-info-uri: http://127.0.0.1:8000/auth/users #返回認證服務器檢查 # prefer-token-info: false token-info-uri: http://127.0.0.1:9200/api-auth/oauth/check_token #直接配置認證中心端口(http://127.0.0.1:9200/oauth/authorize),也可以配置網關端口 prefer-token-info: true ~~~ ## 三、單點登錄測試用例 訪問地址:[http://127.0.0.1:9997/dashboard/](http://127.0.0.1:9997/dashboard/) ### [](#鎖定應用)鎖定應用 鎖定應用“owen”。 訪問sso主頁,auth-server返回: ~~~ [auth-server:169.254.80.80:8000] [f55fce2e23409855,f55fce2e23409855] 2020-12-15 11:20:53.685 ERROR 15308 [http-nio-8000-exec-8] com.open.capacity.uaa.server.service.RedisClientDetailsService clientId:owen,owen [auth-server:169.254.80.80:8000] [f55fce2e23409855,f55fce2e23409855] 2020-12-15 11:20:53.685 ERROR 15308 [http-nio-8000-exec-8] com.open.capacity.uaa.server.service.RedisClientDetailsService clientId:owen,owen [auth-server:169.254.80.80:8000] [f55fce2e23409855,f55fce2e23409855] 2020-12-15 11:20:53.686 INFO 15308 [http-nio-8000-exec-8] org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint Handling OAuth2 error: error="invalid_client", error_description="應用獲取失敗" ~~~ 瀏覽器返回: > OAuth Error error="unsupported\_response\_type", error\_description="??????", code="400", msg="??????" 該日志信息是由org.springframework.security.oauth2.common.exceptions.OAuth2Exception返回的。 ### [](#正常應用)正常應用 ## 四、問題總結 client端無法登錄,auth-server報錯: ~~~ [auth-server:169.254.80.80:8000] [7af92e2ba3037cf2,7af92e2ba3037cf2] 2020-12-15 14:03:59.606 WARN 18032 [http-nio-8000-exec-9] org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder Empty encoded password ~~~ 原因分析: > 剛好看到一篇博文:[《Spring Security 中的 BCryptPasswordEncoder加密、驗證策略》](https://blog.csdn.net/u013019701/article/details/110249239) 應用owen的原始加密秘鑰為:`$2a$10$a1ZEXiZQr604LN.wVxet.etPm6RvDs.HIaXP48J2HKRaEnZORTVwe`。 在系統中進行保存后,生成新的秘鑰為:`$2a$10$.t/BRbvOwUsK5RS4.Jfnnu1BO6M3tthLGdM4o9KqPX3/SKjRy6Xoy`。很明顯二者的加密算法是不一致的,作者真是神坑啊。 源碼分析: ~~~ matches:112, BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt) matches:592, WebSecurityConfigurerAdapter$LazyPasswordEncoder (org.springframework.security.config.annotation.web.configuration) additionalAuthenticationChecks:90, DaoAuthenticationProvider (org.springframework.security.authentication.dao) authenticate:166, AbstractUserDetailsAuthenticationProvider (org.springframework.security.authentication.dao) authenticate:175, ProviderManager (org.springframework.security.authentication) ~~~ ### [](#報錯二)報錯二: ~~~ { "msg": "Failed to handle request [GET http://127.0.0.1:9200/api-auth/oauth/authorize?client_id=owen&redirect_uri=http://127.0.0.1:9997/dashboard/login&response_type=code&state=lhzdiY]: 503 SERVICE_UNAVAILABLE \"Unable to find instance for auth-server\"", "code": 404 } ~~~ 【出錯原因】以上報錯是auth-server和auth-sso剛剛重啟后會出現,原因是這兩個服務重新啟動后,需要在nacos中完成服務注冊,nacos需要一點點時間確認服務可用才會向外暴露。 OAuth2客戶端登錄: 獲取token:org.springframework.security.oauth2.client.OAuth2RestOperations#getAccessToken ## [](#測試用例)測試用例 > 場景:在已登錄過的前提下,再次點擊login;調試到該位置會報錯。 > 報錯位置:`/org/springframework/security/oauth2/client/token/grant/code/AuthorizationCodeAccessTokenProvider.java:204` 錯誤描述:request的size顯示為0,但是resource中是有數據的。如圖: 1-源碼調試:![](https://i0.hdslb.com/bfs/album/408a4ed694d8bca56966b7efea42df2ded019912.png@1e_1c.webp?ynotemdtimestamp=1608128738913) 繼續調試,但是在拋出的異常中能看到`stateKey`:![](https://i0.hdslb.com/bfs/album/85c2fb6f825004a1db96a1f8922a24ef8c0255c3.png@1e_1c.webp?ynotemdtimestamp=1608128738913)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看