Skip to content

Commit

Permalink
Add Splunk token support for rest-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
lowell80 committed Oct 10, 2023
1 parent 380a6d2 commit 0341c62
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/source/changelog.rst
Expand Up @@ -23,6 +23,13 @@ Renames:
- ``ksconf/commands/__init__.py`` -> ``ksconf/command.py``


Ksconf v0.13.2 (2023-10-10)
~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Add ``--token`` to allow bearer authentication for rest-publish.




Ksconf v0.13.1 (2023-10-05)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 2 additions & 0 deletions ksconf/command.py
Expand Up @@ -527,6 +527,8 @@ def add_splunkd_access_args(parser: ArgumentParser) -> ArgumentParser:
parser.add_argument("--session-key", default=None,
help="Use an existing session token instead of using a "
"username and password to login.")
parser.add_argument("--token", default=None,
help="Use a Splunk token (bearer token)")
return parser


Expand Down
7 changes: 6 additions & 1 deletion ksconf/commands/restpublish.py
Expand Up @@ -113,7 +113,12 @@ def make_boolean(stanza: ConfType, attr: str = "disabled"):
def connect_splunkd(self, args: Namespace):
up = urlparse(args.url)
# Take username/password form URL, if encoded there; otherwise use defaults from argparse
if args.session_key:
if args.token:
auth_args = {
"splunkToken": args.token
}
login_fail_info = f"splunkToken={args.token[:10]}..."
elif args.session_key:
auth_args = {
"token": args.session_key
}
Expand Down

0 comments on commit 0341c62

Please sign in to comment.