mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-20 23:41:20 +00:00
Set minimum password length
This commit is contained in:
parent
06dd33fb55
commit
38e081df04
7 changed files with 21 additions and 17 deletions
|
@ -20,14 +20,9 @@ load_dotenv(".env")
|
|||
|
||||
app = Flask(__name__)
|
||||
|
||||
app.config["SECURITY_EMAIL_VALIDATOR_ARGS"] = {
|
||||
"check_deliverability": parse_bool(environ["CHECK_EMAIL_DELIVERABILITY"])
|
||||
}
|
||||
|
||||
set_from_env(app, "SERVER_NAME")
|
||||
|
||||
set_from_env(app, "SECRET_KEY")
|
||||
set_from_env(app, "SECURITY_PASSWORD_SALT")
|
||||
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///../{environ['RELATIVE_DB_DIR']}/advlab.db"
|
||||
makedirs(environ["RELATIVE_DB_DIR"], exist_ok=True)
|
||||
|
@ -67,6 +62,12 @@ from . import models
|
|||
user_datastore = SQLAlchemyUserDatastore(db, models.User, models.Role)
|
||||
Security(app, user_datastore)
|
||||
|
||||
app.config["SECURITY_EMAIL_VALIDATOR_ARGS"] = {
|
||||
"check_deliverability": parse_bool(environ["CHECK_EMAIL_DELIVERABILITY"])
|
||||
}
|
||||
set_from_env(app, "SECURITY_PASSWORD_SALT")
|
||||
app.config["SECURITY_PASSWORD_LENGTH_MIN"] = 15
|
||||
|
||||
try:
|
||||
from . import routes, adminModelViews, assistantModelViews
|
||||
except Exception as ex:
|
||||
|
|
|
@ -31,7 +31,7 @@ from wtforms.validators import URL, DataRequired, Email, NumberRange, Optional
|
|||
from wtforms.widgets import NumberInput
|
||||
|
||||
from . import adminSpace, app, assistantSpace, db, user_datastore
|
||||
from .advlabdb_independent_funs import flashRandomPassword, randomPassword
|
||||
from .advlabdb_independent_funs import flashRandomPassword
|
||||
from .configUtils import getConfig
|
||||
from .customClasses import (
|
||||
CustomIdEndpointLinkRowAction,
|
||||
|
@ -46,6 +46,7 @@ from .model_dependent_funs import (
|
|||
setUserActiveSemester,
|
||||
sortedSemestersStartingWithNewest,
|
||||
)
|
||||
from .model_independent_funs import randomPassword
|
||||
from .models import (
|
||||
MAX_MARK,
|
||||
MAX_YEAR,
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
# Functions not dependent on advlabdb
|
||||
|
||||
from random import choice
|
||||
from string import ascii_letters, digits
|
||||
|
||||
from flask import flash
|
||||
|
||||
|
||||
def randomPassword():
|
||||
return "".join(choice(ascii_letters + digits) for i in range(15))
|
||||
|
||||
|
||||
def flashRandomPassword(password):
|
||||
flash(f"Random password: {password}", category="warning")
|
||||
|
||||
|
|
|
@ -8,10 +8,11 @@ from wtforms.fields import DateField
|
|||
from wtforms.validators import NumberRange, Optional
|
||||
|
||||
from . import assistantSpace, db
|
||||
from .advlabdb_independent_funs import flashRandomPassword, randomPassword
|
||||
from .advlabdb_independent_funs import flashRandomPassword
|
||||
from .customClasses import SecureAssistantBaseView, SecureAssistantModelView
|
||||
from .exceptions import DataBaseException, ModelViewException
|
||||
from .model_dependent_funs import initActiveSemesterMenuLinks
|
||||
from .model_independent_funs import randomPassword
|
||||
from .models import (
|
||||
MAX_MARK,
|
||||
MIN_MARK,
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
# Functions not dependent on advlabdb.models
|
||||
|
||||
from random import choice
|
||||
from string import ascii_letters, digits
|
||||
|
||||
from sqlalchemy import func, select
|
||||
|
||||
from . import db
|
||||
from . import app, db
|
||||
|
||||
|
||||
def randomPassword():
|
||||
password_length = app.config["SECURITY_PASSWORD_LENGTH_MIN"]
|
||||
return "".join(choice(ascii_letters + digits) for i in range(password_length))
|
||||
|
||||
|
||||
def reportBadAttempt(message):
|
||||
|
|
|
@ -2,7 +2,7 @@ from flask_security import admin_change_password
|
|||
from sqlalchemy import select
|
||||
|
||||
from ... import app, db
|
||||
from ...advlabdb_independent_funs import randomPassword
|
||||
from ...model_independent_funs import randomPassword
|
||||
from ...models import Admin, User
|
||||
from ..terminal_utils import box, spaced_hl, validating_input
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ from email_validator import validate_email
|
|||
from flask_security import hash_password
|
||||
|
||||
from ... import app, db, user_datastore
|
||||
from ...advlabdb_independent_funs import randomPassword
|
||||
from ...model_independent_funs import randomPassword
|
||||
from ...models import MAX_YEAR, MIN_YEAR, Admin, Semester
|
||||
from ..terminal_utils import box, confirm, validating_input
|
||||
|
||||
|
|
Loading…
Reference in a new issue