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

Nacos @NacosValue with autoRefreshed Attribute Returns Encrypted String When Updating Configuration #402

Open
HermaeusMoraMainTank opened this issue Sep 14, 2024 · 4 comments

Comments

@HermaeusMoraMainTank
Copy link

HermaeusMoraMainTank commented Sep 14, 2024

Description
When using the @NacosValue annotation with the autoRefreshed attribute in a Spring Boot application, the updated configuration value from Nacos is returned as an encrypted string instead of being decrypted. This issue occurs with Nacos version 2.0.4 and Jasypt version 3.0.5.
Steps to Reproduce

  1. Configure a property in Nacos, such as ${third-auth.wx.mp.secret}, and encrypt its value.
  2. Use the @NacosValue annotation in your Spring Boot application as follows:
    @NacosValue(value = "${third-auth.wx.mp.secret}", autoRefreshed = true) private String secret;
  3. Start the Spring Boot application.
  4. Update the configuration value in Nacos.
  5. Observe that the updated value is returned as an encrypted string instead of the decrypted value.

Expected Behavior
The configuration value should be automatically decrypted and updated in the application when it is refreshed, reflecting the decrypted value.

Actual Behavior
The configuration value remains encrypted even after updating the configuration in Nacos.

Current Workaround
Using new SpringApplicationBuilder().environment(new StandardEncryptableEnvironment()).sources(YourApplicationClass.class).run(args); resolves the issue by ensuring that the environment is properly configured to handle encrypted properties.

Potential Solution
Is there an alternative solution to ensure that encrypted properties are correctly decrypted and updated when using the @NacosValue annotation with the autoRefreshed attribute, aside from configuring the environment with StandardEncryptableEnvironment?

Environment
Nacos Version: 2.0.4
Jasypt Version: 3.0.5
Spring Boot Version: 2.7.10

@shiva-git21
Copy link

Can I look into this issue ?

@HermaeusMoraMainTank
Copy link
Author

HermaeusMoraMainTank commented Dec 4, 2024 via email

@libin-tech
Copy link

@HermaeusMoraMainTank
you try @SpringBootApplication Header add
@NacosPropertySource(dataId = "your third-auth.wx.mp.secret data-id", autoRefreshed = true)

@HermaeusMoraMainTank
Copy link
Author

HermaeusMoraMainTank commented Dec 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants