基板
This commit is contained in:
@@ -8,8 +8,18 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
|
||||
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;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.security.web.authentication.AuthenticationEntryPointFailureHandler;
|
||||
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
@@ -29,9 +39,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/","/index").permitAll()
|
||||
.antMatchers("/register","/login","/toLogin").permitAll()
|
||||
.antMatchers("/source","/source/view/*").permitAll()
|
||||
.antMatchers("/blog","/blog/read/*").permitAll()
|
||||
.antMatchers("/hotspot").permitAll()
|
||||
.antMatchers("/blog/**").authenticated()
|
||||
.antMatchers("/source/**").authenticated()
|
||||
.antMatchers("/user/**").authenticated()
|
||||
.antMatchers("/wx/**").authenticated()
|
||||
.antMatchers("/*").authenticated();
|
||||
|
||||
// 登录配置
|
||||
@@ -40,6 +54,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.passwordParameter("password")
|
||||
.loginPage("/toLogin")
|
||||
.loginProcessingUrl("/login") // 登陆表单提交请求
|
||||
.failureForwardUrl("/loginError")
|
||||
.defaultSuccessUrl("/index"); // 设置默认登录成功后跳转的页面
|
||||
|
||||
// 注销配置
|
||||
|
||||
Reference in New Issue
Block a user