簡體   English   中英

在注銷時不會刪除IdentityServer3令牌

[英]IdentityServer3 Token Not Getting Deleted on Logout

我正在使用IdentityServer3,並實現了自定義授予流,以與現有SSO實現向后兼容。 我正在使用參考令牌進行API身份驗證。 我已經實現了ITokenHandleStore和IUserService。

我能夠成功登錄並訪問我的應用程序。 問題是我注銷后,參考令牌仍然有效。

注銷后,我調用HttpContext.Current.GetOwinContext()。Authentication.SignOut();。 我還調用/ connect / endsession?id_token_hint = mYrEfErEnCeToKeN,並在查詢字符串參數上傳遞用戶的參考令牌。

但是,都不會調用IUserService中的SignOutAsync方法或ITokenHandleStore中的RemoveAsync方法。 因此,令牌保留在我的令牌數據庫表中,即使在用戶注銷后,也將在后續請求中將其視為有效令牌。

執行“自定義授予”流程時注銷用戶的正確方法是什么? 如何將記錄從數據庫令牌存儲中刪除?

當我調用endsession端點時,從IdentityServer進行的日志記錄顯示如下:

Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:07:14.835 -04:00 [信息]結束訪問令牌驗證請求Sam.Web.MicroServices.IdentityService.vshost.exe信息: 0:2016-07-13 04:09:22.289 -04:00 [Information]開始結束會話請求Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:09:22.349 -04 :00 [信息]開始結束會話請求驗證Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:09:22.412 -04:00 [信息]開始身份令牌驗證Sam.Web。 MicroServices.IdentityService.vshost.exe錯誤:0:20​​16-07-13 04:09:22.581 -04:00 [錯誤]格式錯誤的JWT令牌System.ArgumentException:IDX10709:'jwtEncodedString'格式不正確:'7dc2417fb752d096af2870c46ca8a181'。 該字符串必須采用緊湊的JSON格式,其格式為:“ ..”。 在System.IdentityModel.Tokens.JwtSecurityToken..ctor(String jwtEncodedString)中位於c:\\ workspace \\ WilsonForDotNet45Release \\ src \\ System.IdentityModel.To kens.Jwt \\ JwtSecurityToken.cs:IdentityServer3.Core.Validation.TokenValidator.GetClientIdFromJwt的第68行(字符串令牌)在c:\\ local \\ identity \\ server3 \\ Core \\ source \\ Core \\ Validation \\ TokenVa lidator.cs:line 347 Sam.Web.MicroServices.IdentityService.vshost.exe錯誤:0:20​​16-07-13 04 :09:22.648 -04:00 [錯誤]沒有提供clientId,無法在標識中找到ID。 Sam.Web.MicroServices.IdentityService.vshost.exe錯誤:0:20​​16-07-13 04:09:22.701 -04:00 [錯誤]“驗證ID令牌提示時出錯。” “ {
\\“ SubjectId \\”:\\“未知\\”,\\“ Raw \\”:{\\“ id_token_hint \\”:\\“ 7dc2417fb752d096af2870c46ca8a181 \\”}}“ Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16- 07-13 04:09:22.753 -04:00 [Information]重定向到注銷頁面Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:09:22.872 -04:00 [Information ]注銷端點已提交Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:09:22.944 -04:00 [信息]清除cookie Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:09:23.013 -04:00 [信息]呈現注銷頁面

當我調用/ revocation端點時,IdentityServer日志顯示以下內容:

Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:11:14.822 -04:00 [信息]提出了針對來源:“ chrome”的路徑“ // connect / r evocation”的CORS請求-extension:// fhbjgbiflinjbdggehcddcbcdddomop“ Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:11:14.864 -04:00 [信息]已配置AllowedOrigins,其來源為“ c hrome-extension:/ / fhbjgbiflinjbdggehcddcbncdddomop“不允許Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:11:14.906 -04:00 [信息]正在退出; 不允許原始來源“ chrome-extension:// fhb jgbiflinjbdggehcddcbncdddomop” Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:11:14.941 -04:00 [Information] CorsPolicyService不允許來源Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:11:15.005 -04:00 [信息]啟動令牌吊銷請求2016-07-13 04:11:15.063 -04: 00 [調試]開始客戶端驗證2016-07-13 04:11:15.064 -04:00 [調試]開始解析X.509證書2016-07-13 04:11:15.065 -04:00 [調試] client_id為在帖子正文中找不到2016-07-13 04:11:15.066 -04:00 [Debug]在帖子正文中開始對秘密進行解析2016-07-13 04:11:15.067 -04:00 [Debug]在帖子中沒有秘密正文發現2016-07-13 04:11:15.068 -04:00 [調試]開始解析基本身份驗證機密Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:11:15.069- 04:00 [信息]解析器沒有發現秘密的Sam.Web.MicroServices.IdentityService.vshost.exe信息 on:0:20​​16-07-13 04:11:15.124 -04:00 [Information]找不到客戶端秘密Sam.Web.MicroServices.IdentityService.vshost.exe信息:0:20​​16-07-13 04:11:15.175 -04:00 [信息]返回錯誤:invalid_client

您在注銷時收到錯誤的原因是,您正在傳遞id_token_hint參數中的訪問令牌。 此參數需要登錄時已頒發給您的身份令牌(假設您使用的是OpenID Connect)。

如果僅使用OAuth,則endsession端點不適合您。 而是要撤消訪問令牌,需要使用撤消端點 然后,這將從您的數據庫中刪除令牌。

您從吊銷終結點收到的錯誤似乎與另一個問題有關(看起來您沒有提供客戶端ID和密碼)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM