|
|
|
@ -9,9 +9,9 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
|
|
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
|
|
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
|
|
|
|
import org.springframework.security.core.Authentication;
|
|
|
|
|
import ${basePackage}.frame.base.Token;
|
|
|
|
|
import ${basePackage}.frame.utils.CookieUtil;
|
|
|
|
|
import ${basePackage}.frame.utils.LocalData;
|
|
|
|
|
import xyz.wbsite.frame.base.Token;
|
|
|
|
|
import xyz.wbsite.frame.utils.CookieUtil;
|
|
|
|
|
import xyz.wbsite.frame.auth.LocalData;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
@ -20,16 +20,14 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
|
|
|
|
|
|
|
@Value("${r"${web.url.auth.excluded}"}")
|
|
|
|
|
private String[] excluded;
|
|
|
|
|
@Value("${r"${web.url.auth.included}"}")
|
|
|
|
|
private String[] included;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void configure(HttpSecurity http) throws Exception {
|
|
|
|
|
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
|
|
|
|
.and()
|
|
|
|
|
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
|
|
|
|
.authorizeRequests()
|
|
|
|
|
.antMatchers(staticPath).permitAll()
|
|
|
|
|
.antMatchers(excluded).permitAll()
|
|
|
|
|
.antMatchers(included).access("@Authorization.hasPermission(request,authentication)")
|
|
|
|
|
.anyRequest().access("@Authorization.hasPermission(request,authentication)")
|
|
|
|
|
.and().cors()
|
|
|
|
|
.and().headers().frameOptions().disable()
|
|
|
|
|
.and().csrf().disable();
|
|
|
|
@ -70,7 +68,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
|
|
//继承临时Token
|
|
|
|
|
token1.addResourceSet(LocalData.getTempToken());
|
|
|
|
|
//管理员特有资源(这边请用正则表达式)
|
|
|
|
|
token1.putResource("/admin/.*\\.htm");
|
|
|
|
|
token1.putResource(".*\\.htm");
|
|
|
|
|
LocalData.setToken(token1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|