Encryption Key
OCS Inventory Server encrypts sensitive configuration values, such as the LDAP bind password and the OIDC client secret, before storing them in the database. This page explains how that encryption key works and how to change it if needed.
How It Works
The server uses a single encryption key, stored in the server's environment configuration (FIELD_ENCRYPTION_KEY), to encrypt and decrypt these values on the fly:
The LDAP bind password, used to connect to your directory for authentication.
The OIDC client secret, used for single sign-on integration.
Without this key configured, the server can't decrypt these values, LDAP and OIDC logins will fail, and any new sensitive value would be saved unencrypted.
Checking the Current Key
To confirm a key is configured and see how many sensitive values are currently encrypted with it, run this on the server:
python manage.py encryption_key
fingerprint 57c3e6b69c228832
1 secret(s) readable, 0 unreadableThis prints a short fingerprint for the current key, along with how many stored secrets can be successfully read with it. If any secrets can't be decrypted, this command will tell you, that usually means the key was changed without following the rotation steps below.
Backing Up the Key
The key is stored as the FIELD_ENCRYPTION_KEY value in the server's environment file. Back it up the same way you would any other credential.
Changing (Rotating) the Key
You generally shouldn't need to change this key. Only do so if you suspect it has been exposed, or as part of your organization's routine credential rotation policy.
Stop the server. This avoids anyone saving a new LDAP or OIDC configuration while the rotation is in progress.
Generate a new key:
Rotate existing secrets to the new key. This re-encrypts every currently stored secret so it can be read with the new key:
Update your environment file with the new key value, replacing the previous FIELD_ENCRYPTION_KEY.
Restart the server.
Verify that everything decrypts correctly:
This should report all stored secrets as readable. If any aren't, don't discard your old key yet, it may still be needed to recover the affected values.
Troubleshooting
LDAP or OIDC logins suddenly fail after a server change
The encryption key in the environment file doesn't match the one the stored secrets were encrypted with. Restore the correct key from your backup.
Server logs a warning that sensitive values are unencrypted
No FIELD_ENCRYPTION_KEY is configured. Generate one and set it in the environment file, then restart the server.
encryption_key reports secrets as unreadable
The key was changed without rotating existing secrets first. Restore the previous key if you still have it, then follow the rotation steps above properly.
Last updated

