Skip to content

Keep the caller's bearer when routing Graph requests through the proxy - #6

Merged
n1hility merged 1 commit into
mainfrom
keep-placeholder-bearer-through-graph-proxy
Sep 5, 2026
Merged

n1hility merged 1 commit into
mainfrom
keep-placeholder-bearer-through-graph-proxy

Conversation

@n1hility

@n1hility n1hility commented Sep 5, 2026

Copy link
Copy Markdown

Problem

With CLIMICROSOFT365_GRAPH_BASE_URL set, every built-in command (for example m365 outlook message list) rewrites its graph.microsoft.com URL onto the external Graph proxy and, since 6564c4a, deletes the authorization header at the same time. The proxy authenticates its caller with exactly that header, so those commands fail with the proxy's 401, while m365 request --url "$CLIMICROSOFT365_GRAPH_BASE_URL/..." --resource https://graph.microsoft.com keeps working because its URL already targets the proxy and never passes through the rewrite.

The strip assumed a deployment where an intermediary attached the proxy credential on the way out, so the token this process held had to be kept off that path. In the deployment this fork serves, that intermediary no longer exists: CLIMICROSOFT365_ACCESS_TOKEN is the caller's own credential toward the proxy (a governed placeholder substituted in transit, or the proxy's static bearer). The process never holds a Graph token, and the value it holds goes nowhere but the proxy.

Change

  • src/request.ts rewriteGraphUrlForExternalProxy: keep the authorization header on the rewritten request; the comment explains the credential model.
  • src/request.spec.ts: the test that pinned the strip now asserts the rewritten URL and that the header survives.

Requests that are not rewritten (non-Graph resources, or a --url already at the proxy) are unchanged.

Verification

  • mocha dist/request.spec.js: 37 passing.
  • Live check against the proxy: a built-in command that previously returned the proxy's 401 returns Graph data once the header is kept; the request --url form behaves as before.

🤖 Generated with Claude Code

Since 6564c4a, rewriting a graph.microsoft.com URL onto
CLIMICROSOFT365_GRAPH_BASE_URL also deleted the authorization header. The
external Graph proxy authenticates its caller with exactly that header, so
every built-in command failed with the proxy's 401 while
`m365 request --url <proxy>/...` kept working because it never passes
through the rewrite.

The strip assumed an intermediary that attached the proxy credential on
the way out. In the deployment this fork serves there is none:
CLIMICROSOFT365_ACCESS_TOKEN is the caller's own credential toward the
proxy (a governed placeholder substituted in transit, or the proxy's
static bearer). This process never holds a Graph token, and the value it
holds goes nowhere but the proxy. Keep it on the rewritten request; the
spec that pinned the strip now asserts the header survives alongside the
rewritten URL.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@n1hility
n1hility merged commit 6a80fd3 into main Sep 5, 2026
5 checks passed
@n1hility
n1hility deleted the keep-placeholder-bearer-through-graph-proxy branch September 5, 2026 05:53
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