【发布时间】:2019-02-21 19:04:12
【问题描述】:
我们有一个 Springboot 2.0.x 和 Angular 6 多模块应用程序,使用 OAuth2 标准的 OpenID Connect 1.0 实现作为安全性。 初始安全工作、身份验证和授权,并登陆主页。但由于某种原因,我们的 POST 和 DELETE REST 调用正在获得 403 Forbidden 状态代码,用于经过身份验证和授权的用户。 GET 调用不受影响,仍然有效。
有人对此有任何想法吗? 我们没有设置任何角色来过滤任何用户可以做的事情。 只是所有用户,一旦经过身份验证和授权,就可以发布、删除和获取。
这是安全配置:
@Override
public void configure(WebSecurity web) throws Exception {
System.out.println("Error!!/resources/**");
web.ignoring().antMatchers("/resources/**");
}
@Bean
public OpenIdConnectFilter myFilter() {
final OpenIdConnectFilter filter = new OpenIdConnectFilter("/auth/sso/callback");
filter.setRestTemplate(restTemplate);
return filter;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.addFilterAfter(new OAuth2ClientContextFilter(), AbstractPreAuthenticatedProcessingFilter.class)
.addFilterAfter(myFilter(), OAuth2ClientContextFilter.class)
.httpBasic().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/auth/sso/callback"))
// .httpBasic().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/google-login"))
.and()
.authorizeRequests()
.antMatchers("/errorPage").permitAll()
.anyRequest().authenticated()
;
// @formatter:on
}
POST 签名:
@PostMapping("/spreadsheet/upload/{uploader}/{filename}")
public ResponseEntity<?> uploadSpreadsheet(@RequestBody MultipartFile file, @PathVariable("uploader") String uploader, @PathVariable("filename") String filename) {
删除签名:
@DeleteMapping("/spreadsheet/{uploader}/{filename}")
public ResponseEntity<?> deleteUploadedSpreadsheet(@PathVariable(value = "uploader") String uploader, @PathVariable String filename) {
【问题讨论】:
标签: angular spring-boot spring-security oauth-2.0 openid-connect