Add NHN Cloud credentials management and bump version to v0.0.19
All checks were successful
Build And Test / build-and-push (push) Successful in 2m17s

- Add NHN Cloud credential fields to User model (tenant_id, username, encrypted password, storage_account)
- Add API endpoints for credentials CRUD operations
- Implement Fernet encryption for password storage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-14 01:25:43 +09:00
parent dce4663a67
commit e318855b14
5 changed files with 180 additions and 2 deletions

View File

@ -71,6 +71,12 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
encrypted_private_key = models.BinaryField(blank=True, null=True)
last_used_at = models.DateTimeField(blank=True, null=True, verbose_name="SSH 키 마지막 사용 시각")
# ☁️ NHN Cloud 자격증명 필드
nhn_tenant_id = models.CharField(max_length=64, blank=True, null=True, verbose_name="NHN Cloud Tenant ID")
nhn_username = models.EmailField(blank=True, null=True, verbose_name="NHN Cloud Username")
encrypted_nhn_api_password = models.BinaryField(blank=True, null=True, verbose_name="NHN Cloud API Password (암호화)")
nhn_storage_account = models.CharField(max_length=128, blank=True, null=True, verbose_name="NHN Cloud Storage Account")
objects = CustomUserManager()
USERNAME_FIELD = 'email'
@ -112,3 +118,27 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
"""
self.encrypted_private_key = self.encrypt_private_key(private_key)
self.save()
# ☁️ NHN Cloud API Password 암복호화
def encrypt_nhn_password(self, password: str) -> bytes:
"""NHN Cloud API 비밀번호 암호화"""
cipher = Fernet(self.get_encryption_key())
return cipher.encrypt(password.encode())
def decrypt_nhn_password(self) -> str:
"""NHN Cloud API 비밀번호 복호화"""
if self.encrypted_nhn_api_password:
cipher = Fernet(self.get_encryption_key())
return cipher.decrypt(self.encrypted_nhn_api_password).decode()
return ""
def save_nhn_credentials(self, tenant_id: str, username: str, password: str, storage_account: str = None):
"""NHN Cloud 자격증명 저장"""
self.nhn_tenant_id = tenant_id
self.nhn_username = username
self.encrypted_nhn_api_password = self.encrypt_nhn_password(password)
if storage_account:
self.nhn_storage_account = storage_account
self.save(update_fields=[
'nhn_tenant_id', 'nhn_username', 'encrypted_nhn_api_password', 'nhn_storage_account'
])