Skip to content
Merged
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
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.5.5'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.flywaydb.flyway' version '10.21.0'
}

group = 'org.atdev'
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/atdev/artrip/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.atdev.artrip.security.OAuth2LoginSuccessHandler;
import org.atdev.artrip.global.apipayload.exception.handler.JwtAccessDeniedHandler;
import org.atdev.artrip.global.apipayload.exception.handler.JwtAuthenticationEntryPoint;
import org.atdev.artrip.service.RedisService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
Expand All @@ -35,6 +36,7 @@ public class SecurityConfig {
private final ObjectMapper objectMapper;
private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
private final JwtAccessDeniedHandler jwtAccessDeniedHandler;
private final RedisService redisService;

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
Expand All @@ -49,8 +51,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.authorizeHttpRequests(auth -> auth
.requestMatchers("/admin/**").hasRole("ADMIN")
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.requestMatchers("/","/a","/login/**", "/oauth2/**", "/error",
"/swagger-ui/**", "/v3/api-docs/**","/auth/web/reissue","/auth/app/reissue","/s3/**","/auth/social").permitAll()
.requestMatchers("/", "/a", "/login/**", "/oauth2/**", "/error",
"/swagger-ui/**", "/v3/api-docs/**", "/auth/web/reissue", "/auth/app/reissue", "/s3/**", "/auth/social").permitAll()
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**", "/swagger-resources/**", "/swagger-ui.html", "/webjars/**").permitAll()//스웨거 에러
.anyRequest().authenticated()
)
Expand All @@ -69,9 +71,10 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti

return http.build();
}

@Bean
public JwtAuthenticationFilter jwtAuthenticationFilter() {
return new JwtAuthenticationFilter(jwtProvider);
return new JwtAuthenticationFilter(jwtProvider, redisService);
}

@Bean
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/atdev/artrip/constants/Provider.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
package org.atdev.artrip.constants;

import org.atdev.artrip.global.apipayload.code.status.AuthErrorCode;
import org.atdev.artrip.global.apipayload.exception.GeneralException;

import java.util.Arrays;

public enum Provider {
GOOGLE,
KAKAO,
APPLE;


public static Provider from(String providerName){

if(providerName==null){
throw new GeneralException(AuthErrorCode._SOCIAL_EMAIL_NOT_PROVIDED);
}

return Arrays.stream(Provider.values())
.filter(p -> p.name().equalsIgnoreCase(providerName))
.findFirst()
.orElseThrow(() -> new GeneralException(AuthErrorCode._UNSUPPORTED_SOCIAL_PROVIDER));
}
}
52 changes: 25 additions & 27 deletions src/main/java/org/atdev/artrip/controller/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import jakarta.annotation.security.PermitAll;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.atdev.artrip.service.AuthService;
import org.atdev.artrip.controller.dto.request.ReissueRequest;
import org.atdev.artrip.global.apipayload.code.status.UserErrorCode;
import org.atdev.artrip.service.AuthService;
import org.atdev.artrip.controller.dto.request.SocialLoginRequest;
import org.atdev.artrip.controller.dto.response.SocialLoginResponse;
import org.atdev.artrip.global.apipayload.CommonResponse;
import org.atdev.artrip.global.apipayload.code.status.CommonError;
import org.atdev.artrip.global.apipayload.code.status.UserError;
import org.atdev.artrip.global.apipayload.code.status.CommonErrorCode;
import org.atdev.artrip.global.swagger.ApiErrorResponses;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
Expand All @@ -27,8 +27,8 @@ public class AuthController {
@PermitAll
@Operation(summary = "토큰 재발행 (웹 전용)", description = "refresh토큰으로 access토큰을 재발행합니다")
@ApiErrorResponses(
user = {UserError._USER_NOT_FOUND, UserError._INVALID_REFRESH_TOKEN, UserError._INVALID_USER_REFRESH_TOKEN},
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED, CommonError._INTERNAL_SERVER_ERROR}
user = {UserErrorCode._USER_NOT_FOUND, UserErrorCode._INVALID_REFRESH_TOKEN, UserErrorCode._INVALID_USER_REFRESH_TOKEN},
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED, CommonErrorCode._INTERNAL_SERVER_ERROR}
)
@PostMapping("/web/reissue")
public ResponseEntity<CommonResponse<String>> webReissue(
Expand All @@ -44,12 +44,12 @@ public ResponseEntity<CommonResponse<String>> webReissue(
@Operation(summary = "토큰 재발행 (앱 전용)", description = "refresh토큰으로 access토큰을 재발행합니다")
@ApiErrorResponses(
user = {
UserError._USER_NOT_FOUND,
UserError._INVALID_REFRESH_TOKEN,
UserError._INVALID_USER_REFRESH_TOKEN,
UserError._JWT_EXPIRED_REFRESH_TOKEN,
UserErrorCode._USER_NOT_FOUND,
UserErrorCode._INVALID_REFRESH_TOKEN,
UserErrorCode._INVALID_USER_REFRESH_TOKEN,
UserErrorCode._JWT_EXPIRED_REFRESH_TOKEN,
},
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED, CommonError._INTERNAL_SERVER_ERROR}
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED, CommonErrorCode._INTERNAL_SERVER_ERROR}
)
@PostMapping("/app/reissue")
public ResponseEntity<CommonResponse<SocialLoginResponse>> appReissue(@RequestBody (required = false) ReissueRequest refreshToken) {
Expand All @@ -62,44 +62,42 @@ public ResponseEntity<CommonResponse<SocialLoginResponse>> appReissue(@RequestBo
@PermitAll
@Operation(summary = "로그아웃 (웹 전용)", description = "refresh, access 토큰을 제거합니다.")
@ApiErrorResponses(
user = {UserError._INVALID_REFRESH_TOKEN},
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED, CommonError._INTERNAL_SERVER_ERROR}
user = {UserErrorCode._INVALID_REFRESH_TOKEN},
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED, CommonErrorCode._INTERNAL_SERVER_ERROR}
)
@PostMapping("/web/logout")
public ResponseEntity<String> webLogout(@CookieValue(value = "refreshToken", required = false) String refreshToken,
public ResponseEntity<CommonResponse<Void>> webLogout(@CookieValue(value = "refreshToken", required = false) String refreshToken,
HttpServletResponse response) {

authService.webLogout(refreshToken, response);

return ResponseEntity.ok("로그아웃 완료");
return ResponseEntity.ok(CommonResponse.onSuccess(null));
}

@PermitAll
@Operation(summary = "로그아웃 (앱 전용)", description = "refresh, access 토큰을 제거합니다.")
@ApiErrorResponses(
user = {UserError._INVALID_REFRESH_TOKEN},
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED, CommonError._INTERNAL_SERVER_ERROR}
user = {UserErrorCode._INVALID_REFRESH_TOKEN},
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED, CommonErrorCode._INTERNAL_SERVER_ERROR}
)
@PostMapping("/app/logout")
public ResponseEntity<String> appLogout(@RequestBody(required = false) ReissueRequest refreshToken) {

authService.appLogout(refreshToken);
public void appLogout(@RequestBody(required = false) ReissueRequest token) {

return ResponseEntity.ok("로그아웃 완료");
authService.appLogout(token);
}

@PermitAll
@Operation(summary = "소셜 SDK 토큰 검증 후 jwt 발급", description = "만료일 : refresh: 7일 , access: 15분 ,isFirstLogin true:회원가입 false:로그인")
@ApiErrorResponses(
user = {
UserError._SOCIAL_ID_TOKEN_INVALID,
UserError._USER_NOT_FOUND,
UserError._SOCIAL_VERIFICATION_FAILED,
UserError._SOCIAL_TOKEN_EXPIRED,
UserError._SOCIAL_TOKEN_INVALID_SIGNATURE,
UserError._SOCIAL_TOKEN_INVALID_AUDIENCE,
UserErrorCode._SOCIAL_ID_TOKEN_INVALID,
UserErrorCode._USER_NOT_FOUND,
UserErrorCode._SOCIAL_VERIFICATION_FAILED,
UserErrorCode._SOCIAL_TOKEN_EXPIRED,
UserErrorCode._SOCIAL_TOKEN_INVALID_SIGNATURE,
UserErrorCode._SOCIAL_TOKEN_INVALID_AUDIENCE,
},
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED, CommonError._INTERNAL_SERVER_ERROR}
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED, CommonErrorCode._INTERNAL_SERVER_ERROR}
)
@PostMapping("/social")
public ResponseEntity<CommonResponse<SocialLoginResponse>> socialLogin(@RequestBody SocialLoginRequest request) {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/atdev/artrip/controller/ExhibitController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import org.atdev.artrip.service.HomeService;
import org.atdev.artrip.controller.dto.response.RegionResponse;
import org.atdev.artrip.global.apipayload.CommonResponse;
import org.atdev.artrip.global.apipayload.code.status.CommonError;
import org.atdev.artrip.global.apipayload.code.status.HomeError;
import org.atdev.artrip.global.apipayload.code.status.CommonErrorCode;
import org.atdev.artrip.global.apipayload.code.status.HomeErrorCode;
import org.atdev.artrip.controller.dto.request.ImageResizeRequest;
import org.atdev.artrip.global.swagger.ApiErrorResponses;
import org.springdoc.core.annotations.ParameterObject;
Expand All @@ -34,8 +34,8 @@ private Long getUserId(UserDetails userDetails) {
}
@Operation(summary = "장르 조회", description = "키워드 장르 데이터 전체 조회")
@ApiErrorResponses(
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED},
home = {HomeError._HOME_GENRE_NOT_FOUND}
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED},
home = {HomeErrorCode._HOME_GENRE_NOT_FOUND}
)
@GetMapping("/genre")
public ResponseEntity<CommonResponse<List<String>>> getGenres(){
Expand All @@ -45,8 +45,8 @@ public ResponseEntity<CommonResponse<List<String>>> getGenres(){

@Operation(summary = "전시 상세 조회")
@ApiErrorResponses(
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED},
home = {HomeError._HOME_EXHIBIT_NOT_FOUND}
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED},
home = {HomeErrorCode._HOME_EXHIBIT_NOT_FOUND}
)
@GetMapping("/{id}")
public ResponseEntity<CommonResponse<ExhibitDetailResponse>> getExhibit(
Expand All @@ -64,7 +64,7 @@ public ResponseEntity<CommonResponse<ExhibitDetailResponse>> getExhibit(

@Operation(summary = "해외 국가 목록 조회")
@ApiErrorResponses(
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED}
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED}
)
@GetMapping("/overseas")
public ResponseEntity<CommonResponse<List<String>>> getOverseas(){
Expand All @@ -76,7 +76,7 @@ public ResponseEntity<CommonResponse<List<String>>> getOverseas(){

@Operation(summary = "국내 지역 목록 조회")//하드코딩
@ApiErrorResponses(
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED}
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED}
)
@GetMapping("/domestic")
public ResponseEntity<CommonResponse<List<RegionResponse>>> getDomestic(){
Expand All @@ -89,8 +89,8 @@ public ResponseEntity<CommonResponse<List<RegionResponse>>> getDomestic(){

@Operation(summary = "전시 조건 필터 전체 조회",description = "기간, 지역, 장르, 전시 스타일 필터 조회 - null 시 전체선택")
@ApiErrorResponses(
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED},
home = {HomeError._HOME_INVALID_DATE_RANGE, HomeError._HOME_UNRECOGNIZED_REGION, HomeError._HOME_EXHIBIT_NOT_FOUND}
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED},
home = {HomeErrorCode._HOME_INVALID_DATE_RANGE, HomeErrorCode._HOME_UNRECOGNIZED_REGION, HomeErrorCode._HOME_EXHIBIT_NOT_FOUND}
)
@PostMapping("/filter")
public ResponseEntity<FilterResponse> getDomesticFilter(@RequestBody ExhibitFilterRequest dto,
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/org/atdev/artrip/controller/FavoriteController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.atdev.artrip.controller.dto.response.FavoriteResponse;
import org.atdev.artrip.service.FavoriteExhibitService;
import org.atdev.artrip.global.apipayload.CommonResponse;
import org.atdev.artrip.global.apipayload.code.status.CommonError;
import org.atdev.artrip.global.apipayload.code.status.FavoriteError;
import org.atdev.artrip.global.apipayload.code.status.CommonErrorCode;
import org.atdev.artrip.global.apipayload.code.status.FavoriteErrorCode;
import org.atdev.artrip.global.swagger.ApiErrorResponses;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
Expand All @@ -32,8 +32,8 @@ public class FavoriteController {

@Operation(summary = "즐겨찾기 추가", description = "전시 즐겨찾기 추가")
@ApiErrorResponses(
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED},
favorite = {FavoriteError._FAVORITE_NOT_FOUND, FavoriteError._FAVORITE_ALREADY_EXISTS, FavoriteError._FAVORITE_LIMIT_EXCEEDED}
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED},
favorite = {FavoriteErrorCode._FAVORITE_NOT_FOUND, FavoriteErrorCode._FAVORITE_ALREADY_EXISTS, FavoriteErrorCode._FAVORITE_LIMIT_EXCEEDED}
)
@PostMapping("/{exhibitId}")
public CommonResponse<FavoriteResponse> addFavorite(
Expand All @@ -49,8 +49,8 @@ public CommonResponse<FavoriteResponse> addFavorite(

@Operation(summary = "즐겨찾기 삭제", description = "즐겨찾기에서 전시를 삭제")
@ApiErrorResponses(
common = {CommonError._BAD_REQUEST, CommonError._UNAUTHORIZED},
favorite = {FavoriteError._FAVORITE_NOT_FOUND}
common = {CommonErrorCode._BAD_REQUEST, CommonErrorCode._UNAUTHORIZED},
favorite = {FavoriteErrorCode._FAVORITE_NOT_FOUND}
)
@DeleteMapping("/{exhibitId}")
public CommonResponse<Void> removeFavorite(
Expand All @@ -66,8 +66,8 @@ public CommonResponse<Void> removeFavorite(

@Operation(summary = "즐겨찾기 전체 목록 조회", description = "사용자의 모든 즐겨찾기를 조회")
@ApiErrorResponses(
common = {CommonError._UNAUTHORIZED},
favorite = {FavoriteError._FAVORITE_NOT_FOUND}
common = {CommonErrorCode._UNAUTHORIZED},
favorite = {FavoriteErrorCode._FAVORITE_NOT_FOUND}
)
@GetMapping
public CommonResponse<List<FavoriteResponse>> getAllFavorites(
Expand All @@ -85,8 +85,8 @@ public CommonResponse<List<FavoriteResponse>> getAllFavorites(
summary = "날짜별 즐겨찾기 조회",
description = "특정 날짜에 진행 중인 즐겨찾기 전시 조회 (캘린더, 전체 탭)")
@ApiErrorResponses(
common = {CommonError._UNAUTHORIZED},
favorite = {FavoriteError._FAVORITE_NOT_FOUND}
common = {CommonErrorCode._UNAUTHORIZED},
favorite = {FavoriteErrorCode._FAVORITE_NOT_FOUND}
)
@GetMapping("/date")
public CommonResponse<List<FavoriteResponse>> getFavoritesByDate(
Expand All @@ -105,8 +105,8 @@ public CommonResponse<List<FavoriteResponse>> getFavoritesByDate(
summary = "국가별 즐겨찾기 조회",
description = "특정 국가의 즐겨찾기 전시를 조회 (캘린더, 국가별 탭)")
@ApiErrorResponses(
common = {CommonError._UNAUTHORIZED},
favorite = {FavoriteError._FAVORITE_NOT_FOUND}
common = {CommonErrorCode._UNAUTHORIZED},
favorite = {FavoriteErrorCode._FAVORITE_NOT_FOUND}
)
@GetMapping("/country")
public CommonResponse<List<FavoriteResponse>> getFavoritesByCountry(
Expand All @@ -123,8 +123,8 @@ public CommonResponse<List<FavoriteResponse>> getFavoritesByCountry(
summary = "캘린더 날짜 목록 조회",
description = "특정 월에 즐겨찾기한 전시가 있는 날짜 목록 조회")
@ApiErrorResponses(
common = {CommonError._UNAUTHORIZED, CommonError._INTERNAL_SERVER_ERROR},
favorite = {FavoriteError._FAVORITE_NOT_FOUND}
common = {CommonErrorCode._UNAUTHORIZED, CommonErrorCode._INTERNAL_SERVER_ERROR},
favorite = {FavoriteErrorCode._FAVORITE_NOT_FOUND}
)
@GetMapping("/calendar")
public CommonResponse<CalenderResponse> getCalenderDates(
Expand All @@ -143,8 +143,8 @@ public CommonResponse<CalenderResponse> getCalenderDates(
summary = "즐겨찾기 국가 목록 조회",
description = "즐겨찾기한 전시들 국가 목록 조회")
@ApiErrorResponses(
common = {CommonError._UNAUTHORIZED, CommonError._INTERNAL_SERVER_ERROR},
favorite = {FavoriteError._FAVORITE_NOT_FOUND}
common = {CommonErrorCode._UNAUTHORIZED, CommonErrorCode._INTERNAL_SERVER_ERROR},
favorite = {FavoriteErrorCode._FAVORITE_NOT_FOUND}
)
@GetMapping("/countries")
public CommonResponse<List<String>> getFavoriteCountries(
Expand All @@ -161,8 +161,8 @@ public CommonResponse<List<String>> getFavoriteCountries(
summary = "즐겨찾기 여부 확인",
description = "특정 전시가 즐겨찾기에 추가되어 있는지 확인")
@ApiErrorResponses(
common = {CommonError._UNAUTHORIZED, CommonError._INTERNAL_SERVER_ERROR},
favorite = {FavoriteError._FAVORITE_NOT_FOUND}
common = {CommonErrorCode._UNAUTHORIZED, CommonErrorCode._INTERNAL_SERVER_ERROR},
favorite = {FavoriteErrorCode._FAVORITE_NOT_FOUND}
)
@GetMapping("/check/{exhibitId}")
public CommonResponse<Map<String, Boolean>> checkFavorite(
Expand Down
Loading