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

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
主站蜘蛛池模板: 芜湖县| 蕲春县| 宁武县| 前郭尔| 乌兰县| 余庆县| 颍上县| 金山区| 宣武区| 澄城县| 马山县| 湖南省| 双桥区| 江孜县| 乐安县| 长葛市| 海城市| 长葛市| 侯马市| 沧州市| 婺源县| 平罗县| 怀化市| 马山县| 麻江县| 那曲县| 绵竹市| 深泽县| 会昌县| 宝清县| 滕州市| 象州县| 那坡县| 论坛| 潞城市| 岳普湖县| 泰州市| 克东县| 高密市| 黄浦区| 曲周县|