官术网_书友最值得收藏!

Securing a microservice with basic security

Adding basic authentication to Spring Boot is pretty simple. The pom.xml file will have the following dependency. This will include the necessary Spring security library files:

    <dependency>         
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

This will, by default, assume that basic security is required for this project. Run the application, and test it with a browser. The browser will ask for the login username and password.

The default basic authentication assumes the . The default password will be printed on the console at startup:

    Using default security password: a7d08e07-ef5f-4623-b86c-
63054d25baed

Alternately, the username and password can be added in application.properties as shown next:

    security.user.name=guest
security.user.password=guest123
主站蜘蛛池模板: 西平县| 来凤县| 海安县| 陆良县| 遂平县| 新巴尔虎左旗| 安福县| 任丘市| 香河县| 芒康县| 慈溪市| 景洪市| 长丰县| 大厂| 达拉特旗| 石景山区| 德格县| 宁德市| 琼海市| 红河县| 延川县| 垣曲县| 宝应县| 枞阳县| 沈丘县| 仙游县| 田林县| 湟源县| 怀远县| 阿鲁科尔沁旗| 桑植县| 元阳县| 息烽县| 麟游县| 会东县| 双峰县| 洞头县| 巴马| 湘西| 康马县| 察哈|