提交 223bc159 编写于 作者: alvachien's avatar alvachien

Make the login work

上级 53e08eab
......@@ -20,16 +20,16 @@ public class UserAccount {
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(nullable = false, unique = true, length = 50, columnDefinition = "nvarchar(50)")
@Column(nullable = false, unique = true, length = 255, columnDefinition = "nvarchar(255)")
private String username;
@Column(nullable = false, length = 50, columnDefinition = "nvarchar(50)")
@Column(nullable = false, length = 255, columnDefinition = "nvarchar(255)")
private String password;
@Column(nullable = false)
private boolean active;
@OneToMany(mappedBy = "userAccount", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OneToMany(mappedBy = "userAccount", fetch = FetchType.EAGER, cascade = CascadeType.REMOVE)
private List<UserRole> userRoles;
public UserAccount() {
......
......@@ -22,7 +22,7 @@ public class UserRole implements GrantedAuthority {
@Column(nullable = false, length = 50)
private String name;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "useraccount_id", nullable = false)
private UserAccount userAccount;
......
-- From: https://docs.spring.io/spring-security/reference/servlet/appendix/database-schema.html
create table users(
username nvarchar(50) not null primary key,
password nvarchar(50) not null,
username nvarchar(255) not null primary key,
password nvarchar(255) not null,
enabled boolean not null
);
......@@ -18,11 +18,14 @@ This article adds the JPA implementations to client/authorization/authorization-
- [Add Roles to JWT Issued by Spring Authorization Server](https://www.appsdeveloperblog.com/add-roles-to-jwt-issued-by-new-spring-authorization-server/)
- [Role-based Access Control in Spring Authorization Server](https://www.appsdeveloperblog.com/role-based-access-control-in-spring-authorization-server/)
- [Spring Security: Authentication with a Database-backed UserDetailsService](https://www.baeldung.com/spring-security-authentication-with-a-database)
- [Password storage](https://docs.spring.io/spring-security/reference/features/authentication/password-storage.html)
- [Spring Security Architecture](https://docs.spring.io/spring-security/reference/servlet/architecture.html)
To be read?
- [Spring Security ACL](https://www.jianshu.com/p/b971b4e6ec16)
Dependencies:
- Java 17;
- Spring Boot 3.0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册