zhou-hao 7 éve
szülő
commit
1e4da418f4
14 módosított fájl, 61 hozzáadás és 9 törlés
  1. 2 0
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresDataAccess.java
  2. 2 0
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/define/AuthorizeDefinitionInitializedEvent.java
  3. 5 0
      hsweb-authorization/hsweb-authorization-basic/pom.xml
  4. 5 4
      hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java
  5. 10 0
      hsweb-authorization/hsweb-authorization-basic/src/main/resources/META-INF/additional-spring-configuration-metadata.json
  6. 5 0
      hsweb-examples/hsweb-examples-simple/pom.xml
  7. 2 1
      hsweb-examples/hsweb-examples-simple/src/main/resources/application.yml
  8. 2 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/PermissionMapper.xml
  9. 9 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/ActionEntity.java
  10. 6 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/pom.xml
  11. 10 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
  12. 1 1
      hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-controller/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ServerConfigController.java
  13. 1 1
      hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-controller/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserTokenController.java
  14. 1 1
      hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-controller/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientConfigController.java

+ 2 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresDataAccess.java

@@ -53,6 +53,8 @@ public @interface RequiresDataAccess {
      */
     String[] action() default {};
 
+    String[] supportType() default {};
+
     /**
      * @return logical
      */

+ 2 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/define/AuthorizeDefinitionInitializedEvent.java

@@ -6,6 +6,8 @@ import org.springframework.context.ApplicationEvent;
 import java.util.List;
 
 public class AuthorizeDefinitionInitializedEvent extends ApplicationEvent implements AuthorizationEvent {
+    private static final long serialVersionUID = -8185138454949381441L;
+
     public AuthorizeDefinitionInitializedEvent(List<AuthorizeDefinition> all) {
         super(all);
     }

+ 5 - 0
hsweb-authorization/hsweb-authorization-basic/pom.xml

@@ -26,6 +26,11 @@
             <artifactId>spring-boot-starter-aop</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+            <optional>true</optional>
+        </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-webmvc</artifactId>

+ 5 - 4
hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java

@@ -13,6 +13,7 @@ import org.hswebframework.web.authorization.define.Script;
 
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Set;
 
 /**
@@ -33,13 +34,13 @@ public class DefaultBasicAuthorizeDefinition implements AuthorizeDefinition {
 
     private String[] actionDescription = {};
 
-    private Set<String> permissions = new HashSet<>();
+    private Set<String> permissions = new LinkedHashSet<>();
 
-    private Set<String> actions = new HashSet<>();
+    private Set<String> actions = new LinkedHashSet<>();
 
-    private Set<String> roles = new HashSet<>();
+    private Set<String> roles = new LinkedHashSet<>();
 
-    private Set<String> user = new HashSet<>();
+    private Set<String> user = new LinkedHashSet<>();
 
     private Script script;
 

+ 10 - 0
hsweb-authorization/hsweb-authorization-basic/src/main/resources/META-INF/additional-spring-configuration-metadata.json

@@ -0,0 +1,10 @@
+{
+  "properties": [
+    {
+      "name": "hsweb.authorize.auto-parse",
+      "type": "java.lang.Boolean",
+      "defaultValue": "false",
+      "description": "是否自动解析代码中的权限定义信息并触发AuthorizeDefinitionInitializedEvent事件."
+    }
+  ]
+}

+ 5 - 0
hsweb-examples/hsweb-examples-simple/pom.xml

@@ -155,6 +155,11 @@
             <artifactId>hsweb-system-oauth2-server-starter</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+            <optional>true</optional>
+        </dependency>
 
         <dependency>
             <groupId>io.springfox</groupId>

+ 2 - 1
hsweb-examples/hsweb-examples-simple/src/main/resources/application.yml

@@ -21,7 +21,8 @@ hsweb:
       allowed-methods: "*"
       allowed-headers: "*"
     authorize:
-      auto-parse: true
+      auto-parse: true # 自动解析所有代码中到权限,并触发 ApplicationListener<AuthorizeDefinitionInitializedEvent>
+      sync: true # 自动同步权限信息到数据库
       jwt:
         id: test
         secret: dGVzdA==

+ 2 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/PermissionMapper.xml

@@ -29,7 +29,8 @@
         <result property="actions" column="actions" javaType="java.util.List" jdbcType="VARCHAR"/>
         <result property="optionalFields" column="optional_fields" javaType="java.util.List" jdbcType="CLOB"/>
         <result property="supportDataAccessTypes" column="spt_da_types" javaType="java.util.List" jdbcType="CLOB"/>
-        <!--<result property="parents" column="parents" javaType="java.util.List" jdbcType="CLOB"/>-->
+        <result property="parents" column="parents" javaType="java.util.List" jdbcType="CLOB"/>
+        <result property="type" column="type" javaType="string" jdbcType="VARCHAR"/>
     </resultMap>
 
     <!--用于动态生成sql所需的配置-->

+ 9 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/ActionEntity.java

@@ -39,4 +39,13 @@ public class ActionEntity implements CloneableEntity {
         return Arrays.stream(actions).map(ActionEntity::new).collect(Collectors.toList());
     }
 
+    @Override
+    public int hashCode() {
+        return getAction().hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return obj instanceof ActionEntity && obj.hashCode() == hashCode();
+    }
 }

+ 6 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/pom.xml

@@ -54,6 +54,12 @@
             <version>${project.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+            <optional>true</optional>
+        </dependency>
+
         <dependency>
             <groupId>com.h2database</groupId>
             <artifactId>h2</artifactId>

+ 10 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json

@@ -0,0 +1,10 @@
+{
+  "properties": [
+    {
+      "name": "hsweb.authorize.sync",
+      "type": "java.lang.Boolean",
+      "defaultValue": "false",
+      "description": "是否自动将解析的权限定义信息同步到数据库,需满足hsweb.authorize.auto-parse=true."
+    }
+  ]
+}

+ 1 - 1
hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-controller/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ServerConfigController.java

@@ -36,7 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("${hsweb.web.mappings.oauth2-server-config:oauth2-server-config}")
-@Authorize(permission = "oauth2-server-config")
+@Authorize(permission = "oauth2-server-config",description = "OAuth2.0-客户端-服务配置")
 @Api(tags = "OAuth2.0-客户端-服务配置",value = "OAuth2.0-客户端-服务配置")
 public class OAuth2ServerConfigController implements GenericEntityController<OAuth2ServerConfigEntity, String, QueryParamEntity, OAuth2ServerConfigEntity> {
 

+ 1 - 1
hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-controller/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserTokenController.java

@@ -37,7 +37,7 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("${hsweb.web.mappings.oauth2-user-token:oauth2-user-token}")
-@Authorize(permission = "oauth2-user-token")
+@Authorize(permission = "oauth2-user-token",description = "OAuth2.0-客户端-token管理")
 @Api(tags = "OAuth2.0-客户端-token",value = "OAuth2.0-客户端-token")
 public class OAuth2UserTokenController
         implements QueryController<OAuth2UserTokenEntity, String, QueryParamEntity> {

+ 1 - 1
hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-controller/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientConfigController.java

@@ -18,7 +18,7 @@ import java.util.List;
 @RestController
 @RequestMapping("/oauth2/client/config")
 @Api(tags = "OAuth2.0-服务-客户端管理", value = "OAuth2.0-服务-客户端管理")
-@Authorize(permission = "oauth2-client-config", description = "OAuth2.0客户端管理")
+@Authorize(permission = "oauth2-client-config", description = "OAuth2.0-服务-客户端管理")
 public class OAuth2ClientConfigController {
 
     @Autowired