From d0ddf7771186b36e3b657d569454dad5c30883d2 Mon Sep 17 00:00:00 2001 From: Photogrammer <81505228+JuneParkCode@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:57:13 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[FEAT]=20PR=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=EC=B2=B4=ED=81=AC=EB=B4=87=20=EC=B6=94=EA=B0=80=20(#30)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Github action 시에 build check를 하는 봇 추가입니다. --- .github/workflows/pr-bot.yml | 69 ++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/pr-bot.yml diff --git a/.github/workflows/pr-bot.yml b/.github/workflows/pr-bot.yml new file mode 100644 index 00000000..8ea66414 --- /dev/null +++ b/.github/workflows/pr-bot.yml @@ -0,0 +1,69 @@ +name: Java Spring Build Checker + +on: + pull_request: + paths: + - 'server/src/**' + - 'server/build.gradle' + branches: + - develop + workflow_dispatch: + inputs: + comment: + description: '수동 trigger 사유' + default: 'ex) 서버 설정 변경 등' + +permissions: + checks: write + pull-requests: write + +jobs: + build: + name: Build check + runs-on: ubuntu-latest + env: + working-directory: server + steps: + - name: Checkout the code + uses: actions/checkout@v3 + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'corretto' + cache: 'gradle' + + - name: Setup MySQL + uses: mirromutth/mysql-action@v1.1 + with: + mysql database: 'talkka_db' + mysql user: ${{ secrets.MYSQL_USERNAME }} + mysql password: ${{ secrets.MYSQL_PASSWORD }} + + - name: Make application.yaml + run: | + cd ./src/main/resources + touch ./application.yaml + + echo "${{ secrets.APPLICATION_YAML }}" >> ./application.yaml + shell: bash + working-directory: ${{ env.working-directory }} + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + working-directory: ${{ env.working-directory }} + + - name: Build with Gradle + run: ./gradlew clean build --debug --exclude-task test + working-directory: ${{ env.working-directory }} \ No newline at end of file From fd7c9e26412b97fd015f50d80d9bb167d3844c52 Mon Sep 17 00:00:00 2001 From: Gyaak Date: Fri, 2 Aug 2024 15:43:45 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[FEAT]=20=EB=84=A4=EC=9D=B4=EB=B2=84=20?= =?UTF-8?q?=EC=86=8C=EC=85=9C=20=EC=9D=B8=EC=A6=9D=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?#9=20(#31)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 네이버 소셜 인증 구현 - @JuneParkCode 의 코드와 병합하기 위한 작업 --- server/build.gradle | 2 ++ .../com/talkka/server/ServerApplication.java | 4 +-- .../talkka/server/config/SecurityConfig.java | 4 +++ .../oauth/OAuth2LoginFailureHandler.java | 4 +++ .../oauth/OAuth2LoginSuccessHandler.java | 4 +++ .../oauth/controller/AuthController.java | 4 +++ .../server/oauth/domain/AuthUserDto.java | 4 +++ .../oauth/domain/CustomUserPrincipal.java | 4 +++ .../oauth/service/CustomOAuth2Service.java | 4 +++ .../talkka/server/user/dao/UserEntity.java | 8 +++++- .../server/user/dao/UserRepository.java | 2 ++ .../talkka/server/user/dto/UserCreateDto.java | 4 +++ server/src/main/resources/application.yaml | 26 +++++++++++++++++-- 13 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 server/src/main/java/com/talkka/server/config/SecurityConfig.java create mode 100644 server/src/main/java/com/talkka/server/oauth/OAuth2LoginFailureHandler.java create mode 100644 server/src/main/java/com/talkka/server/oauth/OAuth2LoginSuccessHandler.java create mode 100644 server/src/main/java/com/talkka/server/oauth/controller/AuthController.java create mode 100644 server/src/main/java/com/talkka/server/oauth/domain/AuthUserDto.java create mode 100644 server/src/main/java/com/talkka/server/oauth/domain/CustomUserPrincipal.java create mode 100644 server/src/main/java/com/talkka/server/oauth/service/CustomOAuth2Service.java diff --git a/server/build.gradle b/server/build.gradle index 06b12ecc..c1720d0b 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -27,6 +27,8 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.mysql:mysql-connector-j' annotationProcessor 'org.projectlombok:lombok' diff --git a/server/src/main/java/com/talkka/server/ServerApplication.java b/server/src/main/java/com/talkka/server/ServerApplication.java index ea61ead2..7d4d3d99 100644 --- a/server/src/main/java/com/talkka/server/ServerApplication.java +++ b/server/src/main/java/com/talkka/server/ServerApplication.java @@ -2,12 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import jakarta.persistence.EntityListeners; - @SpringBootApplication +@EnableJpaAuditing public class ServerApplication { public static void main(String[] args) { diff --git a/server/src/main/java/com/talkka/server/config/SecurityConfig.java b/server/src/main/java/com/talkka/server/config/SecurityConfig.java new file mode 100644 index 00000000..2842e94d --- /dev/null +++ b/server/src/main/java/com/talkka/server/config/SecurityConfig.java @@ -0,0 +1,4 @@ +package com.talkka.server.config; + +public class SecurityConfig { +} diff --git a/server/src/main/java/com/talkka/server/oauth/OAuth2LoginFailureHandler.java b/server/src/main/java/com/talkka/server/oauth/OAuth2LoginFailureHandler.java new file mode 100644 index 00000000..0aeaf05c --- /dev/null +++ b/server/src/main/java/com/talkka/server/oauth/OAuth2LoginFailureHandler.java @@ -0,0 +1,4 @@ +package com.talkka.server.oauth; + +public class OAuth2LoginFailureHandler { +} diff --git a/server/src/main/java/com/talkka/server/oauth/OAuth2LoginSuccessHandler.java b/server/src/main/java/com/talkka/server/oauth/OAuth2LoginSuccessHandler.java new file mode 100644 index 00000000..6b15d843 --- /dev/null +++ b/server/src/main/java/com/talkka/server/oauth/OAuth2LoginSuccessHandler.java @@ -0,0 +1,4 @@ +package com.talkka.server.oauth; + +public class OAuth2LoginSuccessHandler { +} diff --git a/server/src/main/java/com/talkka/server/oauth/controller/AuthController.java b/server/src/main/java/com/talkka/server/oauth/controller/AuthController.java new file mode 100644 index 00000000..dc28a824 --- /dev/null +++ b/server/src/main/java/com/talkka/server/oauth/controller/AuthController.java @@ -0,0 +1,4 @@ +package com.talkka.server.oauth.controller; + +public class AuthController { +} diff --git a/server/src/main/java/com/talkka/server/oauth/domain/AuthUserDto.java b/server/src/main/java/com/talkka/server/oauth/domain/AuthUserDto.java new file mode 100644 index 00000000..c832c70e --- /dev/null +++ b/server/src/main/java/com/talkka/server/oauth/domain/AuthUserDto.java @@ -0,0 +1,4 @@ +package com.talkka.server.oauth.domain; + +public class AuthUserDto { +} diff --git a/server/src/main/java/com/talkka/server/oauth/domain/CustomUserPrincipal.java b/server/src/main/java/com/talkka/server/oauth/domain/CustomUserPrincipal.java new file mode 100644 index 00000000..9babd035 --- /dev/null +++ b/server/src/main/java/com/talkka/server/oauth/domain/CustomUserPrincipal.java @@ -0,0 +1,4 @@ +package com.talkka.server.oauth.domain; + +public class CustomUserPrincipal { +} diff --git a/server/src/main/java/com/talkka/server/oauth/service/CustomOAuth2Service.java b/server/src/main/java/com/talkka/server/oauth/service/CustomOAuth2Service.java new file mode 100644 index 00000000..674305f3 --- /dev/null +++ b/server/src/main/java/com/talkka/server/oauth/service/CustomOAuth2Service.java @@ -0,0 +1,4 @@ +package com.talkka.server.oauth.service; + +public class CustomOAuth2Service { +} diff --git a/server/src/main/java/com/talkka/server/user/dao/UserEntity.java b/server/src/main/java/com/talkka/server/user/dao/UserEntity.java index a0c4aea8..386819ab 100644 --- a/server/src/main/java/com/talkka/server/user/dao/UserEntity.java +++ b/server/src/main/java/com/talkka/server/user/dao/UserEntity.java @@ -42,6 +42,12 @@ public class UserEntity { @Column(name = "user_id", nullable = false) private Long userId; + @Column(name = "name", nullable = false) + private String name; + + @Column(name = "email", length = 30, nullable = false) + private String email; + @Column(name = "nickname", length = 50, nullable = false) private String nickname; @@ -51,7 +57,7 @@ public class UserEntity { @Column(name = "access_token", length = 255, nullable = false) private String accessToken; - @Column(name = "grade", length = 20, nullable = false) + @Column(name = "grade", length = 20, nullable = true) @Enumerated(EnumType.STRING) private Grade grade; diff --git a/server/src/main/java/com/talkka/server/user/dao/UserRepository.java b/server/src/main/java/com/talkka/server/user/dao/UserRepository.java index 7501228d..f1515865 100644 --- a/server/src/main/java/com/talkka/server/user/dao/UserRepository.java +++ b/server/src/main/java/com/talkka/server/user/dao/UserRepository.java @@ -6,4 +6,6 @@ @Repository public interface UserRepository extends JpaRepository { boolean existsByNickname(String nickname); + + boolean existsByEmail(String email); } diff --git a/server/src/main/java/com/talkka/server/user/dto/UserCreateDto.java b/server/src/main/java/com/talkka/server/user/dto/UserCreateDto.java index 63326b4f..305b8944 100644 --- a/server/src/main/java/com/talkka/server/user/dto/UserCreateDto.java +++ b/server/src/main/java/com/talkka/server/user/dto/UserCreateDto.java @@ -17,6 +17,8 @@ @NoArgsConstructor @AllArgsConstructor public class UserCreateDto { + private String name; + private String email; private String nickname; private String oauthProvider; private String accessToken; @@ -24,6 +26,8 @@ public class UserCreateDto { public UserEntity toEntity() { return UserEntity.builder() + .name(name) + .email(email) .nickname(nickname) .oauthProvider(oauthProvider) .accessToken(accessToken) diff --git a/server/src/main/resources/application.yaml b/server/src/main/resources/application.yaml index 816ccb81..321fef38 100644 --- a/server/src/main/resources/application.yaml +++ b/server/src/main/resources/application.yaml @@ -8,9 +8,31 @@ spring: password: ${MYSQL_PASSWORD} jpa: hibernate: - ddl-auto: validate + ddl-auto: create properties: hibernate: format_sql: true dialect: org.hibernate.dialect.MySQL8Dialect - show-sql: true \ No newline at end of file + show-sql: true + security: + oauth2: + client: + registration: + naver: + client-id: ${NAVER_CLIENT_ID} + client-secret: ${NAVER_CLINET_SECRET} + redirect_uri: http://localhost:8080/login/oauth2/code/naver + client-name: Naver + authorization-grant-type: authorization_code + scope: + - name + - email + provider: + naver: + authorization-uri: https://nid.naver.com/oauth2.0/authorize + token-uri: https://nid.naver.com/oauth2.0/token + user-info-uri: https://openapi.naver.com/v1/nid/me + user-name-attribute: response + thymeleaf: + prefix: classpath:/templates/ + suffix: .html \ No newline at end of file