Skip to content

refactor(auth): adopt @arc-mcp/xsuaa-auth, retire in-tree httpAuth - #1

Open
marianfoo wants to merge 1 commit into
consetto:mainfrom
marianfoo:feat/adopt-arc-mcp-xsuaa-auth
Open

refactor(auth): adopt @arc-mcp/xsuaa-auth, retire in-tree httpAuth#1
marianfoo wants to merge 1 commit into
consetto:mainfrom
marianfoo:feat/adopt-arc-mcp-xsuaa-auth

Conversation

@marianfoo

Copy link
Copy Markdown

What

Replaces calmcp's hand-rolled HTTP auth (src/httpAuth/) with the published
@arc-mcp/xsuaa-auth
package — the auth layer extracted from arc-1, of which calmcp's httpAuth/
was a near-verbatim fork.

Why

  • One maintained source of truth for the XSUAA OAuth proxy + stateless DCR +
    the +-in-state callback fix + chained verifier, instead of a drifting
    in-tree copy.
  • Gains the package's broader redirect-uri allowlist — now covers Copilot
    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's setupHttpAuth facade;
    thin pino → structural-logger adapter.
  • src/index.ts: build AuthOptions; guard loadXsuaaCredentials (the package
    throws 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 Viewer scope and
    passes requiredScopes when XSUAA is also bound.
  • Delete src/httpAuth/ (5 files). Net −1306 LOC.
  • tests/unit/httpAuth.test.ts: the auth-primitive unit tests now live in the
    package; kept + adapted the createHttpApp transport-wiring tests.

Verification

  • npm run build ✓, npm run lint ✓, the createHttpApp auth transport tests 8/8 ✓.
  • Behavior preserved: /health open; /mcp 401 without/with a bad token; OAuth
    discovery served (XSUAA) / absent (api-key only); valid API key → 200.
  • The pre-existing 15 outbound-layer test failures (the undici MockAgent
    test infra in auth/calmClients/httpClient/tools) are present on main
    too and are untouched by this change.

🤖 Generated with Claude Code

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>
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