缺了好几天的博客
我会一 一补上的刚好学到了一个新的注解分享一下吧
@RequiresPermissions() 这是在一个项目里看到的因为是第一次看到不懂是干嘛用的就学了一下
@ResuiresPermissions()当前Subject需要拥有某些特定的权限时,才能执行被该注解标注的方法。如果当前Subject不具有这样的权限,则方法不会被执行。
它是:shiro的注解注解
shiro:
唔因为没学过就查了一下知道是java安全框架,后面用到的时候在具体说吧
@RequiresPermissions
例如: @RequiresPermissions({“file:read”, “write:aFile.txt”} )
void someMethod();
要求subject中必须同时含有file:read和write:aFile.txt的权限才能执行方法someMethod()。否则抛出异常AuthorizationException。
//符合index:hello权限要求
@RequiresPermissions("index:hello")
//必须同时复核index:hello和index:world权限要求
@RequiresPermissions({"index:hello","index:world"})
//符合index:hello或index:world权限要求即可
@RequiresPermissions(value={"index:hello","index:world"},logical=Logical.OR)
RequiresPermissions{“xxx1:xxx2:xxx3”}
是shiro的常用注解
执行这个方法会判断用户有没有相应的权限
会在某个地方进行配置,比如controller层其xxx1/xxx2/xxx3的url路径访问相应资源就可以正常访问。
可查询用户数据
User:view
可查询或编辑用户数据
User:view,edit
可对用户数据进行所有操作
User:* 或 user
可编辑id为123的用户数据
User:edit:123
contraller里方法上写上注解,括号里是前端对应的权限字符串
这样就可以控制已认证用户权限了
学习的不是很准确,缺少的大佬们来补上