Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
9903adf7
Commit
9903adf7
authored
Jul 18, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改cache policy 开关
parent
8bb82d16
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletion
+9
-1
conf.py
apps/jumpserver/conf.py
+1
-0
settings.py
apps/jumpserver/settings.py
+1
-0
mixin.py
apps/perms/api/mixin.py
+7
-1
No files found.
apps/jumpserver/conf.py
View file @
9903adf7
...
...
@@ -378,6 +378,7 @@ defaults = {
'LOGIN_LOG_KEEP_DAYS'
:
90
,
'ASSETS_PERM_CACHE_TIME'
:
3600
*
24
,
'SECURITY_MFA_VERIFY_TTL'
:
3600
,
'ASSETS_PERM_CACHE_ENABLE'
:
False
,
}
...
...
apps/jumpserver/settings.py
View file @
9903adf7
...
...
@@ -610,6 +610,7 @@ EMAIL_SUFFIX = CONFIG.EMAIL_SUFFIX
LOGIN_LOG_KEEP_DAYS
=
CONFIG
.
LOGIN_LOG_KEEP_DAYS
# User or user group permission cache time, default 3600 seconds
ASSETS_PERM_CACHE_ENABLE
=
CONFIG
.
ASSETS_PERM_CACHE_ENABLE
ASSETS_PERM_CACHE_TIME
=
CONFIG
.
ASSETS_PERM_CACHE_TIME
# Asset user auth external backend, default AuthBook backend
...
...
apps/perms/api/mixin.py
View file @
9903adf7
...
...
@@ -28,6 +28,8 @@ def get_etag(request, *args, **kwargs):
cache_policy
=
request
.
GET
.
get
(
"cache_policy"
)
if
cache_policy
!=
'1'
:
return
None
if
not
UserPermissionCacheMixin
.
CACHE_ENABLE
:
return
None
view
=
request
.
parser_context
.
get
(
"view"
)
if
not
view
:
return
None
...
...
@@ -38,6 +40,7 @@ def get_etag(request, *args, **kwargs):
class
UserPermissionCacheMixin
:
cache_policy
=
'0'
RESP_CACHE_KEY
=
'_PERMISSION_RESPONSE_CACHE_V2_{}'
CACHE_ENABLE
=
settings
.
ASSETS_PERM_CACHE_ENABLE
CACHE_TIME
=
settings
.
ASSETS_PERM_CACHE_TIME
_object
=
None
...
...
@@ -111,7 +114,10 @@ class UserPermissionCacheMixin:
@method_decorator
(
condition
(
etag_func
=
get_etag
))
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
cache_policy
=
request
.
GET
.
get
(
'cache_policy'
,
'0'
)
if
not
self
.
CACHE_ENABLE
:
self
.
cache_policy
=
'0'
else
:
self
.
cache_policy
=
request
.
GET
.
get
(
'cache_policy'
,
'0'
)
obj
=
self
.
_get_object
()
if
obj
is
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment