Overview of Spring Security

1 installation

First put the Spring Boot security starter dependency package into pom.xml:

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

When the application starts, Spring Boot's automatic configuration function will detect that Spring Security is in the classpath, and then it will initialize some basic security configurations.

2 Basic usage

After the application is successfully launched, enter http://127.0.0.1:8080 in the browser, and you will enter the login page:

The default user name is user, and the password is randomly generated. It can be found in the application log file and looks like:

By adding Spring Security to the application, we will immediately have the following security features:

  1. All HTTP request paths require authentication;

  2. Authentication is achieved through the login page.

  3. The login account name is user and there is only one.

The following functions can be achieved with Spring Security:

  1. User authentication through a custom login page;

  2. You can define which certain request paths do not require verification, and some request paths require authentication. You can customize the security rules.

Guess you like

Origin blog.csdn.net/deniro_li/article/details/108892926