2016-09-11 01:50:42 +00:00
|
|
|
# coding:utf-8
|
|
|
|
|
2019-07-11 10:12:14 +00:00
|
|
|
from django.urls import path, re_path
|
2016-11-09 16:18:57 +00:00
|
|
|
from rest_framework import routers
|
2019-07-11 10:12:14 +00:00
|
|
|
from common import api as capi
|
2016-11-16 10:12:14 +00:00
|
|
|
from .. import api
|
2016-09-11 01:50:42 +00:00
|
|
|
|
|
|
|
app_name = 'perms'
|
|
|
|
|
2016-11-09 16:18:57 +00:00
|
|
|
router = routers.DefaultRouter()
|
2018-07-13 16:47:21 +00:00
|
|
|
router.register('asset-permissions', api.AssetPermissionViewSet, 'asset-permission')
|
2019-05-20 11:39:53 +00:00
|
|
|
router.register('remote-app-permissions', api.RemoteAppPermissionViewSet, 'remote-app-permission')
|
2016-11-09 16:18:57 +00:00
|
|
|
|
2019-07-02 04:08:25 +00:00
|
|
|
|
2019-05-20 11:39:53 +00:00
|
|
|
asset_permission_urlpatterns = [
|
2019-07-11 10:12:14 +00:00
|
|
|
# Assets
|
2019-07-02 04:08:25 +00:00
|
|
|
path('users/<uuid:pk>/assets/', api.UserGrantedAssetsApi.as_view(), name='user-assets'),
|
2019-07-11 10:12:14 +00:00
|
|
|
path('users/assets/', api.UserGrantedAssetsApi.as_view(), name='my-assets'),
|
|
|
|
|
|
|
|
# Node as tree
|
|
|
|
path('users/<uuid:pk>/nodes/tree/', api.UserGrantedNodesAsTreeApi.as_view(), name='user-nodes-as-tree'),
|
|
|
|
path('users/nodes/tree/', api.UserGrantedNodesAsTreeApi.as_view(), name='my-nodes-as-tree'),
|
|
|
|
|
|
|
|
# Nodes
|
|
|
|
path('users/<uuid:pk>/nodes/', api.UserGrantedNodesApi.as_view(), name='user-nodes'),
|
|
|
|
path('users/nodes/', api.UserGrantedNodesApi.as_view(), name='my-nodes'),
|
|
|
|
|
|
|
|
# Node assets
|
|
|
|
path('users/<uuid:pk>/nodes/<uuid:node_id>/assets/', api.UserGrantedNodeAssetsApi.as_view(), name='user-node-assets'),
|
|
|
|
path('users/nodes/<uuid:node_id>/assets/', api.UserGrantedNodeAssetsApi.as_view(), name='my-node-assets'),
|
|
|
|
|
|
|
|
# Node with assets
|
|
|
|
path('users/<uuid:pk>/nodes-assets/', api.UserGrantedNodesWithAssetsApi.as_view(), name='user-nodes-assets'),
|
|
|
|
path('users/nodes-assets/', api.UserGrantedNodesWithAssetsApi.as_view(), name='my-nodes-assets'),
|
|
|
|
|
|
|
|
# Node assets as tree
|
|
|
|
path('users/<uuid:pk>/nodes-assets/tree/', api.UserGrantedNodesWithAssetsAsTreeApi.as_view(), name='user-nodes-assets-as-tree'),
|
|
|
|
path('users/nodes-assets/tree/', api.UserGrantedNodesWithAssetsAsTreeApi.as_view(), name='my-nodes-assets-as-tree'),
|
2018-12-10 02:11:54 +00:00
|
|
|
|
2017-01-17 09:11:01 +00:00
|
|
|
# 查询某个用户组授权的资产和资产组
|
2019-07-11 10:12:14 +00:00
|
|
|
path('user-groups/<uuid:pk>/assets/', api.UserGroupGrantedAssetsApi.as_view(), name='user-group-assets'),
|
|
|
|
path('user-groups/<uuid:pk>/nodes/', api.UserGroupGrantedNodesApi.as_view(), name='user-group-nodes'),
|
|
|
|
path('user-groups/<uuid:pk>/nodes-assets/', api.UserGroupGrantedNodesWithAssetsApi.as_view(), name='user-group-nodes-assets'),
|
|
|
|
path('user-groups/<uuid:pk>/nodes-assets/tree/', api.UserGroupGrantedNodesWithAssetsAsTreeApi.as_view(), name='user-group-nodes-assets-as-tree'),
|
|
|
|
path('user-groups/<uuid:pk>/nodes/<uuid:node_id>/assets/', api.UserGroupGrantedNodeAssetsApi.as_view(), name='user-group-node-assets'),
|
2018-04-11 07:24:12 +00:00
|
|
|
|
|
|
|
# 用户和资产授权变更
|
2019-07-02 04:08:25 +00:00
|
|
|
path('asset-permissions/<uuid:pk>/user/remove/', api.AssetPermissionRemoveUserApi.as_view(), name='asset-permission-remove-user'),
|
|
|
|
path('asset-permissions/<uuid:pk>/user/add/', api.AssetPermissionAddUserApi.as_view(), name='asset-permission-add-user'),
|
|
|
|
path('asset-permissions/<uuid:pk>/asset/remove/', api.AssetPermissionRemoveAssetApi.as_view(), name='asset-permission-remove-asset'),
|
|
|
|
path('asset-permissions/<uuid:pk>/asset/add/', api.AssetPermissionAddAssetApi.as_view(), name='asset-permission-add-asset'),
|
2017-01-17 09:11:01 +00:00
|
|
|
|
|
|
|
# 验证用户是否有某个资产和系统用户的权限
|
2019-07-11 10:12:14 +00:00
|
|
|
path('asset-permissions/user/validate/', api.ValidateUserAssetPermissionApi.as_view(), name='validate-user-asset-permission'),
|
|
|
|
path('asset-permissions/user/actions/', api.GetUserAssetPermissionActionsApi.as_view(), name='get-user-asset-permission-actions'),
|
2016-10-19 11:30:55 +00:00
|
|
|
]
|
|
|
|
|
2019-05-20 11:39:53 +00:00
|
|
|
|
|
|
|
remote_app_permission_urlpatterns = [
|
|
|
|
# 查询用户授权的RemoteApp
|
2019-07-11 10:12:14 +00:00
|
|
|
path('users/<uuid:pk>/remote-apps/', api.UserGrantedRemoteAppsApi.as_view(), name='user-remote-apps'),
|
|
|
|
path('users/remote-apps/', api.UserGrantedRemoteAppsApi.as_view(), name='my-remote-apps'),
|
2019-05-20 11:39:53 +00:00
|
|
|
|
|
|
|
# 获取用户授权的RemoteApp树
|
2019-07-11 10:12:14 +00:00
|
|
|
path('users/<uuid:pk>/remote-apps/tree/', api.UserGrantedRemoteAppsAsTreeApi.as_view(), name='user-remote-apps-as-tree'),
|
|
|
|
path('users/remote-apps/tree/', api.UserGrantedRemoteAppsAsTreeApi.as_view(), name='my-remote-apps-as-tree'),
|
2019-05-20 11:39:53 +00:00
|
|
|
|
|
|
|
# 查询用户组授权的RemoteApp
|
2019-07-11 10:12:14 +00:00
|
|
|
path('user-groups/<uuid:pk>/remote-apps/', api.UserGroupGrantedRemoteAppsApi.as_view(), name='user-group-remote-apps'),
|
2019-05-20 11:39:53 +00:00
|
|
|
|
|
|
|
# 校验用户对RemoteApp的权限
|
2019-07-11 10:12:14 +00:00
|
|
|
path('remote-app-permissions/user/validate/', api.ValidateUserRemoteAppPermissionApi.as_view(), name='validate-user-remote-app-permission'),
|
2019-05-20 11:39:53 +00:00
|
|
|
|
|
|
|
# 用户和RemoteApp变更
|
2019-07-02 04:08:25 +00:00
|
|
|
path('remote-app-permissions/<uuid:pk>/user/add/', api.RemoteAppPermissionAddUserApi.as_view(), name='remote-app-permission-add-user'),
|
|
|
|
path('remote-app-permissions/<uuid:pk>/user/remove/', api.RemoteAppPermissionRemoveUserApi.as_view(), name='remote-app-permission-remove-user'),
|
|
|
|
path('remote-app-permissions/<uuid:pk>/remote-app/remove/', api.RemoteAppPermissionRemoveRemoteAppApi.as_view(), name='remote-app-permission-remove-remote-app'),
|
|
|
|
path('remote-app-permissions/<uuid:pk>/remote-app/add/', api.RemoteAppPermissionAddRemoteAppApi.as_view(), name='remote-app-permission-add-remote-app'),
|
2019-05-20 11:39:53 +00:00
|
|
|
]
|
|
|
|
|
2019-07-11 10:12:14 +00:00
|
|
|
old_version_urlpatterns = [
|
|
|
|
re_path('(?P<resource>user|user-group|asset-permission|remote-app-permission)/.*', capi.redirect_plural_name_api)
|
|
|
|
]
|
|
|
|
|
|
|
|
urlpatterns = asset_permission_urlpatterns + remote_app_permission_urlpatterns + old_version_urlpatterns
|
2019-05-20 11:39:53 +00:00
|
|
|
|
2016-11-09 16:18:57 +00:00
|
|
|
urlpatterns += router.urls
|
2016-11-16 10:12:14 +00:00
|
|
|
|