Files
msa-django-nhn/nhn/authentication.py
icurfer 8c7739ffad
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Add NHN Cloud API integration with async task support
- NHN Cloud API packages: token, vpc, compute, nks, storage
- REST API endpoints with Swagger documentation
- Async task processing for long-running operations
- CORS configuration for frontend integration
- Enhanced logging for debugging API calls

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 01:29:21 +09:00

29 lines
787 B
Python

from rest_framework_simplejwt.authentication import JWTAuthentication
from rest_framework_simplejwt.exceptions import InvalidToken
class StatelessUser:
"""
Stateless user class for JWT authentication.
Does not require database User model.
"""
def __init__(self, username):
self.username = username
self.is_authenticated = True
def __str__(self):
return self.username
class StatelessJWTAuthentication(JWTAuthentication):
"""
Custom JWT authentication that extracts user from token's 'name' claim.
"""
def get_user(self, validated_token):
name = validated_token.get("name")
if not name:
raise InvalidToken("Token does not contain 'name' claim.")
return StatelessUser(username=name)