简体   繁体   中英

Spring MVC default Authentication How to add a user / registration

When I include spring-boot-starter-security in my project, it automatically creates a new database Table "users" which leads me to believe that it would automatically authenticate against entries in that table when trying to login on the login-page (which is correctly displayed under "/login")

My question is how I can add new users into this table -> what password encryption is used by default, or do I need to change it? Is there maybe a default registration page I can activate and then customize? Or do I need to write my own Login-Verification and then customize my registration to it?

Since the Login-Authentication seems to be already coming with the package I was hoping I could simply write a method to add users but I can't find information on how.

I don't think spring-boot automatically create new users table in your database. It is the default UserDetailsService which as a single user with username user and random password. You can modify it in application.properties file (I supposed you are using .proprites):

spring.security.user.name
spring.security.user.password

I do not think you will do this in production when you application can have multiple users.

For more detail and to implement your worn UserDetailsService, please check here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM