diff --git a/core/admin/mailu/__init__.py b/core/admin/mailu/__init__.py index 1c4ded4c..e4024e47 100644 --- a/core/admin/mailu/__init__.py +++ b/core/admin/mailu/__init__.py @@ -70,3 +70,4 @@ def create_app(): """ config = configuration.ConfigManager() return create_app_from_config(config) + diff --git a/core/admin/mailu/sso/templates/form_sso.html b/core/admin/mailu/sso/templates/form_sso.html index 8ab3101f..efcc95a9 100644 --- a/core/admin/mailu/sso/templates/form_sso.html +++ b/core/admin/mailu/sso/templates/form_sso.html @@ -8,4 +8,4 @@ {{ macros.form_fields( fields, label=False, class="btn btn-default", spacing=False) }} {%- endcall %} -{%- endblock %} \ No newline at end of file +{%- endblock %} diff --git a/core/admin/mailu/sso/templates/sidebar_sso.html b/core/admin/mailu/sso/templates/sidebar_sso.html index 1c511aec..b028faa9 100644 --- a/core/admin/mailu/sso/templates/sidebar_sso.html +++ b/core/admin/mailu/sso/templates/sidebar_sso.html @@ -1,7 +1,7 @@ diff --git a/core/admin/mailu/sso/views/base.py b/core/admin/mailu/sso/views/base.py index b9088c03..fbee52a7 100644 --- a/core/admin/mailu/sso/views/base.py +++ b/core/admin/mailu/sso/views/base.py @@ -13,7 +13,7 @@ def login(): form = forms.LoginForm() form.submitAdmin.label.text = form.submitAdmin.label.text + ' Admin' form.submitWebmail.label.text = form.submitWebmail.label.text + ' Webmail' - + fields = [] if str(app.config["ADMIN"]).upper() != "FALSE": fields.append(form.submitAdmin) @@ -36,7 +36,7 @@ def login(): user = models.User.login(username, form.pw.data) if user: flask.session.regenerate() - flask_login.login_user(user) + flask_login.login_user(user) response = flask.redirect(destination) response.set_cookie('rate_limit', utils.limiter.device_cookie(username), max_age=31536000, path=flask.url_for('sso.login')) flask.current_app.logger.info(f'Login succeeded for {username} from {client_ip}.') @@ -46,10 +46,11 @@ def login(): flask.current_app.logger.warn(f'Login failed for {username} from {client_ip}.') flask.flash('Wrong e-mail or password', 'error') return flask.render_template('login.html', form=form, fields=fields) - + @sso.route('/logout', methods=['GET']) @access.authenticated def logout(): flask_login.logout_user() flask.session.destroy() return flask.redirect(flask.url_for('.login')) + diff --git a/core/admin/mailu/utils.py b/core/admin/mailu/utils.py index 56344b8b..e46ad7d9 100644 --- a/core/admin/mailu/utils.py +++ b/core/admin/mailu/utils.py @@ -103,7 +103,7 @@ class PrefixMiddleware(object): self.app = None def __call__(self, environ, start_response): - return self.app(environ, start_response) + return self.app(environ, start_response) def init_app(self, app): self.app = fixers.ProxyFix(app.wsgi_app, x_for=1, x_proto=1) diff --git a/core/nginx/conf/nginx.conf b/core/nginx/conf/nginx.conf index 3879798b..4db963d3 100644 --- a/core/nginx/conf/nginx.conf +++ b/core/nginx/conf/nginx.conf @@ -1,4 +1,4 @@ -# Basic configuration +# Basic configuration user nginx; worker_processes auto; error_log /dev/stderr info; @@ -6,7 +6,7 @@ pid /var/run/nginx.pid; load_module "modules/ngx_mail_module.so"; events { - worker_connections 1024; + worker_connections 1024; } http { @@ -15,7 +15,7 @@ http { default_type application/octet-stream; access_log /dev/stdout; sendfile on; - keepalive_timeout 65; + keepalive_timeout 65; server_tokens off; absolute_redirect off; resolver {{ RESOLVER }} ipv6=off valid=30s; @@ -47,12 +47,12 @@ http { {% if KUBERNETES_INGRESS != 'true' and TLS_FLAVOR in [ 'letsencrypt', 'cert' ] %} # Enable the proxy for certbot if the flavor is letsencrypt and not on kubernetes - # + # server { # Listen over HTTP listen 80; listen [::]:80; - {% if TLS_FLAVOR == 'letsencrypt' %} + {% if TLS_FLAVOR == 'letsencrypt' %} location ^~ /.well-known/acme-challenge/ { proxy_pass http://127.0.0.1:8008; } @@ -80,7 +80,7 @@ http { {% endif %} # Listen on HTTP only in kubernetes or behind reverse proxy - {% if KUBERNETES_INGRESS == 'true' or TLS_FLAVOR in [ 'mail-letsencrypt', 'notls', 'mail' ] %} + {% if KUBERNETES_INGRESS == 'true' or TLS_FLAVOR in [ 'mail-letsencrypt', 'notls', 'mail' ] %} listen 80; listen [::]:80; {% endif %} @@ -153,8 +153,8 @@ http { rewrite ^{{ WEB_WEBMAIL }}/(.*) /$1 break; {% endif %} include /etc/nginx/proxy.conf; - client_max_body_size {{ MESSAGE_SIZE_LIMIT|int + 8388608 }}; - auth_request /internal/auth/user; + client_max_body_size {{ MESSAGE_SIZE_LIMIT|int + 8388608 }}; + auth_request /internal/auth/user; error_page 403 @webmail_login; proxy_pass http://$webmail; } @@ -177,7 +177,7 @@ http { location @webmail_login { return 302 /sso/login; - } + } {% endif %} {% if ADMIN == 'true' %} location {{ WEB_ADMIN }} { @@ -186,7 +186,7 @@ http { expires $expires; } - location {{ WEB_ADMIN }}/antispam { + location {{ WEB_ADMIN }}/antispam { rewrite ^{{ WEB_ADMIN }}/antispam/(.*) /$1 break; auth_request /internal/auth/admin; proxy_set_header X-Real-IP "";