1
私は、Spring SecurityのSpring MVCプロジェクト(最近4.2.6.RELEASE
に更新されました)の承認を取得しようとしています。 Spring MVC:Spring Security 4はインターセプトされません
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated().and().formLogin()
.loginPage("/login").permitAll().and().logout().permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
}
}
と
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
public class SecurityWebInitializer extends AbstractSecurityWebApplicationInitializer {
}
私は、すべてのURLのは、現在ブロックされていることを期待するだろう:私はのみのクラスを作成する必要が理解するものから
<dependency org="org.springframework.security" name="spring-security-config" rev="4.1.0.RELEASE" />
<dependency org="org.springframework.security" name="spring-security-core" rev="4.1.0.RELEASE" />
<dependency org="org.springframework.security" name="spring-security-crypto" rev="4.1.0.RELEASE" />
<dependency org="org.springframework.security" name="spring-security-taglibs" rev="4.1.0.RELEASE" />
<dependency org="org.springframework.security" name="spring-security-web" rev="4.1.0.RELEASE" />
:だから私は、これらの依存性を追加しました「/」、「/ home」、「/ login」および「/ logout」を除いて、ログインしていないユーザーのためのものです。実際には何もブロックされず、私のwebappは完全にアクセス可能です。だから私はどこかで間違っているはずです...
本当にありがとう、私の問題が何かにヒントを与えることができます。ありがとうございました!