我有一个 spring boot 应用程序,其中包含 spring 安全性,其中添加了 formLogin 和自定义 loginPage 。每当我通过身份验证时,它都会将我发送到 defaultSuccessUrl,即 /app/dashboard,它会发送我一整天都在尝试的架构http ,以使 successUrl 架构成为 https,只是调整 application.properties 上的一些更改,有时使用豆,但我仍然无法实现它。我的应用程序在 cloudfoundry 中,我没有 80 端口,但只有 443(https) 。
我在春天的配置是这样的:
http
.authorizeRequests()
.antMatchers("/", "/forbidden", "/index.html", "/webjars/*", "/app.js", "/access/*", "/signup", "/l10n/*.js", "/", "/tpl/**/*.html", "/fonts/**/*.woff").permitAll()
.anyRequest().authenticated()
.and().addFilterAfter(new CsrfHeaderFilter(), CsrfFilter.class).
csrf().csrfTokenRepository(repo)
.and() .httpBasic().disable()
.formLogin()
.loginPage("/access/signin").permitAll()
.failureUrl("/error")
.defaultSuccessUrl("/app/dashboard")
.and().logout()
.logoutRequestMatcher(new AntPathRequestMatcher("access/logout"))
.logoutSuccessUrl("/access/signin").permitAll();
我也尝试过将绝对 url 与https一起使用,但效果不佳。