feat: 添加用户登录服务及JWT认证功能
refactor: 重构实体类并添加Lombok注解 docs: 更新数据库表结构文档 style: 清理无用代码并优化格式 fix: 修复用户详情服务中的联系方式更新方法 build: 更新pom.xml配置并添加Lombok插件 test: 添加用户登录测试用例 chore: 添加开发和生产环境配置文件
This commit is contained in:
57
src/main/java/com/qf/backend/config/SecurityConfig.java
Normal file
57
src/main/java/com/qf/backend/config/SecurityConfig.java
Normal file
@@ -0,0 +1,57 @@
|
||||
// /*
|
||||
// * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
// * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
// */
|
||||
// package com.qf.backend.config;
|
||||
|
||||
// import org.springframework.context.annotation.Bean;
|
||||
// import org.springframework.context.annotation.Configuration;
|
||||
// import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
// import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
// import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
// import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
// /**
|
||||
// * 安全配置类(仅开发 禁用安全认证)
|
||||
// *
|
||||
// * @author 30803
|
||||
// */
|
||||
// @Configuration
|
||||
// @EnableWebSecurity
|
||||
// public class SecurityConfig {
|
||||
|
||||
// @Bean
|
||||
// public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
// http
|
||||
// .authorizeHttpRequests(auth -> auth
|
||||
// .requestMatchers("/users/**").permitAll() // 公开路径
|
||||
// .requestMatchers("/admin/**").hasRole("ADMIN") // 需要 ADMIN 角色
|
||||
// .anyRequest().authenticated() // 其他请求需登录
|
||||
// )
|
||||
// .formLogin(form -> form
|
||||
// .loginPage("/login") // 自定义登录页(可选)
|
||||
// .permitAll()
|
||||
// )
|
||||
// .logout(logout -> logout
|
||||
// .permitAll()
|
||||
// );
|
||||
// return http.build();
|
||||
// }
|
||||
|
||||
// @Bean
|
||||
// public UserDetailsService userDetailsService() {
|
||||
// UserDetails user = User.withDefaultPasswordEncoder()
|
||||
// .username("user")
|
||||
// .password("123456")
|
||||
// .roles("USER")
|
||||
// .build();
|
||||
|
||||
// UserDetails admin = User.withDefaultPasswordEncoder()
|
||||
// .username("admin")
|
||||
// .password("admin123")
|
||||
// .roles("USER", "ADMIN")
|
||||
// .build();
|
||||
|
||||
// return new InMemoryUserDetailsManager(user, admin);
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user