게시물 등록 및 토큰검증 후 등록 추가
This commit is contained in:
14
blog/authentication.py
Normal file
14
blog/authentication.py
Normal file
@ -0,0 +1,14 @@
|
||||
from rest_framework_simplejwt.authentication import JWTAuthentication
|
||||
from rest_framework_simplejwt.exceptions import InvalidToken
|
||||
|
||||
class StatelessUser:
|
||||
def __init__(self, username):
|
||||
self.username = username
|
||||
self.is_authenticated = True
|
||||
|
||||
class StatelessJWTAuthentication(JWTAuthentication):
|
||||
def get_user(self, validated_token):
|
||||
name = validated_token.get("name")
|
||||
if not name:
|
||||
raise InvalidToken("Token에 'name' 항목이 없습니다.")
|
||||
return StatelessUser(username=name)
|
Reference in New Issue
Block a user