From 9996f5e35e86a98882b7c52295bdf6dfdcba2812 Mon Sep 17 00:00:00 2001 From: nam Date: Fri, 17 Jan 2025 20:26:19 +0900 Subject: [PATCH] =?UTF-8?q?jwt=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 +- .../com/example/digger/user/UserService.java | 10 +- src/main/resources/static/css/home.css | 109 --------- src/main/resources/static/css/login.css | 0 src/main/resources/static/css/register.css | 0 src/main/resources/templates/base.html | 53 ----- src/main/resources/templates/home.html | 209 ------------------ src/main/resources/templates/login.html | 117 ---------- src/main/resources/templates/register.html | 111 ---------- 9 files changed, 6 insertions(+), 606 deletions(-) delete mode 100644 src/main/resources/static/css/home.css delete mode 100644 src/main/resources/static/css/login.css delete mode 100644 src/main/resources/static/css/register.css delete mode 100644 src/main/resources/templates/base.html delete mode 100644 src/main/resources/templates/home.html delete mode 100644 src/main/resources/templates/login.html delete mode 100644 src/main/resources/templates/register.html diff --git a/build.gradle b/build.gradle index 610589d..6022d3c 100644 --- a/build.gradle +++ b/build.gradle @@ -35,11 +35,10 @@ dependencies { testRuntimeOnly 'org.junit.platform:junit-platform-launcher' // Spring Security - implementation 'org.springframework.security:spring-security-crypto' implementation 'org.springframework.boot:spring-boot-starter-security' testImplementation 'org.springframework.security:spring-security-test' - // JWT Token + // JWT implementation 'io.jsonwebtoken:jjwt-api:0.11.5' implementation 'io.jsonwebtoken:jjwt-impl:0.11.5' implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5' diff --git a/src/main/java/com/example/digger/user/UserService.java b/src/main/java/com/example/digger/user/UserService.java index a8e80d4..442b1e5 100644 --- a/src/main/java/com/example/digger/user/UserService.java +++ b/src/main/java/com/example/digger/user/UserService.java @@ -52,11 +52,7 @@ public Map login(String email, String password) { // 리프레시 토큰 저장 refreshTokenStore.put(email, refreshToken); - Map tokens = new HashMap<>(); - tokens.put("accessToken", accessToken); - tokens.put("refreshToken", refreshToken); - - return tokens; + return Map.of("accessToken", accessToken, "refreshToken", refreshToken); } public String refreshAccessToken(String email, String refreshToken) { @@ -66,6 +62,10 @@ public String refreshAccessToken(String email, String refreshToken) { throw new RuntimeException("리프레시 토큰이 유효하지 않습니다."); } + if (!jwtTokenProvider.validateToken(refreshToken)) { + throw new RuntimeException("리프레시 토큰이 만료되었습니다."); + } + // 새 액세스 토큰 발급 return jwtTokenProvider.generateAccessToken(email); } diff --git a/src/main/resources/static/css/home.css b/src/main/resources/static/css/home.css deleted file mode 100644 index c21b9b8..0000000 --- a/src/main/resources/static/css/home.css +++ /dev/null @@ -1,109 +0,0 @@ -body { - font-family: 'Noto Sans KR', sans-serif; - line-height: 1.6; - margin: 0; - padding: 0; - background-color: #f4f4f4; -} -.container { - width: 80%; - margin: 0 auto; - overflow: hidden; -} -header { - background: #333; - color: #fff; - padding-top: 30px; - min-height: 70px; - border-bottom: #bbb 1px solid; -} -header a { - color: #fff; - text-decoration: none; - text-transform: uppercase; - font-size: 16px; -} -header ul { - padding: 0; - margin: 0; - list-style: none; - overflow: hidden; -} -header li { - float: left; - display: inline; - padding: 0 20px 0 20px; -} -header #branding { - float: left; -} -header #branding h1 { - margin: 0; -} -header nav { - float: right; - margin-top: 10px; -} -header .highlight, header .current a { - color: #e8491d; - font-weight: bold; -} -header a:hover { - color: #ffffff; - font-weight: bold; -} -#showcase { - min-height: 400px; - background: url('https://source.unsplash.com/random/1600x900/?music') no-repeat center center/cover; - text-align: center; - color: #ffffff; -} -#showcase h1 { - margin-top: 100px; - font-size: 55px; - margin-bottom: 10px; -} -#showcase p { - font-size: 20px; -} -#main { - float: left; - width: 70%; - padding: 0 30px; - box-sizing: border-box; -} -#sidebar { - float: right; - width: 30%; - background: #333; - color: #fff; - padding: 10px; - box-sizing: border-box; -} -article.post { - background: #fff; - margin-bottom: 20px; - padding: 20px; - border-radius: 5px; -} -footer { - background: #333; - color: #fff; - text-align: center; - padding: 20px; - margin-top: 20px; -} -@media(max-width: 768px) { - header #branding, - header nav, - header nav li, - #main, - #sidebar { - float: none; - text-align: center; - width: 100%; - } - header { - padding-bottom: 20px; - } -} \ No newline at end of file diff --git a/src/main/resources/static/css/login.css b/src/main/resources/static/css/login.css deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/resources/static/css/register.css b/src/main/resources/static/css/register.css deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/resources/templates/base.html b/src/main/resources/templates/base.html deleted file mode 100644 index e5c7ce8..0000000 --- a/src/main/resources/templates/base.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - -
- -
-
-
-
-
- -
- - diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html deleted file mode 100644 index 77f1823..0000000 --- a/src/main/resources/templates/home.html +++ /dev/null @@ -1,209 +0,0 @@ - - - - - - 음악 커뮤니티 - 홈 - - - -
-
-
-

- Digger -

-
- -
-
- -
-
-

Digger

-

다양한 장르, 아티스트에 대해 이야기를 나누고 새로운 음악을 발견하세요.

-
-
- -
-
-

최근 게시물

-
-
-

게시물 제목

-

게시물 내용...

- 작성일 - 더 보기 -
-
-
- - -
- -

환영합니다!

-

로그인 성공! 아래는 발급된 토큰입니다.

- -

Access Token

- - -

Refresh Token

- - -

Access Token과 Refresh Token을 통해 인증 및 재인증이 가능합니다.

- - - -
-

© 2025 Side Project. All rights reserved.

-
- - - - \ No newline at end of file diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html deleted file mode 100644 index fd42273..0000000 --- a/src/main/resources/templates/login.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - 로그인 - - - - - - - diff --git a/src/main/resources/templates/register.html b/src/main/resources/templates/register.html deleted file mode 100644 index e2c1717..0000000 --- a/src/main/resources/templates/register.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - 회원가입 - - - - - - -