我使用Spring引導+春季會議數據rediss
我的情況是用戶A已經登錄和用戶A創建JSESSIONID,現在他發出將被髮送到某些機器和令牌代表他工作幾分鐘即可生效。
問題是,如果不小心一些客戶端通過兩個Cookie和令牌,然後我要優先考慮TOKEN而不是JSESSIONID是否有可能在春季會議。
我無法使Cookie會話無效,因爲它會註銷不需要的UserA。
所以,我想告訴春天使用現有的會議或創建一個新的基於一些條件,並希望給予優先TOKEN。並創建一個全新的會話而不會使Cookie會話失效。要修改的SecurityContext只對當前請求
回答
閱讀官方文檔。
從這個
@EnableRedisHttpSession
public class Config {
@Bean
public LettuceConnectionFactory connectionFactory() {
return new LettuceConnectionFactory();
}
}
它在默認情況下完成的。
The @EnableRedisHttpSession annotation creates a Spring Bean with the name of springSessionRepositoryFilter that implements Filter. The filter is what is in charge of replacing the HttpSession implementation to be backed by Spring Session. In this instance Spring Session is backed by Redis.
We create a RedisConnectionFactory that connects Spring Session to the Redis Server. We configure the connection to connect to localhost on the default port (6379) For more information on configuring Spring Data Redis, refer to the reference documentation.
The DelegatingFilterProxy will look up a Bean by the name of springSessionRepositoryFilter and cast it to a Filter. For every request that DelegatingFilterProxy is invoked, the springSessionRepositoryFilter will be invoked.
所以,你必須做什麼,這是避免Spring配置,或尋找,如果你想以某種方式修改這個默認行爲來創建自己的DelegatingFilterProxy實現並將其設置在您的ServletContext篩選器鏈中。
- 1. 請求POST修改對象?
- 2. 在插入之前修改Laravel請求
- 3. 修改UIWebView請求
- 4. Django:創建/修改請求對象
- 5. 在當前請求中存儲對象
- 6. Java的要求,只有當
- 7. 爲什麼我的修改當前位置請求代碼(JS/jQuery的)工作?
- 8. 將請求修改爲POST
- 9. Rails修改請求路由
- 10. 修改當前網址
- 11. 請求在Github上更改爲之前的修訂
- 12. 請求Javascript修改的源代碼請求
- 13. 修改mod_perl2中的POST請求
- 14. 修改內核,WFP的HTML請求?
- 15. 在UIWebView中修改請求的URL
- 16. 如何修改nginx中的請求URI
- 17. 修改jQuery的Ajax請求連接頭
- 18. ASP.NET MVC - 如何修改請求的URL?
- 19. 修改腳本中的Zapier請求url
- 20. 當前的請求不是多請求 - Spring MVC的
- 21. laravel 5.4在請求驗證前修改數據
- 22. 找出當前請求是否是Firefox中的代理請求?
- 23. 當前請求不是MockMultipartFile測試的多部分請求
- 24. Spring MVC的當前請求不是多請求
- 25. 在Symfony2中修改請求對象中的Url
- 26. 修改窗體只顯示當前用戶信息,aspnet
- 27. 獲取當前請求URL的方案
- 28. jQuery獲取當前會話的請求
- 29. 顯示當前AJAX請求的狀態
- 30. 如何查找當前請求的Url?
我能夠通過提供自己的HttpSessionSecurityContextRepository實現,然後設置http.securityContext()。securityContextRepository(new CustomHttpSessionSecurityContextRepository())來實現此目的。 因此,我正在實現我自己的SaveContextOnUpdateOrErrorResponseWrapper,其中我沒有保存上下文,因此它在會話中沒有更改。 –