server.port=8080
spring.datasource.hikari.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.hikari.jdbc-url=jdbc:mysql://서버주소 : 3306/
spring.datasource.hikari.username=java505_team5
spring.datasource.hikari.password=java505_team5_1234
spring.datasource.hikari.connection-test-query=SELECT 1
mybatis.configuration.map-underscore-to-camel-case=true
configuration / DatabaseConfig
package com.example.securitytest.configuration;
import com.zaxxer.hikari.HikariConfig;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import javax.sql.DataSource;
@Configuration
@RequiredArgsConstructor
@PropertySource("classpath:/application.properties")
public class DatabaseConfiguration {
private final ApplicationContext appContext;
@Bean
@ConfigurationProperties(prefix = "spring.datasource.hikari")
public HikariConfig hikariConfig(){
return new HikariConfig();
}
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
SqlSessionFactoryBean ssfb = new SqlSessionFactoryBean();
ssfb.setDataSource(dataSource);
ssfb.setMapperLocations(appContext.getResources("classpath:/sql/**/sql-*.xml"));
return ssfb.getObject();
}
@Bean
public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory ssf){
return new SqlSessionTemplate(ssf);
}
@Bean
@ConfigurationProperties(prefix = "mybatis.configuration")
public org.apache.ibatis.session.Configuration mybatisConfig(){
return new org.apache.ibatis.session.Configuration();
}
}
암호화 해준 걸 매치해서 true/ false 확인한다.
Dto 생성
package com.example.securitytest.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.HashSet;
import java.util.Set;
@AllArgsConstructor
@Data
@NoArgsConstructor
public class ClubMemberDto {
private String email;
private String password;
private String name;
private boolean fromSocial;
private Set<ClubMemberRole> roleSet = new HashSet<>();
public void addMemberRole(ClubMemberRole clubMemberRole){
roleSet.add(clubMemberRole);
}
}
ClubMemberRole 때문에 에러난다
package com.example.securitytest.dto;
public enum ClubMemberRole {
ADMIN, USER,MANAGER
}
사용자 요청