2026-04-23 11:59:31 +08:00
|
|
|
|
package com.labelsys.backend.config;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
|
|
|
|
2026-05-13 23:29:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 安全配置类
|
|
|
|
|
|
*
|
|
|
|
|
|
* 配置安全相关的 Bean,如密码编码器等。
|
|
|
|
|
|
*/
|
2026-04-23 11:59:31 +08:00
|
|
|
|
@Configuration
|
|
|
|
|
|
public class SecurityBeanConfig {
|
|
|
|
|
|
|
2026-05-13 23:29:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 创建密码编码器
|
|
|
|
|
|
*
|
|
|
|
|
|
* <p>使用 BCrypt 算法对密码进行加密,BCrypt 是一种安全的密码哈希算法,
|
|
|
|
|
|
* 具有自动加盐和可配置的计算复杂度特性。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return BCryptPasswordEncoder 实例
|
|
|
|
|
|
*/
|
2026-04-23 11:59:31 +08:00
|
|
|
|
@Bean
|
|
|
|
|
|
public PasswordEncoder passwordEncoder() {
|
|
|
|
|
|
return new BCryptPasswordEncoder();
|
|
|
|
|
|
}
|
2026-05-13 23:29:43 +08:00
|
|
|
|
}
|