linuxfabrik.lfops.tomcat_pbkdf2 (filter)¶
Hash a password for Tomcat's SecretKeyCredentialHandler
Synopsis¶
- Returns the stored form that Apache Tomcat's
org.apache.catalina.realm.SecretKeyCredentialHandlerexpects intomcat-users.xml, which is<hex salt>$<iterations>$<hex key>. - The key is derived with PBKDF2-HMAC-SHA512 from the UTF-8 encoded password. The handler therefore has to be configured with
algorithm="PBKDF2WithHmacSHA512". - Tomcat reads the salt, the iteration count and the key length from the stored value, so the corresponding handler attributes only matter for hashes that Tomcat creates itself.
- The salt is taken as given, so the result is deterministic and the template that uses it stays idempotent. Pass a salt that differs per host and user.
Available since LFOps 10.0.0.
Mandatory Parameters¶
_input
- The password in clear text.
- Type: String.
salt
- The salt as a hexadecimal string, for example 32 hex digits for 16 bytes.
- Type: String.
Optional Parameters¶
iterations
- The number of PBKDF2 iterations.
- Type: Number.
- Default:
210000
key_length
- The length of the derived key in bits. Must be a multiple of 8.
- Type: Number.
- Default:
512
Examples¶
- name: 'Hash the password of a Tomcat user'
ansible.builtin.debug:
# a salt of 16 bytes (32 hex digits) that is stable per host and user, so re-runs render the same file
msg: '{{ "linuxfabrik" | linuxfabrik.lfops.tomcat_pbkdf2(salt=((inventory_hostname ~ ":tomcat-admin") | hash("sha256"))[:32]) }}'
Return Values¶
_value
- The stored credential,
<hex salt>$<iterations>$<hex key>. - Type: String.