mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
[bs-153] Don't expose classes as resource
Made classpath:/[static,resourecs,public] available instead. Some sample apps had to change so probably some gs-* guides etc as well? [Fixes #51368907]
This commit is contained in:
parent
6c3fd2b2d0
commit
f0d5b8bbe3
@ -121,16 +121,12 @@ public class WebMvcAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// FIXME exposing the root classpath is a security risk
|
||||
// eg http://localhost:8080/org/springframework/bootstrap/Banner.class
|
||||
registry.addResourceHandler("/resources/**").addResourceLocations("/")
|
||||
.addResourceLocations("classpath:/META-INF/resources/")
|
||||
.addResourceLocations("classpath:/resources/")
|
||||
.addResourceLocations("classpath:/");
|
||||
registry.addResourceHandler("/**").addResourceLocations("/")
|
||||
.addResourceLocations("classpath:/META-INF/resources/")
|
||||
.addResourceLocations("classpath:/static/")
|
||||
.addResourceLocations("classpath:/");
|
||||
registry.addResourceHandler("/resources/**").addResourceLocations("/",
|
||||
"classpath:/META-INF/resources/", "classpath:/resources/",
|
||||
"classpath:/public/", "classpath:/static/");
|
||||
registry.addResourceHandler("/**").addResourceLocations("/",
|
||||
"classpath:/META-INF/resources/", "classpath:/resources/",
|
||||
"classpath:/static/", "classpath:/public/");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
@ -78,7 +78,7 @@ public class SampleWebUiApplicationTests {
|
||||
@Test
|
||||
public void testCss() throws Exception {
|
||||
ResponseEntity<String> entity = getRestTemplate().getForEntity(
|
||||
"http://localhost:8080/css/bootstrap.min.css", String.class);
|
||||
"http://localhost:8080/resources/css/bootstrap.min.css", String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("body"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user