Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
6fefe55
init :: project init
phc979 Feb 7, 2025
7e09e8a
fix: convert createdDate and modifiedDate from Instant to LocalDateTime
phc979 Feb 7, 2025
e444e35
fix: convert createdDate and modifiedDate from Instant to LocalDateTime
phc979 Feb 7, 2025
01acb61
Merge pull request #4 from Cloud-Engineering2/fix/convert-instant-to-…
phc979 Feb 7, 2025
b8b62cb
feature-front-backend-post-form
phc979 Feb 9, 2025
9f9e83a
feature : DTOs Annotation fix
phc979 Feb 10, 2025
a8e1476
Merge pull request #5 from Cloud-Engineering2/feature-frontend-post-form
phc979 Feb 10, 2025
636c645
Make View Like but Returned 500 Error Version
KangSeongKwan Feb 10, 2025
bf8d4ed
feature : post-viewpage & fix url mapping
phc979 Feb 10, 2025
ffb8ea9
Merge pull request #6 from Cloud-Engineering2/feature-posts-view
phc979 Feb 10, 2025
6f82a32
현재 회원가입까지 저장,jwt으로 로그인구현중
SUJINJEONG012 Feb 10, 2025
8b13815
병합충돌 오류수정후 다시 커밋
SUJINJEONG012 Feb 10, 2025
032f62f
jwt 부분적 코드 생성
SUJINJEONG012 Feb 10, 2025
45d03f6
feature: register,login page & fix register, login, jwt, security
SUJINJEONG012 Feb 10, 2025
ce5bc1b
Merge pull request #8 from Cloud-Engineering2/feature-frontend-register
SUJINJEONG012 Feb 10, 2025
53176c2
Make View Like but Returned 500 Error Version
KangSeongKwan Feb 10, 2025
a832df2
feature : post-list
phc979 Feb 10, 2025
99d67bb
Merge remote-tracking branch 'origin/develop' into feature-post-list-…
phc979 Feb 10, 2025
dceba35
feature: layouts with Thymeleaf
SUJINJEONG012 Feb 10, 2025
b767de0
Second Version for Like
KangSeongKwan Feb 10, 2025
dd8358f
Solve Confilct my branch
KangSeongKwan Feb 10, 2025
4688b0f
feature : post-list-view
phc979 Feb 10, 2025
5d63d04
Merge pull request #9 from Cloud-Engineering2/feature-post-list-view
phc979 Feb 10, 2025
b2b8e6f
fix : pagination-item-index
phc979 Feb 10, 2025
35e8a62
Merge pull request #10 from Cloud-Engineering2/feature-post-list-view
phc979 Feb 10, 2025
1cc9c65
feature : post write session
phc979 Feb 10, 2025
dfc5190
Merge pull request #13 from Cloud-Engineering2/feature-post-write-ses…
phc979 Feb 10, 2025
42fb2b3
feature : update-recipe & image orphan delete & jwt token ( with cook…
phc979 Feb 10, 2025
3d64450
Merge pull request #14 from Cloud-Engineering2/feature-update-recipe-phc
phc979 Feb 10, 2025
eb6a6c1
feature : update & mypage create & Thymeleaf setting
SUJINJEONG012 Feb 11, 2025
7d3dc08
Feature: Update, Create Mypage
SUJINJEONG012 Feb 11, 2025
49ed759
Merge develop into feature-frontend-register and resolve conflicts
SUJINJEONG012 Feb 11, 2025
30debb7
Feature: Update UserService.java
SUJINJEONG012 Feb 11, 2025
94b52fd
Feature: Modify and Create MyPage with Thymeleaf Configuration
SUJINJEONG012 Feb 11, 2025
d9eed9c
fix : jwt token
phc979 Feb 11, 2025
273706d
Complete Like button without User
KangSeongKwan Feb 10, 2025
120df06
Second Version for Like
KangSeongKwan Feb 10, 2025
b3e4be4
Merge pull request #17 from Cloud-Engineering2/feature-frontend-register
phc979 Feb 11, 2025
ab1cb94
Add JwtTokenProvider.java
SUJINJEONG012 Feb 11, 2025
306c560
Final Version with Like Button without User
KangSeongKwan Feb 11, 2025
85824a6
feature update UserController
SUJINJEONG012 Feb 11, 2025
d29c39f
fix merge conflict and final Like features without user
KangSeongKwan Feb 11, 2025
47a6bf4
Solve post-view page conflict
KangSeongKwan Feb 11, 2025
74ac526
feature update build.gradle
SUJINJEONG012 Feb 11, 2025
1c9a3ee
Merge branch 'develop' into feature-backend-like
phc979 Feb 11, 2025
cdacf9e
Merge pull request #19 from Cloud-Engineering2/feature-backend-like
KangSeongKwan Feb 11, 2025
75139df
feature update jwt -> session
SUJINJEONG012 Feb 11, 2025
d642fe6
Merge branch 'develop' into feature-frontend-register
SUJINJEONG012 Feb 11, 2025
7c106f6
Merge pull request #21 from Cloud-Engineering2/feature-frontend-register
SUJINJEONG012 Feb 11, 2025
e313890
fix : build-gradle
phc979 Feb 11, 2025
1e18cfa
Merge pull request #22 from Cloud-Engineering2/feature-phc
phc979 Feb 11, 2025
d12e6d6
feature update gradle
SUJINJEONG012 Feb 11, 2025
c4212ba
feature update file
SUJINJEONG012 Feb 11, 2025
30d4ba7
feature: post-remove & refactoring for session
phc979 Feb 11, 2025
1706beb
feature: post-remove & refactoring for session
phc979 Feb 11, 2025
62dbd2c
feature: post-remove & refactoring for session
phc979 Feb 11, 2025
5317e33
Merge pull request #23 from Cloud-Engineering2/feature-phc
phc979 Feb 11, 2025
30e2424
:sparkles: feature: delete stale images (incomplete)
amberlee0201 Feb 11, 2025
bc2e5b1
feature update Security & Mapping & Version issue
SUJINJEONG012 Feb 11, 2025
2bfc396
Merge pull request #24 from Cloud-Engineering2/feature-frontend-mypage
SUJINJEONG012 Feb 11, 2025
d55c7bc
Fix : Post/post-write -> post/post-write
phc979 Feb 11, 2025
7829cee
Merge pull request #25 from Cloud-Engineering2/fix-Post-post
phc979 Feb 11, 2025
9c3c0de
feature update view page
SUJINJEONG012 Feb 11, 2025
aadc053
feature: post-remove & refactoring for session
phc979 Feb 11, 2025
7cada0e
Fix : Post/post-write -> post/post-write
phc979 Feb 11, 2025
909d709
feature update view page
SUJINJEONG012 Feb 11, 2025
e6eea3c
feature update mypage & view page
SUJINJEONG012 Feb 11, 2025
7dd87a1
Feature : Frontend css html 수정, Backend myrecipe 추가
phc979 Feb 11, 2025
c047ed2
Feature : Frontend css html 수정, myrecipe, myscrap 추가
phc979 Feb 11, 2025
9d8171c
Feature : Frontend css html 수정, myrecipe, myscrap 추가
phc979 Feb 11, 2025
c32cb40
Feature : Frontend css html 수정, myrecipe, myscrap 추가
phc979 Feb 11, 2025
c448dcc
Feature : Frontend css html 수정, myrecipe, myscrap, error페이지 추가
phc979 Feb 11, 2025
2ef6ced
Feature : Frontend css html 수정, myrecipe, myscrap, error페이지 추가
phc979 Feb 11, 2025
1e09e6a
:zap: feature: complete stale image remove scheduler
amberlee0201 Feb 12, 2025
bff0a21
Merge branch 'develop' into feature-remove-temp-image-scheduler
amberlee0201 Feb 12, 2025
4a90400
Merge pull request #27 from Cloud-Engineering2/feature-remove-temp-im…
amberlee0201 Feb 12, 2025
bcbf34d
Feature : Frontend css html 수정, myrecipe, myscrap, error페이지 추가
phc979 Feb 12, 2025
e818363
Merge branch 'develop' into feature-frontend-mypage-phc-branch
phc979 Feb 12, 2025
d085939
Merge pull request #28 from Cloud-Engineering2/feature-frontend-mypag…
phc979 Feb 12, 2025
4f187df
:sparkles: feature: add eks manifest files and github actions for AWS…
amberlee0201 Feb 12, 2025
7fc4097
:pencil2: fix:
amberlee0201 Feb 12, 2025
12491a9
:pencil2: fix:
amberlee0201 Feb 12, 2025
b4dded1
:pencil2: fix: add Dockerfile
amberlee0201 Feb 12, 2025
51376a8
[CI/CD Automated] Update spring boot image to latest
amberlee0201 Feb 12, 2025
ff936f8
Update eks-app.yaml
amberlee0201 Feb 12, 2025
3c0c85f
:pencil2: fix: add certificate arn
amberlee0201 Feb 12, 2025
02ebf95
:pencil2: fix: test
amberlee0201 Feb 12, 2025
13995d2
[CI/CD Automated] Update spring boot image to latest
amberlee0201 Feb 12, 2025
bffc903
Update aws-eks-actions.yaml
SUJINJEONG012 Feb 12, 2025
8017f35
[CI/CD Automated] Update spring boot image to latest
amberlee0201 Feb 12, 2025
9e800e6
Update eks-app.yaml
phc979 Feb 12, 2025
d4b02a5
Update aws-eks-actions.yaml
SUJINJEONG012 Feb 12, 2025
2b35ccd
[CI/CD Automated] Update spring boot image to latest
amberlee0201 Feb 12, 2025
a95e2ac
Update aws-eks-actions.yaml
SUJINJEONG012 Feb 12, 2025
7698b8d
[CI/CD Automated] Update spring boot image to latest
amberlee0201 Feb 12, 2025
bafbd11
:pencil2: fix: remove jwt package, update manifest for spring boot ac…
amberlee0201 Feb 13, 2025
db3d361
[CI/CD Automated] Update spring boot image to latest
amberlee0201 Feb 13, 2025
4479ccd
:pencil2: fix: actions
amberlee0201 Feb 13, 2025
74e6977
Merge remote-tracking branch 'origin/feature-aws-test' into feature-a…
amberlee0201 Feb 13, 2025
0444e21
[CI/CD Automated] Update spring boot image to latest
amberlee0201 Feb 13, 2025
410d8e3
:wrench: edit: modify actions and remove manifest
amberlee0201 Feb 13, 2025
29354b7
Merge pull request #30 from Cloud-Engineering2/feature-aws-test
amberlee0201 Feb 13, 2025
c6b5780
fix : scrap sorting
phc979 Feb 13, 2025
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
84 changes: 84 additions & 0 deletions .github/workflows/aws-eks-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI Test for AWS EKS
on:
push:
branches:
- main
paths-ignore:
- 'manifest/**' # 특정 디렉토리 무시
pull_request:
branches:
- main
types:
- closed # PR이 병합될 때 실행

jobs:
ci:
environment: aws-eks-test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: add application.properties
run: |
echo "${{ secrets.PROPERTIES }}" >> src/main/resources/application.properties

- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Build with Gradle Wrapper
run: ./gradlew build -x test

- name: Naming jar file
run: mv ./build/libs/project2-team2-0.0.1-SNAPSHOT.jar ./build/libs/app.jar
# @TODO regex

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Login to Amazon ECR private
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: private

- name: Build, tag, and push docker image to Amazon ECR private
env:
REGISTRY_URI: ${{ secrets.REGISTRY_URI }}
IMAGE_TAG: ${{ github.sha }}
run: |
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin $REGISTRY_URI
docker build -t $REGISTRY_URI:$IMAGE_TAG .
docker push $REGISTRY_URI:$IMAGE_TAG

argocd:
environment: aws-eks-test
needs: ci
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: cd-manifest
token: ${{ secrets.T2_YEERYONG_GITHUB_TOKEN }}

- name: Update Image with New SHA
run: |
sed -i "s%image: ${{ secrets.REGISTRY_URI }}:[a-zA-Z0-9._-]*%image: ${{ secrets.REGISTRY_URI }}:${{ github.sha }}%" ./manifest/eks-app.yaml

- name: Commit and push changes
run: |
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git config --local user.name "${{ github.actor }}"
git add .
git commit -m "[CI/CD Automated] Update spring boot image to latest"
git push
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:17
ARG JAR_FILE=build/libs/app.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
41 changes: 25 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.4.2'
id 'io.spring.dependency-management' version '1.1.7'
id 'java'
id 'org.springframework.boot' version '3.1.2'
id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.recipe'
version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'com.auth0:java-jwt:3.18.2'

implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
implementation 'software.amazon.awssdk:s3:2.20.147'
compileOnly 'org.projectlombok:lombok'

developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
Expand All @@ -41,5 +45,10 @@ dependencies {
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}


tasks.withType(JavaCompile).configureEach {
options.compilerArgs.add("-parameters")
}
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing
public class Cld2CookofKingRecipeApplication {

public static void main(String[] args) {
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/com/recipe/cookofking/config/AwsS3Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.recipe.cookofking.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;

@Configuration
public class AwsS3Config {

@Value("${cloud.aws.credentials.access-key}")
private String accessKey;

@Value("${cloud.aws.credentials.secret-key}")
private String secretKey;

@Value("${cloud.aws.region.static}")
private String region;


@Bean
public S3Client s3Client() {
return S3Client.builder()
.region(Region.of(region)) // 주입된 리전 값 사용
.credentialsProvider(StaticCredentialsProvider.create(
AwsBasicCredentials.create(accessKey, secretKey)))
.build();
}
}
24 changes: 24 additions & 0 deletions src/main/java/com/recipe/cookofking/config/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.recipe.cookofking.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@Configuration
public class CorsConfig {

@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true); // 응답 json 결과를 js 처리 가능 설정
config.addAllowedOrigin("*"); // cors 허가 도메인
config.addAllowedHeader("*"); // 허가 헤더 정보값
config.addAllowedMethod("*"); // 허가 메서드
config.addExposedHeader("Authorization"); // Authorization 헤더 노출
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.recipe.cookofking.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

@Configuration
@EnableScheduling // 스케줄링 활성화
public class SchedulerConfig {
}
136 changes: 136 additions & 0 deletions src/main/java/com/recipe/cookofking/config/SecurityConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package com.recipe.cookofking.config;


import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
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.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;

import com.recipe.cookofking.config.auth.PrincipalDetails;
import com.recipe.cookofking.repository.UserRepository;

import lombok.RequiredArgsConstructor;

import java.util.Map;

@RequiredArgsConstructor
@Configuration
@EnableWebSecurity
public class SecurityConfig {

private final UserRepository userRepository;

@Bean
public AuthenticationManager authenticationManager(HttpSecurity http) throws Exception {
return http.getSharedObject(AuthenticationManagerBuilder.class).build();
}



// @Bean
// public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
// http
// .authorizeHttpRequests(auth -> auth
// .anyRequest().permitAll() // 모든 요청 허용
// )
// .csrf(csrf -> csrf.disable()) // CSRF 비활성화 (개발 환경)
// .formLogin(form -> form.disable()); // 폼 로그인 비활성화
//
// return http.build();
// }

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.csrf(csrf -> csrf.disable()) // CSRF 비활성화 (필요시 활성화)
.authorizeHttpRequests(auth -> auth
.requestMatchers(
"/user/login",
"/user/register",
"/js/**",
"/css/**",
"/images/**",
"/static/**",
"/post/list",
"/post/view/**"
).permitAll() // 인증 없이 접근 가능
.requestMatchers("/post/write","/post/edit/**","/user/mypage","/user/myrecipe", "/api/**").authenticated() // 인증 필요
.anyRequest().permitAll()
)
.exceptionHandling(exception ->
exception.authenticationEntryPoint((request, response, authException) -> {
String uri = request.getRequestURI();

if (uri.startsWith("/api/")) {
// API 요청인 경우: JSON 응답
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // 401 상태 코드 설정
response.setContentType("application/json; charset=UTF-8");
response.getWriter().write(new ObjectMapper().writeValueAsString(
Map.of("error", "로그인이 필요한 서비스입니다.")
));
} else {
// 페이지 요청인 경우: 로그인 페이지로 리디렉션
response.sendRedirect("/user/login");
}
})
)


.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) // 필요시 세션 생성
)
.securityContext(securityContext -> securityContext
.securityContextRepository(new HttpSessionSecurityContextRepository()) // 세션에 인증 정보를 저장
)
.formLogin(form -> form
.loginPage("/user/login") // 로그인 페이지 지정
.loginProcessingUrl("/user/login") // 로그인 요청 처리 URL
.defaultSuccessUrl("/post/list", true) // 로그인 성공 시 이동할 페이지
.permitAll()
)
.logout(logout -> logout
.logoutUrl("/user/logout") // 로그아웃 요청 URL
.logoutSuccessUrl("/user/login") // 로그아웃 성공 시 이동할 페이지
.invalidateHttpSession(true) // 세션 무효화
.deleteCookies("JSESSIONID") // JSESSIONID 쿠키 삭제
.permitAll()
);

return http.build();
}

// 로그인 성공 후 처리하는 서비스나 필터에서
public void loginSuccessHandler(PrincipalDetails principalDetails) {
Authentication authentication = new UsernamePasswordAuthenticationToken(
principalDetails, // PrincipalDetails 객체 (로그인한 사용자의 정보)
null, // 비밀번호는 null로 설정 (이미 검증되었으므로)
principalDetails.getAuthorities() // 권한 정보
);

// SecurityContext에 Authentication 객체를 설정
SecurityContextHolder.getContext().setAuthentication(authentication);
}


@Bean
public PasswordEncoder passwordEncoder() {
// BCryptPasswordEncoder를 사용해 비밀번호 암호화
return new BCryptPasswordEncoder();
}

}
Loading
Loading