spring-boot - 不需要使用 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);
}
解决方案
推荐阅读
- java - Java正则表达式:用`+`替换所有字符,给定字符串的实例除外
- c++ - 默认构造函数的分段错误
- php - 如何插入具有这种 SQL 关系的数据?
- corda - 使用我们的正确证书启动节点时出错。“别名cordaclienttls下没有证书链”
- android - Android上的ANR警告onLayout时间太长
- javascript - JavaScript 延迟倒计时
- python - 由于gevent导致heroku应用程序错误
- amazon-web-services - Connect to AWS Lighsail instance on port 9200 from AWS Lambda
- android - Publishing last tweet with twitter4j library - where exactly AsyncTask should be implemented?
- android - 使用android在SQLite数据库表中使用WHERE子句检索值