Browse Source

优化权限配置

zhou-hao 3 years ago
parent
commit
462af2fe90

+ 2 - 2
hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/BasicAuthorizationTokenParser.java

@@ -15,9 +15,9 @@ import javax.servlet.http.HttpServletRequest;
 
 public class BasicAuthorizationTokenParser implements UserTokenForTypeParser {
 
-    private AuthenticationManager authenticationManager;
+    private final AuthenticationManager authenticationManager;
 
-    private UserTokenManager userTokenManager;
+    private final UserTokenManager userTokenManager;
 
     @Override
     public String getTokenType() {

+ 7 - 1
hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/configuration/EnableAopAuthorize.java

@@ -5,13 +5,19 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
 import java.lang.annotation.*;
 
 /**
+ * 开启基于AOP的权限控制
+ *
  * @author zhouhao
+ * @see org.hswebframework.web.authorization.Authentication
+ * @see org.hswebframework.web.authorization.annotation.Authorize
+ * @see org.hswebframework.web.authorization.annotation.Resource
+ * @see org.hswebframework.web.authorization.annotation.ResourceAction
  */
 @Target(ElementType.TYPE)
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 @Inherited
-@ImportAutoConfiguration({AopAuthorizeAutoConfiguration.class, AuthorizingHandlerAutoConfiguration.class})
+@ImportAutoConfiguration({AopAuthorizeAutoConfiguration.class})
 public @interface EnableAopAuthorize {
 
 }

+ 2 - 3
hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/embed/EmbedReactiveAuthenticationManager.java

@@ -12,14 +12,13 @@ import reactor.core.publisher.Mono;
 
 /**
  * @author zhouhao
- * @since 3.0.0-RC
+ * @since 4.0.0
  */
-
 @Order(10)
 @AllArgsConstructor
 public class EmbedReactiveAuthenticationManager implements ReactiveAuthenticationManagerProvider {
 
-    private EmbedAuthenticationProperties properties;
+    private final EmbedAuthenticationProperties properties;
 
     @Override
     public Mono<Authentication> authenticate(Mono<AuthenticationRequest> request) {

+ 1 - 1
hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/UserAllowPermissionHandler.java

@@ -37,7 +37,7 @@ public class UserAllowPermissionHandler {
     @Setter
     private Map<String, Map<String, String>> allows = new HashMap<>();
 
-    private PathMatcher pathMatcher = new AntPathMatcher(".");
+    private final PathMatcher pathMatcher = new AntPathMatcher(".");
 
     @EventListener
     public void handEvent(AuthorizingHandleBeforeEvent event) {

+ 3 - 0
hsweb-authorization/hsweb-authorization-basic/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,3 @@
+# Auto Configure
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.hswebframework.web.authorization.basic.configuration.AuthorizingHandlerAutoConfiguration