alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.21k stars 12.83k forks source link

How to use Jasypt to encrypt the password in Nacos #12303

Closed mitht closed 3 months ago

mitht commented 3 months ago

SpringBoot 2.7.10

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    <version>2021.0.4.0</version>
</dependency>

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
    <version>2021.0.4.0</version>
</dependency>

dependency>
    <groupId>com.github.ulisesbocchio</groupId>
    <artifactId>jasypt-spring-boot-starter</artifactId>
    <version>3.0.3</version>
</dependency>

The bootstrap.properties configuration is as follows:

jasypt.encryptor.password=123456 jasypt.encryptor.algorithm=PBEWithHmacSHA512AndAES_128

spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 spring.cloud.nacos.discovery.username=admin spring.cloud.nacos.discovery.password=ENC(qTE6iEN1qFBmCWeOeCmxoJmlrWPhBZS9QZ3JlAI)

Using the encrypted password to connect to Nacos results in a 403 error.

com.alibaba.nacos.api.exception.NacosException: http error, code=403,msg-user not found! , dataId-app-application-dev.yml,group-DEFAULIGROUP,tenant=1234dddddddddd

KomachiSion commented 3 months ago

Please submit issue to spring cloud alibaba.

Nacos only recived the configuration. jasypt decode password is spring logic handler.