【问题标题】:Spring security configuration not working properlySpring 安全配置无法正常工作
【发布时间】:2020-09-05 04:38:07
【问题描述】:

这是我在配置类中的方法:

@Override
    protected void configure(HttpSecurity http) throws Exception {


        http
                .cors()
                .and()
                .csrf()
                .disable()
                .exceptionHandling()
                .authenticationEntryPoint(unauthorizedHandler)
                .and()
                .sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                .and()
                .authorizeRequests()
               .antMatchers("/api/v1/auth/signin", "/api/v1/auth/register")
                .permitAll()
                .anyRequest()
                .authenticated();


        http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);

    }

我说过 .anyRequest().authenticated();最后应该使'/api/v1/user'不返回所有用户,但确实如此。为什么?

【问题讨论】:

    标签: hibernate spring-boot authentication spring-security jwt


    【解决方案1】:

    它工作正常。我在端点中犯了一个错误。

    【讨论】:

      猜你喜欢
      • 2019-05-31
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-24
      • 2022-10-24
      • 2019-11-15
      相关资源
      最近更新 更多