cockpit icon indicating copy to clipboard operation
cockpit copied to clipboard

How to use the password field?

Open julianschmuckli opened this issue 3 years ago • 1 comments

Hello everyone,

I'm a bit confused about the password field type:

Documentation

There is actually no where documented, how we can use this field. If I use the password field in a collection, the password will be shown hashed:

Hashed password in the overview page

And in the JSON, there is no password to compare actually, which makes somehow sense.

JSON result

So how do we have to use this field or what is the purpose of it?

julianschmuckli avatar Jul 03 '21 17:07 julianschmuckli

Cockpit uses password_hash($string, $algorithm) to save any values in a password field as a hash and later you can use password_verify($string, $savedHash) in order to verify, that a specific value matches the saved hash.

You can see this in action in the auth module https://github.com/agentejo/cockpit/blob/568b0124352f6d27df359e8c19a70d2dd1961e87/modules/Cockpit/module/auth.php#L35

abernh avatar Sep 10 '21 23:09 abernh