-
修改默认用户名/密码方法
使用管理后台更改密码
使用数据库增删改用户或密码
1 获取加密的密码字符串:
pox依赖:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring‐security‐core</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
程序代码
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
public class PasswordEncoderUtil {
public static void main(String[] args) {
String encode = new BCryptPasswordEncoder().encode("456");
System.out.println(encode);
}
}
加密的密码字符串:$2a$10$drSTWHglWb3twzBPCWlouuyKEL9NKHmJ4nvdKAvqDDCt5zIgsia9C
2 数据库执行语句,增加用户
INSERT INTO users (username, password, enabled) VALUES ('nacos1',
'$2a$10$drSTWHglWb3twzBPCWlouuyKEL9NKHmJ4nvdKAvqDDCt5zIgsia9C', TRUE);
INSERT INTO roles (username, role) VALUES ('nacos1', 'ROLE_ADMIN');
关闭登录功能
找到配置文件${nacoshome}/conf/application.properties , 替换以下内容即可。
## spring security config
### turn off security
spring.security.enabled=false
management.security=false
security.basic.enabled=false
nacos.security.ignore.urls=/**
#nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.
ico,/consolefe/
public/**,/v1/auth/login,/v1/console/health,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**