hasRole should not be called on a string with "ROLE_" prefix (#6353)
Removed "ROLE_" from UrlAuthorizationConfigurer This fixes IllegalArgumentException: ROLE_ANONYMOUS should not start with ROLE_ since ROLE_
This commit is contained in:
parent
5fbf9532e1
commit
d099a62a6f
|
@ -344,7 +344,7 @@ public final class UrlAuthorizationConfigurer<H extends HttpSecurityBuilder<H>>
|
|||
* @return the {@link UrlAuthorizationConfigurer} for further customization
|
||||
*/
|
||||
public StandardInterceptUrlRegistry anonymous() {
|
||||
return hasRole("ROLE_ANONYMOUS");
|
||||
return hasRole("ANONYMOUS");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
* @author M.S. Dousti
|
||||
*
|
||||
*/
|
||||
public class UrlAuthorizationConfigurerTests {
|
||||
|
@ -203,6 +204,24 @@ public class UrlAuthorizationConfigurerTests {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void anonymousUrlAuthorization() {
|
||||
loadConfig(AnonymousUrlAuthorizationConfig.class);
|
||||
}
|
||||
|
||||
@EnableWebSecurity
|
||||
@Configuration
|
||||
static class AnonymousUrlAuthorizationConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
// @formatter:off
|
||||
http
|
||||
.apply(new UrlAuthorizationConfigurer<>(null)).getRegistry()
|
||||
.anyRequest().anonymous();
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
|
||||
public void loadConfig(Class<?>... configs) {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(configs);
|
||||
|
|
Loading…
Reference in New Issue