Skip to content

Commit

Permalink
修改密码长度限制为127
Browse files Browse the repository at this point in the history
  • Loading branch information
little3201 committed Mar 25, 2024
1 parent 9b9aea8 commit 080749c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.oauth2.jwt.JwtDecoder;
Expand All @@ -51,6 +52,7 @@
import java.security.KeyPairGenerator;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.List;
import java.util.UUID;

import static org.springframework.security.config.Customizer.withDefaults;
Expand Down Expand Up @@ -100,7 +102,11 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
@Bean
UserDetailsService userDetailsService(DataSource dataSource) {
JdbcUserDetailsManager jdbcUserDetailsManager = new JdbcUserDetailsManager(dataSource);
jdbcUserDetailsManager.createUser(User.withUsername("admin").password("123456").accountLocked(true).roles("ADMIN").build());
if (!jdbcUserDetailsManager.userExists("admin")) {
jdbcUserDetailsManager.createUser(User.withUsername("admin").password("123456").roles("ADMIN").build());
jdbcUserDetailsManager.addUserToGroup("admin", "manager");
}

return jdbcUserDetailsManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class User extends AuditMetadata {
/**
* password
*/
@Column(name = "password", nullable = false, length = 50)
@Column(name = "password", nullable = false, length = 127)
private String password;

/**
Expand Down
2 changes: 1 addition & 1 deletion hypervisor/src/main/resources/sql/table-ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ DROP TABLE IF EXISTS users;
CREATE TABLE users (
id bigserial PRIMARY KEY NOT NULL,
username varchar(50) UNIQUE NOT NULL,
password varchar(50) NOT NULL,
password varchar(127) NOT NULL,
firstname varchar(16),
lastname varchar(16),
avatar varchar(127),
Expand Down

0 comments on commit 080749c

Please sign in to comment.