Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2018/06/23 15:40:33 ____ :sun_with_face::sunflower::palm_tree::house_…
…with_garden::office::octocat::guitar::meat_on_bone:
- Loading branch information
1 parent
5d299df
commit cbeefd7
Showing
11 changed files
with
199 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
color 0a | ||
@echo off & setlocal | ||
git pull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
color 0a | ||
@echo off & setlocal | ||
:: cd img/top-photo/ | ||
:: call 0-rename-jpg.bat | ||
:: cd .. | ||
|
||
set var=":sun_with_face::sunflower::palm_tree::house_with_garden::office::octocat::guitar::meat_on_bone:" | ||
set d=%date:~0,10% | ||
set t=%time:~0,8% | ||
git add . | ||
git commit -am"%d% %t% ____ %var%" | ||
git push origin master |
This file was deleted.
Oops, something went wrong.
184 changes: 92 additions & 92 deletions
184
spring-boot-11-SpringSecurity/src/main/java/cn/timebusker/security/SpringSecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,92 @@ | ||
package cn.timebusker.security; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider; | ||
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; | ||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | ||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | ||
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.userdetails.UserDetailsService; | ||
|
||
/** | ||
* @DESC:SpringSecurityConfig | ||
* @author: timebusker | ||
* @date:2018/5/3 | ||
*/ | ||
@EnableWebSecurity | ||
@EnableGlobalMethodSecurity(prePostEnabled = true)//开启@PreAuthorize注解 | ||
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter { | ||
|
||
@Autowired | ||
private UrlsDao urlsDao; | ||
@Autowired | ||
private UserInfoDao userInfoDao; | ||
|
||
@Override | ||
protected void configure(AuthenticationManagerBuilder auth) throws Exception { | ||
auth.userDetailsService(userDetailsServiceBean()); | ||
//密码MD5加密配置 | ||
auth.authenticationProvider(authenticationProvider()); | ||
} | ||
|
||
@Bean | ||
public DaoAuthenticationProvider authenticationProvider() throws Exception { | ||
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider(); | ||
authenticationProvider.setUserDetailsService(userDetailsServiceBean()); | ||
authenticationProvider.setPasswordEncoder(new Md5PasswordEncoder()); | ||
return authenticationProvider; | ||
} | ||
|
||
@Override | ||
public UserDetailsService userDetailsServiceBean() throws Exception { | ||
return new CustomUserService(userInfoDao, urlsDao); | ||
} | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
http | ||
//.csrf().disable() | ||
.authorizeRequests() | ||
.antMatchers("/").permitAll() | ||
.antMatchers("/js/**", "/css/**", "/images/**").permitAll() | ||
.antMatchers("/logout").permitAll() | ||
.antMatchers("/user/list").permitAll() | ||
.anyRequest().authenticated() | ||
.and() | ||
.formLogin() | ||
.loginPage("/login") | ||
.defaultSuccessUrl("/", false) | ||
.permitAll() | ||
.and() | ||
.exceptionHandling().accessDeniedPage("/nolimit") | ||
.and() | ||
.httpBasic(); | ||
} | ||
|
||
/** | ||
* 加载自定义过滤器 | ||
* | ||
* @return | ||
*/ | ||
@Bean | ||
public FilterRegistrationBean someFilterRegistration() { | ||
FilterRegistrationBean registration = new FilterRegistrationBean(); | ||
registration.setFilter(someFilter()); | ||
registration.addUrlPatterns("/*"); | ||
// registration.addInitParameter("paramName", "paramValue"); | ||
registration.setName("commonFilter"); | ||
registration.setOrder(1); | ||
return registration; | ||
} | ||
|
||
@Bean(name = "commonFilter") | ||
public Filter someFilter() { | ||
return new CommonFilter(); | ||
} | ||
|
||
|
||
} | ||
//package cn.timebusker.security; | ||
// | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
//import org.springframework.context.annotation.Bean; | ||
//import org.springframework.security.authentication.dao.DaoAuthenticationProvider; | ||
//import org.springframework.security.authentication.encoding.Md5PasswordEncoder; | ||
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | ||
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | ||
//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.userdetails.UserDetailsService; | ||
// | ||
///** | ||
// * @DESC:SpringSecurityConfig | ||
// * @author: timebusker | ||
// * @date:2018/5/3 | ||
// */ | ||
//@EnableWebSecurity | ||
//@EnableGlobalMethodSecurity(prePostEnabled = true)//开启@PreAuthorize注解 | ||
//public class SpringSecurityConfig extends WebSecurityConfigurerAdapter { | ||
// | ||
// @Autowired | ||
// private UrlsDao urlsDao; | ||
// @Autowired | ||
// private UserInfoDao userInfoDao; | ||
// | ||
// @Override | ||
// protected void configure(AuthenticationManagerBuilder auth) throws Exception { | ||
// auth.userDetailsService(userDetailsServiceBean()); | ||
// //密码MD5加密配置 | ||
// auth.authenticationProvider(authenticationProvider()); | ||
// } | ||
// | ||
// @Bean | ||
// public DaoAuthenticationProvider authenticationProvider() throws Exception { | ||
// DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider(); | ||
// authenticationProvider.setUserDetailsService(userDetailsServiceBean()); | ||
// authenticationProvider.setPasswordEncoder(new Md5PasswordEncoder()); | ||
// return authenticationProvider; | ||
// } | ||
// | ||
// @Override | ||
// public UserDetailsService userDetailsServiceBean() throws Exception { | ||
// return new CustomUserService(userInfoDao, urlsDao); | ||
// } | ||
// | ||
// @Override | ||
// protected void configure(HttpSecurity http) throws Exception { | ||
// http | ||
// //.csrf().disable() | ||
// .authorizeRequests() | ||
// .antMatchers("/").permitAll() | ||
// .antMatchers("/js/**", "/css/**", "/images/**").permitAll() | ||
// .antMatchers("/logout").permitAll() | ||
// .antMatchers("/user/list").permitAll() | ||
// .anyRequest().authenticated() | ||
// .and() | ||
// .formLogin() | ||
// .loginPage("/login") | ||
// .defaultSuccessUrl("/", false) | ||
// .permitAll() | ||
// .and() | ||
// .exceptionHandling().accessDeniedPage("/nolimit") | ||
// .and() | ||
// .httpBasic(); | ||
// } | ||
// | ||
// /** | ||
// * 加载自定义过滤器 | ||
// * | ||
// * @return | ||
// */ | ||
// @Bean | ||
// public FilterRegistrationBean someFilterRegistration() { | ||
// FilterRegistrationBean registration = new FilterRegistrationBean(); | ||
// registration.setFilter(someFilter()); | ||
// registration.addUrlPatterns("/*"); | ||
//// registration.addInitParameter("paramName", "paramValue"); | ||
// registration.setName("commonFilter"); | ||
// registration.setOrder(1); | ||
// return registration; | ||
// } | ||
// | ||
// @Bean(name = "commonFilter") | ||
// public Filter someFilter() { | ||
// return new CommonFilter(); | ||
// } | ||
// | ||
// | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.