spring - Spring Security 和 i18n
问题描述
当我在页面上更改语言时,我无法访问。
没有.antMatchers("/login*").permitAll()
不起作用,但使用/login*几乎可以,但是当我在 URL 中提供“ http://localhost:8080/login?lang=estest123 ”或登录后与 i18n 无关的东西时,我收到 ??language.change_estest123? ?.
我尝试添加.regexMatchers("^login\\?lang=[a-zA-Z]{2}|^login\\?lang=_{1}[a-zA-Z]{2}").permitAll()
但结果与/login*相同。
是否可以仅访问 i18n ?在其他情况下提供错误?或者也许是 i18n 的另一种配置方式,它允许以简单的方式提供这个?
我的网络安全配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**", "/registration").permitAll()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
解决方案
参数的存在是否会影响安全性的 url 解析?只需使用/login
and 它应该通过/login
and /login?lang=xxx
。
但是如果你想在你的配置中使用直接映射,你可以同时使用它们:.antMatchers("/login", "/login*").permitAll()
推荐阅读
- javascript - 如何在特定单词之后找到所有出现的文本?
- snmp - SNMP Mac ID 格式问题
- sql - Pl sql 在查询中获取字符串的 x 字符
- arcore - 如何在 android 中从渲染的 3D 模型中隐藏特定的子节点?
- r - 用 NA 重塑长而完整
- c++ - 关于 std::lower_bound 和 std::upper_bound 的问题
- c# - 带有 if 条件的复选框项目
- android - 在 Google Play 中部分部署应用程序
- android - (R.layout.activity_main)?R 为红色
- regex - 选择 2 个单词之间的一组数字