feat: support configuring multiple SSH keys for users

This commit is contained in:
wangruidong
2024-07-29 19:37:50 +08:00
committed by Bryan
parent 7a38c9136e
commit 2a5c41dfaf
16 changed files with 162 additions and 87 deletions

View File

@@ -1,7 +1,7 @@
from .access_key import *
from .connection_token import *
from .private_token import *
from .ssh_key import *
from .sso_token import *
from .temp_token import *
from ..backends.passkey.models import *

View File

@@ -0,0 +1,27 @@
import sshpubkeys
from django.db import models
from django.utils.translation import gettext_lazy as _
from common.db.models import JMSBaseModel, CASCADE_SIGNAL_SKIP
from users.models import AuthMixin
from common.db import fields
class SSHKey(JMSBaseModel, AuthMixin):
name = models.CharField(max_length=128, verbose_name=_("Name"))
is_active = models.BooleanField(default=True, verbose_name=_('Active'))
private_key = fields.EncryptTextField(
blank=True, null=True, verbose_name=_("Private key")
)
public_key = fields.EncryptTextField(
blank=True, null=True, verbose_name=_("Public key")
)
date_last_used = models.DateTimeField(null=True, blank=True, verbose_name=_('Date last used'))
user = models.ForeignKey(
'users.User', on_delete=CASCADE_SIGNAL_SKIP, verbose_name=_('User'), db_constraint=False,
related_name='ssh_keys'
)
class Meta:
verbose_name = _('SSH key')