Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native hint for the users JDBC schema #11907

Closed
willemvd opened this issue Sep 27, 2022 · 1 comment
Closed

Add native hint for the users JDBC schema #11907

willemvd opened this issue Sep 27, 2022 · 1 comment
Assignees
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Milestone

Comments

@willemvd
Copy link

Describe the bug
When using Spring Boot 3.0.0-M5 to build a native application with the ./mvnw -Pnative package and the auth.jdbcAuthentication().withDefaultSchema() option set on the JdbcUserDetailsManagerConfigurer, the application is compiled as native application but gives a runtime exception.
The exception is:
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/security/core/userdetails/jdbc/users.ddl] cannot be opened because it does not exist

This seems to be related to the https://github.com/spring-projects/spring-security/blob/main/core/src/main/java/org/springframework/security/aot/hint/CoreSecurityRuntimeHints.java which is missing the DDL schema as resource. This causes GraalVM to not include the DDL schema when building the native application.

Leaving out the .withDefaultSchema() part, the application is starting without issues.

To Reproduce
Start a Spring Boot 3.0.0-M5 application and include the Spring Security module.
Add a Bean configuration which returns the UserDetailsManger created from the AuthenticationManagerBuilder. Set it with:
return auth.jdbcAuthentication().withDefaultSchema().getUserDetailsService()

Expected behavior
The application should start with loading the default schema, into the datasource given, when configured using the .withDefaultSchema() option.

Sample
https://github.com/willemvd/jdbc-security-default-schema-native

@willemvd willemvd added status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Sep 27, 2022
@marcusdacoregio marcusdacoregio self-assigned this Sep 28, 2022
@marcusdacoregio marcusdacoregio added in: config An issue in spring-security-config and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 28, 2022
@marcusdacoregio marcusdacoregio added this to the 6.0.x milestone Sep 28, 2022
@marcusdacoregio marcusdacoregio added type: enhancement A general enhancement and removed type: bug A general bug labels Sep 28, 2022
@marcusdacoregio marcusdacoregio changed the title Native application fails to start when using JdbcUserDetailsManagerConfigurer withDefaultSchema Add native hint for the default JDBC schema Sep 29, 2022
@marcusdacoregio marcusdacoregio added in: core An issue in spring-security-core and removed in: config An issue in spring-security-config labels Sep 29, 2022
@marcusdacoregio marcusdacoregio modified the milestones: 6.0.x, 6.0.0-RC1 Sep 29, 2022
@marcusdacoregio marcusdacoregio changed the title Add native hint for the default JDBC schema Add native hint for the users JDBC schema Sep 29, 2022
@marcusdacoregio
Copy link
Contributor

Thank you for the report @willemvd.

This is now fixed in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Projects
Status: Done
Development

No branches or pull requests

2 participants