Skip to content

Commit ae4d32f

Browse files
committed
新增了资源管理页面
1 parent 4d0f667 commit ae4d32f

File tree

22 files changed

+515
-22
lines changed

22 files changed

+515
-22
lines changed

auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/rest/AuthenticationController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ public class AuthenticationController {
2727
@ApiResponses(@ApiResponse(code = 200, message = "处理成功", response = Result.class))
2828
@PostMapping(value = "/auth/permission")
2929
public Result decide(@RequestParam String url, @RequestParam String method, HttpServletRequest request) {
30+
log.debug("权限验证->url:{},method:{}",url,method);
3031
boolean decide = authenticationService.decide(new HttpServletRequestAuthWrapper(request, url, method));
32+
log.debug("权限验证结果->{}",decide);
3133
return Result.success(decide);
3234
}
3335

34-
}
36+
}

auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/service/impl/AuthenticationService.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,21 @@ public class AuthenticationService implements IAuthenticationService {
3030
*/
3131
@Override
3232
public boolean decide(HttpServletRequest authRequest) {
33-
log.debug("正在访问的url是:{},method:{}", authRequest.getServletPath(), authRequest.getMethod());
33+
log.debug("正在访问的url是:{},method:{},ip{},port{}",
34+
authRequest.getServletPath(),
35+
authRequest.getMethod(),
36+
authRequest.getRemoteHost(),
37+
authRequest.getRemotePort());
3438
//获取用户认证信息
3539
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
40+
log.debug("authentication:",authentication.toString());
3641
//获取此url,method访问对应的权限资源信息
3742
ConfigAttribute urlConfigAttribute = resourceService.findConfigAttributesByUrl(authRequest);
38-
if (NONEXISTENT_URL.equals(urlConfigAttribute.getAttribute()))
43+
log.debug("urlConfigAttribute.toString()");
44+
log.debug(urlConfigAttribute.toString());
45+
if (NONEXISTENT_URL.equals(urlConfigAttribute.getAttribute())) {
3946
log.debug("url未在资源池中找到,拒绝访问");
47+
}
4048
//获取此访问用户所有角色拥有的权限资源
4149
Set<Resource> userResources = findResourcesByUsername(authentication.getName());
4250
//用户拥有权限资源 与 url要求的资源进行对比

auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/service/impl/ResourceService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public synchronized void loadResource() {
7070

7171
@Override
7272
public ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest) {
73+
74+
log.debug("========findConfigAttributesByUrl==============");
75+
log.debug(resourceConfigAttributes.toString());
76+
log.debug("===============================================");
77+
7378
return resourceConfigAttributes.keySet().stream()
7479
.filter(requestMatcher -> requestMatcher.matches(authRequest))
7580
.map(requestMatcher -> resourceConfigAttributes.get(requestMatcher))
@@ -94,4 +99,4 @@ public Set<Resource> queryByUsername(String username) {
9499
private MvcRequestMatcher newMvcRequestMatcher(String url, String method) {
95100
return new NewMvcRequestMatcher(mvcHandlerMappingIntrospector, url, method);
96101
}
97-
}
102+
}

auth/authorization-server/src/main/java/com/springboot/auth/authorization/oauth2/CustomUserDetailsService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class CustomUserDetailsService implements UserDetailsService {
2828
public UserDetails loadUserByUsername(String uniqueId) {
2929

3030
User user = userService.getByUniqueId(uniqueId);
31-
log.info("load user by username :{}", user.toString());
31+
log.info("load user by username :{}", user.getId().toString());
3232

3333
return new org.springframework.security.core.userdetails.User(
3434
user.getUsername(),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.springboot.cloud.common.core.constants;
2+
3+
/**
4+
* @author: dongwei
5+
* @date: 2020/08/15 15:18
6+
* @description:
7+
*/
8+
public interface CommonConstants {
9+
10+
/**
11+
* 树的根节点值
12+
*/
13+
Integer TREE_ROOT = -1;
14+
15+
String SPRINGCLOUD_REDIS_LIST_LEY = "springcloud_client_id_to_access:cloud";
16+
17+
18+
19+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.springboot.cloud.common.core.enums;
2+
3+
/**
4+
* @author: dongwei
5+
* @date: 2020/08/15 10:41
6+
* @description: 用户状态枚举
7+
*/
8+
public enum DataStatusEnum {
9+
10+
NORMAL("0", "正常"),
11+
LOCK("1","删除");
12+
13+
14+
private String code;
15+
16+
private String message;
17+
18+
DataStatusEnum(String code, String message) {
19+
this.code = code;
20+
this.message = message;
21+
}
22+
23+
public String getCode() {
24+
return code;
25+
}
26+
27+
public String getMessage() {
28+
return message;
29+
}
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.springboot.cloud.common.core.enums;
2+
3+
/**
4+
* @author: dongwei
5+
* @date: 2020/08/15 16:03
6+
* @description: 资源类型枚举
7+
*/
8+
public enum ResourceTypeEnum {
9+
MENU("0", "菜单"),
10+
BUTTON("1","按钮");
11+
12+
13+
private String code;
14+
15+
private String message;
16+
17+
ResourceTypeEnum(String code, String message) {
18+
this.code = code;
19+
this.message = message;
20+
}
21+
22+
public String getCode() {
23+
return code;
24+
}
25+
26+
public String getMessage() {
27+
return message;
28+
}
29+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package com.springboot.cloud.sysadmin.organization.entity.dto;
2+
3+
import lombok.Data;
4+
5+
import java.time.LocalDateTime;
6+
import java.util.List;
7+
8+
/**
9+
* @author: dongwei
10+
* @date: 2020/08/15 13:35
11+
* @description: 资源树
12+
*/
13+
@Data
14+
public class SysResourceTree {
15+
16+
/**
17+
* 子节点
18+
*/
19+
private List<SysResourceTree> children;
20+
21+
22+
/**
23+
* 主键
24+
*/
25+
private String id;
26+
27+
/**
28+
* 资源名称
29+
*/
30+
private String name;
31+
32+
/**
33+
* 资源类型 0-菜单 1-按钮
34+
*/
35+
private String type;
36+
37+
/**
38+
* 前端url
39+
*/
40+
private String path;
41+
42+
/**
43+
* 按钮权限资源标识
44+
*/
45+
private String code;
46+
47+
/**
48+
* 颜色
49+
*/
50+
private String color;
51+
52+
/**
53+
* 父资源id
54+
*/
55+
private Integer parentId;
56+
57+
/**
58+
* 图标
59+
*/
60+
private String icon;
61+
62+
/**
63+
* 组件路径
64+
*/
65+
private String component;
66+
67+
/**
68+
* 排序权重
69+
*/
70+
private Integer sort;
71+
72+
/**
73+
* 创建时间
74+
*/
75+
private LocalDateTime createTime;
76+
77+
/**
78+
* 更新时间
79+
*/
80+
private LocalDateTime modifyTime;
81+
82+
/**
83+
* 是否删除 1-删除,0-未删除
84+
*/
85+
private String delFlag;
86+
87+
/**
88+
* 后台请求url
89+
*/
90+
private String url;
91+
92+
93+
/**
94+
* 请求方式
95+
*/
96+
private String method;
97+
98+
public void addChildren(SysResourceTree tree) {
99+
this.children.add(tree);
100+
}
101+
102+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.springboot.cloud.sysadmin.organization.entity.dto;
2+
3+
import lombok.Data;
4+
5+
import java.time.LocalDateTime;
6+
import java.util.List;
7+
8+
/**
9+
* @author: dongwei
10+
* @date: 2020/08/15 13:35
11+
* 权限
12+
*/
13+
@Data
14+
public class SysRoleDTO {
15+
16+
17+
/**
18+
* 主键
19+
*/
20+
private Integer roleId;
21+
22+
/**
23+
* 角色code用于springsecurity角色标识码
24+
*/
25+
private String roleCode;
26+
27+
/**
28+
* 角色名称
29+
*/
30+
private String roleName;
31+
32+
/**
33+
* 创建时间
34+
*/
35+
private LocalDateTime createTime;
36+
37+
/**
38+
* 更新时间
39+
*/
40+
private LocalDateTime modifyTime;
41+
42+
/**
43+
* 是否删除 1-删除,0-未删除
44+
*/
45+
private String delFlag;
46+
47+
/**
48+
* 绑定的资源id集合
49+
*/
50+
private List<Integer> sysResourceIds;
51+
52+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.springboot.cloud.sysadmin.organization.entity.dto;
2+
3+
import com.springboot.cloud.sysadmin.organization.entity.po.User;
4+
import lombok.Data;
5+
6+
import java.util.List;
7+
8+
/**
9+
* @author: dongwei
10+
* @date: 2020/08/15 13:35
11+
*/
12+
@Data
13+
public class SysUserInfoDTO {
14+
15+
private User sysUser;
16+
17+
private List<String> roles;
18+
19+
private List<String> permissions;
20+
}

0 commit comments

Comments
 (0)