Add XUSER authentication for MaxDB (closes #2)#33
Open
Simon0Harms wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add XUSER authentication for MaxDB (closes #2)
Summary
Adds the option to authenticate against the MaxDB via an XUSER key
(
dbmcli -U <key>) instead of a username/password pair. When an XUSER key isconfigured, no plaintext credentials are written to
maxdb.cfg, which resolvesthe concern raised in issue #2.
The change is fully backward compatible: existing configurations that use
user/passwordcontinue to work unchanged. XUSER is opt-in and, when set,takes precedence.
Motivation
Previously the agent plugin built the connection as
dbmcli -d <db> -u <user>,<password>, and the bakery wrote bothuserandpasswordin clear text into${MK_CONFDIR}/maxdb.cfg. On production hosts aplaintext DB password in an agent config file is undesirable. MaxDB's native
XUSER mechanism stores the credentials in the OS user's protected XUSER store,
so the agent only needs to reference a key name.
Changes
share/check_mk/agents/plugins/maxdb.py): ifxuser_keyis present in a section, the command becomes
dbmcli -U <key>; otherwise theclassic
-d <db> -u <user,password>is used. The key is validated against^[A-Za-z0-9_.-]+$before use to avoid injecting unexpected arguments.lib/check_mk/base/cee/plugins/bakery/maxdb.py): emitsxuser_key=intomaxdb.cfgwhen configured, otherwiseuser=/password=as before. Reads credentials from the new nested
authdict, with a fallbackto the flat layout for older rule data.
share/check_mk/web/plugins/wato/agent_bakery_maxdb.py):replaces the fixed username/password fields with an
Alternativevaluespecoffering either "XUSER key (no plaintext password)" or "User and password
(clear text in maxdb.cfg)".
Configuration example (
maxdb.cfg)XUSER (new):
User/password (unchanged, still supported):
The XUSER key must be created beforehand for the OS user that runs the Checkmk
agent, e.g.:
Testing
python3 -m py_compilepasses for the agent and bakery modules; the WATOfile parses via
ast.parse(it imports cmk GUI modules only available insidea site, so it cannot be byte-compiled standalone).
dbmcliargument list and thatan invalid key (containing spaces/
;) is rejected before execution.Notes for maintainer
.mkpas usual.user/passwordbranch could later be marked deprecated inthe WATO help text once XUSER adoption is confirmed.