[英]Spring boot Oauth2 - Security incompatibility between Authorization and Resource server
[英]Spring boot security, oauth2 and thymeleaf static resource cannot be found
我在Resource然后静态文件夹下添加了我的css和js。 当我访问路径“forgotpassword”时,我的所有静态资源都被正确加载。 在此输入图像描述
但是,当我尝试访问相同的路径但这次使用尾部斜杠“forgotpassword /”时,我的所有静态资源都没有加载。 我得到状态404未找到此处输入图像描述
这是我的安全配置
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Order(-20)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
@Qualifier("customUserDetailsService")
UserDetailsService userDetailsService;
static private Logger logger = LoggerFactory.getLogger(Oauth2AuthserverApplication.class);
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
}
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests()
.antMatchers("/resources/**", "/forgotpassword/**")
.permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.requestMatchers().antMatchers("/forgotpassword/**", "/login", "/oauth/authorize", "/oauth/confirm_access");
// @formatter:on
}
}
对于css,这是我必须做的th:href="@{/css/Default/css/style.css}"
和js th:src="@{/js/jquery/dist/jquery.min.js}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.