Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ› accessToken โ†’ Authorization header๋กœ ๋ณ€๊ฒฝ #110

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@

import java.util.Map;

import static kr.co.fitapet.api.common.security.jwt.consts.AuthConstants.ACCESS_TOKEN;
import static kr.co.fitapet.api.common.security.jwt.consts.AuthConstants.REFRESH_TOKEN;
import static kr.co.fitapet.api.common.security.jwt.consts.AuthConstants.*;


@Tag(name = "์œ ์ € ๊ด€๋ฆฌ API", description = "์œ ์ € ์ธ์ฆ๊ณผ ๊ด€๋ จ๋œ API")
Expand Down Expand Up @@ -98,7 +97,7 @@ else if (token.refreshToken() == null)

return ResponseEntity.ok()
.header(HttpHeaders.SET_COOKIE, cookie.toString())
.header(ACCESS_TOKEN.getValue(), token.accessToken())
.header(AUTH_HEADER.getValue(), token.accessToken())
.body(SuccessResponse.from(Map.of("member", "๋“ฑ๋ก๋œ oauth ๊ณ„์ • ์—ฐ๋™ ์„ฑ๊ณต")));
}

Expand Down Expand Up @@ -183,7 +182,7 @@ public ResponseEntity<?> refresh(@CookieValue("refreshToken") @Valid String refr

return ResponseEntity.ok()
.header(HttpHeaders.SET_COOKIE, cookie.toString())
.header(ACCESS_TOKEN.getValue(), tokens.accessToken())
.header(AUTH_HEADER.getValue(), tokens.accessToken())
.body(SuccessResponse.noContent());
}

Expand All @@ -205,7 +204,7 @@ private ResponseEntity<?> getResponseEntity(Long userId, Jwt tokens) {

return ResponseEntity.ok()
.header(HttpHeaders.SET_COOKIE, cookie.toString())
.header(ACCESS_TOKEN.getValue(), tokens.accessToken())
.header(AUTH_HEADER.getValue(), tokens.accessToken())
.body(SuccessResponse.from(Map.of("userId", userId)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
import java.util.Map;
import java.util.Optional;

import static kr.co.fitapet.api.common.security.jwt.consts.AuthConstants.ACCESS_TOKEN;
import static kr.co.fitapet.api.common.security.jwt.consts.AuthConstants.REFRESH_TOKEN;
import static kr.co.fitapet.api.common.security.jwt.consts.AuthConstants.*;

@Tag(name = "OAuth API")
@RestController
Expand Down Expand Up @@ -109,7 +108,7 @@ public ResponseEntity<?> signUpSmsAuthorization(
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
else if (token.getValue().refreshToken() == null)
return ResponseEntity.ok()
.header(ACCESS_TOKEN.getValue(), token.getValue().accessToken())
.header(AUTH_HEADER.getValue(), token.getValue().accessToken())
.body(SuccessResponse.from(Map.of("member", "์‹ ๊ทœ ํšŒ์›")));

return getJwtResponseEntity(token.getKey(), token.getValue());
Expand All @@ -120,7 +119,7 @@ private ResponseEntity<?> getJwtResponseEntity(Long userId, Jwt jwt) {

return ResponseEntity.ok()
.header(HttpHeaders.SET_COOKIE, cookie.toString())
.header(ACCESS_TOKEN.getValue(), jwt.accessToken())
.header(AUTH_HEADER.getValue(), jwt.accessToken())
.body(SuccessResponse.from(Map.of("userId", userId)));
}
}
5 changes: 5 additions & 0 deletions fitapet-app-external-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@ spring:
server:
port: 8080
forward-headers-strategy: framework
http2:
enabled: true

spring:
config:
activate:
on-profile: prod

main:
allow-bean-definition-overriding: true

mvc:
throw-exception-if-no-handler-found: true
web:
Expand Down
21 changes: 18 additions & 3 deletions fitapet-infra/src/main/resources/application-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,23 @@ oauth2:
client-name: Apple

ncp:
api-key: ${NCP_API_ACCESS_KEY}
secret-key: ${NCP_SECRET_KEY}
credentials:
api-key: ${NCP_API_ACCESS_KEY}
secret-key: ${NCP_SECRET_KEY}
sms:
service-key: ${NCP_SMS_KEY}
sender-phone: ${SENDER_PHONE}
sender-phone: ${SENDER_PHONE}

cloud:
aws:
s3:
endpoint: ${NCP_OBJECT_STORAGE_URI}
bucket: ${NCP_OBJECT_STORAGE_BUCKET}
credentials:
access-key: ${NCP_API_ACCESS_KEY}
secret-key: ${NCP_SECRET_KEY}
region:
static: ${NCP_OBJECT_STORAGE_REGION}
auto: false
stack:
auto: false
2 changes: 1 addition & 1 deletion proxy/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ server {
ssl_certificate_key /etc/letsencrypt/live/fitapet.co.kr/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

ssl_protocols TLSv1.2 TLSv1.3;

access_log /var/log/nginx/access.log;

Expand Down
Loading