|
|
@ -34,7 +34,7 @@ default_config = {
|
|
|
|
'FRONTEND': 'none',
|
|
|
|
'FRONTEND': 'none',
|
|
|
|
'TLS_FLAVOR': 'cert',
|
|
|
|
'TLS_FLAVOR': 'cert',
|
|
|
|
'CERTS_PATH': '/certs',
|
|
|
|
'CERTS_PATH': '/certs',
|
|
|
|
'PASSWORD_SCHEME': 'SHA512-CRYPT'
|
|
|
|
'PASSWORD_SCHEME': 'SHA512-CRYPT',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Load configuration from the environment if available
|
|
|
|
# Load configuration from the environment if available
|
|
|
@ -71,9 +71,29 @@ login_manager = flask_login.LoginManager()
|
|
|
|
login_manager.init_app(app)
|
|
|
|
login_manager.init_app(app)
|
|
|
|
login_manager.login_view = ".login"
|
|
|
|
login_manager.login_view = ".login"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_manager.unauthorized_handler
|
|
|
|
|
|
|
|
def handle_needs_login():
|
|
|
|
|
|
|
|
return flask.redirect(
|
|
|
|
|
|
|
|
flask.url_for('.login', next=flask.request.endpoint)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@app.context_processor
|
|
|
|
@app.context_processor
|
|
|
|
def inject_user():
|
|
|
|
def inject_user():
|
|
|
|
return dict(current_user=flask_login.current_user)
|
|
|
|
return dict(current_user=flask_login.current_user)
|
|
|
|
|
|
|
|
|
|
|
|
# Import views
|
|
|
|
# Import views
|
|
|
|
from mailu.views import *
|
|
|
|
from mailu.views import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create the prefix middleware
|
|
|
|
|
|
|
|
class PrefixMiddleware(object):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, app):
|
|
|
|
|
|
|
|
self.app = app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __call__(self, environ, start_response):
|
|
|
|
|
|
|
|
prefix = environ.get('HTTP_X_FORWARDED_PREFIX', '')
|
|
|
|
|
|
|
|
if prefix:
|
|
|
|
|
|
|
|
environ['SCRIPT_NAME'] = prefix
|
|
|
|
|
|
|
|
return self.app(environ, start_response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.wsgi_app = PrefixMiddleware(app.wsgi_app)
|
|
|
|