password-hashing-configuration

This commit is contained in:
sebastien yaal 2025-01-08 09:25:06 +00:00 committed by Éloi Rivard
parent 74449fc53d
commit de541fc8ca
3 changed files with 18 additions and 1 deletions

View file

@ -4,6 +4,11 @@
Added Added
^^^^^ ^^^^^
- ``--version`` option to the CLI. :pr:`209` - ``--version`` option to the CLI. :pr:`209`
- :attr:`~canaille.backends.sql.configuration.SQLSettings.PASSWORD_SCHEMES` :issue:`175`
Changed
^^^^^^^
- fixed a bug on updating user's settings :issue:`206`
Changed Changed
^^^^^^^ ^^^^^^^

View file

@ -15,3 +15,10 @@ class SQLSettings(BaseModel):
DATABASE_URI = "postgresql://user:password@localhost/database_name" DATABASE_URI = "postgresql://user:password@localhost/database_name"
""" """
PASSWORD_SCHEMES: str = "pbkdf2_sha512"
"""Password hashing scheme.
Defines password hashing scheme in SQL database.
examples : "mssql2000", "ldap_salted_sha1", "pbkdf2_sha512"
"""

View file

@ -74,7 +74,12 @@ class User(canaille.core.models.User, Base, SqlAlchemyModel):
) )
user_name: Mapped[str] = mapped_column(String, unique=True, nullable=False) user_name: Mapped[str] = mapped_column(String, unique=True, nullable=False)
password: Mapped[str] = mapped_column( password: Mapped[str] = mapped_column(
PasswordType(schemes=["pbkdf2_sha512"]), nullable=True PasswordType(
onload=lambda **kwargs: dict(
schemes=current_app.config["CANAILLE_SQL"]["PASSWORD_SCHEMES"], **kwargs
),
),
nullable=True,
) )
password_last_update: Mapped[datetime.datetime] = mapped_column( password_last_update: Mapped[datetime.datetime] = mapped_column(
TZDateTime(timezone=True), nullable=True TZDateTime(timezone=True), nullable=True