Repository navigation
Keep the caller's bearer when routing Graph requests through the proxy - #6
Merged
Merged
Conversation
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>
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.
Problem
With
CLIMICROSOFT365_GRAPH_BASE_URLset, every built-in command (for examplem365 outlook message list) rewrites itsgraph.microsoft.comURL onto the external Graph proxy and, since 6564c4a, deletes theauthorizationheader at the same time. The proxy authenticates its caller with exactly that header, so those commands fail with the proxy's 401, whilem365 request --url "$CLIMICROSOFT365_GRAPH_BASE_URL/..." --resource https://graph.microsoft.comkeeps 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_TOKENis 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.tsrewriteGraphUrlForExternalProxy: keep theauthorizationheader 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
--urlalready at the proxy) are unchanged.Verification
mocha dist/request.spec.js: 37 passing.request --urlform behaves as before.🤖 Generated with Claude Code