增加存储和超级签权限管理

pull/1/head
xiaoyu 4 years ago
parent 97cb1f08bc
commit b0abdfa8d2
  1. 3
      fir_client/src/components/FirAppInfossecurity.vue
  2. 6
      fir_client/src/components/FirHeader.vue
  3. 1
      fir_client/src/components/FirSuperSignBase.vue
  4. 11
      fir_client/src/components/FirUserProfileBase.vue
  5. 4
      fir_ser/api/models.py
  6. 33
      fir_ser/api/utils/auth.py
  7. 2
      fir_ser/api/utils/serializer.py
  8. 2
      fir_ser/api/utils/storage/caches.py
  9. 2
      fir_ser/api/views/receiveudids.py
  10. 3
      fir_ser/api/views/storage.py
  11. 5
      fir_ser/api/views/supersign.py

@ -42,7 +42,8 @@
</el-form-item> </el-form-item>
<el-form-item v-if="currentapp.type === 1" label-width="200px" label="自动超级签名"> <el-form-item v-if="currentapp.type === 1 && $store.state.userinfo.supersign_active" label-width="200px"
label="自动超级签名">
<el-tooltip :content="supersign.msg" placement="top"> <el-tooltip :content="supersign.msg" placement="top">
<el-switch <el-switch

@ -27,8 +27,10 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="userinfo">个人资料</el-dropdown-item> <el-dropdown-item command="userinfo">个人资料</el-dropdown-item>
<el-dropdown-item command="chpasswd">修改密码</el-dropdown-item> <el-dropdown-item command="chpasswd">修改密码</el-dropdown-item>
<el-dropdown-item command="storage">存储管理</el-dropdown-item> <el-dropdown-item command="storage" v-if="$store.state.userinfo.storage_active">存储管理
<el-dropdown-item command="supersign">超级签名</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="supersign" v-if="$store.state.userinfo.supersign_active">超级签名
</el-dropdown-item>
<el-dropdown-item command="exit">退出</el-dropdown-item> <el-dropdown-item command="exit">退出</el-dropdown-item>

@ -604,6 +604,7 @@
if (this.codeactiveVisible) { if (this.codeactiveVisible) {
this.codeactiveVisible = false; this.codeactiveVisible = false;
} }
loading.close();
}, params) }, params)
}, },
iosdevicesudidFun(action, data) { iosdevicesudidFun(action, data) {

@ -19,7 +19,7 @@
<div class="user_pro_tabs"> <div class="user_pro_tabs">
<el-row :gutter="12" class="row"> <el-row :gutter="12" class="row">
<el-col :span="6" :offset="3"> <el-col :span="tspan" :offset="3">
<div class="col-4"> <div class="col-4">
<a @click="$router.push({name:'FirUserProfileInfo'})" ref="userinfo" class=""> <a @click="$router.push({name:'FirUserProfileInfo'})" ref="userinfo" class="">
<span> <span>
@ -29,7 +29,7 @@
</a> </a>
</div> </div>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="tspan">
<div class="col-4"> <div class="col-4">
<a ref="changepwd" class="" @click="$router.push({name:'FirUserProfileChangePwd'})"> <a ref="changepwd" class="" @click="$router.push({name:'FirUserProfileChangePwd'})">
<span><i class="el-icon-lock"></i></span> <span><i class="el-icon-lock"></i></span>
@ -39,7 +39,7 @@
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6" v-if="userinfo.storage_active">
<div class="col-4"> <div class="col-4">
<a ref="storage" class="" @click="$router.push({name:'FirUserProfileStorage'})"> <a ref="storage" class="" @click="$router.push({name:'FirUserProfileStorage'})">
<span><i class="el-icon-coin"></i></span> <span><i class="el-icon-coin"></i></span>
@ -72,6 +72,7 @@
imageUrl: '', imageUrl: '',
userinfo: {}, userinfo: {},
uploadconf: {}, uploadconf: {},
tspan: 9,
} }
}, },
methods: { methods: {
@ -129,7 +130,9 @@
this.$store.dispatch("doUserinfo", data.data); this.$store.dispatch("doUserinfo", data.data);
this.$store.dispatch('doucurrentapp', {}); this.$store.dispatch('doucurrentapp', {});
this.imageUrl = data.data.head_img; this.imageUrl = data.data.head_img;
if (this.userinfo.storage_active) {
this.tspan = 6
}
if (datainfo.data) { if (datainfo.data) {
this.$message.success("更新成功") this.$message.success("更新成功")
} }

@ -23,6 +23,8 @@ class UserInfo(AbstractUser):
mobile = models.BigIntegerField(verbose_name="手机", unique=True, help_text="用于手机验证码登录", null=True) mobile = models.BigIntegerField(verbose_name="手机", unique=True, help_text="用于手机验证码登录", null=True)
qq = models.BigIntegerField(verbose_name="QQ", blank=True, null=True, db_index=True) qq = models.BigIntegerField(verbose_name="QQ", blank=True, null=True, db_index=True)
is_active = models.BooleanField(default=True, verbose_name="账户状态,默认启用") is_active = models.BooleanField(default=True, verbose_name="账户状态,默认启用")
storage_active = models.BooleanField(default=False, verbose_name="配置存储,默认关闭")
supersign_active = models.BooleanField(default=False, verbose_name="配置超级签,默认关闭")
job = models.TextField("职位", max_length=128, blank=True, null=True) job = models.TextField("职位", max_length=128, blank=True, null=True)
company = models.CharField("公司", max_length=128, blank=True, null=True) company = models.CharField("公司", max_length=128, blank=True, null=True)
@ -36,7 +38,7 @@ class UserInfo(AbstractUser):
memo = models.TextField('备注', blank=True, null=True, default=None, ) memo = models.TextField('备注', blank=True, null=True, default=None, )
date_joined = models.DateTimeField(auto_now_add=True, verbose_name="注册时间") date_joined = models.DateTimeField(auto_now_add=True, verbose_name="注册时间")
download_times = models.IntegerField(default=100, verbose_name="下载次数") download_times = models.IntegerField(default=100, verbose_name="可用下载次数")
all_download_times = models.BigIntegerField(default=0, verbose_name="总共下载次数") all_download_times = models.BigIntegerField(default=0, verbose_name="总共下载次数")
domain_name = models.CharField(verbose_name="下载页面域名", blank=True, null=True, max_length=64) domain_name = models.CharField(verbose_name="下载页面域名", blank=True, null=True, max_length=64)
history_release_limit = models.IntegerField(default=10, verbose_name="app 历史记录版本", blank=True, null=True) history_release_limit = models.IntegerField(default=10, verbose_name="app 历史记录版本", blank=True, null=True)

@ -1,14 +1,13 @@
from django.core.cache import cache from django.core.cache import cache
from rest_framework.authentication import BaseAuthentication from rest_framework.authentication import BaseAuthentication
from rest_framework.exceptions import AuthenticationFailed from rest_framework.exceptions import AuthenticationFailed
from api.models import Token, UserInfo from api.models import UserInfo
from rest_framework.permissions import BasePermission
from fir_ser.settings import CACHE_KEY_TEMPLATE from fir_ser.settings import CACHE_KEY_TEMPLATE
import base64 import base64
class ExpiringTokenAuthentication(BaseAuthentication): def get_user_from_auth(request):
def authenticate(self, request):
if request.method == "OPTIONS": if request.method == "OPTIONS":
return None return None
request_token = request.META.get("HTTP_AUTHORIZATION", request.query_params.get("token", None)) request_token = request.META.get("HTTP_AUTHORIZATION", request.query_params.get("token", None))
@ -42,3 +41,29 @@ class ExpiringTokenAuthentication(BaseAuthentication):
return user_obj, auth_token return user_obj, auth_token
else: else:
raise AuthenticationFailed({"code": 1001, "error": "用户被禁用"}) raise AuthenticationFailed({"code": 1001, "error": "用户被禁用"})
class ExpiringTokenAuthentication(BaseAuthentication):
def authenticate(self, request):
return get_user_from_auth(request)
class StoragePermission(BasePermission):
message = "权限不足"
def has_permission(self, request, view):
results = get_user_from_auth(request)
if results and results[0]:
return results[0].storage_active
return True
class SuperSignPermission(BasePermission):
message = "权限不足"
def has_permission(self, request, view):
results = get_user_from_auth(request)
if results and results[0]:
return results[0].supersign_active
return True

@ -17,7 +17,7 @@ class UserInfoSerializer(serializers.ModelSerializer):
# fields="__all__" # fields="__all__"
# exclude = ["password","is_active","user_permissions","role",] # exclude = ["password","is_active","user_permissions","role",]
fields = ["username", "uid", "mobile", "job", "email", "domain_name", "last_login", "first_name", fields = ["username", "uid", "mobile", "job", "email", "domain_name", "last_login", "first_name",
'head_img'] 'head_img', 'storage_active', 'supersign_active']
head_img = serializers.SerializerMethodField() head_img = serializers.SerializerMethodField()

@ -34,7 +34,7 @@ def get_download_url_by_cache(app_obj, filename, limit, isdownload=True, key='',
if appudid_obj: if appudid_obj:
SuperSign_obj = APPSuperSignUsedInfo.objects.filter(udid__udid=udid, SuperSign_obj = APPSuperSignUsedInfo.objects.filter(udid__udid=udid,
app_id_id=app_obj.get("pk")).first() app_id_id=app_obj.get("pk")).first()
if SuperSign_obj: if SuperSign_obj and SuperSign_obj.user_id.supersign_active:
APPToDeveloper_obj = APPToDeveloper.objects.filter(app_id_id=app_obj.get("pk"), APPToDeveloper_obj = APPToDeveloper.objects.filter(app_id_id=app_obj.get("pk"),
developerid=SuperSign_obj.developerid).first() developerid=SuperSign_obj.developerid).first()
if APPToDeveloper_obj: if APPToDeveloper_obj:

@ -24,7 +24,7 @@ class IosUDIDView(View):
app_info = Apps.objects.filter(short=short).first() app_info = Apps.objects.filter(short=short).first()
if app_info: if app_info:
if app_info.issupersign: if app_info.issupersign and app_info.user_id.supersign_active:
AppUDID.objects.update_or_create(app_id=app_info, **format_udid_info, AppUDID.objects.update_or_create(app_id=app_info, **format_udid_info,
defaults={'udid': format_udid_info.get('udid')}) defaults={'udid': format_udid_info.get('udid')})
ios_obj = IosUtils(format_udid_info, app_info.user_id, app_info) ios_obj = IosUtils(format_udid_info, app_info.user_id, app_info)

@ -6,7 +6,7 @@
from rest_framework.views import APIView from rest_framework.views import APIView
from api.utils.response import BaseResponse from api.utils.response import BaseResponse
from api.utils.auth import ExpiringTokenAuthentication from api.utils.auth import ExpiringTokenAuthentication, StoragePermission
from rest_framework.response import Response from rest_framework.response import Response
import json import json
from api.utils.storage.caches import del_cache_storage from api.utils.storage.caches import del_cache_storage
@ -20,6 +20,7 @@ logger = logging.getLogger(__file__)
class StorageView(APIView): class StorageView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ] authentication_classes = [ExpiringTokenAuthentication, ]
permission_classes = [StoragePermission, ]
def get(self, request): def get(self, request):
res = BaseResponse() res = BaseResponse()

@ -6,7 +6,7 @@
from rest_framework.views import APIView from rest_framework.views import APIView
from api.utils.response import BaseResponse from api.utils.response import BaseResponse
from api.utils.auth import ExpiringTokenAuthentication from api.utils.auth import ExpiringTokenAuthentication, SuperSignPermission
from rest_framework.response import Response from rest_framework.response import Response
from api.models import AppIOSDeveloperInfo, APPSuperSignUsedInfo, AppUDID from api.models import AppIOSDeveloperInfo, APPSuperSignUsedInfo, AppUDID
from api.utils.serializer import DeveloperSerializer, SuperSignUsedSerializer, DeviceUDIDSerializer from api.utils.serializer import DeveloperSerializer, SuperSignUsedSerializer, DeviceUDIDSerializer
@ -28,6 +28,7 @@ class AppsPageNumber(PageNumberPagination):
class DeveloperView(APIView): class DeveloperView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ] authentication_classes = [ExpiringTokenAuthentication, ]
permission_classes = [SuperSignPermission, ]
def get(self, request): def get(self, request):
@ -170,6 +171,7 @@ class DeveloperView(APIView):
class SuperSignUsedView(APIView): class SuperSignUsedView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ] authentication_classes = [ExpiringTokenAuthentication, ]
permission_classes = [SuperSignPermission, ]
def get(self, request): def get(self, request):
res = BaseResponse() res = BaseResponse()
@ -199,6 +201,7 @@ class SuperSignUsedView(APIView):
class AppUDIDUsedView(APIView): class AppUDIDUsedView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ] authentication_classes = [ExpiringTokenAuthentication, ]
permission_classes = [SuperSignPermission, ]
def get(self, request): def get(self, request):
res = BaseResponse() res = BaseResponse()

Loading…
Cancel
Save