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

Feat: Security 작업 및 Request Response Logging #11

Merged
merged 57 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d35a3b7
feat: Add Security Config
jinsu4755 Aug 3, 2023
dae771b
feat: Create Request Response Log
jinsu4755 Aug 3, 2023
abcf2ee
chore: re setting module
jinsu4755 Sep 18, 2023
3f05a80
feat: Add BadRequest Exception
jinsu4755 Sep 18, 2023
ce9371d
feat: Add BusinessException
jinsu4755 Sep 18, 2023
b43471f
feat: Add Unauthorized
jinsu4755 Sep 18, 2023
6835a7e
feat: separate sealed class
jinsu4755 Sep 18, 2023
ff30676
feat: Add Conflict Exception
jinsu4755 Sep 18, 2023
80aea76
feat: Add NotFound Exception
jinsu4755 Sep 18, 2023
05f1f50
feat: Add ServiceUnavailable Exception
jinsu4755 Sep 18, 2023
c75e6dd
feat: Add InternalServerError Exception
jinsu4755 Sep 18, 2023
433ce28
feat: Add NotAcceptable Exception
jinsu4755 Sep 18, 2023
e496c2c
feat: Add UnsupportedMediaType Exception
jinsu4755 Sep 18, 2023
0dcec47
feat: Add Bad Request Detail Case
jinsu4755 Sep 18, 2023
5ac6c90
feat: Add Unauthorized Detail Case
jinsu4755 Sep 18, 2023
513254b
feat: Add Sns Auth Type
jinsu4755 Sep 18, 2023
b697451
feat: Add SnsType
jinsu4755 Sep 18, 2023
bda9cbd
feat: Add SnsType attribute convertor
jinsu4755 Sep 18, 2023
455bcc8
feat: Add UserEntity
jinsu4755 Sep 18, 2023
7c7abc0
feat: Add UserEntity
jinsu4755 Sep 18, 2023
9479856
feat: Add User detail for security
jinsu4755 Sep 18, 2023
1b82d74
feat: Add user domain model
jinsu4755 Sep 18, 2023
fca4a37
feat: Add user mapper
jinsu4755 Sep 18, 2023
8591671
style: add comma
jinsu4755 Sep 18, 2023
1f3cf3c
feat: change private id to public
jinsu4755 Sep 18, 2023
dc1b158
feat: Create LoadUserInputBoundary
jinsu4755 Sep 18, 2023
1de913b
feat: Create UserGateway
jinsu4755 Sep 18, 2023
3e93095
feat: Add User find feature
jinsu4755 Sep 19, 2023
80bb3b3
build: Add jwt category bundle
jinsu4755 Sep 19, 2023
d0e018f
build: Add springdoc dependency
jinsu4755 Sep 19, 2023
9d4f244
feat: Add JwtConfig file
jinsu4755 Sep 19, 2023
b468e63
feat: Add jwt value property in JwtConfig
jinsu4755 Sep 19, 2023
bb31d1b
style: fix style
jinsu4755 Sep 19, 2023
d3482de
style: fix typo
jinsu4755 Sep 19, 2023
1df56ae
build: Add Mockk Dependency
jinsu4755 Sep 19, 2023
38f6e45
build: Add JwtConfigContract
jinsu4755 Sep 19, 2023
c09072f
build: Add mockK in version catalog
jinsu4755 Sep 19, 2023
ddb2cbf
feat: Add AuthToken Domain Model
jinsu4755 Sep 19, 2023
c712b8c
feat: Add BeIssuedAuthTokenUseCase
jinsu4755 Sep 19, 2023
91d5c91
feat: Add BeIssuedAuthTokenUseCase
jinsu4755 Sep 19, 2023
dee41a1
feat: Move ZoneId to JwtConfigContract Companion
jinsu4755 Sep 19, 2023
dde7b6c
feat: Add jwt validate usecase
jinsu4755 Sep 19, 2023
7940988
feat: Move ZoneId to JwtConfigContract Companion
jinsu4755 Sep 19, 2023
de4f90e
test: Add unexpired token verification test
jinsu4755 Sep 19, 2023
57c5bcd
feat: Add AuthenticationToken
jinsu4755 Sep 19, 2023
d7db66d
chore: Fix file name
jinsu4755 Sep 19, 2023
7537d34
test: Add Unauthorized Case Test
jinsu4755 Sep 20, 2023
4c60c78
feat: move magic string to companion object
jinsu4755 Sep 20, 2023
562395c
feat: change magic string to const
jinsu4755 Sep 20, 2023
08b30dd
feat: Change Validate Use Case to Extract Token Use Case
jinsu4755 Sep 20, 2023
c989225
feat: Fix Extract token throw method
jinsu4755 Sep 20, 2023
59a84f3
feat: Add Jwt Authentication with Security
jinsu4755 Sep 20, 2023
90cb4e6
chore: Fix CI action
jinsu4755 Sep 20, 2023
590eb3f
chore: Fix CI action
jinsu4755 Sep 20, 2023
674d625
chore: Fix CI action
jinsu4755 Sep 20, 2023
f05489b
chore: Fix CI action
jinsu4755 Sep 20, 2023
39cf2cc
chore: Fix CI action test files path
jinsu4755 Sep 20, 2023
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
41 changes: 41 additions & 0 deletions .github/workflows/gradle_task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
workflow_call:
inputs:
tasks:
description: gradle execute option
type: string

jobs:
gradle-task:
strategy:
matrix:
gradle: ${{ fromJSON(inputs.tasks) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.CI_TOKEN }}
submodules: true

- name: Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Run Gradle Task
run: ./gradlew ${{matrix.gradle}}
128 changes: 45 additions & 83 deletions .github/workflows/pr_ci_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,95 +11,57 @@ permissions:
pull-requests: write

jobs:
ktlint:
ci:
uses: ./.github/workflows/gradle_task.yml
with:
tasks: '["ktlintCheck", "build -x test -x ktlintCheck", "test"]'
secrets: inherit

publish-test-result:
needs:
- ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
token: ${{ secrets.CI_TOKEN }}
submodules: true
files: |
module-domain/build/test-results/**/*.xml
module-infrastructure/build/test-results/**/*.xml
module-usecase/build/test-results/**/*.xml
- name: Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: ktlintCheck
run: ./gradlew ktlintCheck
build:
result-success:
needs:
- ci
if: success()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.CI_TOKEN }}
submodules: true

- name: Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: build
run: ./gradlew build -x test -x ktlintCheck

test:
- name: On Success!! Congratulations
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: '#53A551'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_TITLE: 'Uni/PR Check S.U.C.C.E.S.S 🎉🎉🎉'
SLACK_ICON: ${{ github.event.org.avatar_url }}
MSG_MINIMAL: event,actions url, commit
SLACK_USERNAME: Uni-server
SLACK_MESSAGE: '${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.number}}'

result-failure:
needs:
- ci
if: failure()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.CI_TOKEN }}
submodules: true

- name: Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: test
run: ./gradlew test
- name: On Failed, Notify in Slack
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: '#ff0000'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_TITLE: 'Uni/Server Debug build Fail❌ 에러를 확인해주세요'
SLACK_ICON: ${{ github.event.org.avatar_url }}
MSG_MINIMAL: event,actions url, commit
SLACK_USERNAME: Uni-server
SLACK_MESSAGE: '${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.number}}'
7 changes: 7 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ springdoc = "2.1.0"
jjwt = "0.11.5"
kotlin = "1.8.22"
ktlint = "11.0.0"
mockk = "1.13.7"

service = "0.0.1-SNAPSHOT"

Expand Down Expand Up @@ -47,6 +48,7 @@ test-spring-boot-starter = { module = "org.springframework.boot:spring-boot-star
test-spring-security = { module = "org.springframework.security:spring-security-test" }
test-junit5-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" }
test-junit5-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" }
test-mockk = { module = "io.mockk:mockk", version.ref = "mockk" }

[plugins]
# common
Expand All @@ -62,3 +64,8 @@ ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
# kotlin

[bundles]
jjwt = [
"jjwt-api",
"jjwt-impl",
"jjwt-jackson"
]

This file was deleted.

This file was deleted.

This file was deleted.

55 changes: 0 additions & 55 deletions module-data/build.gradle

This file was deleted.

9 changes: 0 additions & 9 deletions module-data/settings.gradle

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion module-data/src/main/resources/application.properties

This file was deleted.

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package universe.sparkle.domain

import java.time.ZoneId

interface JwtConfigContract {
fun getSecret(): String
fun getAccessExpiryPeriodDay(): Long
fun getRefreshExpiryPeriodDay(): Long

companion object {
val zoneIdKST = ZoneId.of("Asia/Seoul")
}
}
12 changes: 12 additions & 0 deletions module-domain/src/main/kotlin/universe/sparkle/domain/SnsType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package universe.sparkle.domain

enum class SnsType {
KAKAO, GOOGLE, APPLE;

companion object {
fun findSnsTypeBy(snsTypeName: String): SnsType {
return values().find { it.name == snsTypeName }
?: throw IllegalArgumentException("Unsupported social login type: $snsTypeName")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package universe.sparkle.domain.exception

sealed class BadRequest(
code: Int,
message: String,
) : BusinessException(code, message) {
data class InvalidRequestMethod(
override val message: String = "잘못된 방식의 요청입니다.",
) : BadRequest(1001, message)

data class AlreadyGameCreated(
override val message: String = "이미 승부가 생성되었습니다.",
) : BadRequest(1002, message)

data class UserNotExistent(
override val message: String = "존재하지 않는 유저의 요청입니다.",
) : BadRequest(1003, message)

data class AlreadyGameDone(
override val message: String = "이미 게임이 종료 되었습니다.",
) : BadRequest(1004, message)

data class CoupleNotExistent(
override val message: String = "존재하지 않는 커플의 요청입니다.",
) : BadRequest(1005, message)

data class InvalidInviteCode(
override val message: String = "올바르지 않은 초대 코드입니다.",
) : BadRequest(1006, message)

data class PartnerResultNotEntered(
override val message: String = "상대방이 아직 결과를 입력하지 않았습니다.",
) : BadRequest(1007, message)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package universe.sparkle.domain.exception

sealed class BusinessException(
open val code: Int,
override val message: String,
) : RuntimeException(message)
Loading
Loading