Password Policy not checked with REST interface /user/register?_format=json

Created on 25 October 2018, over 5 years ago
Updated 7 April 2024, 3 months ago

Hi
I configured the following policy

character_types: Minimum password character types: 2	
password_policy_character_constraint:	Password must contain 1 special characters	
password_policy_character_constraint:	Password must contain 1 numeric characters	
password_length:	Password character length of at least 8	
password_username:	Password must not contain the user's username.	

It is working if I create the account through Registration web form
However, I tested REST API /user/register and I found that the policy is not checked when the user is created via JSON
--> I was able to create the account with a password not compliant with the rules.

Here the example of request and response

**** REQUEST ****
POST /user/register?_format=json HTTP/1.1
Host: localhost:8080
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 1ecde1a9-d5d6-ac09-4f3c-a22534e27874

{
	"name":{
		"value":"test"
	},
	"mail":{
		"value":"test@mail.com"
	},
	"pass":{
		"value":"test"
	}
}

**** RESPONSE ****

{"uid":[{"value":17}],"uuid":[{"value":"617edc4b-6680-40ef-ad9f-7240cba08705"}],"langcode":[{"value":"en"}],"name":[{"value":"test"}],"created":[{"value":"2018-10-25T11:28:31+00:00","format":"Y-m-d\\TH:i:sP"}],"changed":[{"value":"2018-10-25T11:28:31+00:00","format":"Y-m-d\\TH:i:sP"}],"default_langcode":[{"value":true}],"field_last_password_reset":[{"value":"2018-10-25T13:28:34"}],"field_password_expiration":[{"value":false}]}

🐛 Bug report
Status

Postponed: needs info

Version

4.0

Component

Code

Created by

🇮🇹Italy axel80

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024