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

Authentication & Authorization #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Authentication & Authorization #3

wants to merge 2 commits into from

Conversation

CryingDitto
Copy link
Owner

@CryingDitto CryingDitto commented Oct 3, 2022

Account - Token create, verify, blacklist added
Post - Authentication, Authorization added
Comment - Authentication, Authorization added

settings.py에 라이브 서버 포트 번호 등록해줬고 django-cors-header 설치했는데도 첫날에는 작동했던 Live server가 자꾸 cors 에러 때문에 작동을 안함.
일단 postman에서 잘 돌아가는 거 확인한 데까지만 업로드.

Copy link

@toto9602 toto9602 left a comment

Choose a reason for hiding this comment

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

@CryingDitto 님 정말 수고 많으셨습니다!! 👏 👏
너무 잘 작성해주셔서 리뷰할 내용도 많이 없었네요 ㅎㅎ
제가 작성한 리뷰 중에 모호한 부분이 있으시면, 추후에 연락 주시면 감사할 것 같습니다!! 👍

Comment on lines +17 to +18
path('major/', MajorList.as_view()),
path('major/<int:major_pk>/', MajorDetail.as_view()),
Copy link

Choose a reason for hiding this comment

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

혹시 MajorList와 MajorDetail을 반환하는 path는 어떤 경우에 활용하는 엔드포인트일지 궁금합니다!

Comment on lines +64 to +65
# 에러나길래 유저 생성 제대로 된 거 맞는지 확인용으로 사용했음
# 이 방법 말고 방법이 있는지?
Copy link

Choose a reason for hiding this comment

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

admin 페이지에서 확인하시거나, DB 관리 툴을 설치하시면 되지 않을까 싶습니다!
DBeaver, TablePlus....?

Comment on lines +165 to +167
def get_user(self, user_pk):
user = get_object_or_404(Profile, pk = user_pk)
return user
Copy link

Choose a reason for hiding this comment

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

바로 get_object_or_404를 사용하지 않고, get_user로 한 번 더 감싸서 사용하시는 이유가 있는지 궁금합니다!
정말 그냥 궁금해서 여쭤보는 것이라ㅎㅎ Ditto 님 의견을 알려주시면 감사할 것 같습니다 🙇

Comment on lines +11 to +13
fields = ['title', 'author', 'category', 'content', 'like_counts', 'like_users'] # 일부 설정
# fields = '__all__' # 전부 설정

Copy link

Choose a reason for hiding this comment

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

한두 개 정도의 필드를 제외하고 모든 필드를 사용하신다면, exclude 속성도 괜찮을 것 같아요!

    class Meta:
        model = Post
        exclude = ('field1', )

return Response(serializer.errors, status = status.HTTP_400_BAD_REQUEST)
else:
context = {"msg":'Wrong request. This post is not yours.'}
return Response(context, status = status.HTTP_403_FORBIDDEN)
Copy link

Choose a reason for hiding this comment

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

401과 403 구분까지...! 멋지네요 👏

return Response(context, status = status.HTTP_403_FORBIDDEN)

class CommentList(APIView):
def get_comment(self, post_pk):
Copy link

Choose a reason for hiding this comment

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

get_comment 함수는 뭔가 이름이 한 개의 comment만을 가져오는 느낌인 것 같아요!
이름을 조금 수정해 보면 어떨까요..?

Comment on lines +241 to +242
# 이렇게 넣어주는 방법 밖에는 없는지...? ㅠㅠ
# author를 serializer에서 제외하면서도 request.user를 like model에 직접 넣어주는 방법은 없는지..?
Copy link

Choose a reason for hiding this comment

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

음... User와 Post를 ManyToManyField로 관계 설정을 한다면, Like를 누르는 로직 자체를 수정해 볼 수 있을 것 같아요!

@gitguardian
Copy link

gitguardian bot commented Aug 1, 2023

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id Secret Commit Filename
7543755 Django Secret Key 86c836e Session4/websocket/websocket/settings.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants