mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
510 B
21 lines
510 B
5 years ago
|
# -*- coding: utf-8 -*-
|
||
|
#
|
||
|
|
||
|
from rest_framework.viewsets import ModelViewSet
|
||
|
|
||
|
from common.permissions import IsValidUser
|
||
|
from .. import serializers
|
||
|
|
||
|
|
||
|
class AccessKeyViewSet(ModelViewSet):
|
||
|
permission_classes = (IsValidUser,)
|
||
|
serializer_class = serializers.AccessKeySerializer
|
||
|
search_fields = ['^id', '^secret']
|
||
|
|
||
|
def get_queryset(self):
|
||
|
return self.request.user.access_keys.all()
|
||
|
|
||
|
def perform_create(self, serializer):
|
||
|
user = self.request.user
|
||
|
user.create_access_key()
|