Commit 03ba3c5c by Guba Sándor

store-server: force SSL option

parent 7f43535f
...@@ -23,19 +23,38 @@ SITE_HOST = config.get('store', 'site_host') ...@@ -23,19 +23,38 @@ SITE_HOST = config.get('store', 'site_host')
SITE_PORT = config.get('store', 'site_port') SITE_PORT = config.get('store', 'site_port')
# Temporary dir for tar.gz # Temporary dir for tar.gz
TEMP_DIR = config.get('store', 'temp_dir') TEMP_DIR = config.get('store', 'temp_dir')
#ForceSSL
try:
FORCE_SSL = config.get('store', 'force_ssl') == "True"
except:
FORCE_SSL = False
def force_ssl(original_function):
def new_function(*args, **kwargs):
ssl = request.environ.get('SSL_CLIENT_VERIFY', 'NONE')
if ssl != "SUCCESS":
abort(403, "Forbidden requests. This site need SSL verification! SSL status: "+ssl)
else:
return original_function(*args, **kwargs)
if FORCE_SSL:
return new_function
else:
return original_function(*args, **kwargs)
@route('/') @route('/')
@force_ssl
def index(): def index():
response = "NONE" response = "NONE"
try: try:
response = request.environi.get('SSL_CLIENT_VERIFY', 'NONE') response = request.environ.get('SSL_CLIENT_VERIFY', 'NONE')
except: except:
pass pass
return "It works! SSL: "+response return "It works! SSL: "+response
# @route('/<neptun:re:[a-zA-Z0-9]{6}>', method='GET') # @route('/<neptun:re:[a-zA-Z0-9]{6}>', method='GET')
@route('/<neptun>', method='GET') @route('/<neptun>', method='GET')
@force_ssl
def neptun_GET(neptun): def neptun_GET(neptun):
home_path = '/home/'+neptun+'/home' home_path = '/home/'+neptun+'/home'
if os.path.exists(home_path) != True: if os.path.exists(home_path) != True:
...@@ -47,6 +66,7 @@ def neptun_GET(neptun): ...@@ -47,6 +66,7 @@ def neptun_GET(neptun):
COMMANDS = {} COMMANDS = {}
@route('/<neptun>', method='POST') @route('/<neptun>', method='POST')
@force_ssl
def neptun_POST(neptun): def neptun_POST(neptun):
# Check if user avaiable (home folder ready) # Check if user avaiable (home folder ready)
home_path = '/home/'+neptun+'/home' home_path = '/home/'+neptun+'/home'
...@@ -180,6 +200,7 @@ def cmd_toplist(request, neptun, home_path): ...@@ -180,6 +200,7 @@ def cmd_toplist(request, neptun, home_path):
COMMANDS['TOPLIST'] = cmd_toplist COMMANDS['TOPLIST'] = cmd_toplist
@route('/set/<neptun>', method='POST') @route('/set/<neptun>', method='POST')
@force_ssl
def set_keys(neptun): def set_keys(neptun):
key_list = [] key_list = []
smb_password = '' smb_password = ''
...@@ -198,6 +219,7 @@ def set_keys(neptun): ...@@ -198,6 +219,7 @@ def set_keys(neptun):
@route('/new/<neptun>', method='POST') @route('/new/<neptun>', method='POST')
@force_ssl
def new_user(neptun): def new_user(neptun):
key_list = [] key_list = []
smbpasswd='' smbpasswd=''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment