完善auth-server

This commit is contained in:
wangiegie@gmail.com 2018-01-06 16:29:39 +08:00
parent 9161613263
commit 822f6ed5bc
5 changed files with 34 additions and 2 deletions

View File

@ -36,6 +36,7 @@ pig
■ 缓存服务(CacheCloud)
■ 分布式数据访问层(ShardingJDBC)
■ 统一认证服务 (Spring Cloud Oauth 2.0)
■ 代码自动生成 (Velocity Template)
○ 持续交付
■ 持续集成,多环境和发布流水线
■ 蓝绿、金丝雀和灰度发布

View File

@ -6,6 +6,7 @@ import com.github.pig.common.constant.SecurityConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -29,6 +30,7 @@ import org.springframework.security.oauth2.provider.token.store.redis.RedisToken
*/
@Configuration
@Order(Integer.MIN_VALUE)
@EnableAuthorizationServer
public class PigAuthorizationConfig extends AuthorizationServerConfigurerAdapter {
@Autowired

View File

@ -0,0 +1,31 @@
package com.github.pig.auth.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
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;
/**
* @author lengleng
* @date 2018/1/6
* AUTH-SERVER 安全配置
* 要在 auth-server 配置之后
*/
@Order(value = Integer.MAX_VALUE)
@Configuration
@EnableWebSecurity
public class PigWebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests().anyRequest().authenticated()
.and()
.csrf().disable();
}
}

View File

@ -4,7 +4,6 @@ import com.github.pig.common.constant.SecurityConstants;
import com.github.pig.common.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import org.springframework.web.bind.annotation.PostMapping;

View File

@ -1,6 +1,5 @@
package com.github.pig.gateway.componet;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pig.common.constant.CommonConstant;
import com.github.pig.common.util.R;