Merge branch '175-password-hashing-configuration' into 'main'

password-hashing-configuration

Closes #175

See merge request yaal/canaille!210
This commit is contained in:
Éloi Rivard 2025-01-08 09:25:06 +00:00
commit c8f8e9fd06
3 changed files with 18 additions and 1 deletions

View file

@ -4,6 +4,11 @@
Added
^^^^^
- ``--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
^^^^^^^

View file

@ -15,3 +15,10 @@ class SQLSettings(BaseModel):
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)
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(
TZDateTime(timezone=True), nullable=True