如何使用postman访问若依后台权限功能
生活随笔
收集整理的這篇文章主要介紹了
如何使用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 下载失败 解决方案
- 下一篇: SpringBoot整合Mybatis-