首页 > 解决方案 > 不需要使用 jwt 进行身份验证的 URL

问题描述

我创建了两个项目第一个用于在 API 中发布数据,我已经实现了没有令牌的 JWT 令牌我将无法在其中发布数据第二个项目我创建了具有前端的 web 动态项目,我们可以在第一个项目中发布数据,但在第一个项目中实施 jwt 两个之后,现在无法使用具有前端的第二个项目发布我已经尝试了下面的程序,当我打开它仍在进行身份验证时举个例子

@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
    // We don't need CSRF for this example
    httpSecurity.csrf().disable()
            // dont authenticate this particular request
            .authorizeRequests().antMatchers("/swagger-ui.html").permitAll().antMatchers(HttpMethod.GET, "/**").permitAll()
            .antMatchers("/user/login").permitAll().antMatchers(HttpMethod.OPTIONS, "/**")
            .permitAll().
            // all other requests need to be authenticated
                    anyRequest().authenticated().and().
            // make sure we use stateless session; session won't be used to
            // store user's state.
                    exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint).and().sessionManagement()
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS);

    // Add a filter to validate the tokens with every request
    httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
}

标签: spring-bootjwt

解决方案


推荐阅读