Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 6 additions & 5 deletions src/main/java/com/bamboo/log/common/config/CorsMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ public class CorsMvcConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry corsRegistry) {

corsRegistry.addMapping("/**")
.exposedHeaders("Set-Cookie")
//프론트 url 넣기
.allowedOrigins("http://localhost:3000");
.allowedOrigins("*") // 모든 Origin 허용
.allowedMethods("*") // 모든 HTTP 메서드 허용
.allowedHeaders("*") // 모든 헤더 허용
.allowCredentials(true) // 쿠키 허용
.exposedHeaders("Set-Cookie");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +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());
.anyRequest().hasAnyRole("USER"));


http.sessionManagement((session) -> session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public class CustomFailureHandler extends SimpleUrlAuthenticationFailureHandler

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
response.sendRedirect("http://localhost:3000");
response.sendRedirect("http://localhost:3000/login");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
addRefreshEntity(name, username, refreshToken, 1209600000L);
response.addCookie(createCookie("refresh", refreshToken));
response.addCookie(UnScretCreateCookie("access", accessToken));
response.sendRedirect("http://localhost:3000/");
response.sendRedirect("http://localhost:3000/welcome");
}

private Cookie createCookie(String key, String value) {
Expand Down
44 changes: 44 additions & 0 deletions src/main/resources/application.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

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}
emotion:
api:
url: ${EMOTION_URL}
46 changes: 24 additions & 22 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# application.yml

spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_NAME}
username: ${MYSQL_USERNAME}
password: ${MYSQL_PASSWORD}
url: jdbc:mysql://localhost:3306/OAuth2?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul&allowPublicKeyRetrieval=true
username: root
password: heodongun0922
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
show-sql: true
Expand All @@ -18,28 +16,32 @@ 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: http://localhost:8080/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: vmfhaltmskdlstkfkdgodyroqkfwkdbalroqkfwkdbalaaaaaaaaaaaaaaaabbbbb

elice:
api:
token: ${API_TOKEN}
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NDA1NDYyMjgsIm5iZiI6MTc0MDU0NjIyOCwiZXhwIjoxNzUwNDYzOTk5LCJrZXlfaWQiOiJjYzI2YjZjMi0zNWExLTQ0NmEtODhkYS02ZjdkZGExNDMzYWMifQ.tqRvmEibKaRZUJK9m7pp7ZOWsdzy2rGg8YxjQ1MrSDk
url:
face: ${FACE_URL}
img: ${IMG_URL}
chat: ${CHAT_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: null

emotion:
api:
url: ${EMOTION_URL}
url: null