Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] GPS-코드 변환 API, 동네 인증 API 개발 #78

Merged
merged 17 commits into from
Feb 19, 2024

Conversation

JIN-076
Copy link
Collaborator

@JIN-076 JIN-076 commented Feb 18, 2024

🚀 개발 사항

  • 사용자의 GPS 좌표를 받아 법정구역코드로 변환하는 API 개발
  • 동네 인증 요청 API 개발
  • 각 API에 대한 Swagger 작성

이슈 번호

특이 사항 🫶

  • GPS-코드 변환 API를 작성하는 과정에서 클라이언트에게 사용자의 GPS 좌표를 받아오게 되는데, 의미 상으로 보았을 때 '코드를 받아온다'는 GET 매핑과 쿼리 파라미터로 좌표를 받아오는 게 맞지 않을까 생각했는데, 사용자의 현재 위치 좌표를 담고 있는 정보를 쿼리 파라미터로 받으면 보안상 위험하지 않을까! 하는 생각이 들어 Body에 받아오면서 POST로 개발을 진행했습니다. (GET 요청에 Body를 담는 것은 보안상으로 권장하지 않는다고 합니다,,) 이 부분에 대해서 더 좋은 생각이나, 다른 생각이 있다면 피드백 부탁드립니다!
  • 동네 인증 요청 API를 POST로 보낼 것인지, PUT으로 보낼 것인지에 대해 고민이 있습니다. 현재는 동네 인증을 하게 되면 이전에 저장된 값은 삭제되고 새로운 값이 생성된다는 의미로 POST를 사용하였는데, 이에 대해 혹시 제가 미처 고려하지 못한 부분이 있거나, 다른 생각이 있다면 피드백 부탁드립니다!

@JIN-076 JIN-076 added ⭐️ Feat 새로운 기능 🎯 MVP1 mvp1 개발사항 labels Feb 18, 2024
@JIN-076 JIN-076 self-assigned this Feb 18, 2024
Copy link

github-actions bot commented Feb 18, 2024

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 131b3aa.

♻️ This comment has been updated with latest results.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

@happyjamy
Copy link
Collaborator

GPS-코드 변환 API를 작성하는 과정에서 클라이언트에게 사용자의 GPS 좌표를 받아오게 되는데, 의미 상으로 보았을 때 '코드를 받아온다'는 GET 매핑과 쿼리 파라미터로 좌표를 받아오는 게 맞지 않을까 생각했는데, 사용자의 현재 위치 좌표를 담고 있는 정보를 쿼리 파라미터로 받으면 보안상 위험하지 않을까! 하는 생각이 들어 Body에 받아오면서 POST로 개발을 진행했습니다. (GET 요청에 Body를 담는 것은 보안상으로 권장하지 않는다고 합니다,,) 이 부분에 대해서 더 좋은 생각이나, 다른 생각이 있다면 피드백 부탁드립니다!

  • GET 요청에 Body를 못 붙여 보내는걸로 알고 있었는데 보낼 수는 있나 보군요....! 저 같으면 사용자의 현재위치를 받아 코드로 변환한다 라는 개념 보다는 받은 좌표를 코드로 변환해서 보내준다 라는 개념으로 api 설계를 할 것 같아서 쿼리파라미터에 넣을 것 같아요!

동네 인증 요청 API를 POST로 보낼 것인지, PUT으로 보낼 것인지에 대해 고민이 있습니다. 현재는 동네 인증을 하게 되면 이전에 저장된 값은 삭제되고 새로운 값이 생성된다는 의미로 POST를 사용하였는데, 이에 대해 혹시 제가 미처 고려하지 못한 부분이 있거나, 다른 생각이 있다면 피드백 부탁드립니다!

  • 유저의 동네 정보 자체가 유저에게 종속 되어 있고 필드값이 계속 변경 되는거라 저같으면 PATCH 를 썼을 것 같긴한데, POST 도 나쁘지 않다고 생각합니다.

mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E080101", value = SwaggerGeoErrorExamples.INVALID_SERVICE_REGION))),
@ApiResponse(responseCode = "401", description = "동네 인증 권한이 없음",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

보통 401은 아예 인증을 받지 않은 유저 (유저 정보 없음, 로그인 안함) 에 관한 상태코드인데 이 의미 맞나요?

Copy link
Member

@tidavid1 tidavid1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 확인해주세요! 👍🏻


private final GeoService geoService;

@PostMapping("/areacode")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위도 경도 데이터는 사용자 위치에 대한 정보기는 하지만 파라미터 공개가 사용자에게만 이루어지니까 Get에서 쿼리로 받는거도 괜찮을 것 같다는 생각이듭니다!

Comment on lines +33 to +43
private int validateCoordinatesCoverage(Double x, Double y) {
int areaCode = getAreaCodeAboutCoordinates(x, y);
validateCodeCoverage(areaCode);
return areaCode;
}

private void validateCodeCoverage(int areaCode) {
if (Region.getByAreaCode(areaCode) == null) {
throw new GeoException(INVALID_SERVICE_REGION);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private 메서드들은 public 메서드 이하에 위치하면 좋을 것 같습니다! 👍🏻


private final CertService certService;

@PostMapping("/certificate")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Microsoft의 웹 API 디자인 모범 사례 - HTTP 메서드 측면에서 API 작업 정의에 따르면 지정된 URI에 리소스를 대체하는 용도로 PUT 메서드를 사용하는 방식을 제안하는데 이에 대한 생각은 어떠신가요?

@JIN-076 JIN-076 merged commit c108e17 into develop Feb 19, 2024
3 checks passed
@JIN-076 JIN-076 deleted the feat/#13-authentication_neighborhood branch March 4, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐️ Feat 새로운 기능 🎯 MVP1 mvp1 개발사항
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[💡 FEAT] 사용자 GPS 기반 동네 인증 기능 개발
3 participants