-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
7decaef
commit d2f68b1
Showing
59 changed files
with
362 additions
and
148 deletions.
There are no files selected for viewing
Binary file modified
BIN
+0 Bytes
(100%)
contents/todoListAPI/hyeonseung/todolist/.gradle/8.4/checksums/checksums.lock
Binary file not shown.
Binary file added
BIN
+18.7 KB
contents/todoListAPI/hyeonseung/todolist/.gradle/8.4/checksums/md5-checksums.bin
Binary file not shown.
Binary file added
BIN
+19.3 KB
contents/todoListAPI/hyeonseung/todolist/.gradle/8.4/checksums/sha1-checksums.bin
Binary file not shown.
Binary file modified
BIN
+81.1 KB
(520%)
contents/todoListAPI/hyeonseung/todolist/.gradle/8.4/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
contents/todoListAPI/hyeonseung/todolist/.gradle/8.4/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified
BIN
+3.47 KB
(120%)
contents/todoListAPI/hyeonseung/todolist/.gradle/8.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
contents/todoListAPI/hyeonseung/todolist/.gradle/8.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file added
BIN
+19.5 KB
contents/todoListAPI/hyeonseung/todolist/.gradle/8.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
contents/todoListAPI/hyeonseung/todolist/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
contents/todoListAPI/hyeonseung/todolist/.gradle/buildOutputCleanup/cache.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#Mon May 20 18:55:02 KST 2024 | ||
#Mon May 27 04:36:59 KST 2024 | ||
gradle.version=8.4 |
Binary file modified
BIN
+198 Bytes
(100%)
contents/todoListAPI/hyeonseung/todolist/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
contents/todoListAPI/hyeonseung/todolist/.gradle/file-system.probe
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+3.74 KB
...nseung/todolist/build/classes/java/main/com/todolist/todolist/config/JwtTokenFilter.class
Binary file not shown.
Binary file added
BIN
+5.16 KB
...nseung/todolist/build/classes/java/main/com/todolist/todolist/config/SecurityConfig.class
Binary file not shown.
Binary file modified
BIN
+353 Bytes
(110%)
.../todolist/build/classes/java/main/com/todolist/todolist/controller/MemberController.class
Binary file not shown.
Binary file modified
BIN
+324 Bytes
(110%)
.../todolist/build/classes/java/main/com/todolist/todolist/domain/Member$MemberBuilder.class
Binary file not shown.
Binary file modified
BIN
+450 Bytes
(120%)
...API/hyeonseung/todolist/build/classes/java/main/com/todolist/todolist/domain/Member.class
Binary file not shown.
Binary file added
BIN
+1.12 KB
...stAPI/hyeonseung/todolist/build/classes/java/main/com/todolist/todolist/domain/Role.class
Binary file not shown.
Binary file added
BIN
+2.78 KB
...list/build/classes/java/main/com/todolist/todolist/security/CustomUserDetailService.class
Binary file not shown.
Binary file added
BIN
+5.87 KB
...ng/todolist/build/classes/java/main/com/todolist/todolist/security/JwtTokenProvider.class
Binary file not shown.
Binary file added
BIN
+710 Bytes
...eung/todolist/build/classes/java/main/com/todolist/todolist/security/PasswordConfig.class
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...nseung/todolist/build/classes/java/main/com/todolist/todolist/service/MemberService.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
contents/todoListAPI/hyeonseung/todolist/build/resources/main/application 2.properties
This file was deleted.
Oops, something went wrong.
15 changes: 8 additions & 7 deletions
15
contents/todoListAPI/hyeonseung/todolist/build/resources/main/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
spring.application.name=todolist | ||
|
||
## DB 설정 | ||
## DB ì¤ì | ||
|
||
# MySQL | ||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver | ||
|
||
# DB Source URL | ||
spring.datasource.url=jdbc:mysql://localhost:3306/todolist? | ||
spring.datasource.url=jdbc:mysql://localhost:3306/todolist | ||
#characterEncoding=UTF-8&serverTimezone=UTC | ||
spring.datasource.username=root | ||
spring.datasource.password=root | ||
|
||
# DDL(create,alter,drop) | ||
spring.jpa.hibernate.ddl-auto=update | ||
spring.jpa.hibernate.ddl-auto=create | ||
|
||
#sql 보여주기 | ||
#sql ë³´ì¬ì£¼ê¸° | ||
spring.jpa.show-sql=true | ||
|
||
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQLDialect | ||
spring.jpa.properties.hibernate.format_sql=true | ||
|
||
|
||
#DRIVER SETTING | ||
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect | ||
#spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect | ||
|
||
#SERVER PORT SETTING | ||
#server.port=UR_PORT | ||
# jwt | ||
jwt.secret=VlwEyVBsYt9V7zq57TejMnVUyzblYcfPQye08f7MGVA9XkHa | ||
jwt.token-validity-in-seconds=86400000 |
Binary file added
BIN
+3.74 KB
...odolist/build/tmp/compileJava/compileTransaction/stash-dir/JwtTokenFilter.class.uniqueId3
Binary file not shown.
Binary file added
BIN
+5.45 KB
...olist/build/tmp/compileJava/compileTransaction/stash-dir/JwtTokenProvider.class.uniqueId1
Binary file not shown.
Binary file removed
BIN
-2.14 KB
...t/build/tmp/compileJava/compileTransaction/stash-dir/Member$MemberBuilder.class.uniqueId6
Binary file not shown.
Binary file removed
BIN
-2.56 KB
...nseung/todolist/build/tmp/compileJava/compileTransaction/stash-dir/Member.class.uniqueId4
Binary file not shown.
Binary file added
BIN
+5.73 KB
...olist/build/tmp/compileJava/compileTransaction/stash-dir/MemberController.class.uniqueId0
Binary file not shown.
Binary file removed
BIN
-5.39 KB
...olist/build/tmp/compileJava/compileTransaction/stash-dir/MemberController.class.uniqueId2
Binary file not shown.
Binary file removed
BIN
-1.44 KB
...todolist/build/tmp/compileJava/compileTransaction/stash-dir/MemberMapper.class.uniqueId11
Binary file not shown.
Binary file removed
BIN
-2.8 KB
...olist/build/tmp/compileJava/compileTransaction/stash-dir/MemberMapperImpl.class.uniqueId7
Binary file not shown.
44 changes: 0 additions & 44 deletions
44
...dolist/build/tmp/compileJava/compileTransaction/stash-dir/MemberMapperImpl.java.uniqueId5
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-1.02 KB
...olist/build/tmp/compileJava/compileTransaction/stash-dir/MemberRepository.class.uniqueId1
Binary file not shown.
Binary file removed
BIN
-5.66 KB
...odolist/build/tmp/compileJava/compileTransaction/stash-dir/MemberService.class.uniqueId12
Binary file not shown.
Binary file added
BIN
+5.16 KB
...odolist/build/tmp/compileJava/compileTransaction/stash-dir/SecurityConfig.class.uniqueId2
Binary file not shown.
Binary file removed
BIN
-2.34 KB
...list/build/tmp/compileJava/compileTransaction/stash-dir/Todo$TodoBuilder.class.uniqueId10
Binary file not shown.
Binary file removed
BIN
-3.02 KB
...onseung/todolist/build/tmp/compileJava/compileTransaction/stash-dir/Todo.class.uniqueId15
Binary file not shown.
Binary file removed
BIN
-4.58 KB
...odolist/build/tmp/compileJava/compileTransaction/stash-dir/TodoController.class.uniqueId3
Binary file not shown.
Binary file removed
BIN
-1.47 KB
...g/todolist/build/tmp/compileJava/compileTransaction/stash-dir/TodoMapper.class.uniqueId14
Binary file not shown.
Binary file removed
BIN
-3.49 KB
...odolist/build/tmp/compileJava/compileTransaction/stash-dir/TodoMapperImpl.class.uniqueId0
Binary file not shown.
64 changes: 0 additions & 64 deletions
64
...todolist/build/tmp/compileJava/compileTransaction/stash-dir/TodoMapperImpl.java.uniqueId9
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-1.17 KB
...odolist/build/tmp/compileJava/compileTransaction/stash-dir/TodoRepository.class.uniqueId8
Binary file not shown.
Binary file removed
BIN
-6.33 KB
.../todolist/build/tmp/compileJava/compileTransaction/stash-dir/TodoService.class.uniqueId13
Binary file not shown.
Binary file modified
BIN
+18.6 KB
(140%)
contents/todoListAPI/hyeonseung/todolist/build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
70 changes: 70 additions & 0 deletions
70
...istAPI/hyeonseung/todolist/src/main/java/com/todolist/todolist/config/JwtTokenFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.todolist.todolist.config; | ||
|
||
import com.todolist.todolist.domain.Member; | ||
import com.todolist.todolist.security.JwtTokenProvider; | ||
import com.todolist.todolist.service.MemberService; | ||
import jakarta.servlet.FilterChain; | ||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||
import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.filter.OncePerRequestFilter; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class JwtTokenFilter extends OncePerRequestFilter { | ||
|
||
private final MemberService memberService; | ||
|
||
private final JwtTokenProvider jwtTokenProvider; | ||
@Override | ||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { | ||
String authorizationHeader = request.getHeader(HttpHeaders.AUTHORIZATION); | ||
|
||
// 토큰 전송 x -> 로그인 x | ||
if(authorizationHeader == null){ | ||
filterChain.doFilter(request, response); | ||
return; | ||
} | ||
|
||
// "Bearer"로 시작 x -> 잘못된 토큰 | ||
if(!authorizationHeader.startsWith("Bearer")){ | ||
filterChain.doFilter(request, response); | ||
return; | ||
} | ||
|
||
String token = authorizationHeader.split(" ")[1]; | ||
|
||
if(jwtTokenProvider.isExpired(token)){ | ||
filterChain.doFilter(request, response); | ||
return; | ||
} | ||
|
||
String loginId = jwtTokenProvider.getLoginIdFromToken(token); | ||
|
||
if ( loginId != null && SecurityContextHolder.getContext().getAuthentication() == null) { | ||
|
||
if (jwtTokenProvider.validateToken(token,loginId)) { | ||
Member loginMember = memberService.throwFindbyLoginId(loginId); | ||
|
||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken( | ||
loginMember.getLoginId(), null, List.of(new SimpleGrantedAuthority(loginMember.getRole().name()))); | ||
|
||
authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); | ||
|
||
SecurityContextHolder.getContext().setAuthentication(authenticationToken); | ||
} | ||
} | ||
filterChain.doFilter(request, response); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...istAPI/hyeonseung/todolist/src/main/java/com/todolist/todolist/config/SecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.todolist.todolist.config; | ||
|
||
import com.todolist.todolist.security.JwtTokenProvider; | ||
import com.todolist.todolist.service.MemberService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
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.config.http.SessionCreationPolicy; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
public class SecurityConfig { | ||
|
||
@Autowired | ||
private JwtTokenFilter jwtTokenFilter; | ||
|
||
@Bean | ||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | ||
http | ||
// CSRF 토큰 없이 요청 처리 | ||
.csrf((csrfConfig) -> | ||
csrfConfig.disable()) | ||
.cors((corsConfig) -> | ||
corsConfig.disable()) | ||
.sessionManagement((sessionManagement) -> | ||
sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
.authorizeHttpRequests((authorizeRequests) -> | ||
authorizeRequests | ||
.requestMatchers("/","/swagger-ui/**","/v3/api-docs/**").permitAll() | ||
.requestMatchers("/api/members","api/members/login").permitAll() | ||
.anyRequest().authenticated()) | ||
.addFilterBefore(jwtTokenFilter, UsernamePasswordAuthenticationFilter.class); | ||
|
||
return http.build(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.