feat(security): 实现JWT认证与授权功能

重构用户登录服务,引入Spring Security和JWT认证机制
- 新增JwtUtils工具类处理JWT生成与验证
- 添加JwtAuthenticationFilter拦截请求验证token
- 实现UserDetailsService从数据库加载用户信息
- 创建AuthController处理登录请求返回JWT
- 重构用户角色权限相关接口,支持基于角色的访问控制
- 移除旧的安全配置,启用新的SecurityConfig
- 新增LoginResponse DTO替代旧的LoginUser
- 优化用户密码加密存储,使用BCryptPasswordEncoder
This commit is contained in:
qingfeng1121
2025-12-04 14:03:29 +08:00
parent d99580f0c9
commit 20f8a9d132
20 changed files with 970 additions and 320 deletions

View File

@@ -6,7 +6,7 @@
package com.qf.backend.service;
import com.qf.backend.common.Result;
import com.qf.backend.dto.LoginUser;
import com.qf.backend.dto.LoginResponse;
/**
* 用户登录服务接口
@@ -16,7 +16,7 @@ public interface UserLoginService {
* 用户登录
* @param username 用户名
* @param password 密码
* @return 登录结果
* @return 登录结果包含登录状态、token等信息
*/
Result<LoginUser> login(String username, String password);
Result<LoginResponse> login(String username, String password);
}