refactor:调整生成环境的命名空间

This commit is contained in:
haoxr 2021-02-13 21:40:07 +08:00
parent 026b064b66
commit c653b63c32
5 changed files with 20 additions and 10 deletions

View File

@ -152,13 +152,13 @@
<version>1.0.0</version>
<executions>
<!--执行mvn package,即执行 mvn clean package docker:build-->
<!--<execution>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>-->
</execution>
</executions>
<configuration>

View File

@ -8,9 +8,10 @@ spring:
nacos:
discovery:
server-addr: http://c.youlai.store:8848
namespace: prod_namespace_id
config:
# docker启动nacos-server需要配置
server-addr: ${spring.cloud.nacos.discovery.server-addr}
file-extension: yaml
group: DEFAULT_GROUP
prefix: ${spring.application.name}
namespace: prod_namespace_id

View File

@ -72,12 +72,6 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
</dependencies>
@ -93,7 +87,13 @@
<version>1.0.0</version>
<executions>
<!--执行mvn package,即执行 mvn clean package docker:build-->
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>

View File

@ -35,6 +35,8 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
@Override
public Mono<AuthorizationDecision> check(Mono<Authentication> mono, AuthorizationContext authorizationContext) {
ServerHttpRequest request = authorizationContext.getExchange().getRequest();
String path = request.getMethodValue() + "_" + request.getURI().getPath();
PathMatcher pathMatcher = new AntPathMatcher();
@ -48,11 +50,14 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
return Mono.just(new AuthorizationDecision(true));
}
// token为空拒绝访问
String token = request.getHeaders().getFirst(AuthConstants.JWT_TOKEN_HEADER);
if (StrUtil.isBlank(token)) {
return Mono.just(new AuthorizationDecision(false));
}
// 从缓存取资源权限角色关系列表
Map<Object, Object> permissionRoles = redisTemplate.opsForHash().entries(AuthConstants.PERMISSION_ROLES_KEY);
Iterator<Object> iterator = permissionRoles.keySet().iterator();
@ -64,6 +69,8 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
authorities.addAll(Convert.toList(String.class, permissionRoles.get(pattern)));
}
}
log.info("require authorities:{}", authorities);
Mono<AuthorizationDecision> authorizationDecisionMono = mono
.filter(Authentication::isAuthenticated)
.flatMapIterable(Authentication::getAuthorities)

View File

@ -10,6 +10,8 @@ spring:
nacos:
discovery:
server-addr: http://c.youlai.store:8848
namespace: prod_namespace_id
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
file-extension: yaml
namespace: prod_namespace_id