google-chrome - 登录后如何配置 Spring Security 以使用 https 重定向?
问题描述
Chrome 中的一个新功能/错误 ( https://bugs.chromium.org/p/chromium/issues/detail?id=1158169 ) 向我的用户显示一个错误,因为 Spring Security 在 http (而不是 https ) 即使登录页面和登录表单都是 https。我有一个负载均衡器,它强制使用 https,然后使用 http 传递到多个 Apache/Tomcat 服务器。
关于如何纠正这个问题的任何想法?
如果需要,我的 Spring Security 登录设置如下:
// Apply sameOrigin policy for iframe embeddings
http.headers().frameOptions().sameOrigin();
// Authorization filters
http.authorizeRequests().antMatchers("/sysAdmin/**", "/monitoring/**").access("isFullyAuthenticated() and hasRole('GOD')");
http.authorizeRequests().antMatchers("/app/**").authenticated();
http.authorizeRequests().antMatchers("/**").permitAll();
http.formLogin()
.loginPage("/public/login.jsp")
.loginProcessingUrl("/login")
.usernameParameter("username")
.passwordParameter("password")
.defaultSuccessUrl("/app/Dashboard.action", false)
.failureHandler(customAuthenticationFailureHandler());
// Disable so that logout "get" url works (otherwise you have to do a html form)
http.csrf().disable();
http.logout().logoutSuccessUrl("/public/login.jsp");
http.sessionManagement()
.invalidSessionUrl("/public/expiredSession.jsp?expiredId=2")
.maximumSessions(2)
.sessionRegistry(sessionRegistry())
.expiredUrl("/public/expiredSession.jsp?expiredId=3");
解决方案
如果您在使用 SSL 终止的代理服务器后面运行,那么您需要确保正确设置它。这通常涉及确保代理发送正确的X-Forwarded-
标头并启用 Spring ForwardedHeaderFilter
。
推荐阅读
- svn - 带有 Subversion 的 Trac 缺少“浏览源”按钮
- javascript - 如何创建可以在邮递员请求中多次使用的生成器函数?
- f# - F# - 从头开始学习的资源
- cordova - 如何在cordova inappbrowser中检测重定向的URL并关闭浏览器
- sql - postgresql 过程中的变量插值
- sql - SQL:如何同时获取匹配和不匹配记录
- html - 如何将背景图像添加到 CSS 类
- r - 如何从自定义函数输出矩阵,其名称基于输入矩阵的名称
- intellij-idea - Robolectric 4 AndroidX NoClassDefFoundError MonitoringInstrumentation with IntelliJ 2018.3.4
- javascript - 使用 Scrolltop 功能自动向下滚动在 php/javascript 中不起作用