Моя цель состоит в том, чтобы (в общем) обеспечить определенные URL-пути для (типа) раскрывающихся мандатов.Я думал о том, чтобы извлечь информацию о манданте из URL как path-variable
с помощью ant-matcher (см. https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#el-access-web-path-variables) и каким-то образом мог работать с ним в дальнейшем. В приведенном ниже примере переменная пути - {mandant}
Защита шаблона URL работает, но я не знаю, как правильно получить доступ к переменной пути (меня перенаправляют на /man-{mandant}/..
, что означает, что подстановка переменной пути не была сделана).
Есть мысли?
@Configuration
public class SecurityConfig2 {
@Configuration
public static class RegularSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/css/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/regular/login")
.defaultSuccessUrl("/regular/home")
.permitAll()
.and()
.logout()
.logoutUrl("/regular/logout")
.permitAll();
}
}
@Configuration
@Order(1)
public static class GenericMandantSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/man-{mandant}/**")
.authorizeRequests()
.anyRequest().access("hasRole('USER_#mandant')")
.and()
.formLogin()
.loginPage("/man-{mandant}/login")
.defaultSuccessUrl("/man-{mandant}/home")
.permitAll()
.and()
.logout()
.logoutUrl("/man-{mandant}/logout")
.permitAll();
}
}
...
}