Closed
Description
Spring Security ships with converters for reading RSA public and private key files. These are applied to the application context's ConversionService
through a BeanFactoryPostProcessor
.
This allows an application to do things like:
@ConfigurationProperties("jwt")
public class Jwt {
private RSAPublicKey key;
}
to retrieve keys from configuration.
This doesn't work, though, if a Spring Boot application includes auto-configuration that includes a @ConfigurationPropertiesBinding
for another set of properties. It appears this may change the loading order such that Spring Security's RsaKeyConversionServicePostProcessor
doesn't get applied to Boot's conversion service.
I believe the correct enhancement is for Spring Boot to add @ConfigurationPropertiesBinding
@Bean
s to Security's auto configuration like so:
@Bean
@ConfigurationPropertiesBinding
Converter<String, RSAPrivateKey> privateKeys() {
return new ResourceKeyConverterAdapter<>(RsaKeyConverters.pkcs8());
}
@Bean
@ConfigurationPropertiesBinding
Converter<String, RSAPublicKey> publicKeys() {
return new ResourceKeyConverterAdapter<>(RsaKeyConverters.x509());
}