Springcloud security settings for application Configuration Center Config

Source: Internet
Author: User
Tags decrypt

Springcloud security settings for application Configuration Center Config

In Springcloud application development, in order to facilitate the online management of our configuration files, usually with a configuration center config-server, which hosts some of the application's configuration files, these profiles are configured with many of our account information: MySQL, Redis, Accounts and passwords for MongoDB, RABBITMQ, and so on. The account information involved, we must guarantee how to ensure its security.

1. Ensure the security of the container file access, that is, to ensure that all network resource requests are required to log in

With the security of Springboot configuration properties, configuring Security.user.name and Security.user.password can initially achieve the effect of secure access. Configuration: In Application.yml, configure the following:

The security of the Springboot configuration attribute plus the following is better:
Security:  basic:    true

Increased in pom dependency

Security dependency

When you restart Config-server and then access the file resource through a URL,

Security Secure Login Page * * *: If the URL is called directly, then you need to add parameters in the URL, add in headers inside, Authorization:basic *************=********* After Base64 to the user name password encryption, get it can be logged in the security login page above, F12 Open, find the request headers inside. Or use the Postman Test tool to enter the username and password, to headers view.

2. Encrypt the password in all configuration files in the configuration to ensure its redaction

Springcloud's Configuration Service Center has the Decrypt/encrypt function, can encrypt the original text into ciphertext, also can decrypt the ciphertext into the original text. Its working principle is, first of all the original password and so on through the developer set key and Springcloud in the encrypt encryption into ciphertext, with a cipher to replace the source code center of the original password; When the project starts loading the configuration center, The ciphertext is automatically decrypted into the original text and loaded into the context of spring (the spring context caches the original text rather than the ciphertext). The following steps are described:

A. First go to http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html to download and unzip the file, you can see Local_ Policy.jar and Us_export_policy.jar and Readme.txt, if the JRE is installed, place two jar files in the%jre_home%\lib\security file directory, if the JDK is installed, The two jar files are also placed in the%jdk_home%\jre\lib\security file directory. (JDK8 Environment)

B. Set the encryption key to configure the Security.key=your key in the Application.yml file in the Config-server microservices

Configure keys

C. Restart the Configuration Center service and you will find

Security Policy encryption/decryption method discovery

D. Encrypt the original password

Encrypt with postman tool

E. Copy encrypted ciphertext, plus {cipher} identity, edit in config file (cannot have any characters in the middle of identifiers and ciphertext, including spaces)

Editing a configuration file

After the fix, all the passwords in our configuration file are ciphertext, even if the configuration file is hosted on GitHub, others can not see what the original password is.



Transferred from: https://www.jianshu.com/p/93592860993d

Springcloud security settings for application Configuration Center Config

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.