Skip to content

Commit

Permalink
Merge pull request #50 from KNU-HAEDAL-Website/chore-aws-s3-issue-49
Browse files Browse the repository at this point in the history
Chore: AWS S3 설정
  • Loading branch information
tfer2442 authored Jun 10, 2024
2 parents 7c043ee + 09bccca commit 94ff29c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 5 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repositories {
}

dependencies {

implementation 'io.awspring.cloud:spring-cloud-aws-starter-s3:3.1.1'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'io.jsonwebtoken:jjwt-api:0.12.3'
Expand All @@ -38,7 +38,6 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

}

tasks.named('test') {
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ services:
SPRING_DATA_REDIS_PORT: ${SPRING_DATA_REDIS_PORT}
SPRING_DATA_REDIS_PASSWORD: ${SPRING_DATA_REDIS_PASSWORD}
SPRING_JWT_SECRET_KEY: ${SPRING_JWT_SECRET_KEY}
AWS_IAM_ACCESS_KEY: ${AWS_IAM_ACCESS_KEY}
AWS_IAM_SECRET_KEY: ${AWS_IAM_SECRET_KEY}
haedal-mysql:
image: mysql:8.0.36
volumes:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/haedal/haedalweb/jwt/LoginFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

@RequiredArgsConstructor
public class LoginFilter extends UsernamePasswordAuthenticationFilter {
private static final ObjectMapper objectMapper = new ObjectMapper();
private final AuthenticationManager authenticationManager;
private final JWTUtil jwtUtil;

Expand Down Expand Up @@ -64,7 +65,6 @@ protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServle

private LoginDTO parseLoginRequest(HttpServletRequest request) {
try {
ObjectMapper objectMapper = new ObjectMapper();
ServletInputStream inputStream = request.getInputStream();
String messageBody = StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/haedal/haedalweb/util/CookieUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import java.util.Optional;

public class CookieUtil {

private CookieUtil() {
}

public static Cookie createCookie(String key, String value, int maxAge) {
Cookie cookie = new Cookie(key, value);
cookie.setMaxAge(maxAge);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/haedal/haedalweb/util/ResponseUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

public class ResponseUtil {
private static final Logger logger = LoggerFactory.getLogger(ResponseUtil.class);
private static final ObjectMapper objectMapper = new ObjectMapper();

private ResponseUtil() {}

public static void sendSuccessResponse(HttpServletResponse response, SuccessCode successCode) {
response.setStatus(successCode.getHttpStatus().value());
Expand All @@ -33,7 +36,7 @@ public static ResponseEntity<SuccessResponse> buildSuccessResponseEntity(Success

public static void writeAsJsonResponse(HttpServletResponse response, Object data) {
try {
String jsonData = new ObjectMapper().writeValueAsString(data);
String jsonData = objectMapper.writeValueAsString(data);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(jsonData);
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/application-aws.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB

spring.cloud.aws.credentials.access-key=${AWS_IAM_ACCESS_KEY}
spring.cloud.aws.credentials.secret-key=${AWS_IAM_SECRET_KEY}
spring.cloud.aws.region.static=ap-northeast-2
spring.cloud.aws.s3.bucket=${AWS_S3_BUCKET_NAME}
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spring.profiles.include=db, jwt
spring.profiles.include=db, jwt, aws

#logging.level.org.springframework=DEBUG
#spring.mvc.log-request-details=true

0 comments on commit 94ff29c

Please sign in to comment.