refactor(auth): adopt @arc-mcp/xsuaa-auth, retire in-tree httpAuth - #1
Open
marianfoo wants to merge 1 commit into
Open
refactor(auth): adopt @arc-mcp/xsuaa-auth, retire in-tree httpAuth#1marianfoo wants to merge 1 commit into
marianfoo wants to merge 1 commit into
Conversation
Replace calmcp's hand-rolled HTTP auth (src/httpAuth/: stateless DCR client store, OAuth-state codec, XSUAA OAuth proxy + token verifier, API-key verifier, #214 callback proxy) with the published @arc-mcp/xsuaa-auth package — the same auth layer extracted from arc-1, of which calmcp's httpAuth was a near-verbatim fork. - package.json: + @arc-mcp/xsuaa-auth ^0.1.3; drop @sap/xssec + @sap/xsenv (now transitive via the package / unused — zero references outside the deleted dir). - transport/http.ts: wire auth through the package's setupHttpAuth facade (HttpAppOptions.auth is now the package AuthOptions); thin pino -> structural Logger adapter (message,data <- obj,msg). - index.ts: guard loadXsuaaCredentials (the package throws when no xsuaa binding is present) so an unbound app stays API-key-only / open instead of crashing; thread the knobs that preserve calmcp's behavior — clientIdPrefix 'calmcp-', dcrKdfLabel 'calmcp-dcr/v1', stateKdfLabel 'calmcp-oauth-state/v1' (existing DCR client_ids + state tokens stay valid), scopesSupported + requiredScopes ['Viewer'], resourceName, dcrSigningSecret (CALM_DCR_SIGNING_SECRET || clientsecret). The API key now carries the Viewer scope so it passes requiredScopes when XSUAA is also bound. - tests: the auth-primitive unit tests (codec / DCR store / redirect-uri / verifiers) now live in the package; keep + adapt the createHttpApp transport-wiring tests (XSUAA 401 + discovery, API-key 401/200, open-mode no-discovery). Behavior-preserving; net -1306 LOC. The package's default redirect-uri patterns are a superset of calmcp's (additionally cover Copilot Studio's azure-apim and Mistral). build + lint + the httpAuth transport tests are green. The 15 pre-existing outbound-layer test failures (undici MockAgent infra in auth/calmClients/httpClient/tools tests) are unrelated and untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
What
Replaces calmcp's hand-rolled HTTP auth (
src/httpAuth/) with the published@arc-mcp/xsuaa-authpackage — the auth layer extracted from arc-1, of which calmcp's
httpAuth/was a near-verbatim fork.
Why
the
+-in-state callback fix + chained verifier, instead of a driftingin-tree copy.
Studio (
global.consent.azure-apim.net) and Mistral out of the box.Changes
package.json: +@arc-mcp/xsuaa-auth@^0.1.3; drop@sap/xssec+@sap/xsenv(now transitive / unused — no references outside the deleted dir).
src/transport/http.ts: wire auth via the package'ssetupHttpAuthfacade;thin pino → structural-logger adapter.
src/index.ts: buildAuthOptions; guardloadXsuaaCredentials(the packagethrows when no xsuaa binding is present, so an unbound app stays API-key-only
/ open). Behavior-preserving knobs:
clientIdPrefix:'calmcp-',dcrKdfLabel:'calmcp-dcr/v1',stateKdfLabel:'calmcp-oauth-state/v1'(existing DCR client_ids stay valid),
scopesSupported+requiredScopes:['Viewer'],resourceName,dcrSigningSecret(CALM_DCR_SIGNING_SECRET || clientsecret).The API key is passed in entry form so it carries the
Viewerscope andpasses
requiredScopeswhen XSUAA is also bound.src/httpAuth/(5 files). Net −1306 LOC.tests/unit/httpAuth.test.ts: the auth-primitive unit tests now live in thepackage; kept + adapted the
createHttpApptransport-wiring tests.Verification
npm run build✓,npm run lint✓, thecreateHttpAppauth transport tests 8/8 ✓./healthopen;/mcp401 without/with a bad token; OAuthdiscovery served (XSUAA) / absent (api-key only); valid API key → 200.
undiciMockAgenttest infra in
auth/calmClients/httpClient/tools) are present onmaintoo and are untouched by this change.
🤖 Generated with Claude Code