当前位置:
首页 >
如何使用postman访问若依后台权限功能
发布时间:2024/10/6
43
豆豆
生活随笔
收集整理的这篇文章主要介绍了
如何使用postman访问若依后台权限功能
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
1.前言
今天需要使用postman测试一下后端代码,但是访问方法需要登录权限,在询问了前辈后了解了解决方法,特此记录。
2. 解决方法
首先将想要测试的方法上的权限注解注释掉
@PreAuthorize("@ss.hasPermi(‘system:project:list’)")注释的这里表示方法的请求URL。
然后找到framework/config/SecurityConfig
protected void configure(HttpSecurity httpSecurity) throws Exception{httpSecurity// CRSF禁用,因为不使用session.csrf().disable()// 认证失败处理类.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()// 基于token,所以不需要session.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()// 过滤请求.authorizeRequests()// 对于登录login 验证码captchaImage 允许匿名访问.antMatchers("/login", "/captchaImage").anonymous().antMatchers(HttpMethod.GET,"/*.html","/**/*.html","/**/*.css","/**/*.js").permitAll().antMatchers("/profile/**").anonymous().antMatchers("/common/download**").anonymous().antMatchers("/common/download/resource**").anonymous().antMatchers("/swagger-ui.html").anonymous().antMatchers("/swagger-resources/**").anonymous().antMatchers("/webjars/**").anonymous().antMatchers("/*/api-docs").anonymous().antMatchers("/druid/**").anonymous().antMatchers("/ctwing/receive**").anonymous().antMatchers("/ctwing/receive/getDate**").anonymous()//在这里添加想要测试的方法访问URL,后面添加匿名访问的权限permitAll().antMatchers("/system/project/list").permitAll()// 除上面外的所有请求全部需要鉴权认证.anyRequest().authenticated().and().headers().frameOptions().disable();httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);// 添加JWT filterhttpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);}完成上面的工作就可以使用postman测试了。
总结
以上是生活随笔为你收集整理的如何使用postman访问若依后台权限功能的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: node-sass 下载失败 解决方案
- 下一篇: MybatisPlus代码生成器配置