mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-10-21 19:17:25 +08:00
v.1.12.0新特性:路由拦截式鉴权
This commit is contained in:
@@ -13,10 +13,10 @@
|
||||
``` java
|
||||
@Configuration
|
||||
public class MySaTokenConfig implements WebMvcConfigurer {
|
||||
// 注册sa-token的拦截器,打开注解式鉴权功能
|
||||
// 注册sa-token的注解拦截器,打开注解式鉴权功能
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new SaCheckInterceptor()).addPathPatterns("/**"); // 全局拦截器
|
||||
registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**");
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -119,22 +119,3 @@ public class UserService {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ## 3、扩展
|
||||
- 其实在注册拦截器时,我们也可以根据路由前缀设置不同 `StpLogic`, 从而达到不同模块不同鉴权方式的目的
|
||||
- 以下为参考示例:
|
||||
``` java
|
||||
@Configuration
|
||||
public class MySaTokenConfig implements WebMvcConfigurer {
|
||||
// 注册sa-token的拦截器,打开注解式鉴权功能
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new SaCheckInterceptor(StpUtil.stpLogic)).addPathPatterns("/admin/**");
|
||||
registry.addInterceptor(new SaCheckInterceptor(StpUserUtil.stpLogic)).addPathPatterns("/user/**");
|
||||
}
|
||||
}
|
||||
``` -->
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user