Skip to content

feat(token hook): allow a custom header for the Azure token hook - #64

Merged
0xFustang merged 1 commit into
mainfrom
upd-flexible-token-hook
Aug 31, 2026
Merged

feat(token hook): allow a custom header for the Azure token hook#64
0xFustang merged 1 commit into
mainfrom
upd-flexible-token-hook

Conversation

@0xFustang

Copy link
Copy Markdown
Collaborator

Description

The Azure token hook was hardcoded to send its credential in an X-API-Key header, which does not work with gateways expecting a different header name. This adds support for an arbitrary header name and value while keeping the existing behaviour untouched.

Changes

  • Add get_token_hook_headers() in src/droid/platforms/common.py as the single source of truth for the token hook headers.
  • Support DROID_AZURE_TOKEN_HEADER and DROID_AZURE_TOKEN_HEADER_VALUE to define a custom header.
  • Raise a ValueError when only one of the two variables is set, instead of silently sending no header.
  • Use the shared helper in both sentinel.py and ms_xdr.py, removing the duplicated header logic.

Behaviour

Environment Header sent
Nothing set none
DROID_AZURE_TOKEN_X_API_KEY X-API-Key: <value>
DROID_AZURE_TOKEN_HEADER + DROID_AZURE_TOKEN_HEADER_VALUE <name>: <value>
Custom header + DROID_AZURE_TOKEN_X_API_KEY custom header wins
Only one of the custom header variables ValueError, no request sent

Existing setups relying on DROID_AZURE_TOKEN_X_API_KEY are unaffected.

Tests

  • tests/test_platforms_common.py covers the header resolution logic and the error cases.
  • tests/test_token_hook.py covers the end to end behaviour for both Sentinel and MS XDR, asserting the headers actually passed to requests.get and that no request is made when the configuration is incomplete.

DROID_AZURE_TOKEN_HEADER and DROID_AZURE_TOKEN_HEADER_VALUE define a
custom header to send to the Azure token hook, taking precedence over
the default X-API-Key header sourced from DROID_AZURE_TOKEN_X_API_KEY.
Setting only one of the two raises an error to avoid a confusing 401
from the hook.

The header logic is moved to a shared get_token_hook_headers() function
used by both the Sentinel and Microsoft XDR platforms, and covered by
unit tests.
@0xFustang 0xFustang self-assigned this Aug 31, 2026
@0xFustang
0xFustang merged commit 6cf6f11 into main Aug 31, 2026
2 checks passed
@0xFustang
0xFustang deleted the upd-flexible-token-hook branch August 31, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant