【发布时间】:2021-09-03 05:34:33
【问题描述】:
在我的WebSecurityConfigurerAdapter 中,我使用了以下方法:
private final AuthenticationProvider authenticationProvider;
private final JWTFilter jwtFilter;
@Override
protected void configure(AuthenticationManagerBuilder auth) {
auth.authenticationProvider(authenticationProvider);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.cors().disable()
.authorizeRequests()
.antMatchers("/graphql").permitAll()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.addFilterBefore(jwtFilter, RequestHeaderAuthenticationFilter.class); // Filter
}
但是,在我的 GraphQLMutationResolver 中,我无法访问以下方法(错误代码:403 - 无日志):
@PreAuthorize("isAnonymous()")
public User registerUser(String email, String passwordHash, String associationLocation) throws ChangeSetPersister.NotFoundException {
return userService.registerUser(email, passwordHash, associationService.findAssociationByPlaceName(associationLocation));
}
关于安全配置的任何想法? - @PreAuthorize("isAnonymous()")-Part 是否正确?
【问题讨论】:
-
在您的
application.properties文件中添加属性logging.level.spring.framework.security=TRACE。这有助于查看日志,您可以将其添加到问题中
标签: spring spring-boot spring-security graphql