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

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
主站蜘蛛池模板: 沂源县| 常山县| 巴林左旗| 江华| 昌平区| 桂平市| 凌源市| 定州市| 灵川县| 突泉县| 德格县| 乐安县| 黔东| 乌拉特中旗| 富蕴县| 阳谷县| 那曲县| 札达县| 卫辉市| 榕江县| 行唐县| 闽侯县| 徐闻县| 凌云县| 汕尾市| 建始县| 大厂| 陵川县| 泗阳县| 汝阳县| 花垣县| 双流县| 纳雍县| 金堂县| 龙岩市| 青冈县| 南阳市| 乌拉特中旗| 尼勒克县| 阳曲县| 治多县|