feat: session-key auth, auth login/status, and config profiles (#13) - #32
Merged
JacobPEvans-personal merged 6 commits intoJun 23, 2026
Merged
Conversation
- The client now supports `Authorization: Splunk <sessionKey>` alongside Bearer tokens. config_from_env: SPLUNK_TOKEN -> Bearer (unchanged); else SPLUNK_SESSION_KEY -> the Splunk scheme. - `splunk auth login` mints a session key via /services/auth/login (username + password from env or a no-echo prompt, never a flag) and prints it; `auth status` reports the active scheme and target without revealing the secret. - Config-file profiles (stdlib INI): `--profile` / SPLUNK_PROFILE selects a [section] supplying url / token / session_key / app / owner. Precedence is flag > env > profile > default, applied per value. With no config file there is no change -- fully backward compatible. Closes #13
This was referenced Jun 23, 2026
JacobPEvans-personal
added a commit
that referenced
this pull request
Jun 23, 2026
## What
Splunk's REST API accepts two Authorization schemes: `Bearer <JWT>` and
`Splunk <sessionKey>`. The client now supports **both**, picked by env
var:
- `SPLUNK_TOKEN` → `Authorization: Bearer <token>` (default, primary
path — unchanged)
- `SPLUNK_SESSION_KEY` → `Authorization: Splunk <key>`
A session key comes directly from `POST /services/auth/login`, so it
needs no
token-auth enablement and no JWT minting.
## Why
The CI integration job had a long, fragile `mint-token.sh` (enable token
auth →
mint a JWT → parse it, which broke with an opaque `JSONDecodeError`).
That whole
dance is unnecessary: a session key is a single login call. This PR
replaces
`mint-token.sh` with a short `get-session-key.sh` and points the
integration job
at `SPLUNK_SESSION_KEY`.
## Auth posture (intentional)
Username/password is **not** promoted: no `auth login` command is added,
and the
docs keep the JWT/token as the primary path with only a one-clause
mention of
`SPLUNK_SESSION_KEY`. The password only appears inside the CI login
script, which
is internal.
## Scope / safety
- Additive only — the Bearer path and the `{data, meta}` contract are
unchanged.
- The credential still lives only in a request header and is never
logged.
- The integration job stays manual-only (`workflow_dispatch`) and
timeout-capped;
this PR only swaps how it obtains a credential.
## Tests
`tests/unit/test_session_key_auth.py`: with only `SPLUNK_SESSION_KEY`
set, the
client sends `Authorization: Splunk <key>`; the existing Bearer test
still passes.
Gate (via `.venv/bin`): ruff/pyright clean; `73 passed, 1 skipped`.
> Branched off fresh `origin/main`. Note: phase-9 (#32) later adds a
richer
> session-login + profiles layer on top of this same client seam; I'll
reconcile
> it to this when it merges.
…feat/phase-9-auth-profiles # Conflicts: # src/vct_splunk/core/client.py
JacobPEvans-personal
merged commit Jun 23, 2026
41643d6
into
feat/phase-8-health-depth
3 checks passed
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.
Summary
Adds session-key authentication,
authcommands, and config-file profiles —without changing the default token path. Stacked on #31.
What landed
Authorization: Splunk <sessionKey>whenSPLUNK_SESSION_KEYis set;SPLUNK_TOKENstill maps toBearerand takesprecedence. One new
ClientConfig.auth_schemefield; existing behavior isbyte-for-byte unchanged.
splunk auth login— mints a session key via/services/auth/login(username from
--username/$SPLUNK_USERNAME, password from$SPLUNK_PASSWORDor a no-echo prompt — never a flag), prints it, and does not persist the
secret.
splunk auth statusreports the active scheme + target withoutrevealing the secret.
configparserINI ($VCT_SPLUNK_CONFIG, else$XDG_CONFIG_HOME/vct-splunk/config).--profile/$SPLUNK_PROFILEselects a[section]supplyingurl/token/session_key/app/owner.Precedence: flag > env > profile > default, per value. No new dependency.
Backward compatibility
With no config file,
load_profilereturns{}and nothing changes — confirmed bythe unchanged existing client tests. Profiles only fill gaps the flag and env leave.
Testing
ruff,pyright(0 errors),pytest(113 passed, 3 integration skipped) green.New tests: the
Splunkauth header,config_from_envtoken-vs-session precedence,profile-fills-when-env-unset and env-wins-over-profile,
auth loginsession-keyparse (no Authorization header on the login POST), and
auth status.Stacked on #31 — review against the
feat/phase-8-health-depthbase.Closes #13