摘要: 注销成功处理器 阅读全文
posted @ 2023-04-26 19:15 漁夫 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 认证成功处理器 认证失败处理器 阅读全文
posted @ 2023-04-26 19:09 漁夫 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 基于配置的权限控制 CSRF ​ CSRF是指跨站请求伪造(Cross-site request forgery),是web常见的攻击之一。 ​ https://blog.csdn.net/freeking101/article/details/86537087 ​SpringSecurity去防止 阅读全文
posted @ 2023-04-26 14:57 漁夫 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 其他权限校验方法 我们前面都是使用@PreAuthorize注解,然后在在其中使用的是hasAuthority方法进行校验。SpringSecurity还为我们提供了其它方法例如:hasAnyAuthority,hasRole,hasAnyRole等。 ​ 这里我们先不急着去介绍这些方法,我们先去理 阅读全文
posted @ 2023-04-26 14:40 漁夫 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 从数据库查询权限信息 记得打开redis 自定义失败处理 我们还希望在认证失败或者是授权失败的情况下也能和我们的接口一样返回相同结构的json,这样可以让前端能对响应进行统一的处理。要实现这个功能我们需要知道SpringSecurity的异常处理机制。 ​ 在SpringSecurity中,如果我们 阅读全文
posted @ 2023-04-26 11:52 漁夫 阅读(68) 评论(0) 推荐(0) 编辑
摘要: RBAC权限模型 RBAC权限模型(Role-Based Access Control)即:基于角色的权限控制。这是目前最常被开发者使用也是相对易用、通用权限模型 建表及SQL语句编写 sys_user表之前创建了,现在这里就不展示了 CREATE TABLE sys_menu ( id bigin 阅读全文
posted @ 2023-04-25 16:41 漁夫 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 授权基本流程 在SpringSecurity中,会使用默认的FilterSecurityInterceptor来进行权限校验,在FilterSecurityInterceptor中会从SecurityContextHilder获取其中的Authentication,然后获取其中的权限信息,当前用户是 阅读全文
posted @ 2023-04-25 15:09 漁夫 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 认证配置详解 Config package com.sangeng.config; import com.sangeng.filter.JwtAuthenticationTokenFilter; import org.springframework.beans.factory.annotation. 阅读全文
posted @ 2023-04-25 11:36 漁夫 阅读(51) 评论(0) 推荐(0) 编辑
摘要: 配置认证过滤器 Config package com.sangeng.config; import com.sangeng.filter.JwtAuthenticationTokenFilter; import org.springframework.beans.factory.annotation 阅读全文
posted @ 2023-04-25 11:10 漁夫 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 登录接口代码实现 @RestController @RestController public class LoginController { @Autowired private LoginServcie loginServcie; @PostMapping("/user/login") publ 阅读全文
posted @ 2023-04-24 20:02 漁夫 阅读(48) 评论(0) 推荐(0) 编辑