분류 전체보기

    [Django] JWT#2, 장고 JWT토큰 사용하기, payload, Pyjwt, 장고 로그인 유지

    [Django] JWT#2, 장고 JWT토큰 사용하기, payload, Pyjwt, 장고 로그인 유지

    [Django] JWT#1, Serializer을 이용하여 password 암호화하여 데이터베이스(DB) 저장하기, 비밀번호 암호화 JWT을 통하여 회원가입 로그인 로그아웃을 토큰을 통하여 하는 방법을 알아내기 위해, 꽤 많은 구글링을 거쳤다. 공식문서에서는 simple-jwt를 사용하라고 했었는데, 해외 유튜버를 참고하여 pyJWT를 devforyou.tistory.com # 토큰을 쓰는 이유가 무엇일까? 우리가 이용하는 서비스의 대다수는 "로그인"시스템이 존재한다. 로그인을 한 후 접근가능한 사이트에서 또는 서비스를 이용하게 된다. 그렇다면 로그인을 마치고 다음으로 이동하는 사이트에서 우리가 로그인 한 사용자라는 것은 어떻게 알 것인가? 여기에서는 대표적으로 세션 방식과 토큰을 이용하는 방식이 이용된..

    [Django] JWT#1, Serializer을 이용하여 password 암호화하여 데이터베이스(DB) 저장하기, 비밀번호 암호화하기

    [Django] JWT#1, Serializer을 이용하여 password 암호화하여 데이터베이스(DB) 저장하기, 비밀번호 암호화하기

    JWT을 통하여 회원가입 로그인 로그아웃을 토큰을 통하여 하는 방법을 알아내기 위해, 꽤 많은 구글링을 거쳤다. 공식문서에서는 simple-jwt를 사용하라고 했었는데, 해외 유튜버를 참고하여 pyJWT를 사용하여 구현하는 방법을 알아 낼 수 있었다. 이번 포스팅에서는 jwt 토큰을 주고받기 전에 password를 DB에 저장할때 암호화(hashing)을 통하여 저장 할 수 있는 방법에 대해서 기록하도록 하겠다. ## 필요한 라이브러리 Serializer을 사용해야하기 때문에 DRF를 pip를 통하여 설치해야 하며, setting.py에 restframework를 추가해주도록 하자 Django-rest-framework # serializer 작성 Serializer.py를 account 앱 또는 사용할..

    [Django] 장고 커스텀 유저 만들기#2 forms.py admin.py , custom User, 장고 User 바꾸기

    [Django] 장고 커스텀 유저 만들기#2 forms.py admin.py , custom User, 장고 User 바꾸기

    [Django] 장고 커스텀 유저 만들기#1 models.py , custom User, 장고 User 바꾸기 DRF를 이용해서 로그인 api를 구현하기 위해서 어제 많은 자료들을 찾아 봤다. DRF자체적으로 세션,토큰, 또 simple jwt를 이용하게 되면 JWT까지 쉽게 구현 가능하다고 한다. 그래서 고민고민하면서 devforyou.tistory.com #1에 이어서 진행하도록 하겠다. # forms.py를 만들어 주자! from django import forms from django.contrib.auth.forms import ReadOnlyPasswordHashField from .models import User # email, name, nickname, phoneNumber, dateO..

    [Django] 장고 커스텀 유저 만들기#1 models.py , custom User, 장고 User 바꾸기

    [Django] 장고 커스텀 유저 만들기#1 models.py , custom User, 장고 User 바꾸기

    DRF를 이용해서 로그인 api를 구현하기 위해서 어제 많은 자료들을 찾아 봤다. DRF자체적으로 세션,토큰, 또 simple jwt를 이용하게 되면 JWT까지 쉽게 구현 가능하다고 한다. 그래서 고민고민하면서 구현해보고자 했다. 그런데 해당기능들은 장고 자체에 내장된 auth기능을 활용하는거 같았는데 auth는 장고의 내장 User모델을 사용한다. User모델은 장고가 이미 정해놨다. 어떤 서비스를 만들어 유저를 관리한다고 하면 그 유저에 대한 정보를 담는 것 가지각색이다. 그래서 User를 내 입맛에 맞게 바꾸는걸 먼저 해야했다. 한번 알아두면 두고두고 보면서 활용하면 좋을거 같아서 기록하도록 하겠다. 참고한 자료는 여러 공식문서와 블로그인데 마지막에 링크로 첨부하도록 하겠다. # AbstractUs..

    [Django] django-rest-framework 공식문서 튜토리얼 따라하기#5

    [Django] django-rest-framework 공식문서 튜토리얼 따라하기#5

    5 - Relationships and hyperlinked APIs - Django REST framework At the moment relationships within our API are represented by using primary keys. In this part of the tutorial we'll improve the cohesion and discoverability of our API, by instead using hyperlinking for relationships. Right now we have endpoints for 'snip www.django-rest-framework.org # users와 snippets를 한번에 볼 수 있는 view 만들기 from rest..

    [Django] django-rest-framework 공식문서 튜토리얼 따라하기#4, 로그인과 auth인증

    [Django] django-rest-framework 공식문서 튜토리얼 따라하기#4, 로그인과 auth인증

    4 - Authentication and permissions - Django REST framework Currently our API doesn't have any restrictions on who can edit or delete code snippets. We'd like to have some more advanced behavior in order to make sure that: Code snippets are always associated with a creator. Only authenticated users may create snipp www.django-rest-framework.org 장고 튜툐리얼#4 포스팅이다. 인증 및 권한을 다루는데 게시물을 작성할때 유저체크를 하고, 유..