Skip to content

Commit ef26546

Browse files
committed
优化权限控制
1 parent 4124897 commit ef26546

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Permission.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ public interface Permission extends Serializable {
6161
*/
6262
String ACTION_EXPORT = "export";
6363

64+
/**
65+
* 禁用
66+
*/
67+
String ACTION_DISABLE = "disable";
68+
69+
/**
70+
* 启用
71+
*/
72+
String ACTION_ENABLE = "enable";
73+
6474
/**
6575
* 获取权限ID,权限的唯一标识
6676
*

hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/listener/UserAuthorizationListener.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ default void onAuthorizeBefore(String username) {
3636
default void onAuthorizeFail(String username) {
3737
}
3838

39+
default void onLoginOut(Authorization authorization){
40+
41+
}
3942
void onAuthorizeSuccess(boolean isRemembered, Authorization authorization);
4043
}

hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/ListenerAuthorizingRealm.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ private AuthenticationInfo createAuthenticationInfo(Authorization authorization)
6767
authorization.getUser().getName());
6868
}
6969

70+
@Override
71+
public void onLoginOut(Authorization authorization) {
72+
if (null != authorization)
73+
getCache(authorization.getUser().getUsername()).clear();
74+
SecurityUtils.getSubject().logout();
75+
}
76+
7077
@Override
7178
public void onAuthorizeSuccess(boolean isRemembered, Authorization authorization) {
7279
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();

hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/SimpleAuthorizeMethodInterceptor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void assertAuthorized(Annotation a) throws AuthorizationException {
6565
if (!(a instanceof Authorize)) return;
6666
MethodInterceptorHolder holder = MethodInterceptorHolder.current();
6767
if (null == holder) {
68+
logger.warn("MethodInterceptorHolder is null,maybe config is error!");
6869
return;
6970
}
7071
AuthorizeConfig authorizeConfig = new AuthorizeConfig(holder.getArgs());

hsweb-examples/hsweb-examples-simple/src/main/java/org/hswebframework/web/example/simple/TestController.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ public ResponseMessage testUpdate(@PathVariable String id, @RequestBody UserEnti
6161
return ResponseMessage.ok(entity);
6262
}
6363

64-
public static void main(String[] args) throws NoSuchMethodException {
65-
System.out.println(UserController.class.getMethod("list", Entity.class));
66-
}
67-
6864
@Override
6965
public TestService getService() {
7066
return new TestService();

0 commit comments

Comments
 (0)