@Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off http .httpBasic().and() .apply(new UrlAuthorizationConfigurer(getApplicationContext())).getRegistry() .mvcMatchers("/path").hasRole("ADMIN"); // @formatter:on }
/** * Adds a mapping of the {@link RequestMatcher} instances to the * {@link ConfigAttribute} instances. * @param requestMatchers the {@link RequestMatcher} instances that should map to the * provided {@link ConfigAttribute} instances * @param configAttributes the {@link ConfigAttribute} instances that should be mapped * by the {@link RequestMatcher} instances * @return the {@link ExpressionUrlAuthorizationConfigurer} for further customizations */ private StandardInterceptUrlRegistry addMapping( Iterable<? extends RequestMatcher> requestMatchers, Collection<ConfigAttribute> configAttributes) { for (RequestMatcher requestMatcher : requestMatchers) { REGISTRY.addMapping(new AbstractConfigAttributeRequestMatcherRegistry.UrlMapping( requestMatcher, configAttributes)); } return REGISTRY; }
public UrlAuthorizationConfigurer(ApplicationContext context) { this.REGISTRY = new StandardInterceptUrlRegistry(context); }
/** * Creates the {@link FilterInvocationSecurityMetadataSource} to use. The * implementation is a {@link DefaultFilterInvocationSecurityMetadataSource}. * * @param http the builder to use */ @Override FilterInvocationSecurityMetadataSource createMetadataSource(H http) { return new DefaultFilterInvocationSecurityMetadataSource( REGISTRY.createRequestMap()); }
/** * Adds a mapping of the {@link RequestMatcher} instances to the * {@link ConfigAttribute} instances. * @param requestMatchers the {@link RequestMatcher} instances that should map to the * provided {@link ConfigAttribute} instances * @param configAttributes the {@link ConfigAttribute} instances that should be mapped * by the {@link RequestMatcher} instances * @return the {@link ExpressionUrlAuthorizationConfigurer} for further customizations */ private StandardInterceptUrlRegistry addMapping( Iterable<? extends RequestMatcher> requestMatchers, Collection<ConfigAttribute> configAttributes) { for (RequestMatcher requestMatcher : requestMatchers) { REGISTRY.addMapping(new AbstractConfigAttributeRequestMatcherRegistry.UrlMapping( requestMatcher, configAttributes)); } return REGISTRY; }
public UrlAuthorizationConfigurer(ApplicationContext context) { this.REGISTRY = new StandardInterceptUrlRegistry(context); }
/** * Creates the {@link FilterInvocationSecurityMetadataSource} to use. The * implementation is a {@link DefaultFilterInvocationSecurityMetadataSource}. * * @param http the builder to use */ @Override FilterInvocationSecurityMetadataSource createMetadataSource(H http) { return new DefaultFilterInvocationSecurityMetadataSource( REGISTRY.createRequestMap()); }
/** * Adds a mapping of the {@link RequestMatcher} instances to the * {@link ConfigAttribute} instances. * @param requestMatchers the {@link RequestMatcher} instances that should map to the * provided {@link ConfigAttribute} instances * @param configAttributes the {@link ConfigAttribute} instances that should be mapped * by the {@link RequestMatcher} instances * @return the {@link ExpressionUrlAuthorizationConfigurer} for further customizations */ private StandardInterceptUrlRegistry addMapping( Iterable<? extends RequestMatcher> requestMatchers, Collection<ConfigAttribute> configAttributes) { for (RequestMatcher requestMatcher : requestMatchers) { REGISTRY.addMapping(new AbstractConfigAttributeRequestMatcherRegistry.UrlMapping( requestMatcher, configAttributes)); } return REGISTRY; }
public UrlAuthorizationConfigurer(ApplicationContext context) { this.REGISTRY = new StandardInterceptUrlRegistry(context); }
/** * Creates the {@link FilterInvocationSecurityMetadataSource} to use. The * implementation is a {@link DefaultFilterInvocationSecurityMetadataSource}. * * @param http the builder to use */ @Override FilterInvocationSecurityMetadataSource createMetadataSource(H http) { return new DefaultFilterInvocationSecurityMetadataSource( REGISTRY.createRequestMap()); }
@Override protected void configure(HttpSecurity http) throws Exception { http .apply(new UrlAuthorizationConfigurer<>(getApplicationContext())).getRegistry() .antMatchers("/users**", "/sessions/**").hasRole("USER") .antMatchers("/signup").hasRole("ANONYMOUS") .anyRequest().hasRole("USER"); }
@Override public void configure(HttpSecurity http) throws Exception { // @formatter:off http .apply(new UrlAuthorizationConfigurer<>(null)).getRegistry() .anyRequest().anonymous(); // @formatter:on } }
@Override protected void configure(HttpSecurity http) throws Exception { // @formatter:off http .httpBasic().and() .apply(new UrlAuthorizationConfigurer(getApplicationContext())).getRegistry() .mvcMatchers("/path").servletPath("/spring").hasRole("ADMIN"); // @formatter:on }