Skip to content

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

@HermaeusMoraMainTank

Description

@HermaeusMoraMainTank

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions