Skip to content

Commit f3b2f31

Browse files
committed
Add runtime hints for CSS resource
1 parent bceefc0 commit f3b2f31

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

web/src/main/java/org/springframework/security/web/aot/hint/WebMvcSecurityRuntimeHints.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.springframework.aot.hint.RuntimeHints;
2121
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2222
import org.springframework.aot.hint.TypeReference;
23+
import org.springframework.core.io.ClassPathResource;
2324
import org.springframework.security.web.access.expression.WebSecurityExpressionRoot;
2425

2526
/**
@@ -40,6 +41,16 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
4041
TypeReference
4142
.of("org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler$SupplierCsrfToken"),
4243
MemberCategory.INVOKE_DECLARED_METHODS);
44+
45+
ClassPathResource css = new ClassPathResource("org/springframework/security/spring-security.css");
46+
if (css.exists()) {
47+
hints.resources().registerResource(css);
48+
}
49+
50+
ClassPathResource javascript = new ClassPathResource("org/springframework/security/spring-security.js");
51+
if (javascript.exists()) {
52+
hints.resources().registerResource(javascript);
53+
}
4354
}
4455

4556
}

web/src/test/java/org/springframework/security/web/aot/hint/WebMvcSecurityRuntimeHintsTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,10 @@ void supplierCsrfTokenHasHints() {
6262
.withMemberCategories(MemberCategory.INVOKE_DECLARED_METHODS)).accepts(this.hints);
6363
}
6464

65+
@Test
66+
void cssHasHints() {
67+
assertThat(RuntimeHintsPredicates.resource().forResource("org/springframework/security/spring-security.css"))
68+
.accepts(this.hints);
69+
}
70+
6571
}

0 commit comments

Comments
 (0)