[bs-138] Make it easy to secure only the management endpoints

Example: web UI with publicly available static assets

    # application.properties:
    security.ignored: /css/**,/script/**

Example: web UI with publicly available everything, but secure
management endpoints.

    # application.properties:
    # Empty path for basic security (default is /**)
    security.basic.path=

[Fixes #50721675]
This commit is contained in:
Dave Syer
2013-05-30 15:37:49 +01:00
parent 7b0ec252dd
commit e011312c68
12 changed files with 244 additions and 46 deletions

View File

@@ -23,6 +23,7 @@ import org.springframework.bootstrap.bind.PropertiesConfigurationFactory;
import org.springframework.bootstrap.context.annotation.EnableConfigurationPropertiesImportSelector.ConfigurationPropertiesHolder;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.env.PropertySources;
import org.springframework.validation.Validator;
@@ -40,6 +41,8 @@ public class PropertySourcesBindingPostProcessor implements BeanPostProcessor {
private ConversionService conversionService;
private DefaultConversionService defaultConversionService = new DefaultConversionService();
/**
* @param propertySources
*/
@@ -81,7 +84,10 @@ public class PropertySourcesBindingPostProcessor implements BeanPostProcessor {
target);
factory.setPropertySources(this.propertySources);
factory.setValidator(this.validator);
factory.setConversionService(this.conversionService);
// If no explicit conversion service is provided we add one so that (at least)
// comma-separated arrays of convertibles can be bound automatically
factory.setConversionService(this.conversionService == null ? this.defaultConversionService
: this.conversionService);
String targetName = null;
if (annotation != null) {
factory.setIgnoreInvalidFields(annotation.ignoreInvalidFields());

View File

@@ -48,6 +48,15 @@ public class EnableConfigurationPropertiesTests {
assertEquals("foo", this.context.getBean(TestProperties.class).getName());
}
@Test
public void testArrayPropertiesBinding() {
this.context.register(TestConfiguration.class);
TestUtils.addEnviroment(this.context, "name:foo", "array:1,2,3");
this.context.refresh();
assertEquals(1, this.context.getBeanNamesForType(TestProperties.class).length);
assertEquals(3, this.context.getBean(TestProperties.class).getArray().length);
}
@Test
public void testPropertiesBindingWithoutAnnotation() {
this.context.register(MoreConfiguration.class);
@@ -186,6 +195,7 @@ public class EnableConfigurationPropertiesTests {
@ConfigurationProperties
protected static class TestProperties {
private String name;
private int[] array;
public String getName() {
return this.name;
@@ -194,6 +204,14 @@ public class EnableConfigurationPropertiesTests {
public void setName(String name) {
this.name = name;
}
public void setArray(int... values) {
this.array = values;
}
public int[] getArray() {
return this.array;
}
}
protected static class MoreProperties {