mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-21 18:03:54 +03:00
fixed so now Redirect To Https will redirect ALWAYS :)
This commit is contained in:
parent
815de57b86
commit
2521f41e76
@ -109,7 +109,6 @@ class CommonService(object):
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def setReady(self):
|
||||
self.api.setReady([(v.mac, v.ip) for v in operations.getNetworkInfo()])
|
||||
|
||||
|
@ -164,6 +164,7 @@ MIDDLEWARE_CLASSES = (
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'uds.core.util.request.GlobalRequestMiddleware',
|
||||
'uds.core.util.middleware.XUACompatibleMiddleware',
|
||||
'uds.core.util.middleware.RedirectMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
)
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from uds.core.util.Config import GlobalConfig
|
||||
from django.http import HttpResponseRedirect
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -42,3 +44,14 @@ class XUACompatibleMiddleware(object):
|
||||
if response.get('content-type', '').startswith('text/html'):
|
||||
response['X-UA-Compatible'] = 'IE=edge'
|
||||
return response
|
||||
|
||||
class RedirectMiddleware(object):
|
||||
def process_request(self, request):
|
||||
if GlobalConfig.REDIRECT_TO_HTTPS.getBool() and request.is_secure() is False:
|
||||
if request.method == 'POST':
|
||||
url = request.build_absolute_uri(GlobalConfig.LOGIN_URL.get())
|
||||
else:
|
||||
url = request.build_absolute_uri(request.get_full_path())
|
||||
url = url.replace('http://', 'https://')
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user