disable alias suffix by setting DISABLE_ALIAS_SUFFIX
This commit is contained in:
parent
70e16bb415
commit
f56ba95b4d
|
@ -29,6 +29,10 @@ EMAIL_SERVERS_WITH_PRIORITY=[(10, "email.hostname.")]
|
||||||
# these emails are ignored when computing stats
|
# these emails are ignored when computing stats
|
||||||
# IGNORED_EMAILS = ["my_email@domain.com"]
|
# IGNORED_EMAILS = ["my_email@domain.com"]
|
||||||
|
|
||||||
|
# By default, new aliases must end with ".{random_word}". This is to avoid a person taking all "nice" aliases.
|
||||||
|
# this option doesn't make sense in self-hosted. Set this variable to disable this option.
|
||||||
|
# DISABLE_ALIAS_SUFFIX=1
|
||||||
|
|
||||||
# the DKIM private key used to compute DKIM-Signature
|
# the DKIM private key used to compute DKIM-Signature
|
||||||
DKIM_PRIVATE_KEY_PATH=local_data/dkim.key
|
DKIM_PRIVATE_KEY_PATH=local_data/dkim.key
|
||||||
|
|
||||||
|
|
|
@ -291,6 +291,7 @@ EMAIL_SERVERS_WITH_PRIORITY=[(10, "app.mydomain.com.")]
|
||||||
DKIM_PRIVATE_KEY_PATH=/dkim.key
|
DKIM_PRIVATE_KEY_PATH=/dkim.key
|
||||||
DKIM_PUBLIC_KEY_PATH=/dkim.pub.key
|
DKIM_PUBLIC_KEY_PATH=/dkim.pub.key
|
||||||
DB_URI=postgresql://myuser:mypassword@sl-db:5432/simplelogin
|
DB_URI=postgresql://myuser:mypassword@sl-db:5432/simplelogin
|
||||||
|
DISABLE_ALIAS_SUFFIX=1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,9 @@ if os.environ.get("IGNORED_EMAILS"):
|
||||||
else:
|
else:
|
||||||
IGNORED_EMAILS = []
|
IGNORED_EMAILS = []
|
||||||
|
|
||||||
|
# disable the alias suffix, i.e. the ".random_word" part
|
||||||
|
DISABLE_ALIAS_SUFFIX = "DISABLE_ALIAS_SUFFIX" in os.environ
|
||||||
|
|
||||||
DKIM_PRIVATE_KEY_PATH = get_abs_path(os.environ["DKIM_PRIVATE_KEY_PATH"])
|
DKIM_PRIVATE_KEY_PATH = get_abs_path(os.environ["DKIM_PRIVATE_KEY_PATH"])
|
||||||
DKIM_PUBLIC_KEY_PATH = get_abs_path(os.environ["DKIM_PUBLIC_KEY_PATH"])
|
DKIM_PUBLIC_KEY_PATH = get_abs_path(os.environ["DKIM_PUBLIC_KEY_PATH"])
|
||||||
DKIM_SELECTOR = b"dkim"
|
DKIM_SELECTOR = b"dkim"
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<div class="col-sm-6 align-self-center" style="height:1.5rem">
|
<div class="col-sm-6 align-self-center" style="height:1.5rem">
|
||||||
<input type="hidden" name="email-suffix" value="{{ email_suffix }}">
|
<input type="hidden" name="email-suffix" value="{{ email_suffix }}">
|
||||||
<h4>
|
<h4>
|
||||||
.{{ email_suffix }}@{{ EMAIL_DOMAIN }}
|
{{ email_suffix }}@{{ EMAIL_DOMAIN }}
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from flask import render_template, redirect, url_for, flash, request, session
|
from flask import render_template, redirect, url_for, flash, request, session
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
|
||||||
from app.config import EMAIL_DOMAIN, HIGHLIGHT_GEN_EMAIL_ID
|
from app.config import EMAIL_DOMAIN, HIGHLIGHT_GEN_EMAIL_ID, DISABLE_ALIAS_SUFFIX
|
||||||
from app.dashboard.base import dashboard_bp
|
from app.dashboard.base import dashboard_bp
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
|
@ -27,18 +27,20 @@ def custom_alias():
|
||||||
email_prefix = convert_to_id(email_prefix)
|
email_prefix = convert_to_id(email_prefix)
|
||||||
email_suffix = request.form.get("email-suffix")
|
email_suffix = request.form.get("email-suffix")
|
||||||
|
|
||||||
# verify email_suffix
|
# verify email_suffix: do not verify when DISABLE_ALIAS_SUFFIX is set
|
||||||
if not word_exist(email_suffix):
|
if not DISABLE_ALIAS_SUFFIX:
|
||||||
flash(
|
# email suffix must be in the format ".{word}"
|
||||||
"nice try :). The suffix is there so no one can take all the *nice* aliases though",
|
if email_suffix[0] != "." or not word_exist(email_suffix[1:]):
|
||||||
"warning",
|
flash(
|
||||||
)
|
"nice try :). The suffix is there so no one can take all the *nice* aliases though",
|
||||||
return redirect(url_for("dashboard.custom_alias"))
|
"warning",
|
||||||
|
)
|
||||||
|
return redirect(url_for("dashboard.custom_alias"))
|
||||||
|
|
||||||
if not email_prefix:
|
if not email_prefix:
|
||||||
error = "alias prefix cannot be empty"
|
error = "alias prefix cannot be empty"
|
||||||
else:
|
else:
|
||||||
full_email = f"{email_prefix}.{email_suffix}@{EMAIL_DOMAIN}"
|
full_email = f"{email_prefix}{email_suffix}@{EMAIL_DOMAIN}"
|
||||||
# check if email already exists
|
# check if email already exists
|
||||||
if GenEmail.get_by(email=full_email) or DeletedAlias.get_by(
|
if GenEmail.get_by(email=full_email) or DeletedAlias.get_by(
|
||||||
email=full_email
|
email=full_email
|
||||||
|
@ -95,7 +97,7 @@ def custom_alias():
|
||||||
session[HIGHLIGHT_GEN_EMAIL_ID] = gen_email.id
|
session[HIGHLIGHT_GEN_EMAIL_ID] = gen_email.id
|
||||||
return redirect(url_for("dashboard.index"))
|
return redirect(url_for("dashboard.index"))
|
||||||
|
|
||||||
email_suffix = random_word()
|
email_suffix = "" if DISABLE_ALIAS_SUFFIX else "." + random_word()
|
||||||
return render_template(
|
return render_template(
|
||||||
"dashboard/custom_alias.html",
|
"dashboard/custom_alias.html",
|
||||||
error=error,
|
error=error,
|
||||||
|
|
Loading…
Reference in New Issue