Process code review remarks PR2023

master
Dimitri Huisman 3 years ago
parent 8784971b7f
commit 3449b67c86

@ -1,5 +1,5 @@
from flask import Blueprint from flask import Blueprint
sso = Blueprint('sso', __name__, static_folder='None' ,template_folder='templates') sso = Blueprint('sso', __name__, static_folder=None ,template_folder='templates')
from mailu.sso.views import * from mailu.sso.views import *

@ -1,12 +1,6 @@
from wtforms import validators, fields, widgets from wtforms import validators, fields
from wtforms_components import fields as fields_
from flask_babel import lazy_gettext as _ from flask_babel import lazy_gettext as _
import flask_login
import flask_wtf import flask_wtf
import re
LOCALPART_REGEX = "^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*$"
class LoginForm(flask_wtf.FlaskForm): class LoginForm(flask_wtf.FlaskForm):
class Meta: class Meta:
@ -15,5 +9,3 @@ class LoginForm(flask_wtf.FlaskForm):
pw = fields.PasswordField(_('Password'), [validators.DataRequired()]) pw = fields.PasswordField(_('Password'), [validators.DataRequired()])
submitAdmin = fields.SubmitField(_('Sign in')) submitAdmin = fields.SubmitField(_('Sign in'))
submitWebmail = fields.SubmitField(_('Sign in')) submitWebmail = fields.SubmitField(_('Sign in'))

@ -2,14 +2,6 @@
<nav class="mt-2"> <nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" role="menu"> <ul class="nav nav-pills nav-sidebar flex-column" role="menu">
<li class="nav-header text-uppercase text-primary" role="none">{% trans %}Go to{% endtrans %}</li> <li class="nav-header text-uppercase text-primary" role="none">{% trans %}Go to{% endtrans %}</li>
{%- if config["WEBMAIL"] != "none" %}
<li class="nav-item" role="none">
<a href="{{ config["WEB_WEBMAIL"] }}" target="_blank" class="nav-link" role="menuitem">
<i class="nav-icon far fa-envelope"></i>
<p>{% trans %}Webmail{% endtrans %} <i class="fas fa-external-link-alt text-xs"></i></p>
</a>
</li>
{% endif %}
{% if config['ADMIN'] %} {% if config['ADMIN'] %}
<li class="nav-item"> <li class="nav-item">
<a href="{{ url_for('ui.client') }}" class="nav-link"> <a href="{{ url_for('ui.client') }}" class="nav-link">
@ -24,8 +16,8 @@
<p>{% trans %}Website{% endtrans %} <i class="fas fa-external-link-alt text-xs"></i></p> <p>{% trans %}Website{% endtrans %} <i class="fas fa-external-link-alt text-xs"></i></p>
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item" role="none">
<a href="https://mailu.io" target="_blank" class="nav-link"> <a href="https://mailu.io" target="_blank" class="nav-link" role="menuitem">
<i class="nav-icon fa fa-life-ring"></i> <i class="nav-icon fa fa-life-ring"></i>
<p class="text">{% trans %}Help{% endtrans %}</p> <p class="text">{% trans %}Help{% endtrans %}</p>
</a> </a>
@ -39,8 +31,8 @@
{% if config['DOMAIN_REGISTRATION'] %} {% if config['DOMAIN_REGISTRATION'] %}
{% if not current_user.is_authenticated %} {% if not current_user.is_authenticated %}
{% if config['ADMIN'] %} {% if config['ADMIN'] %}
<li class="nav-item"> <li class="nav-item" role="none">
<a href="{{ url_for('ui.domain_signup') }}" class="nav-link"> <a href="{{ url_for('ui.domain_signup') }}" class="nav-link" role="menuitem">
<i class="nav-icon fa fa-plus-square"></i> <i class="nav-icon fa fa-plus-square"></i>
<p class="text">{% trans %}Register a domain{% endtrans %}</p> <p class="text">{% trans %}Register a domain{% endtrans %}</p>
</a> </a>
@ -57,8 +49,8 @@
{% if not current_user.is_authenticated %} {% if not current_user.is_authenticated %}
{% if signup_domains %} {% if signup_domains %}
{% if config['ADMIN'] %} {% if config['ADMIN'] %}
<li class="nav-item"> <li class="nav-item" role="none">
<a href="{{ url_for('ui.user_signup') }}" class="nav-link"> <a href="{{ url_for('ui.user_signup') }}" class="nav-link" role="menuitem">
<i class="nav-icon fa fa-user-plus"></i> <i class="nav-icon fa fa-user-plus"></i>
<p class="text">{% trans %}Sign up{% endtrans %}</p> <p class="text">{% trans %}Sign up{% endtrans %}</p>
</a> </a>

@ -1,6 +1,4 @@
from mailu.sso import sso, forms from mailu.sso import sso
from mailu.ui import access
import flask import flask
@sso.route('/language/<language>', methods=['POST']) @sso.route('/language/<language>', methods=['POST'])

@ -1,6 +1,6 @@
from flask import Blueprint from flask import Blueprint
ui = Blueprint('ui', __name__, static_folder='None', template_folder='templates') ui = Blueprint('ui', __name__, static_folder=None, template_folder='templates')
from mailu.ui.views import * from mailu.ui.views import *

@ -92,7 +92,7 @@
{%- endif %} {%- endif %}
<li class="nav-header text-uppercase text-primary" role="none">{% trans %}Go to{% endtrans %}</li> <li class="nav-header text-uppercase text-primary" role="none">{% trans %}Go to{% endtrans %}</li>
{%- if config["WEBMAIL"] != "none" %} {%- if config["WEBMAIL"] != "none" and current_user.is_authenticated %}
<li class="nav-item" role="none"> <li class="nav-item" role="none">
<a href="{{ config["WEB_WEBMAIL"] }}" target="_blank" class="nav-link" role="menuitem"> <a href="{{ config["WEB_WEBMAIL"] }}" target="_blank" class="nav-link" role="menuitem">
<i class="nav-icon far fa-envelope"></i> <i class="nav-icon far fa-envelope"></i>
@ -136,8 +136,8 @@
</a> </a>
</li> </li>
{% else %} {% else %}
<li class="nav-item"> <li class="nav-item" role="none">
<a href="{{ url_for('sso.login') }}" class="nav-link"> <a href="{{ url_for('sso.login') }}" class="nav-link" role="menuitem">
<i class="nav-icon fas fa-sign-in-alt"></i> <i class="nav-icon fas fa-sign-in-alt"></i>
<p>{% trans %}Sign in{% endtrans %}</p> <p>{% trans %}Sign in{% endtrans %}</p>
</a> </a>

@ -113,7 +113,7 @@ http {
add_header X-XSS-Protection '1; mode=block'; add_header X-XSS-Protection '1; mode=block';
add_header Referrer-Policy 'same-origin'; add_header Referrer-Policy 'same-origin';
{% if TLS_FLAVOR == 'mail-letsencrypt' %} {% if TLS_FLAVOR == 'mail-letsencrypt' %}
location ^~ /.well-known/acme-challenge/ { location ^~ /.well-known/acme-challenge/ {
proxy_pass http://127.0.0.1:8008; proxy_pass http://127.0.0.1:8008;
} }
@ -175,15 +175,13 @@ http {
proxy_pass http://$webmail; proxy_pass http://$webmail;
} }
location @webmail_login { location @webmail_login {
return 302 /sso/login; return 302 /sso/login;
} }
{% else %}
{% endif %} {% endif %}
{% if ADMIN == 'true' %} {% if ADMIN == 'true' %}
location {{ WEB_ADMIN }} { location {{ WEB_ADMIN }} {
include /etc/nginx/proxy.conf; include /etc/nginx/proxy.conf;
proxy_pass http://$admin; proxy_pass http://$admin;
expires $expires; expires $expires;
} }

@ -54,30 +54,11 @@ Because the admin interface is served as ``/admin``, the Webmail as ``/webmail``
server { server {
# [...] here goes your standard configuration # [...] here goes your standard configuration
location /webmail { location ~ ^/(admin|sso|static|webdav|webmail)/ {
proxy_pass https://localhost:8443/webmail; proxy_pass https://localhost:8443;
}
location /admin {
proxy_pass https://localhost:8443/admin;
proxy_set_header Host $http_host; proxy_set_header Host $http_host;
} }
location /sso {
proxy_pass https://localhost:8443/sso;
proxy_set_header Host $http_host;
}
location /webdav {
proxy_pass https://localhost:8443/webdav;
proxy_set_header Host $http_host;
}
location /static {
proxy_pass https://localhost:8443/static;
proxy_set_header Host $http_host;
}
location /main_app { location /main_app {
proxy_pass https://some-host; proxy_pass https://some-host;
} }

Loading…
Cancel
Save