当前位置:网站首页>基于配置的权限控制
基于配置的权限控制
2022-06-09 09:37:00 【Leon_Jinhai_Sun】
我们也可以在配置类中使用使用配置的方式对资源进行权限控制。
@Override
protected void configure(HttpSecurity http) throws Exception {
http
//关闭csrf
.csrf().disable()
//不通过Session获取SecurityContext
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
// 对于登录接口 允许匿名访问
.antMatchers("/user/login").anonymous()
.antMatchers("/testCors").hasAuthority("system:dept:list222")
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated();
//添加过滤器
http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
//配置异常处理器
http.exceptionHandling()
//配置认证失败处理器
.authenticationEntryPoint(authenticationEntryPoint)
.accessDeniedHandler(accessDeniedHandler);
//允许跨域
http.cors();
}边栏推荐
- 自定义失败处理
- MSF practice - harm of ms17-010 vulnerability
- 如何实现合规的远程办公?
- LeetCode_ Monotone stack_ Medium_ 739. daily temperature
- 机器学习笔记 - 使用scikit-learn创建混淆矩阵
- 31. 下一个排列
- Terrain learning summary (6) -- terrain practice based on Alibaba cloud platform
- [practical skills] from the book "beautiful teams"
- Composition of IT resources accessible anywhere, anytime
- 【科技、商业和管理】看剧学创业:《硅谷》第五季第1-3集
猜你喜欢

openstack详解(十一)——openstack Glance服务理论知识

Openstack explanation (13) -- Grace keystone setup and startup
![[1 data collection] complete learning path of data crawler](/img/73/5224cc4476f05aa190c135eea0aafd.jpg)
[1 data collection] complete learning path of data crawler

eBPF 在云原生环境中的应用

明道云上榜2022年中国信创行业办公软件排行榜

MSF information collection based on TCP protocol

机器学习笔记 - 使用scikit-learn创建混淆矩阵

WebService service call
![[graph machine learning] Introduction to graph neural network (I) spectral graph theory](/img/e2/3ffc0783e87f83d7a39e1ed3aa26d1.png)
[graph machine learning] Introduction to graph neural network (I) spectral graph theory

MSF基于SNMP协议的信息收集
随机推荐
【genius_platform软件平台开发】第三十七讲:网卡混杂模式和原始套接字
- Bean method ‘redisConnectionFactory‘ in ‘JedisConnectionConfiguration‘ not loaded because @Conditi
With good conditional access, remote office is more secure and efficient
Openstack explanation (XV) -- basic principle of openstack Nova node
[brain opening] how can knowledge-based enterprises start their own businesses recruit talents?
[recommendation system] user based collaborative filtering
MSF基于FTP协议的信息收集
[practical skills] inspiration from ai/ml of Google i/o 2022 Conference for developers
LeetCode_ Simulation_ Medium_ 621. task scheduler
Openstack explanation (18) -- Nova service startup and service creation
从零开始实现递归神经网络——【torch学习笔记】
MSF基于SSH协议的信息收集
Visual slam Summary - superpoint / superglue
机器学习之房屋租赁价格预测:探索型数据分析+特征工程+建模+报告
31. 下一个排列
数字图像处理 图解图像恢复任务
[technology, business and management] drama learning and Entrepreneurship: Silicon Valley season 5 Episode 1-3
Changan chain chainmaker multi machine environment
Machine learning housing rental price forecasting: exploratory data analysis + Feature Engineering + modeling + reporting
LeetCode_ Binary tree_ Prefix and_ Medium_ 437. path sum III