Introduce kernel parameters allowing to specify password hashing algorithm and options

Created on 14 June 2025, 20 days ago

Problem/Motivation

The constructor of the PhpPassword hashing class accepts two optional parameters for the algorithm and hashing options. These parameters were chosen to match the PHP password_hash() parameters.

However, the function signature changed a couple of times before and after the original issue went in ( 📌 Replace custom password hashing library with PHP password_hash() Fixed ). Especially the $algo paramater only became nullable with PHP 8.0. For lower versions it had to be specified explicitly. At the time when the original issue went in, it was unpractical to expose the $algorithm constructor parameter as a kernel parameter. Simply because the default is a PHP constant, and that directly encoded the default algorithm as a string.

Since the $algo parameter is nullable nowadays, it is possible to expose the password hashing algorithm as a kernel parameter (null by default). This makes it easier for contrib and custom code to switch it to something else.

Steps to reproduce

Proposed resolution

Modify the constructor of PhpPassword to make the $algorithm parameter nullable, parameter references to the @password@ service definition and add two new kernel parameters:

  password.algorithm: ~
  password.options: []

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

11.0 🔥

Component

base system

Created by

🇨🇭Switzerland znerol

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024