Skip to content

Commit

Permalink
[DEPLOY] dev -> main 머지 (makers 5th sprint 0 오늘의 솝마디 prod 배포) (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarlgnszx authored Oct 21, 2024
2 parents c48fd03 + c4f4c95 commit ba66f07
Show file tree
Hide file tree
Showing 260 changed files with 3,620 additions and 4,942 deletions.
Empty file modified .github/ISSUE_TEMPLATE.md
100644 → 100755
Empty file.
Empty file modified .github/PULL_REQUEST_TEMPLATE.md
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions .github/workflows/build-dev.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
uses: actions/checkout@v3

# 2) JDK 11버전 설치, 다른 JDK 버전을 사용하다면 수정
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'corretto'

# 3) 환경변수 파일 생성
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-dev-code_deploy.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
- name: checkout
uses: actions/checkout@v3

- name: set up JDK 17
- name: set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
java-version: '21'

- name: mkdir resources folder
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-prod.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
- name: checkout
uses: actions/checkout@v3

- name: set up JDK 17
- name: set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
java-version: '21'

- name: mkdir resources folder
run: |
Expand Down
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified appspec.yml
100644 → 100755
Empty file.
111 changes: 50 additions & 61 deletions build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
// QueryDSL 추가
buildscript {
ext {
queryDslVersion = "5.0.0"
}
}

plugins {
id 'org.springframework.boot' version '2.7.4'
id 'io.spring.dependency-management' version '1.0.14.RELEASE'
//querydsl 추가
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
id 'java'
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.5'
id 'java-library'
id 'jacoco'
}

ext {
springCloudVersion = "2023.0.3"
}

group = 'org.sopt'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

java {
sourceCompatibility = '21'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}


repositories {
mavenCentral()
}
Expand All @@ -33,26 +32,35 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'

// OpenFeign Client
implementation 'io.github.openfeign:feign-core:12.4'
implementation 'io.github.openfeign:feign-okhttp:12.4'
implementation 'io.github.openfeign:feign-jackson:12.4'
implementation 'io.github.openfeign:feign-slf4j:12.4'
implementation "io.github.openfeign:feign-okhttp"
implementation "io.github.openfeign:feign-jackson"
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'


// swagger
implementation 'org.springdoc:springdoc-openapi-ui:1.6.12'
implementation 'org.springdoc:springdoc-openapi-security:1.6.12'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'

// sentry
implementation 'io.sentry:sentry-spring-boot-starter:6.17.0'
implementation 'io.sentry:sentry-logback:6.17.0'

// QueryDSL
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta" // 버전 명시
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'

//postgres
runtimeOnly 'org.postgresql:postgresql'

// mapper
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
annotationProcessor "org.mapstruct:mapstruct-processor:1.4.2.Final"
implementation 'org.mapstruct:mapstruct:1.5.3.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'

// jwt
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
Expand All @@ -61,69 +69,50 @@ dependencies {

// DB
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'

// postgres
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.23'
runtimeOnly 'org.postgresql:postgresql'

//ImmutableMap
implementation 'com.google.guava:guava:30.1.1-jre'
// redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

// querydsl
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
implementation "com.querydsl:querydsl-apt:${queryDslVersion}"
implementation "com.querydsl:querydsl-core:${queryDslVersion}" // 한개 더 추가!
// ImmutableMap
implementation 'com.google.guava:guava:32.0.1-jre'

//hibernate-type52 추가 array type을 위해
implementation group: 'com.vladmihalcea', name: 'hibernate-types-52', version: '2.19.0'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: '2.7.5'
implementation 'io.hypersistence:hypersistence-utils-hibernate-63:3.8.2'
implementation 'org.springframework.boot:spring-boot-starter-validation'

//aws-s3
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-aws', version: '2.2.5.RELEASE'
// aws-s3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

// retry
implementation 'org.springframework.retry:spring-retry:1.2.5.RELEASE'
implementation 'org.springframework.retry:spring-retry:2.0.6'

// test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
implementation 'com.google.code.gson:gson:2.8.7'
testImplementation 'org.mockito:mockito-core:4.5.1'
testImplementation 'org.mockito:mockito-junit-jupiter:4.5.1'
implementation 'com.google.code.gson:gson:2.10.1'
testImplementation 'org.mockito:mockito-core:5.5.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.5.0'
implementation 'net.bytebuddy:byte-buddy:1.14.15'
implementation 'org.objenesis:objenesis:3.4'

// slack
implementation 'com.slack.api:slack-api-client:1.30.0'
}

//config-server
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
}
tasks.named('test') {
useJUnitPlatform()
}

//querydsl 추가 시작
def querydslDir = "$buildDir/generated/querydsl"

querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets {
main.java.srcDir querydslDir
}
compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
test {
exclude '**/*RepositoryTest.*'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion"
}
querydsl.extendsFrom compileClasspath
}
//querydsl 추가 끝

springBoot {
buildInfo()
}
Empty file modified gradle/wrapper/gradle-wrapper.jar
100644 → 100755
Empty file.
6 changes: 4 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
Empty file modified script/start.sh
100644 → 100755
Empty file.
Empty file modified script/stop.sh
100644 → 100755
Empty file.
Empty file modified script/valid.sh
100644 → 100755
Empty file.
Empty file modified settings.gradle
100644 → 100755
Empty file.
4 changes: 3 additions & 1 deletion src/main/java/org/sopt/app/AppApplication.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package org.sopt.app;

import jakarta.annotation.PostConstruct;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;

import javax.annotation.PostConstruct;
import java.util.TimeZone;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableJpaAuditing // JPA Auditing(감시, 감사) 기능을 활성화 하는 어노테이션 createdDate, modifiedDate 저장 활성화
@EnableAsync
@EnableScheduling
@SpringBootApplication
public class AppApplication {

Expand Down
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion src/main/java/org/sopt/app/application/auth/CustomUserDetailService.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public class CustomUserDetailService implements UserDetailsService {

public UserDetails loadUserByUsername(String username) throws NotFoundException {
return userRepository.findUserById(Long.parseLong(username))
.orElseThrow(() -> new NotFoundException(ErrorCode.USER_NOT_FOUND.getMessage()));
.orElseThrow(() -> new NotFoundException(ErrorCode.USER_NOT_FOUND));
}
}
44 changes: 18 additions & 26 deletions src/main/java/org/sopt/app/application/auth/JwtTokenService.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package org.sopt.app.application.auth;

import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Header;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.*;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.util.Base64;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.joda.time.LocalDateTime;
import org.sopt.app.application.auth.dto.PlaygroundAuthTokenInfo.AppToken;
import org.sopt.app.application.auth.dto.PlaygroundProfileInfo;
import org.sopt.app.application.user.UserInfo;
import org.sopt.app.common.exception.UnauthorizedException;
import org.sopt.app.common.response.ErrorCode;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
Expand All @@ -40,67 +36,63 @@ private Key getSigningKey(String keyString) {
return Keys.hmacShaKeyFor(Decoders.BASE64.decode(secretKey));
}

public AppToken issueNewTokens(UserInfo.Id userId,
PlaygroundProfileInfo.PlaygroundMain playgroundMember) {
val accessToken = this.encodeJwtToken(userId, playgroundMember.getId());
public AppToken issueNewTokens(Long userId, Long playgroundId) {
val accessToken = this.encodeJwtToken(userId, playgroundId);
val refreshToken = this.encodeJwtRefreshToken(userId);
return AppToken.builder().accessToken(accessToken).refreshToken(refreshToken).build();
}

private String encodeJwtToken(UserInfo.Id userId, Long playgroundId) {
private String encodeJwtToken(Long userId, Long playgroundId) {
val now = LocalDateTime.now();

return Jwts.builder()
.setHeaderParam(Header.TYPE, Header.JWT_TYPE)
.setIssuer("sopt-makers")
.setIssuedAt(now.toDate())
.setSubject(userId.getId().toString())
.setSubject(userId.toString())
.setExpiration(now.plusDays(1).toDate())
.claim("id", userId.getId())
.claim("id", userId)
.claim("playgroundId", playgroundId)
.claim("roles", "USER")
.signWith(getSigningKey(JWT_SECRET), SignatureAlgorithm.HS256)
.compact();
}

private String encodeJwtRefreshToken(UserInfo.Id userId) {
private String encodeJwtRefreshToken(Long userId) {
val now = LocalDateTime.now();
return Jwts.builder()
.setIssuedAt(now.toDate())
.setSubject(userId.getId().toString())
.setSubject(userId.toString())
.setExpiration(now.plusDays(30).toDate())
.claim("id", userId.getId())
.claim("id", userId)
.claim("roles", "USER")
.signWith(getSigningKey(JWT_SECRET), SignatureAlgorithm.HS256)
.compact();
}

public UserInfo.Id getUserIdFromJwtToken(String token) {
public Long getUserIdFromJwtToken(String token) {
try {
val claims = Jwts.parser()
.setSigningKey(this.encodeKey(JWT_SECRET))
.parseClaimsJws(token)
.getBody();
return UserInfo.Id.builder().id(Long.parseLong(claims.getSubject())).build();
return Long.parseLong(claims.getSubject());
} catch (ExpiredJwtException e) {
throw new UnauthorizedException("토큰이 만료되었습니다.");
throw new UnauthorizedException(ErrorCode.TOKEN_EXPIRED);
} catch (Exception e) {
throw new UnauthorizedException("토큰이 유효하지 않습니다.");
throw new UnauthorizedException(ErrorCode.INVALID_ACCESS_TOKEN);
}
}

public Authentication getAuthentication(String token) {
val userDetails = customUserDetailsService.loadUserByUsername(
this.getUserIdFromJwtToken(token).getId().toString());
return new UsernamePasswordAuthenticationToken(userDetails, "",
userDetails.getAuthorities());
val userDetails = customUserDetailsService.loadUserByUsername(this.getUserIdFromJwtToken(token).toString());
return new UsernamePasswordAuthenticationToken(userDetails, "", userDetails.getAuthorities());
}


public Boolean validateToken(String token) {
try {
val claims = Jwts.parser()
.setSigningKey(this.encodeKey(JWT_SECRET)).parseClaimsJws(token);
val claims = Jwts.parser().setSigningKey(this.encodeKey(JWT_SECRET)).parseClaimsJws(token);

return !claims.getBody().getExpiration().before(new Date());
} catch (Exception e) {
Expand Down
Loading

0 comments on commit ba66f07

Please sign in to comment.