diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index 0839229b8..c214f93ab 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -1,31 +1,31 @@ -import os -import abc -import json -import time import base64 +import json +import os +import time import urllib.parse + from django.http import HttpResponse from django.shortcuts import get_object_or_404 -from rest_framework.request import Request from rest_framework import status -from rest_framework.exceptions import PermissionDenied from rest_framework.decorators import action -from rest_framework.response import Response +from rest_framework.exceptions import PermissionDenied from rest_framework.request import Request +from rest_framework.response import Response from common.drf.api import JMSModelViewSet from common.http import is_true from orgs.mixins.api import RootOrgViewMixin from perms.models import ActionChoices from terminal.models import EndpointRule +from ..models import ConnectionToken from ..serializers import ( ConnectionTokenSerializer, ConnectionTokenSecretSerializer, SuperConnectionTokenSerializer, ConnectionTokenDisplaySerializer, ) -from ..models import ConnectionToken __all__ = ['ConnectionTokenViewSet', 'SuperConnectionTokenViewSet'] + # ExtraActionApiMixin diff --git a/apps/perms/models/__init__.py b/apps/perms/models/__init__.py index ee7787f7f..9041990f2 100644 --- a/apps/perms/models/__init__.py +++ b/apps/perms/models/__init__.py @@ -1,5 +1,6 @@ # coding: utf-8 # -from .permed_node import * from .asset_permission import * +from .perm_node import * +from .perm_token import * diff --git a/apps/perms/models/permed_node.py b/apps/perms/models/perm_node.py similarity index 100% rename from apps/perms/models/permed_node.py rename to apps/perms/models/perm_node.py diff --git a/apps/perms/models/perm_token.py b/apps/perms/models/perm_token.py new file mode 100644 index 000000000..857cb9dd7 --- /dev/null +++ b/apps/perms/models/perm_token.py @@ -0,0 +1,14 @@ +from django.db import models +from django.utils.translation import gettext_lazy as _ + + +class PermToken(models.Model): + user = models.ForeignKey('users.User', on_delete=models.CASCADE, verbose_name=_('User')) + asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE, verbose_name=_('Asset')) + account = models.CharField(max_length=128, verbose_name=_('Account')) + secret = models.CharField(max_length=1024, verbose_name=_('Secret')) + protocol = models.CharField(max_length=32, verbose_name=_('Protocol')) + connect_method = models.CharField(max_length=32, verbose_name=_('Connect method')) + + class Meta: + abstract = True