|  | @@ -17,6 +17,7 @@ from tg.util import lazify
 | 
	
		
			
			| 17 | 17 |  from redis import Redis
 | 
	
		
			
			| 18 | 18 |  from rq import Queue
 | 
	
		
			
			| 19 | 19 |  
 | 
	
		
			
			|  | 20 | +from wsgidav.middleware import BaseMiddleware
 | 
	
		
			
			| 20 | 21 |  from tracim.lib.base import logger
 | 
	
		
			
			| 21 | 22 |  from webob import Response
 | 
	
		
			
			| 22 | 23 |  from webob.exc import WSGIHTTPException
 | 
	
	
		
			
			|  | @@ -180,3 +181,22 @@ def get_rq_queue(queue_name: str= 'default') -> Queue:
 | 
	
		
			
			| 180 | 181 |          port=cfg.EMAIL_SENDER_REDIS_PORT,
 | 
	
		
			
			| 181 | 182 |          db=cfg.EMAIL_SENDER_REDIS_DB,
 | 
	
		
			
			| 182 | 183 |      ))
 | 
	
		
			
			|  | 184 | +
 | 
	
		
			
			|  | 185 | +
 | 
	
		
			
			|  | 186 | +class TracimEnforceHTTPS(BaseMiddleware):
 | 
	
		
			
			|  | 187 | +
 | 
	
		
			
			|  | 188 | +    def __init__(self, application, config):
 | 
	
		
			
			|  | 189 | +        super().__init__(application, config)
 | 
	
		
			
			|  | 190 | +        self._application = application
 | 
	
		
			
			|  | 191 | +        self._config = config
 | 
	
		
			
			|  | 192 | +
 | 
	
		
			
			|  | 193 | +    def __call__(self, environ, start_response):
 | 
	
		
			
			|  | 194 | +        # TODO - G.M - 06-03-2018 - Check protocol from http header first
 | 
	
		
			
			|  | 195 | +        # see http://www.bortzmeyer.org/7239.html
 | 
	
		
			
			|  | 196 | +        # if this params doesn't exist, rely on tracim config
 | 
	
		
			
			|  | 197 | +        from tracim.config.app_cfg import CFG
 | 
	
		
			
			|  | 198 | +        cfg = CFG.get_instance()
 | 
	
		
			
			|  | 199 | +
 | 
	
		
			
			|  | 200 | +        if cfg.WEBSITE_BASE_URL.startswith('https'):
 | 
	
		
			
			|  | 201 | +            environ['wsgi.url_scheme'] = 'https'
 | 
	
		
			
			|  | 202 | +        return self._application(environ, start_response)
 |