为了账号安全,请及时绑定邮箱和手机立即绑定

Tomcat 9 中的 POST 请求禁止 Spring Boot 403

Tomcat 9 中的 POST 请求禁止 Spring Boot 403

米脂 2021-09-12 20:11:19
我是 Spring Boot 的新手,我正在创建一个 Web 应用程序。我在没有 JWT 令牌身份验证的情况下绕过“/auth/login”URL。我创建了一个控制器来处理登录请求并给出响应。当我使用http://localhost:9505/auth/login带有 body 参数的URL 在本地使用 URL 调用我的 Web 服务时{    "username":"abcd@g.l",    "password" : "newPassword"}它工作正常,不检查令牌,但是当我导出它并创建 WAR 文件并部署在服务器上时,它给了我 403 Forbidden 错误。下面是我在 tomcat 9 服务器上部署后用来调用 API 的 URLhttp://localhost:9505/myapplicationame/auth/login你能指导我会有什么问题吗?下面是我的安全配置方法。@Override    protected void configure(HttpSecurity http) throws Exception {    logger.info("SecurityConfig => configure : Configure in SecurityConfig");    logger.info("http Request Path : ");    logger.info("servletContext.getContextPath()) : " + servletContext.getContextPath());    http    .csrf()        .disable()   .exceptionHandling()       .authenticationEntryPoint(unauthorizedHandler)       .and()   .sessionManagement()       .sessionCreationPolicy(SessionCreationPolicy.STATELESS)       .and()   .authorizeRequests()       .antMatchers("/",           "/favicon.ico",           "/**/*.png",           "/**/*.gif",           "/**/*.svg",           "/**/*.jpg",           "/**/*.html",           "/**/*.css",           "/**/*.js")           .permitAll()        .antMatchers("/auth/**")           .permitAll()        .antMatchers("/auth/login")           .permitAll()       .antMatchers("/permissions")           .permitAll()       .anyRequest()           .authenticated();    // Add our custom JWT security filter    http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);}
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 314 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信