use of org.springframework.security.web.SecurityFilterChain in project motech by motech.
the class MotechProxyManagerBundleIT method testProxyHasDefaultSecurityChains.
@Test
public void testProxyHasDefaultSecurityChains() {
FilterChainProxy filterChainProxy = proxyManager.getFilterChainProxy();
List<SecurityFilterChain> filterChains = filterChainProxy.getFilterChains();
assertTrue(filterChains.size() > 0);
}
use of org.springframework.security.web.SecurityFilterChain in project motech by motech.
the class MotechProxyManager method updateSecurityChain.
/**
* Updates security chain with given {@link org.motechproject.security.domain.MotechURLSecurityRule}
*
* @param securityRules list that contains new security rules
*/
private void updateSecurityChain(List<MotechURLSecurityRule> securityRules) {
LOGGER.debug("Updating security chain");
// sort rules by priority descending
TreeSet<MotechURLSecurityRule> sortedRules = new TreeSet<>(new SecurityRuleComparator());
sortedRules.addAll(securityRules);
List<SecurityFilterChain> newFilterChains = new ArrayList<>();
for (MotechURLSecurityRule securityRule : sortedRules) {
if (securityRule.isActive() && !securityRule.isDeleted()) {
LOGGER.debug("Creating SecurityFilterChain for: {}", securityRule.getPattern());
for (HTTPMethod method : securityRule.getMethodsRequired()) {
newFilterChains.add(securityRuleBuilder.buildSecurityChain(securityRule, method));
}
LOGGER.debug("Created SecurityFilterChain for: {}", securityRule.getPattern());
}
}
proxy = new FilterChainProxy(newFilterChains);
LOGGER.debug("Updated security chain.");
}
use of org.springframework.security.web.SecurityFilterChain in project spring-boot by spring-projects.
the class ManagementWebSecurityAutoConfigurationTests method backOffIfRemoteDevToolsSecurityFilterChainIsPresent.
@Test
void backOffIfRemoteDevToolsSecurityFilterChainIsPresent() {
this.contextRunner.withUserConfiguration(TestRemoteDevToolsSecurityFilterChainConfig.class).run((context) -> {
SecurityFilterChain testSecurityFilterChain = context.getBean("testSecurityFilterChain", SecurityFilterChain.class);
SecurityFilterChain testRemoteDevToolsSecurityFilterChain = context.getBean("testRemoteDevToolsSecurityFilterChain", SecurityFilterChain.class);
List<SecurityFilterChain> orderedSecurityFilterChains = context.getBeanProvider(SecurityFilterChain.class).orderedStream().collect(Collectors.toList());
assertThat(orderedSecurityFilterChains).containsExactly(testRemoteDevToolsSecurityFilterChain, testSecurityFilterChain);
assertThat(context).doesNotHaveBean(ManagementWebSecurityAutoConfiguration.class);
});
}
use of org.springframework.security.web.SecurityFilterChain in project spring-boot by spring-projects.
the class OAuth2ResourceServerAutoConfigurationTests method getBearerTokenFilter.
private Filter getBearerTokenFilter(AssertableWebApplicationContext context) {
FilterChainProxy filterChain = (FilterChainProxy) context.getBean(BeanIds.SPRING_SECURITY_FILTER_CHAIN);
List<SecurityFilterChain> filterChains = filterChain.getFilterChains();
List<Filter> filters = filterChains.get(0).getFilters();
return filters.stream().filter((f) -> f instanceof BearerTokenAuthenticationFilter).findFirst().orElse(null);
}
use of org.springframework.security.web.SecurityFilterChain in project spring-boot by spring-projects.
the class CloudFoundryActuatorAutoConfigurationTests method cloudFoundryPathsIgnoredBySpringSecurity.
@Test
void cloudFoundryPathsIgnoredBySpringSecurity() {
this.contextRunner.withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id").run((context) -> {
FilterChainProxy securityFilterChain = (FilterChainProxy) context.getBean(BeanIds.SPRING_SECURITY_FILTER_CHAIN);
SecurityFilterChain chain = securityFilterChain.getFilterChains().get(0);
MockHttpServletRequest request = new MockHttpServletRequest();
request.setServletPath("/cloudfoundryapplication/my-path");
assertThat(chain.getFilters()).isEmpty();
assertThat(chain.matches(request)).isTrue();
request.setServletPath("/some-other-path");
assertThat(chain.matches(request)).isFalse();
});
}
Aggregations