Skip to content

contribute graalvm native image hints for resources needed in spring security 3.4 #16153

@joshlong

Description

@joshlong

small regression in that the following Resources don't seem to exist when compiling to a graalvm native image


public static DefaultResourcesFilter css() {
    return new DefaultResourcesFilter(AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/default-ui.css"), new ClassPathResource("org/springframework/security/default-ui.css"), new MediaType("text", "css", StandardCharsets.UTF_8));
}

public static DefaultResourcesFilter webauthn() {
    return new DefaultResourcesFilter(AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/login/webauthn.js"), new ClassPathResource("org/springframework/security/spring-security-webauthn.js"), new MediaType("text", "javascript", StandardCharsets.UTF_8));

its easy to fix

@ImportRuntimehints(UiResourcesRuntimeHintsRegistrar.class)

and

static class UiResourcesRuntimeHintsRegistrar implements RuntimeHintsRegistrar {

    @Override
    public void registerHints(RuntimeHints hints, ClassLoader classLoader) {

       var resources = Set.of(new ClassPathResource("org/springframework/security/spring-security-webauthn.js"),
             new ClassPathResource("org/springframework/security/default-ui.css"));

       for (var r : resources)
          hints.resources().registerResource(r);

    }

}

it would be ideal if those hints were furnished as part of spring security, however

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions