1

我有一个spring boot项目,需要认证才能访问项目,我使用的是OAuth2,这是我的配置:

@Override
public void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers(HttpMethod.OPTIONS).permitAll()
            .antMatchers("/rest/api/**").authenticated();
}

我确实permitAll()允许访问 html 文件并保护了我的 rest 控制器 (/rest/api/),我也在使用Spring Data Rest,它会在没有身份验证的情况下公开所有实体,因此任何未经身份验证的用户都可以访问它localhost:8080/entityName

我不能做这样的事情:antMatchers("/**").authenticated(),因为服务器会阻止对 IHM 的访问,所以如何保护实体不被暴露而不删除Spring .Data Rest

4

0 回答 0