Skip to content

Commit 6cf0599

Browse files
authored
Merge pull request #261 from prgrms-web-devcourse-final-project/setting/security-uri(WR9-150)
Setting/security-uri(wr9 150)
2 parents ec399a1 + e16b0d5 commit 6cf0599

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

src/main/java/io/crops/warmletter/domain/badword/controller/BadWordController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import jakarta.validation.Valid;
1414
import lombok.RequiredArgsConstructor;
1515
import org.springframework.http.ResponseEntity;
16+
import org.springframework.security.access.prepost.PreAuthorize;
1617
import org.springframework.web.bind.annotation.*;
1718

1819
import java.util.List;
@@ -29,13 +30,15 @@ public class BadWordController {
2930

3031
@PostMapping
3132
@Operation(summary = "금칙어 등록", description = "금칙어 등록하는 API입니다.")
33+
@PreAuthorize("hasRole('ADMIN')")
3234
public ResponseEntity<BaseResponse<BadWordResponse>> createBadWord(@RequestBody @Valid CreateBadWordRequest request) {
3335
BadWordResponse response = badWordService.createBadWord(request);
3436
return ResponseEntity.ok(BaseResponse.of(response, "금칙어 등록완료"));
3537
}
3638

3739
@PatchMapping("/{badWordId}/status")
3840
@Operation(summary = "금칙어 상태변경", description = "금칙어 상태변경 활성여부 API입니다.")
41+
@PreAuthorize("hasRole('ADMIN')")
3942
public ResponseEntity<BaseResponse<BadWordResponse>> updateBadWordStatus(
4043
@PathVariable Long badWordId,
4144
@RequestBody @Valid UpdateBadWordStatusRequest request) {
@@ -45,13 +48,15 @@ public ResponseEntity<BaseResponse<BadWordResponse>> updateBadWordStatus(
4548

4649
@GetMapping
4750
@Operation(summary = "금칙어 조회", description = "등록된 금칙어 조회하는 API입니다.")
51+
@PreAuthorize("hasRole('ADMIN')")
4852
public ResponseEntity<BaseResponse<List<Map<String, String>>>> getBadWords() {
4953
List<Map<String, String>> response = badWordService.getBadWords();
5054
return ResponseEntity.ok(BaseResponse.of(response, "금칙어 조회"));
5155
}
5256

5357
@PatchMapping("/{badWordId}")
5458
@Operation(summary = "금칙어 변경", description = "기존에 있는 금칙어를 변경하는 API입니다.")
59+
@PreAuthorize("hasRole('ADMIN')")
5560
public ResponseEntity<BaseResponse<UpdateBadWordResponse>> updateBadWord(
5661
@PathVariable Long badWordId,
5762
@RequestBody @Valid UpdateBadWordRequest request) {
@@ -60,6 +65,7 @@ public ResponseEntity<BaseResponse<UpdateBadWordResponse>> updateBadWord(
6065
}
6166

6267
@DeleteMapping("/{badwordId}")
68+
@PreAuthorize("hasRole('ADMIN')")
6369
public ResponseEntity<BaseResponse<String>> deleteBadWord(@PathVariable("badwordId") Long badWordId) {
6470
badWordService.deleteBadWord(badWordId);
6571
return ResponseEntity.ok(BaseResponse.of(null, "금칙어 영구삭제"));

src/main/java/io/crops/warmletter/domain/eventpost/controller/EventPostController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.springframework.data.domain.Sort;
1515
import org.springframework.data.web.PageableDefault;
1616
import org.springframework.http.ResponseEntity;
17+
import org.springframework.security.access.prepost.PreAuthorize;
1718
import org.springframework.web.bind.annotation.*;
1819

1920
import java.util.Map;
@@ -27,6 +28,7 @@ public class EventPostController {
2728

2829
@GetMapping("/admin/event-posts")
2930
@Operation(summary = "전체 이벤트 게시판 조회", description = "이벤트 게시판 전체를 조회합니다.")
31+
@PreAuthorize("hasRole('ADMIN')")
3032
public ResponseEntity<BaseResponse<PageResponse<EventPostsResponse>>> getEventPosts(
3133
@PageableDefault(size = 10, sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable) {
3234
Pageable eventPostsPageable = PageableConverter.convertToPageable(pageable);
@@ -35,12 +37,14 @@ public ResponseEntity<BaseResponse<PageResponse<EventPostsResponse>>> getEventPo
3537

3638
@PostMapping("/admin/event-posts")
3739
@Operation(summary = "이벤트 게시판 생성", description = "미사용인 새로운 이벤트 게시판을 생성합니다.")
40+
@PreAuthorize("hasRole('ADMIN')")
3841
public ResponseEntity<BaseResponse<EventPostResponse>> createEventPost(@RequestBody @Valid CreateEventPostRequest createEventPostRequest){
3942
return ResponseEntity.ok(BaseResponse.of(eventPostService.createEventPost(createEventPostRequest),"게시판 생성 성공"));
4043
}
4144

4245
@DeleteMapping("/admin/event-posts/{eventPostId}")
4346
@Operation(summary = "이벤트 게시판 삭제", description = "특정 이벤트 게시판을 삭제합니다.(임시 기능)")
47+
@PreAuthorize("hasRole('ADMIN')")
4448
public ResponseEntity<BaseResponse<Map<String,Long>>> deleteEventPost(@PathVariable Long eventPostId){
4549
return ResponseEntity.ok(BaseResponse.of(eventPostService.deleteEventPost(eventPostId),"게시판 삭제 성공"));
4650
}
@@ -62,6 +66,7 @@ public ResponseEntity<BaseResponse<EventPostDetailResponse>> getEventPostDetail(
6266

6367
@PatchMapping("/admin/event-posts/{eventPostId}/status")
6468
@Operation(summary = "이벤트 게시판 사용여부 변경", description = "이벤트 게시판의 사용 여부를 변경하며, 사용중인 게시판은 하나만 적용됩니다. (사용중(true) <-> 미사용(false))")
69+
@PreAuthorize("hasRole('ADMIN')")
6570
public ResponseEntity<BaseResponse<EventPostStatusResponse>> updateEventPostIsUsed(@PathVariable Long eventPostId){
6671
return ResponseEntity.ok(BaseResponse.of(eventPostService.updateEventPostIsUsed(eventPostId),"게시판 사용여부 변경 성공"));
6772
}

src/main/java/io/crops/warmletter/domain/eventpost/entity/EventComment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class EventComment extends BaseEntity {
2222
@Column(nullable = false)
2323
private Long writerId;
2424

25-
@Column(nullable = false)
25+
@Column(nullable = false, length = 1000)
2626
private String content;
2727

2828
@Column(nullable = false)

src/main/java/io/crops/warmletter/domain/report/controller/ReportController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.data.domain.Sort;
2525
import org.springframework.data.web.PageableDefault;
2626
import org.springframework.http.ResponseEntity;
27+
import org.springframework.security.access.prepost.PreAuthorize;
2728
import org.springframework.web.bind.annotation.*;
2829

2930
@RestController
@@ -44,6 +45,7 @@ public ResponseEntity<BaseResponse<ReportResponse>> createReport(@RequestBody Cr
4445

4546
@GetMapping
4647
@Operation(summary = "신고 목록 조회", description = "신고 목록 조회하는 API입니다.")
48+
@PreAuthorize("hasRole('ADMIN')")
4749
public ResponseEntity<BaseResponse<PageResponse<ReportsResponse>>> getAllReports(
4850
@RequestParam(required = false) String reportType,
4951
@RequestParam(required = false) String status,
@@ -60,6 +62,7 @@ public ResponseEntity<BaseResponse<PageResponse<ReportsResponse>>> getAllReports
6062

6163
@PatchMapping("/{reportId}")
6264
@Operation(summary = "신고 처리", description = "신고 처리해주는 API 입니다 . PENDING-미처리, RESOLVED-해결 ,REJECTED-거절 ")
65+
@PreAuthorize("hasRole('ADMIN')")
6366
public ResponseEntity<BaseResponse<UpdateReportResponse>> updateReport(@PathVariable Long reportId, @RequestBody @Valid UpdateReportRequest request) {
6467
UpdateReportResponse response = reportService.updateReport(reportId, request);
6568
return ResponseEntity.ok(BaseResponse.of(response, "신고 처리 완료"));

src/main/java/io/crops/warmletter/global/config/SecurityConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
6262
authorizeRequests
6363
.requestMatchers("/api/reissue")
6464
.permitAll()
65-
.requestMatchers("/api/auth/**")
65+
.requestMatchers("/api/auth/token")
6666
.permitAll()
6767
.requestMatchers("/swagger-ui/**")
6868
.permitAll() // Swagger UI 허용
69-
.requestMatchers("/api/**").permitAll()
7069
.requestMatchers("/v3/api-docs/**")
7170
.permitAll() // API Docs 허용
7271
.requestMatchers("/login/**")

src/main/java/io/crops/warmletter/global/jwt/provider/JwtTokenProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class JwtTokenProvider {
2525

2626
private final RedisTemplate<String, String> redisTemplate;
2727

28-
private final long ACCESS_TOKEN_EXPIRE_TIME = 1000L * 60 * 5; // 30분
28+
private final long ACCESS_TOKEN_EXPIRE_TIME = 1000L * 60 * 30; // 30분
2929
private final long REFRESH_TOKEN_EXPIRE_TIME = 1000L * 60 * 60 * 24 * 14; // 14일
3030

3131
private Key key; // JWT 서명에 사용할 키

0 commit comments

Comments
 (0)