如何在Spring安全配置文件中获取用户访问的URL

时间:2016-07-19 05:35:18

标签: java spring spring-mvc web-applications spring-security

我正在使用自定义安全评估程序方法在java-springs Web应用程序中工作, 我需要将user命中的URL作为方法permissionEvaluator.canUserAccessPage(URLHitByUser)的参数传递。

如何获取用户点击的网址。

@Override
protected void configure(HttpSecurity http) throws Exception {

        http
    .authorizeRequests()
        //.antMatchers("/view/**").permitAll()
        .antMatchers("/assets/**").permitAll()
        .antMatchers("/view/admin.html").access("@permissionEvaluator.canUserAccessPage(URLHitByUser)")
        .anyRequest().authenticated()
        .and()
    .formLogin()
        .loginPage("/login").usernameParameter("username").passwordParameter("password")
        .defaultSuccessUrl("/index") 
        .permitAll() 

    // [...]
}

1 个答案:

答案 0 :(得分:0)

如果您打算控制对某些角色的访问,可以通过在applicationContext-security-preauth.xml中使用sec:intercept-url来实现。

由于