Class PasswordHash
admin.createUser("orders-service", PasswordHash.sha256(secret), "monitoring");
The format is base64(salt + digest(salt + utf8(password))) with a random four-byte
salt — what rabbit_password_hashing_sha256 and rabbit_password_hashing_sha512
compute, and what password_hash in a user or in a definitions file holds. Computed
here, the password never leaves this process: the broker is sent the hash and the name of the
algorithm and can verify a login against it, but cannot recover the password from it.
The management API also has GET /api/auth/hash_password/{password}, which this
class deliberately does not call. It puts the password in a URL path, which is the one part
of a request that access logs, proxies and browser histories all record.
toString() does not print the hash. A hash is not the password, and it is still
enough to stand up a broker the password works against.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanhash()inthashCode()booleanstatic PasswordHashA hash computed elsewhere — read from a secrets store, or out of a definitions export.static PasswordHashstatic PasswordHashtoString()
-
Field Details
-
SHA256
RabbitMQ's default since 3.6.- See Also:
-
SHA512
Accepted by every broker that acceptsSHA256.- See Also:
-
-
Method Details
-
sha256
- Parameters:
password- the password to hash, which is not kept- Returns:
- its salted SHA-256 hash, with a fresh salt
-
sha512
- Parameters:
password- the password to hash, which is not kept- Returns:
- its salted SHA-512 hash, with a fresh salt
-
of
A hash computed elsewhere — read from a secrets store, or out of a definitions export. -
matches
- Parameters:
password- a candidate- Returns:
- whether the broker would accept it for this hash
-
hash
- Returns:
- the base64 value sent as
password_hash
-
algorithm
- Returns:
- the value sent as
hashing_algorithm
-
equals
-
hashCode
public int hashCode() -
toString
-