mirror of https://gitee.com/maxjhandsome/pig
【优化】 优化配置
This commit is contained in:
parent
a123034e01
commit
fc5baba24d
|
@ -11,8 +11,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
|||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class AdminApplication extends BaseController {
|
||||
public class PigAdminApplication extends BaseController {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApplication.class, args);
|
||||
SpringApplication.run(PigAdminApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.github.pig.admin.controller;
|
||||
|
||||
import com.github.pig.common.web.BaseController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
@ -11,5 +12,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController extends BaseController {
|
||||
|
||||
@GetMapping
|
||||
public String user() {
|
||||
return getUser();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,6 @@
|
|||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!--消息总线-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
|
||||
</dependency>
|
||||
<!--Redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.github.pig.auth.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/10/28
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "pig.auth")
|
||||
public class AuthServerConfig {
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private String scope;
|
||||
private String signKey;
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return clientSecret;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getSignKey() {
|
||||
return signKey;
|
||||
}
|
||||
|
||||
public void setSignKey(String signKey) {
|
||||
this.signKey = signKey;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,8 @@ import org.springframework.security.oauth2.config.annotation.web.configurers.Aut
|
|||
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
|
||||
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/10/27
|
||||
|
@ -22,6 +24,8 @@ import org.springframework.security.oauth2.provider.token.store.redis.RedisToken
|
|||
@Configuration
|
||||
@EnableAuthorizationServer
|
||||
public class PigAuthorizationConfig extends AuthorizationServerConfigurerAdapter {
|
||||
@Autowired
|
||||
private AuthServerConfig authServerConfig;
|
||||
|
||||
@Autowired
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
@ -35,10 +39,10 @@ public class PigAuthorizationConfig extends AuthorizationServerConfigurerAdapter
|
|||
@Override
|
||||
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
|
||||
clients.inMemory()
|
||||
.withClient("lengleng")
|
||||
.secret("lengleng")
|
||||
.withClient(authServerConfig.getClientId())
|
||||
.secret(authServerConfig.getClientSecret())
|
||||
.authorizedGrantTypes("refresh_token", "password")
|
||||
.scopes("ui");
|
||||
.scopes(authServerConfig.getScope());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +57,7 @@ public class PigAuthorizationConfig extends AuthorizationServerConfigurerAdapter
|
|||
@Bean
|
||||
public JwtAccessTokenConverter jwtAccessTokenConverter(){
|
||||
JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
|
||||
jwtAccessTokenConverter.setSigningKey("pig");
|
||||
jwtAccessTokenConverter.setSigningKey(authServerConfig.getSignKey());
|
||||
return jwtAccessTokenConverter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,15 +12,9 @@ spring:
|
|||
bus:
|
||||
trace:
|
||||
enabled: true
|
||||
rabbitmq:
|
||||
port: 5672
|
||||
host: localhost
|
||||
username: guest
|
||||
password: guest
|
||||
eureka:
|
||||
instance:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
serviceUrl:
|
||||
defaultZone: http://127.0.0.1:9000/eureka/
|
||||
|
||||
|
|
|
@ -22,11 +22,6 @@
|
|||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-server</artifactId>
|
||||
</dependency>
|
||||
<!--消息总线-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
@ -28,11 +28,6 @@
|
|||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zuul</artifactId>
|
||||
</dependency>
|
||||
<!--消息总线-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
|
||||
</dependency>
|
||||
<!--oauth2.0-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
|
|
|
@ -26,7 +26,7 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
if (principal != null) {
|
||||
//TODO 根据用户名查询缓存,没有的查询数据库
|
||||
Set<String> urls = new HashSet<>();
|
||||
urls.add("/demo");
|
||||
urls.add("/user");
|
||||
|
||||
for (String url : urls) {
|
||||
if (request.getRequestURI().contains(url)){
|
||||
|
|
|
@ -12,11 +12,6 @@ spring:
|
|||
bus:
|
||||
trace:
|
||||
enabled: true
|
||||
rabbitmq:
|
||||
port: 5672
|
||||
host: localhost
|
||||
username: guest
|
||||
password: guest
|
||||
|
||||
eureka:
|
||||
instance:
|
||||
|
|
Loading…
Reference in New Issue