简体   繁体   English

Spring MVC默认身份验证如何添加用户/注册

[英]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") 当我在项目中包含spring-boot-starter-security时,它会自动创建一个新的数据库表“ users”,这使我相信,当尝试在登录页面上登录时,它将自动对该表中的条目进行身份验证(正确显示在“ /登录”下)

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. 由于该软件包已经随附了Login-Authentication,所以我希望我可以编写一种添加用户的方法,但是找不到有关该方法的信息。

I don't think spring-boot automatically create new users table in your database. 我认为spring-boot不会在数据库中自动创建新的users表。 It is the default UserDetailsService which as a single user with username user and random password. 这是默认的UserDetailsService ,作为具有用户名user和随机密码的单个用户。 You can modify it in application.properties file (I supposed you are using .proprites): 您可以在application.properties文件中修改它(我想您正在使用.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 有关更多详细信息并实施您已使用的UserDetailsS​​ervice,请在此处检查

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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