Package com.bank.auth_service.config
Class KeyConfig
java.lang.Object
com.bank.auth_service.config.KeyConfig
Configuration class for RSA-based JWT encoder and decoder beans using Nimbus JOSE + JWT.
This class loads RSA public and private keys from application properties and uses them to:
- Sign JWT tokens with the private key (via
JwtEncoder
) - Verify JWT signatures with the public key (via
JwtDecoder
)
Note: This configuration uses asymmetric cryptography (RSA) and the RS256 algorithm (SHA-256 with RSA signature). The tokens are signed but not encrypted — anyone with the public key can verify the token, but its content is readable unless encrypted separately.
- Since:
- 1.0.0
- Version:
- 1.0.0, 06/23/2025
- Author:
- Fernando Cruz Cavina
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.oauth2.jwt.JwtDecoder
Creates a JwtDecoder bean using the configured RSA public key.org.springframework.security.oauth2.jwt.JwtEncoder
Creates a JwtEncoder bean using the configured RSA public and private keys.
-
Constructor Details
-
KeyConfig
public KeyConfig()
-
-
Method Details
-
jwtDecoder
@Bean public org.springframework.security.oauth2.jwt.JwtDecoder jwtDecoder()Creates a JwtDecoder bean using the configured RSA public key.- Returns:
- a JwtDecoder for verifying JWT tokens
-
jwtEncoder
@Bean public org.springframework.security.oauth2.jwt.JwtEncoder jwtEncoder()Creates a JwtEncoder bean using the configured RSA public and private keys.- Returns:
- a JwtEncoder for signing JWT tokens
-