当前位置:网站首页>Custom permission verification method
Custom permission verification method
2022-06-09 10:20:00 【Leon_ Jinhai_ Sun】
We can also define our own permission verification methods , stay @PreAuthorize Use our method in the annotation .
@Component("ex")
public class SGExpressionRoot {
public boolean hasAuthority(String authority){
// Get the permission of the current user
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
List<String> permissions = loginUser.getPermissions();
// Judge whether there exists in the user permission set authority
return permissions.contains(authority);
}
}stay SPEL Use in expressions @ex It's equivalent to getting... In the container bean Your name is not ex The object of . And then call the object's hasAuthority Method
@RequestMapping("/hello")
@PreAuthorize("@ex.hasAuthority('system:dept:list')")
public String hello(){
return "hello";
}边栏推荐
- MSF tips
- CSRF跨站请求伪造
- 978. 最长湍流子数组
- Openstack explanation (13) -- Grace keystone setup and startup
- Openstack explanation (16) -- openstack Nova installation and database configuration
- Openstack explanation (XI) -- openstack grace service theoretical knowledge
- Web版SSH客戶端Sshwifty
- 【LeetCode】【牛客】二叉树刷题
- JWT and session
- 31. next spread
猜你喜欢

机器学习笔记 - R语言学习入门系列一

Openstack explanation (17) -- other configurations of openstack Nova

机器学习之房屋租赁价格预测:探索型数据分析+特征工程+建模+报告

MSF module search details

损失 3 亿美元后,IBM 宣布退出俄罗斯!

106. 从中序与后序遍历序列构造二叉树

8、 Vertices, extremum points and basic feasible solutions of linear programming

Machine learning notes - Interpretation of u-net papers

Kubernetes第七篇:Pod进阶、Controller进阶、Resource和Dashboard

Openstack explanation (XIV) -- Grace keystone registration
随机推荐
[genius_platform software platform development] lesson 35: UDP for cross network segment broadcasting
【genius_platform软件平台开发】第三十五讲:UDP进行跨网段广播
Openstack explanation (13) -- Grace keystone setup and startup
面试题 01.06. 字符串压缩
Security monitoring video easycvr video access interface adds the close button of a single video
1324. 竖直打印单词-力扣双百代码
基于云的 LDAP 如何解救传统 LDAP?
Construction of vocabulary and sampling -- [torch learning notes]
基于云的 LDAP 入门(上)
电池充放电设备招投标解决方案
MSF SSH protocol based information collection
106. construct binary tree from middle order and post order traversal sequence
There is no network for the computer web browser, but QQ and wechat can log in to solve the browser network problem
MSF module search details
如何管理云计算平台用户?
損失 3 億美元後,IBM 宣布退出俄羅斯!
16. 最接近的三数之和-快速排序加双指针法
JWT and session
Kubernetes Chapter 7: Advanced pod, advanced controller, resource and dashboard
Interview question 04.02 Minimum height tree - depth first traversal, plus tree divide and conquer