Add NHN Cloud API integration with async task support
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
- 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>
This commit is contained in:
28
nhn/authentication.py
Normal file
28
nhn/authentication.py
Normal file
@ -0,0 +1,28 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user