Skip to content

Commit d5be526

Browse files
committed
1. 移除role相关代码;
2. 优化权限接口;
1 parent bb7b096 commit d5be526

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+261
-2127
lines changed

assets/src/main/resources/application-dev.yaml

-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
logging:
2-
level:
3-
root: info
4-
org:
5-
springframework: info
6-
71
spring:
8-
cloud:
9-
consul:
10-
host: 127.0.0.1
11-
port: 8500
12-
discovery:
13-
prefer-ip-address: true
14-
152
r2dbc:
163
url: r2dbc:postgresql://postgres@localhost:5432
174
username: postgres

assets/src/main/resources/application-prod.yaml

-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
logging:
2-
level:
3-
root: info
4-
org:
5-
springframework: info
6-
71
spring:
8-
cloud:
9-
consul:
10-
host: 127.0.0.1
11-
port: 8500
12-
discovery:
13-
prefer-ip-address: true
14-
152
r2dbc:
163
url: r2dbc:postgresql://postgres@localhost:5432
174
username: postgres

auth/src/main/java/io/leafage/auth/config/AuthorizationServerConfiguration.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
import org.springframework.security.web.SecurityFilterChain;
4242
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
4343
import org.springframework.security.web.util.matcher.MediaTypeRequestMatcher;
44+
import org.springframework.web.cors.CorsConfiguration;
45+
import org.springframework.web.cors.CorsConfigurationSource;
46+
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
4447

4548
import static org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer.authorizationServer;
4649

@@ -73,7 +76,7 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
7376
new LoginUrlAuthenticationEntryPoint("/login"),
7477
new MediaTypeRequestMatcher(MediaType.TEXT_HTML)
7578
));
76-
return http.build();
79+
return http.cors(Customizer.withDefaults()).build();
7780
}
7881

7982
@Bean
@@ -110,4 +113,16 @@ public JWKSource<SecurityContext> jwkSource() {
110113
public JwtDecoder jwtDecoder(JWKSource<SecurityContext> jwkSource) {
111114
return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource);
112115
}
116+
117+
@Bean
118+
public CorsConfigurationSource corsConfigurationSource() {
119+
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
120+
CorsConfiguration configuration = new CorsConfiguration();
121+
configuration.setAllowCredentials(true);
122+
configuration.addAllowedOrigin("http://127.0.0.1:9000");
123+
configuration.addAllowedHeader("*");
124+
configuration.addAllowedMethod("*");
125+
source.registerCorsConfiguration("/**", configuration);
126+
return source;
127+
}
113128
}

auth/src/main/java/io/leafage/auth/config/DefaultSecurityConfiguration.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ public SecurityFilterChain standardSecurityFilterChain(HttpSecurity http) throws
4343
.anyRequest().authenticated())
4444
.formLogin(Customizer.withDefaults());
4545

46-
return http.build();
46+
return http.cors(Customizer.withDefaults()).build();
4747
}
4848

4949
@Bean
5050
UserDetailsService userDetailsService(DataSource dataSource) {
51-
return new JdbcUserDetailsManager(dataSource);
51+
JdbcUserDetailsManager jdbcUserDetailsManager = new JdbcUserDetailsManager(dataSource);
52+
jdbcUserDetailsManager.setEnableGroups(true);
53+
return jdbcUserDetailsManager;
5254
}
5355

5456
@Bean

hypervisor/src/main/java/io/leafage/basic/hypervisor/bo/GroupBO.java

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2024 little3201.
2+
* Copyright 2018-2025 little3201.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,11 +32,6 @@ public abstract class GroupBO {
3232
@NotBlank(message = "group name must not be empty.")
3333
private String name;
3434

35-
/**
36-
* 负责人
37-
*/
38-
private String principal;
39-
4035
/**
4136
* 描述
4237
*/
@@ -60,24 +55,6 @@ public void setName(String name) {
6055
this.name = name;
6156
}
6257

63-
/**
64-
* <p>Getter for the field <code>principal</code>.</p>
65-
*
66-
* @return a {@link java.lang.String} object
67-
*/
68-
public String getPrincipal() {
69-
return principal;
70-
}
71-
72-
/**
73-
* <p>Setter for the field <code>principal</code>.</p>
74-
*
75-
* @param principal a {@link java.lang.String} object
76-
*/
77-
public void setPrincipal(String principal) {
78-
this.principal = principal;
79-
}
80-
8158
/**
8259
* <p>Getter for the field <code>description</code>.</p>
8360
*

hypervisor/src/main/java/io/leafage/basic/hypervisor/bo/PrivilegeBO.java

+33-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2024 little3201.
2+
* Copyright 2018-2025 little3201.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,9 +19,10 @@
1919

2020

2121
import jakarta.validation.constraints.NotBlank;
22-
import jakarta.validation.constraints.NotNull;
2322
import jakarta.validation.constraints.Size;
2423

24+
import java.util.Set;
25+
2526
/**
2627
* bo class for privilege
2728
*
@@ -36,12 +37,6 @@ public abstract class PrivilegeBO {
3637
@Size(max = 32, message = "privilege name max length is 32.")
3738
private String name;
3839

39-
/**
40-
* 类型
41-
*/
42-
@NotNull(message = "type must not be null.")
43-
private Character type;
44-
4540
/**
4641
* 图标
4742
*/
@@ -53,6 +48,16 @@ public abstract class PrivilegeBO {
5348
*/
5449
private String path;
5550

51+
/**
52+
* redirect
53+
*/
54+
private String redirect;
55+
/**
56+
* component
57+
*/
58+
private String component;
59+
60+
private Set<String> actions;
5661
/**
5762
* 描述
5863
*/
@@ -76,22 +81,28 @@ public void setName(String name) {
7681
this.name = name;
7782
}
7883

79-
/**
80-
* <p>Getter for the field <code>type</code>.</p>
81-
*
82-
* @return a {@link java.lang.Character} object
83-
*/
84-
public Character getType() {
85-
return type;
84+
public String getRedirect() {
85+
return redirect;
8686
}
8787

88-
/**
89-
* <p>Setter for the field <code>type</code>.</p>
90-
*
91-
* @param type a {@link java.lang.Character} object
92-
*/
93-
public void setType(Character type) {
94-
this.type = type;
88+
public void setRedirect(String redirect) {
89+
this.redirect = redirect;
90+
}
91+
92+
public String getComponent() {
93+
return component;
94+
}
95+
96+
public void setComponent(String component) {
97+
this.component = component;
98+
}
99+
100+
public Set<String> getActions() {
101+
return actions;
102+
}
103+
104+
public void setActions(Set<String> actions) {
105+
this.actions = actions;
95106
}
96107

97108
/**

hypervisor/src/main/java/io/leafage/basic/hypervisor/bo/RoleBO.java

-75
This file was deleted.

hypervisor/src/main/java/io/leafage/basic/hypervisor/bo/UserBO.java

+24-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2024 little3201.
2+
* Copyright 2018-2025 little3201.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,12 +37,17 @@ public abstract class UserBO {
3737
/**
3838
* 名
3939
*/
40-
private String firstname;
40+
private String givenName;
41+
42+
/**
43+
* 中间名
44+
*/
45+
private String middleName;
4146

4247
/**
4348
* 姓
4449
*/
45-
private String lastname;
50+
private String familyName;
4651

4752
/**
4853
* 头像
@@ -83,40 +88,28 @@ public void setUsername(String username) {
8388
this.username = username;
8489
}
8590

86-
/**
87-
* <p>Getter for the field <code>firstname</code>.</p>
88-
*
89-
* @return a {@link java.lang.String} object
90-
*/
91-
public String getFirstname() {
92-
return firstname;
91+
public String getGivenName() {
92+
return givenName;
9393
}
9494

95-
/**
96-
* <p>Setter for the field <code>firstname</code>.</p>
97-
*
98-
* @param firstname a {@link java.lang.String} object
99-
*/
100-
public void setFirstname(String firstname) {
101-
this.firstname = firstname;
95+
public void setGivenName(String givenName) {
96+
this.givenName = givenName;
10297
}
10398

104-
/**
105-
* <p>Getter for the field <code>lastname</code>.</p>
106-
*
107-
* @return a {@link java.lang.String} object
108-
*/
109-
public String getLastname() {
110-
return lastname;
99+
public String getMiddleName() {
100+
return middleName;
111101
}
112102

113-
/**
114-
* <p>Setter for the field <code>lastname</code>.</p>
115-
*
116-
* @param lastname a {@link java.lang.String} object
117-
*/
118-
public void setLastname(String lastname) {
119-
this.lastname = lastname;
103+
public void setMiddleName(String middleName) {
104+
this.middleName = middleName;
105+
}
106+
107+
public String getFamilyName() {
108+
return familyName;
109+
}
110+
111+
public void setFamilyName(String familyName) {
112+
this.familyName = familyName;
120113
}
121114

122115
/**

0 commit comments

Comments
 (0)