Skip to content

Commit

Permalink
Merge pull request #66 from f-lab-edu/feature/64-logincheck
Browse files Browse the repository at this point in the history
[#64] 로그인 AOP 제거
  • Loading branch information
hoa0217 authored Mar 27, 2024
2 parents ba87738 + 67b5074 commit d179dd3
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.modoospace.alarm.controller.dto.AlarmResponse;
import com.modoospace.alarm.domain.AlarmType;
import com.modoospace.alarm.service.AlarmService;
import com.modoospace.config.auth.aop.CheckLogin;
import com.modoospace.config.auth.resolver.LoginMember;
import com.modoospace.member.domain.Member;
import lombok.RequiredArgsConstructor;
Expand All @@ -20,23 +19,23 @@ public class AlarmController {

private final AlarmService alarmService;

@CheckLogin

@GetMapping()
public ResponseEntity<Page<AlarmResponse>> search(@LoginMember Member loginMember,
Pageable pageable) {
Page<AlarmResponse> alarms = alarmService.searchAlarms(loginMember, pageable);
return ResponseEntity.ok().body(alarms);
}

@CheckLogin

@DeleteMapping("/{alarmId}")
public ResponseEntity<Void> delete(@PathVariable Long alarmId,
@LoginMember Member loginMember) {
alarmService.delete(alarmId, loginMember);
return ResponseEntity.noContent().build();
}

@CheckLogin

@GetMapping(value = "/subscribe", produces = "text/event-stream")
public ResponseEntity<SseEmitter> subscribe(@LoginMember Member loginMember) {
return ResponseEntity.ok(alarmService.connectAlarm(loginMember.getEmail()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.headers().frameOptions().disable() // h2-console화면을 사용하기 위해 해당 옵션들을 disable
.and()
.authorizeHttpRequests(request -> request
.antMatchers(HttpMethod.GET, "/", "/error", "/api/v1/spaces/**",
"/api/v1/spaces/*/facilities/**",
"/api/v1/test/**",
"/api/v1/facilities/*/schedules/**",
"/api/v1/visitors/reservations/facilities/*/availability/**").permitAll()
.antMatchers(HttpMethod.POST, "/api/v1/alarms/send/**").permitAll()
.antMatchers("/api/v1/admin/**").hasRole(Role.ADMIN.name())
.anyRequest().authenticated()
.antMatchers(HttpMethod.GET, "/", "/error", "/api/v1/spaces/**",
"/api/v1/spaces/*/facilities/**",
"/api/v1/test/**",
"/api/v1/facilities/*/schedules/**",
"/api/v1/visitors/reservations/facilities/*/availability/**").permitAll()
.antMatchers(HttpMethod.POST, "/api/v1/alarms/send/**").permitAll()
.antMatchers("/api/v1/admin/**").hasRole(Role.ADMIN.name())
.antMatchers("/api/v1/hosts/**").hasRole(Role.HOST.name())
.anyRequest().authenticated()
)
.oauth2Login().userInfoEndpoint()
.userService(customOAuth2UserService); // 로그인 성공 후 후속조치를 진행할 UserServie 인터페이스의 구현체 등록
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/com/modoospace/config/auth/aop/CheckLogin.java

This file was deleted.

28 changes: 0 additions & 28 deletions src/main/java/com/modoospace/config/auth/aop/CheckLoginAspect.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package com.modoospace.member.controller;

import com.modoospace.config.auth.aop.CheckLogin;
import com.modoospace.config.auth.resolver.LoginMember;
import com.modoospace.member.controller.dto.MemberUpdateRequest;
import com.modoospace.member.domain.Member;
import com.modoospace.member.service.MemberService;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RequiredArgsConstructor
@RestController
Expand All @@ -21,7 +17,6 @@ public class AdminMemberController {

private final MemberService memberService;

@CheckLogin
@PutMapping("/{memberId}")
public ResponseEntity<Void> updateRole(@PathVariable Long memberId,
@RequestBody @Valid MemberUpdateRequest updateRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.modoospace.common.exception.EmptyResponseException;
import com.modoospace.config.auth.aop.CheckLogin;
import com.modoospace.config.auth.resolver.LoginMember;
import com.modoospace.member.domain.Member;
import com.modoospace.mockData.controller.dto.MockAddressResponse;
Expand Down Expand Up @@ -75,7 +74,6 @@ private MockAddressResponse getMockAddress(String address) throws IOException, I
return addressResponse;
}

@CheckLogin
@PostMapping("/space/{spaceId}")
public ResponseEntity<Void> saveSpace(@PathVariable String spaceId, @LoginMember Member loginMember) throws IOException, InterruptedException {
MockSpaceResponse spaceResponse = getMockSpace(spaceId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.modoospace.reservation.controller;

import com.modoospace.config.auth.aop.CheckLogin;
import com.modoospace.config.auth.resolver.LoginMember;
import com.modoospace.member.domain.Member;
import com.modoospace.reservation.controller.dto.ReservationResponse;
Expand All @@ -20,7 +19,6 @@ public class AdminReservationController {

private final ReservationService reservationService;

@CheckLogin
@GetMapping("/visitor/{memberId}")
public ResponseEntity<List<ReservationResponse>> findAllAsMember(@PathVariable Long memberId,
@LoginMember Member loginMember) {
Expand All @@ -29,7 +27,6 @@ public ResponseEntity<List<ReservationResponse>> findAllAsMember(@PathVariable L
return ResponseEntity.ok().body(reservations);
}

@CheckLogin
@GetMapping("/host/{memberId}")
public ResponseEntity<List<ReservationResponse>> findAllAsHost(@PathVariable Long memberId,
@LoginMember Member loginMember) {
Expand All @@ -38,7 +35,6 @@ public ResponseEntity<List<ReservationResponse>> findAllAsHost(@PathVariable Lon
return ResponseEntity.ok().body(reservations);
}

@CheckLogin
@PutMapping("/{reservationId}")
public ResponseEntity<Void> update(
@PathVariable Long reservationId,
Expand All @@ -49,7 +45,6 @@ public ResponseEntity<Void> update(
return ResponseEntity.ok().build();
}

@CheckLogin
@GetMapping("/{reservationId}")
public ResponseEntity<ReservationResponse> find(@PathVariable Long reservationId,
@LoginMember Member loginMember) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.modoospace.reservation.controller;

import com.modoospace.config.auth.aop.CheckLogin;
import com.modoospace.config.auth.resolver.LoginMember;
import com.modoospace.member.domain.Member;
import com.modoospace.reservation.controller.dto.ReservationResponse;
Expand All @@ -20,22 +19,19 @@ public class HostReservationController {

private final ReservationService reservationService;

@CheckLogin
@GetMapping
public ResponseEntity<List<ReservationResponse>> findAll(@LoginMember Member loginMember) {
List<ReservationResponse> reservations = reservationService.findAllAsHost(loginMember);
return ResponseEntity.ok().body(reservations);
}

@CheckLogin
@PutMapping("/{reservationId}/approve")
public ResponseEntity<Void> approveReservation(@PathVariable Long reservationId,
@LoginMember Member loginMember) {
reservationService.approveReservation(reservationId, loginMember);
return ResponseEntity.noContent().build();
}

@CheckLogin
@PutMapping("/{reservationId}")
public ResponseEntity<Void> update(
@PathVariable Long reservationId,
Expand All @@ -46,7 +42,6 @@ public ResponseEntity<Void> update(
return ResponseEntity.ok().build();
}

@CheckLogin
@GetMapping("/{reservationId}")
public ResponseEntity<ReservationResponse> find(@PathVariable Long reservationId,
@LoginMember Member loginMember) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.modoospace.reservation.controller;

import com.modoospace.common.DateFormatManager;
import com.modoospace.config.auth.aop.CheckLogin;
import com.modoospace.config.auth.resolver.LoginMember;
import com.modoospace.member.domain.Member;
import com.modoospace.reservation.controller.dto.AvailabilityTimeResponse;
Expand All @@ -24,7 +23,6 @@ public class VisitorsReservationController {

private final ReservationService reservationService;

@CheckLogin
@GetMapping
public ResponseEntity<List<ReservationResponse>> findAll(@LoginMember Member loginMember) {
List<ReservationResponse> reservations = reservationService.findAllAsVisitor(loginMember);
Expand All @@ -40,7 +38,6 @@ public ResponseEntity<AvailabilityTimeResponse> getAvailabilityTime(
return ResponseEntity.ok().body(availableTimes);
}

@CheckLogin
@PostMapping("/facilities/{facilityId}")
public ResponseEntity<Long> createReservation(@PathVariable Long facilityId,
@LoginMember Member loginMember,
Expand All @@ -50,7 +47,6 @@ public ResponseEntity<Long> createReservation(@PathVariable Long facilityId,
return ResponseEntity.ok().body(reservationId);
}

@CheckLogin
@GetMapping("/{reservationId}")
public ResponseEntity<ReservationResponse> find(@PathVariable Long reservationId,
@LoginMember Member loginMember) {
Expand All @@ -59,7 +55,6 @@ public ResponseEntity<ReservationResponse> find(@PathVariable Long reservationId
return ResponseEntity.ok().body(reservation);
}

@CheckLogin
@PutMapping("/{reservationId}/cancel")
public ResponseEntity<Void> cancelReservation(@PathVariable Long reservationId,
@LoginMember Member loginMember) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.modoospace.space.controller;

import com.modoospace.config.auth.aop.CheckLogin;
import com.modoospace.config.auth.resolver.LoginMember;
import com.modoospace.member.domain.Member;
import com.modoospace.space.controller.dto.facility.*;
Expand All @@ -21,7 +20,6 @@ public class FacilityController {

private final FacilityService facilityService;

@CheckLogin
@PostMapping()
public ResponseEntity<Void> create(@PathVariable Long spaceId,
@RequestBody @Valid FacilityCreateRequest createRequest,
Expand All @@ -45,7 +43,6 @@ public ResponseEntity<FacilityResponse> find(@PathVariable Long facilityId) {
return ResponseEntity.ok().body(facilityReadDto);
}

@CheckLogin
@PutMapping("/{facilityId}")
public ResponseEntity<Void> update(@PathVariable Long facilityId,
@RequestBody @Valid FacilityUpdateRequest updateRequest,
Expand All @@ -54,7 +51,6 @@ public ResponseEntity<Void> update(@PathVariable Long facilityId,
return ResponseEntity.noContent().build();
}

@CheckLogin
@PutMapping("/{facilityId}/setting")
public ResponseEntity<Void> updateSetting(@PathVariable Long facilityId,
@RequestBody @Valid FacilitySettingUpdateRequest updateRequest,
Expand All @@ -63,7 +59,6 @@ public ResponseEntity<Void> updateSetting(@PathVariable Long facilityId,
return ResponseEntity.noContent().build();
}

@CheckLogin
@DeleteMapping("/{facilityId}")
public ResponseEntity<Void> delete(@PathVariable Long facilityId,
@LoginMember Member loginMember) {
Expand Down
Loading

0 comments on commit d179dd3

Please sign in to comment.