From cf86ff35c1f31171602bb8be1a9d1ad9d8f901bc Mon Sep 17 00:00:00 2001 From: heodongun <“heodongun0922@gmail.com”> Date: Mon, 24 Feb 2025 20:48:06 +0900 Subject: [PATCH 1/6] =?UTF-8?q?FIX=20:=20spring=EC=97=90=EB=8B=A4=EA=B0=80?= =?UTF-8?q?=20security=EA=B0=80=20=EC=95=88=EB=93=A4=EC=96=B4=EA=B0=94?= =?UTF-8?q?=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d7ccf57..bff74b3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -11,29 +11,29 @@ spring: ddl-auto: update properties: hibernate.dialect: org.hibernate.dialect.MySQL8Dialect + security: + oauth2: + client: + registration: + kakao: + client-authentication-method: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_AUTHENTICATION_METHOD} + client-name: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_NAME} + client-id: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_ID} + client-secret: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_SECRET} + redirect-uri: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI} + authorization-grant-type: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE} + scope: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE} + provider: + kakao: + authorization-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI} + token-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI} + user-info-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI} + user-name-attribute: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE} + jwt: + secret: ${JWT_SECRET} face: api: url: ${API_URL} token: ${API_TOKEN} -security: - oauth2: - client: - registration: - kakao: - client-authentication-method: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_AUTHENTICATION_METHOD} - client-name: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_NAME} - client-id: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_ID} - client-secret: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_SECRET} - redirect-uri: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI} - authorization-grant-type: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE} - scope: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE} - provider: - kakao: - authorization-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI} - token-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI} - user-info-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI} - user-name-attribute: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE} -jwt: - secret: ${JWT_SECRET} From 03e7a83660035db40dd6230f29fd89bea168d5bb Mon Sep 17 00:00:00 2001 From: heodongun <“heodongun0922@gmail.com”> Date: Tue, 25 Feb 2025 22:00:30 +0900 Subject: [PATCH 2/6] =?UTF-8?q?F=E3=85=91=E3=85=8C=20:=20=EC=8B=A4?= =?UTF-8?q?=ED=96=89=EC=9D=B4=20=EC=95=88=EB=90=98=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- build.gradle | 7 +-- .../log/common/config/SecurityConfig.java | 1 + .../elice/service/ImageGenerationService.java | 2 +- .../impl/FaceDetectionServiceImpl.java | 4 +- .../com/bamboo/log/utils/SecurityConfig.java | 23 ---------- src/main/resources/application.txt | 40 +++++++++++++++++ src/main/resources/application.yml | 45 +++++++++---------- 8 files changed, 69 insertions(+), 55 deletions(-) delete mode 100644 src/main/java/com/bamboo/log/utils/SecurityConfig.java create mode 100644 src/main/resources/application.txt diff --git a/.env b/.env index 3f466ec..983dc22 100644 --- a/.env +++ b/.env @@ -13,7 +13,7 @@ SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_AUTHENTICATION_METHOD=client_se SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_NAME=kakao SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_ID=649c1e34aedc1a7db892333d900725f2 SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_SECRET=FqJEAF5XKaO0n4Bv3KVXWCpUcHQWahY8 -SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI=http://localhost:8080/login/oauth2/code/kakao +SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI=https://qbdffmpbayqfbgja.tunnel-pt.elice.io/login/oauth2/code/kakao SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE=authorization_code SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE=profile_nickname,account_email diff --git a/build.gradle b/build.gradle index 56f4f0e..25ad86f 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,7 @@ dependencies { compileOnly 'org.projectlombok:lombok:1.18.26' runtimeOnly 'com.mysql:mysql-connector-j:8.0.32' annotationProcessor 'org.projectlombok:lombok:1.18.26' + implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' testImplementation 'org.springframework.boot:spring-boot-starter-test:3.1.0' implementation 'org.hibernate.validator:hibernate-validator:8.0.1.Final' @@ -44,9 +45,9 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-security:3.0.4' // JWT - implementation 'io.jsonwebtoken:jjwt-api:0.11.5' - implementation 'io.jsonwebtoken:jjwt-impl:0.11.5' - implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5' + implementation 'io.jsonwebtoken:jjwt-api:0.12.3' + implementation 'io.jsonwebtoken:jjwt-impl:0.12.3' + implementation 'io.jsonwebtoken:jjwt-jackson:0.12.3' // chatGPT API implementation 'io.github.flashvayne:chatgpt-spring-boot-starter:1.0.4' diff --git a/src/main/java/com/bamboo/log/common/config/SecurityConfig.java b/src/main/java/com/bamboo/log/common/config/SecurityConfig.java index f36c518..d40a6fe 100644 --- a/src/main/java/com/bamboo/log/common/config/SecurityConfig.java +++ b/src/main/java/com/bamboo/log/common/config/SecurityConfig.java @@ -52,6 +52,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .requestMatchers("/refresh").permitAll() .requestMatchers("/logout").hasAnyRole("USER") .requestMatchers("/swagger-ui/**","/v3/api-docs/**","/swagger-resources/**","/webjars/**").permitAll() + .requestMatchers("/api/images/**").hasAnyRole("USER") .anyRequest().authenticated()); diff --git a/src/main/java/com/bamboo/log/elice/service/ImageGenerationService.java b/src/main/java/com/bamboo/log/elice/service/ImageGenerationService.java index d7aa11b..d318cce 100644 --- a/src/main/java/com/bamboo/log/elice/service/ImageGenerationService.java +++ b/src/main/java/com/bamboo/log/elice/service/ImageGenerationService.java @@ -22,7 +22,7 @@ public class ImageGenerationService { public ImageGenerationService(RestTemplate restTemplate, @Value("${elice.api.token}") String apiKey, - @Value("${elice.api.url}") String apiUrl) { + @Value("${elice.api.url.img}") String apiUrl) { this.restTemplate = restTemplate; this.apiKey = apiKey; this.apiUrl = apiUrl; diff --git a/src/main/java/com/bamboo/log/emotion/service/impl/FaceDetectionServiceImpl.java b/src/main/java/com/bamboo/log/emotion/service/impl/FaceDetectionServiceImpl.java index 0e3fa52..47e6d8a 100644 --- a/src/main/java/com/bamboo/log/emotion/service/impl/FaceDetectionServiceImpl.java +++ b/src/main/java/com/bamboo/log/emotion/service/impl/FaceDetectionServiceImpl.java @@ -19,10 +19,10 @@ @RequiredArgsConstructor public class FaceDetectionServiceImpl implements FaceDetectionService { - @Value("${face.api.url}") + @Value("${elice.api.url.face}") private String faceApiUrl; - @Value("${face.api.token}") + @Value("${elice.api.token}") private String faceToken; private final OkHttpClient client = new OkHttpClient(); diff --git a/src/main/java/com/bamboo/log/utils/SecurityConfig.java b/src/main/java/com/bamboo/log/utils/SecurityConfig.java deleted file mode 100644 index 5d51eb4..0000000 --- a/src/main/java/com/bamboo/log/utils/SecurityConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.bamboo.log.utils; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -public class SecurityConfig { - @Bean - public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http - .csrf(csrf -> csrf.disable()) // CSRF 비활성화 - .authorizeHttpRequests(auth -> auth - .requestMatchers("/api/images/**").permitAll() // 이미지 API 인증 없이 허용 - .anyRequest().authenticated() - ); - - return http.build(); - } -} diff --git a/src/main/resources/application.txt b/src/main/resources/application.txt new file mode 100644 index 0000000..f930f54 --- /dev/null +++ b/src/main/resources/application.txt @@ -0,0 +1,40 @@ +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_NAME} + username: ${MYSQL_USERNAME} + password: ${MYSQL_PASSWORD} + jpa: + show-sql: true + open-in-view: false + hibernate: + ddl-auto: update + properties: + hibernate.dialect: org.hibernate.dialect.MySQL8Dialect + security: + oauth2: + client: + registration: + kakao: + client-authentication-method: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_AUTHENTICATION_METHOD} + client-name: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_NAME} + client-id: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_ID} + client-secret: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_SECRET} + redirect-uri: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI} + authorization-grant-type: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE} + scope: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE} + provider: + kakao: + authorization-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI} + token-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI} + user-info-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI} + user-name-attribute: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE} + jwt: + secret: ${JWT_SECRET} +elice: + api: + token: ${API_TOKEN} + url: + face: ${FACE_API_URL} + img: ${IMG_API_URL} + chat: ${CHAT_API_URL} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 99a2856..d73895c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,15 +1,14 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_NAME} - username: ${MYSQL_USERNAME} - password: ${MYSQL_PASSWORD} - + url: jdbc:mysql://localhost:3306/OAuth2 + username: root + password: heodongun0922 jpa: show-sql: true open-in-view: false hibernate: - ddl-auto: update + ddl-auto: update properties: hibernate.dialect: org.hibernate.dialect.MySQL8Dialect security: @@ -17,30 +16,26 @@ spring: client: registration: kakao: - client-authentication-method: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_AUTHENTICATION_METHOD} - client-name: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_NAME} - client-id: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_ID} - client-secret: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_SECRET} - redirect-uri: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI} - authorization-grant-type: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE} - scope: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE} + client-authentication-method: client_secret_post + client-name: kakao + client-id: 649c1e34aedc1a7db892333d900725f2 + client-secret: FqJEAF5XKaO0n4Bv3KVXWCpUcHQWahY8 + redirect-uri: https://qbdffmpbayqfbgja.tunnel-pt.elice.io/login/oauth2/code/kakao + authorization-grant-type: authorization_code + scope: profile_nickname,account_email provider: kakao: - authorization-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI} - token-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI} - user-info-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI} - user-name-attribute: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE} + authorization-uri: https://kauth.kakao.com/oauth/authorize + token-uri: https://kauth.kakao.com/oauth/token + user-info-uri: https://kapi.kakao.com/v2/user/me + user-name-attribute: id jwt: - secret: ${JWT_SECRET} - + secret: fkldjfklsdjfaslkjflaksdjklfjaljewofijaenndlksjajojf -<<<<<<< HEAD -======= elice: api: - token: ${API_TOKEN} + token: yJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3Mzg4MzQxNDgsIm5iZiI6MTczODgzNDE0OCwia2V5X2lkIjoiZTdmNTUxN2MtYzNlZC00ZmVmLWFkNzYtNTUxZjA3ZDJmMjNiIn0.sMIASpWdac5l3GdIXshb7NnuB-PQlHMFyNurcpu4Cms url: - face: ${FACE_API_URL} - img: ${IMG_API_URL} - chat: ${CHAT_API_URL} ->>>>>>> 26d32802fbee3eb134324181a8ee6563352db34b + face: https://api-cloud-function.elice.io/d5ff1aef-c59f-433c-8e1c-f9b52ac4ab6a/predict + img: https://api-cloud-function.elice.io/0133c2f7-9f3f-44b6-a3d6-c24ba8ef4510/generate + chat: https://api-cloud-function.elice.io/9f071d94-a459-429d-a375-9601e521b079/v1/chat/completions From 70e0b7c587a4f0d6be1db9f217d1e7daeac7bf4f Mon Sep 17 00:00:00 2001 From: heodongun <“heodongun0922@gmail.com”> Date: Tue, 25 Feb 2025 22:06:36 +0900 Subject: [PATCH 3/6] =?UTF-8?q?Fix=20:=20=EC=8B=A4=ED=96=89=EC=9D=B4=20?= =?UTF-8?q?=EC=95=88=EB=90=98=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 30 ------------------------- src/main/resources/application.txt | 24 +++++++++++--------- src/main/resources/application.yml | 36 ------------------------------ 3 files changed, 13 insertions(+), 77 deletions(-) diff --git a/build.gradle b/build.gradle index 44ef86e..53c709f 100644 --- a/build.gradle +++ b/build.gradle @@ -24,16 +24,6 @@ repositories { } dependencies { -<<<<<<< HEAD - implementation 'org.springframework.boot:spring-boot-starter-data-jpa:3.0.4' - implementation 'org.springframework.boot:spring-boot-starter-web:3.1.0' - testImplementation 'org.projectlombok:lombok:1.18.26' - compileOnly 'org.projectlombok:lombok:1.18.26' - runtimeOnly 'com.mysql:mysql-connector-j:8.0.32' - annotationProcessor 'org.projectlombok:lombok:1.18.26' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' - testImplementation 'org.springframework.boot:spring-boot-starter-test:3.1.0' -======= implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-validation' @@ -43,7 +33,6 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-api:0.12.3' implementation 'io.jsonwebtoken:jjwt-impl:0.12.3' implementation 'io.jsonwebtoken:jjwt-jackson:0.12.3' ->>>>>>> 63ef269f5e00a859d97f46db4c165311a5033d33 developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'com.mysql:mysql-connector-j' @@ -55,27 +44,8 @@ dependencies { testImplementation 'org.springframework.security:spring-security-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' -<<<<<<< HEAD - // Spring Security - implementation 'org.springframework.boot:spring-boot-starter-security:3.0.4' - - // JWT - implementation 'io.jsonwebtoken:jjwt-api:0.12.3' - implementation 'io.jsonwebtoken:jjwt-impl:0.12.3' - implementation 'io.jsonwebtoken:jjwt-jackson:0.12.3' - - // chatGPT API - implementation 'io.github.flashvayne:chatgpt-spring-boot-starter:1.0.4' - - // JSON 라이브러리 - implementation 'org.json:json:20230227' - - implementation 'org.springframework:spring-test:6.0.6' - testImplementation 'org.springframework.boot:spring-boot-starter-test:3.1.0' -======= // okhttp implementation 'com.squareup.okhttp3:okhttp:4.12.0' ->>>>>>> 63ef269f5e00a859d97f46db4c165311a5033d33 } tasks.named('test') { diff --git a/src/main/resources/application.txt b/src/main/resources/application.txt index f930f54..746ba36 100644 --- a/src/main/resources/application.txt +++ b/src/main/resources/application.txt @@ -1,16 +1,17 @@ spring: datasource: - driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_NAME} username: ${MYSQL_USERNAME} password: ${MYSQL_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver jpa: show-sql: true open-in-view: false hibernate: - ddl-auto: update + ddl-auto: update properties: hibernate.dialect: org.hibernate.dialect.MySQL8Dialect + security: oauth2: client: @@ -23,18 +24,19 @@ spring: redirect-uri: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI} authorization-grant-type: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE} scope: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE} - provider: - kakao: - authorization-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI} - token-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI} - user-info-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI} - user-name-attribute: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE} + provider: + kakao: + authorization-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI} + token-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI} + user-info-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI} + user-name-attribute: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE} jwt: secret: ${JWT_SECRET} + elice: api: token: ${API_TOKEN} url: - face: ${FACE_API_URL} - img: ${IMG_API_URL} - chat: ${CHAT_API_URL} + face: ${FACE_URL} + img: ${IMG_URL} + chat: ${CHAT_URL} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8b1e288..e7731bb 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,16 +1,9 @@ spring: datasource: -<<<<<<< HEAD driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/OAuth2 username: root password: heodongun0922 -======= - url: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_NAME} - username: ${MYSQL_USERNAME} - password: ${MYSQL_PASSWORD} - driver-class-name: com.mysql.cj.jdbc.Driver ->>>>>>> 63ef269f5e00a859d97f46db4c165311a5033d33 jpa: show-sql: true open-in-view: false @@ -18,16 +11,11 @@ spring: ddl-auto: update properties: hibernate.dialect: org.hibernate.dialect.MySQL8Dialect -<<<<<<< HEAD -======= - ->>>>>>> 63ef269f5e00a859d97f46db4c165311a5033d33 security: oauth2: client: registration: kakao: -<<<<<<< HEAD client-authentication-method: client_secret_post client-name: kakao client-id: 649c1e34aedc1a7db892333d900725f2 @@ -43,34 +31,10 @@ spring: user-name-attribute: id jwt: secret: fkldjfklsdjfaslkjflaksdjklfjaljewofijaenndlksjajojf -======= - client-authentication-method: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_AUTHENTICATION_METHOD} - client-name: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_NAME} - client-id: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_ID} - client-secret: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_SECRET} - redirect-uri: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI} - authorization-grant-type: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE} - scope: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE} - provider: - kakao: - authorization-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI} - token-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI} - user-info-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI} - user-name-attribute: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE} - jwt: - secret: ${JWT_SECRET} ->>>>>>> 63ef269f5e00a859d97f46db4c165311a5033d33 - elice: api: token: yJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3Mzg4MzQxNDgsIm5iZiI6MTczODgzNDE0OCwia2V5X2lkIjoiZTdmNTUxN2MtYzNlZC00ZmVmLWFkNzYtNTUxZjA3ZDJmMjNiIn0.sMIASpWdac5l3GdIXshb7NnuB-PQlHMFyNurcpu4Cms url: -<<<<<<< HEAD face: https://api-cloud-function.elice.io/d5ff1aef-c59f-433c-8e1c-f9b52ac4ab6a/predict img: https://api-cloud-function.elice.io/0133c2f7-9f3f-44b6-a3d6-c24ba8ef4510/generate chat: https://api-cloud-function.elice.io/9f071d94-a459-429d-a375-9601e521b079/v1/chat/completions -======= - face: ${FACE_URL} - img: ${IMG_URL} - chat: ${CHAT_URL} ->>>>>>> 63ef269f5e00a859d97f46db4c165311a5033d33 From 7045e3b60e436c364dc034fa8108dbe186bda178 Mon Sep 17 00:00:00 2001 From: heodongun <“heodongun0922@gmail.com”> Date: Wed, 26 Feb 2025 00:51:27 +0900 Subject: [PATCH 4/6] =?UTF-8?q?Fix=20:=20yml=20=EC=97=90=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bamboo/log/diary/repository/DiaryRepository.java | 1 + .../log/domain/user/oauth/dto/CustomOAuth2User.java | 4 ++++ src/main/resources/application.yml | 12 ++++++------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/bamboo/log/diary/repository/DiaryRepository.java b/src/main/java/com/bamboo/log/diary/repository/DiaryRepository.java index 416db42..2ef3b85 100644 --- a/src/main/java/com/bamboo/log/diary/repository/DiaryRepository.java +++ b/src/main/java/com/bamboo/log/diary/repository/DiaryRepository.java @@ -4,4 +4,5 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface DiaryRepository extends JpaRepository { + Diary findByContext(String diaryContent); } diff --git a/src/main/java/com/bamboo/log/domain/user/oauth/dto/CustomOAuth2User.java b/src/main/java/com/bamboo/log/domain/user/oauth/dto/CustomOAuth2User.java index 3e33b94..dcabe8e 100644 --- a/src/main/java/com/bamboo/log/domain/user/oauth/dto/CustomOAuth2User.java +++ b/src/main/java/com/bamboo/log/domain/user/oauth/dto/CustomOAuth2User.java @@ -45,4 +45,8 @@ public String getName() { public String getUsername() { return userDTO.getUsername(); } + + public String userId(){ + return userDTO.getId + } } \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index e7731bb..cecbe40 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -23,12 +23,12 @@ spring: redirect-uri: https://qbdffmpbayqfbgja.tunnel-pt.elice.io/login/oauth2/code/kakao authorization-grant-type: authorization_code scope: profile_nickname,account_email - provider: - kakao: - authorization-uri: https://kauth.kakao.com/oauth/authorize - token-uri: https://kauth.kakao.com/oauth/token - user-info-uri: https://kapi.kakao.com/v2/user/me - user-name-attribute: id + provider: + kakao: + authorization-uri: https://kauth.kakao.com/oauth/authorize + token-uri: https://kauth.kakao.com/oauth/token + user-info-uri: https://kapi.kakao.com/v2/user/me + user-name-attribute: id jwt: secret: fkldjfklsdjfaslkjflaksdjklfjaljewofijaenndlksjajojf elice: From be1d417f3d5d972e0724d52df07e89857249ee3b Mon Sep 17 00:00:00 2001 From: heodongun <“heodongun0922@gmail.com”> Date: Wed, 26 Feb 2025 00:53:04 +0900 Subject: [PATCH 5/6] =?UTF-8?q?Fix=20:=20yml=20=EC=97=90=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 25 ------------------ src/main/resources/application.txt | 42 ------------------------------ src/main/resources/application.yml | 40 ++++++++++++++-------------- 3 files changed, 21 insertions(+), 86 deletions(-) delete mode 100644 .env delete mode 100644 src/main/resources/application.txt diff --git a/.env b/.env deleted file mode 100644 index 983dc22..0000000 --- a/.env +++ /dev/null @@ -1,25 +0,0 @@ -MYSQL_HOST=localhost -MYSQL_PORT=3306 -MYSQL_NAME=OAuth2 -MYSQL_USERNAME=root -MYSQL_PASSWORD=heodongun0922 - -SPRING_JPA_SHOW_SQL=true -SPRING_JPA_OPEN_IN_VIEW=false -SPRING_JPA_HIBERNATE_DDL_AUTO=update -SPRING_JPA_PROPERTIES_HIBERNATE_DIALECT=org.hibernate.dialect.MySQL8Dialect - -SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_AUTHENTICATION_METHOD=client_secret_post -SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_NAME=kakao -SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_ID=649c1e34aedc1a7db892333d900725f2 -SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_SECRET=FqJEAF5XKaO0n4Bv3KVXWCpUcHQWahY8 -SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI=https://qbdffmpbayqfbgja.tunnel-pt.elice.io/login/oauth2/code/kakao -SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE=authorization_code -SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE=profile_nickname,account_email - -SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI=https://kauth.kakao.com/oauth/authorize -SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI=https://kauth.kakao.com/oauth/token -SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI=https://kapi.kakao.com/v2/user/me -SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE=id - -JWT_SECRET=fkldjfklsdjfaslkjflaksdjklfjaljewofijaenndlksjajojf \ No newline at end of file diff --git a/src/main/resources/application.txt b/src/main/resources/application.txt deleted file mode 100644 index 746ba36..0000000 --- a/src/main/resources/application.txt +++ /dev/null @@ -1,42 +0,0 @@ -spring: - datasource: - url: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_NAME} - username: ${MYSQL_USERNAME} - password: ${MYSQL_PASSWORD} - driver-class-name: com.mysql.cj.jdbc.Driver - jpa: - show-sql: true - open-in-view: false - hibernate: - ddl-auto: update - properties: - hibernate.dialect: org.hibernate.dialect.MySQL8Dialect - - security: - oauth2: - client: - registration: - kakao: - client-authentication-method: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_AUTHENTICATION_METHOD} - client-name: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_NAME} - client-id: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_ID} - client-secret: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_SECRET} - redirect-uri: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI} - authorization-grant-type: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE} - scope: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE} - provider: - kakao: - authorization-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI} - token-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI} - user-info-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI} - user-name-attribute: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE} - jwt: - secret: ${JWT_SECRET} - -elice: - api: - token: ${API_TOKEN} - url: - face: ${FACE_URL} - img: ${IMG_URL} - chat: ${CHAT_URL} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index cecbe40..17527e6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,9 +1,11 @@ +# application.yml + spring: datasource: + url: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_NAME} + username: ${MYSQL_USERNAME} + password: ${MYSQL_PASSWORD} driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/OAuth2 - username: root - password: heodongun0922 jpa: show-sql: true open-in-view: false @@ -16,25 +18,25 @@ spring: client: registration: kakao: - client-authentication-method: client_secret_post - client-name: kakao - client-id: 649c1e34aedc1a7db892333d900725f2 - client-secret: FqJEAF5XKaO0n4Bv3KVXWCpUcHQWahY8 - redirect-uri: https://qbdffmpbayqfbgja.tunnel-pt.elice.io/login/oauth2/code/kakao - authorization-grant-type: authorization_code - scope: profile_nickname,account_email + client-authentication-method: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_AUTHENTICATION_METHOD} + client-name: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_NAME} + client-id: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_ID} + client-secret: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_CLIENT_SECRET} + redirect-uri: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_REDIRECT_URI} + authorization-grant-type: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_AUTHORIZATION_GRANT_TYPE} + scope: ${SECURITY_OAUTH2_CLIENT_REGISTRATION_KAKAO_SCOPE} provider: kakao: - authorization-uri: https://kauth.kakao.com/oauth/authorize - token-uri: https://kauth.kakao.com/oauth/token - user-info-uri: https://kapi.kakao.com/v2/user/me - user-name-attribute: id + authorization-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_AUTHORIZATION_URI} + token-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_TOKEN_URI} + user-info-uri: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_INFO_URI} + user-name-attribute: ${SECURITY_OAUTH2_PROVIDER_KAKAO_USER_NAME_ATTRIBUTE} jwt: - secret: fkldjfklsdjfaslkjflaksdjklfjaljewofijaenndlksjajojf + secret: ${JWT_SECRET} elice: api: - token: yJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3Mzg4MzQxNDgsIm5iZiI6MTczODgzNDE0OCwia2V5X2lkIjoiZTdmNTUxN2MtYzNlZC00ZmVmLWFkNzYtNTUxZjA3ZDJmMjNiIn0.sMIASpWdac5l3GdIXshb7NnuB-PQlHMFyNurcpu4Cms + token: ${API_TOKEN} url: - face: https://api-cloud-function.elice.io/d5ff1aef-c59f-433c-8e1c-f9b52ac4ab6a/predict - img: https://api-cloud-function.elice.io/0133c2f7-9f3f-44b6-a3d6-c24ba8ef4510/generate - chat: https://api-cloud-function.elice.io/9f071d94-a459-429d-a375-9601e521b079/v1/chat/completions + face: ${FACE_URL} + img: ${IMG_URL} + chat: ${CHAT_URL} \ No newline at end of file From e4dc9a0b1461dffa42bbf64f6303576956f9c488 Mon Sep 17 00:00:00 2001 From: heodongun <“heodongun0922@gmail.com”> Date: Wed, 26 Feb 2025 00:53:46 +0900 Subject: [PATCH 6/6] =?UTF-8?q?Fix=20:=20yml=20=EC=97=90=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/bamboo/log/diary/repository/DiaryRepository.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/bamboo/log/diary/repository/DiaryRepository.java b/src/main/java/com/bamboo/log/diary/repository/DiaryRepository.java index 2ef3b85..416db42 100644 --- a/src/main/java/com/bamboo/log/diary/repository/DiaryRepository.java +++ b/src/main/java/com/bamboo/log/diary/repository/DiaryRepository.java @@ -4,5 +4,4 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface DiaryRepository extends JpaRepository { - Diary findByContext(String diaryContent); }