# sa-token-plugin-ignore **Repository Path**: bootx/sa-token-plugin-ignore ## Basic Information - **Project Name**: sa-token-plugin-ignore - **Description**: 忽略权限验证 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: v1.25.0 - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 2 - **Created**: 2021-08-03 - **Last Updated**: 2024-06-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Sa-Token-Plugin-Redis插件 - 介绍 有时候我们会有一些接口不需要登录就可以访问,但专门在配置文件中配置也比较麻烦,所以提供一个在接口上添加注解就可以忽略权限验证的插件。 - 添加pom依赖 ```xml com.gitee.bootx sa-token-plugin-ignore ${sa-token.plugin.version} ``` - 注册到拦截器中 ```java @Configuration public class SaTokenConfigure implements WebMvcConfigurer { // 注册拦截器 @Override public void addInterceptors(InterceptorRegistry registry) { // 注册Sa-Token的路由拦截器 registry.addInterceptor(new SaRouteInterceptor( new SaRouteInterceptor((req, res, handler)-> // 将match中的SaFunction function参数设置为IgnoreSaRouteFunction对象,就可以实现添加注解忽略权限验证 SaRouter.match(Collections.singletonList("/**"), Collections.singletonList("/login"), new IgnoreSaRouteFunction(handler))) .addPathPatterns("/**"); } } ``` - 注解形式 ```java // 添加 IgnoreAuth 注解后,将忽略本接口的权限认证,不适用与aop模式 @IgnoreAuth @ApiOperation("测试") @GetMapping("/hello") public ResResult hello(){ return Res.ok("hello"); }