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
4a3e5e9b
Commit
4a3e5e9b
authored
Mar 12, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of bitbucket.org:jumpserver/core into dev
parents
43b4b7c5
b92ccdd0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
31 deletions
+14
-31
api.py
apps/terminal/api.py
+13
-31
requirements.txt
requirements/requirements.txt
+1
-0
No files found.
apps/terminal/api.py
View file @
4a3e5e9b
...
@@ -4,7 +4,6 @@ from collections import OrderedDict
...
@@ -4,7 +4,6 @@ from collections import OrderedDict
import
logging
import
logging
import
os
import
os
import
uuid
import
uuid
import
boto3
# AWS S3 sdk
from
django.core.cache
import
cache
from
django.core.cache
import
cache
from
django.shortcuts
import
get_object_or_404
,
redirect
from
django.shortcuts
import
get_object_or_404
,
redirect
...
@@ -13,6 +12,8 @@ from django.core.files.storage import default_storage
...
@@ -13,6 +12,8 @@ from django.core.files.storage import default_storage
from
django.http
import
HttpResponseNotFound
from
django.http
import
HttpResponseNotFound
from
django.conf
import
settings
from
django.conf
import
settings
import
jms_storage
from
rest_framework
import
viewsets
,
serializers
from
rest_framework
import
viewsets
,
serializers
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.permissions
import
AllowAny
from
rest_framework.permissions
import
AllowAny
...
@@ -282,36 +283,17 @@ class SessionReplayViewSet(viewsets.ViewSet):
...
@@ -282,36 +283,17 @@ class SessionReplayViewSet(viewsets.ViewSet):
url
=
default_storage
.
url
(
path
)
url
=
default_storage
.
url
(
path
)
return
redirect
(
url
)
return
redirect
(
url
)
else
:
else
:
config
=
settings
.
TERMINAL_REPLAY_STORAGE
.
items
()
configs
=
settings
.
TERMINAL_REPLAY_STORAGE
.
items
()
if
config
:
if
configs
:
for
name
,
value
in
config
:
for
name
,
config
in
configs
:
if
value
.
get
(
"TYPE"
,
''
)
==
"s3"
:
client
=
jms_storage
.
init
(
config
)
client
,
bucket
=
self
.
s3Client
(
value
)
date
=
self
.
session
.
date_start
.
strftime
(
'
%
Y-
%
m-
%
d'
)
try
:
if
client
.
has_file
(
os
.
path
.
join
(
date
,
str
(
self
.
session
.
id
)
+
'.replay.gz'
))
\
date
=
self
.
session
.
date_start
.
strftime
(
'
%
Y-
%
m-
%
d'
)
and
\
client
.
download_file
(
os
.
path
.
join
(
date
,
str
(
self
.
session
.
id
)
+
'.replay.gz'
),
client
.
head_object
(
Bucket
=
bucket
,
default_storage
.
base_location
+
'/'
+
path
):
Key
=
os
.
path
.
join
(
date
,
str
(
self
.
session
.
id
)
+
'.replay.gz'
))
return
redirect
(
default_storage
.
url
(
path
))
client
.
download_file
(
bucket
,
os
.
path
.
join
(
date
,
str
(
self
.
session
.
id
)
+
'.replay.gz'
),
return
HttpResponseNotFound
()
default_storage
.
base_location
+
'/'
+
path
)
return
redirect
(
default_storage
.
url
(
path
))
except
:
pass
return
HttpResponseNotFound
()
def
s3Client
(
self
,
config
):
bucket
=
config
.
get
(
"BUCKET"
,
"jumpserver"
)
REGION
=
config
.
get
(
"REGION"
,
None
)
ACCESS_KEY
=
config
.
get
(
"ACCESS_KEY"
,
None
)
SECRET_KEY
=
config
.
get
(
"SECRET_KEY"
,
None
)
if
ACCESS_KEY
and
REGION
and
SECRET_KEY
:
s3
=
boto3
.
client
(
's3'
,
region_name
=
REGION
,
aws_access_key_id
=
ACCESS_KEY
,
aws_secret_access_key
=
SECRET_KEY
)
else
:
s3
=
boto3
.
client
(
's3'
)
return
s3
,
bucket
class
TerminalConfig
(
APIView
):
class
TerminalConfig
(
APIView
):
...
...
requirements/requirements.txt
View file @
4a3e5e9b
...
@@ -61,6 +61,7 @@ pytz==2017.3
...
@@ -61,6 +61,7 @@ pytz==2017.3
PyYAML==3.12
PyYAML==3.12
redis==2.10.6
redis==2.10.6
requests==2.18.4
requests==2.18.4
jms-storage==0.0.11
s3transfer==0.1.13
s3transfer==0.1.13
simplejson==3.13.2
simplejson==3.13.2
six==1.11.0
six==1.11.0
...
...
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