Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Birin Sanchez
Keel - LDH Middleware
Commits
ebe34a69
Commit
ebe34a69
authored
Mar 13, 2019
by
Birin Sanchez
Browse files
Add a public area so unauthenticated users can download files.
Signed-off-by:
Birin Sanchez
<
birin.sanchez@puri.sm
>
parent
31971e49
Pipeline
#4995
passed with stage
in 40 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
middleware/urls.py
View file @
ebe34a69
...
...
@@ -49,5 +49,7 @@ urlpatterns = [
url
(
r
'^captcha/'
,
include
(
'captcha.urls'
)),
url
(
r
'^cart/(?P<reward>\d+)/$'
,
CartRegistrationView
.
as_view
(),
name
=
"register_reward"
),
url
(
r
'^tunnel/api/v1/get_user_creds'
,
purist
.
views
.
UserDetail
.
as_view
(),
name
=
'get_user_creds'
)
purist
.
views
.
UserDetail
.
as_view
(),
name
=
'get_user_creds'
),
url
(
r
'^public/(?P<target>.*)'
,
purist
.
views
.
public_area
,
name
=
'public_area'
)
]
purist/views.py
View file @
ebe34a69
...
...
@@ -5,7 +5,7 @@ from rest_framework.views import APIView
from
rest_framework.response
import
Response
from
rest_framework
import
permissions
from
.serializers
import
UserSerializer
from
django.http
import
Http404
from
django.http
import
Http404
,
FileResponse
class
UserDetail
(
APIView
):
...
...
@@ -43,3 +43,12 @@ def jslicense(request):
}
return
render
(
request
,
'purist/jslicense.html'
,
render_data
)
def
public_area
(
request
,
target
):
if
target
==
'certificate.ovpn'
:
f
=
open
(
'/etc/opt/purist/middleware/certificate.ovpn'
,
'rb'
)
else
:
raise
Http404
res
=
FileResponse
(
f
,
content_type
=
'application/octet-stream'
)
return
res
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