kafka-security-manager
kafka-security-manager copied to clipboard
Exec source
Mentioned in #126: An additional ACL source of truth that calls some executable on the system and uses the CSV or YAML from the stdout. This can be useful for a user that wants to use a source type that is not implemented in the other source types and does not want to implement it in Scala and have to rebuild the security manager. The executable can be written in any language (Python, Perl, Ruby, etc), as long as it can be called from a command shell.
Hypothetical use cases:
- User wants to use a table in a database (MySQL, Postgres, etc)
- User wants to use an Elasticsearch index
- User wants to use a directory of CSV/YAML files (as opposed to a single file)
- User wants to use multiple source types
The user would be responsible for creating the executable to generate the CSV/YAML as needed.
Use:
-
SOURCE_EXEC_CMD
: Full path to the executable -
SOURCE_EXEC_ARGS
: Arguments passed to the executable, they will be split by the below separator value. Defaults to '' -
SOURCE_EXEC_ARGS_SEP
: String separator to split the argument value. Defaults to ','. For example, setting the args to 'a,b,c,d' and the separator to ',' will pass in the args [a, b, c, d] to the executable -
SOURCE_EXEC_PARSER
: 'yaml' or 'csv', defaults to 'yaml'
Example:
- SOURCE_EXEC_CMD=/usr/sbin/myscript.py
- SOURCE_EXEC_ARGS=--dburi;postgres://postgres:[email protected]:5432/dummy
- SOURCE_EXEC_ARGS_SEP=';'
- SOURCE_EXEC_PARSER=csv
- Results in the security manager calling '/usr/sbin/myscript.py --dburi postgres://postgres:[email protected]:5432/dummy' and parsing the csv from the stdout on every refresh
Notes:
- Assumes SOURCE_EXEC_CMD exists - probably best idea to use a full path to ensure the security manager sees it
- The source will return None on a non-zero exit status
- The test cases I wrote assume a UNIX-like environment (calls /bin/cat and /bin/false)
- The user will need to keep in mind the potential performance impacts - the executable will be called every single refresh. Perhaps set a larger value for the refresh frequency if this is a concern.
- The security of the executable is the responsibility of the user :)
Please note - I am new to Scala and this is also my first contribution to open-source software. I am open to any and all feedback (even criticism - preferably constructive :) )