Repository navigation
fix: make provider requests overridable - #485
Merged
Merged
Conversation
Route every request of the REST providers through a protected fetch() method, so that subclasses can add headers such as Authorization. The documented auth examples overrode fetch(), which the providers never called. Also fix the authentication examples in the providers docs and add WES provider tests.
Contributor
Reviewer's GuideThis PR restores the documented authentication pattern by routing all REST provider requests through an overridable protected fetch method, preserving default behavior and multipart uploads. Documentation now demonstrates usable authentication/custom-header implementations, and WES tests verify complete hook coverage and request semantics. Sequence diagram for overridable authenticated provider requestssequenceDiagram
participant App
participant Provider as RestWesProviderSubclass
participant FetchHook as fetch
participant Network as API
App->>Provider: getServiceInfo()
Provider->>FetchHook: fetch(input, init)
FetchHook->>FetchHook: Add current Authorization header
FetchHook->>Network: global fetch(input, init)
Network-->>FetchHook: Response
FetchHook-->>Provider: Response
Provider-->>App: ServiceInfo
Flow diagram for preserving WES multipart uploadsflowchart LR
A["runWorkflow()"] --> B[Create FormData]
B --> C["Overridden fetch(input, init)"]
C --> D[Add authentication headers]
D --> E[global fetch]
E --> F[Browser sets multipart Content-Type]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
|
anuragxxd
marked this pull request as ready for review
October 27, 2026 13:13
Contributor
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="apps/documentation/pages/docs/providers.mdx" line_range="153-154" />
<code_context>
- });
+ fetch(input, init = {}) {
+ const headers = new Headers(init.headers);
+ headers.set('X-API-Key', this.apiKey);
+ return super.fetch(input, { ...init, headers });
}
}
</code_context>
<issue_to_address>
**API keys leak through redirects**
When an authenticated endpoint responds with a redirect to an attacker-controlled cross-origin URL, the browser follows the redirect and forwards custom headers such as `X-API-Key` to the destination, which lets that host capture credentials and impersonate the caller.
For requests carrying credentials, prevent automatic cross-origin redirects or ensure credential headers are removed before following them.
Also at `packages/ecc-client-elixir-cloud-registry/src/providers/rest-cr-provider.ts:24`, `packages/ecc-client-elixir-drs-filer/src/providers/rest-drs-filer-provider.ts:24`, `packages/ecc-client-elixir-trs-filer/src/providers/rest-trs-filer-provider.ts:28`, `packages/ecc-client-ga4gh-drs/src/providers/rest-drs-provider.ts:17`, `packages/ecc-client-ga4gh-service-registry/src/providers/rest-sr-provider.ts:22`, `packages/ecc-client-ga4gh-trs/src/providers/rest-trs-provider.ts:25`, `packages/ecc-client-ga4gh-wes/src/providers/rest-wes-provider.ts:29`.
</issue_to_address>
### Comment 2
<location path="apps/documentation/pages/docs/providers.mdx" line_range="136" />
<code_context>
### Authentication Patterns
+Components don't handle authentication; your app does. Every REST provider sends all of its requests through a `fetch(input, init)` method. Override it in a subclass to add headers such as `Authorization`, so you can use any auth flow (OAuth/OIDC, API keys, ...). You can also implement the provider interface yourself.
+
+<Callout type='warning'>
</code_context>
<issue_to_address>
**TES requests lose authentication headers**
When a consumer applies the documented authentication guidance to TES requests, `fetchService`, `fetchTasks`, and `tesGet` call global `fetch` instead of the documented provider override, so TES requests omit the added headers and protected endpoints return authorization failures rather than data.
Route TES API calls through the overridable provider `fetch` method.
</issue_to_address>
### Comment 3
<location path="packages/ecc-client-ga4gh-wes/src/providers/rest-wes-provider.ts" line_range="114" />
<code_context>
const encodedObjectId = encodeURIComponent(objectId);
const encodedAccessId = encodeURIComponent(accessId);
- const response = await fetch(
+ const response = await this.fetch(
`${this.baseUrl}/objects/${encodedObjectId}/access/${encodedAccessId}`
);
</code_context>
<issue_to_address>
**URL-backed WES logs omit auth**
When a WES run log contains an HTTP(S) stdout or stderr URL that requires the same authentication as the WES API, `getRunLog` retrieves the log metadata through the override, but `ECCClientGa4ghWesRun.fetchLogUrlToCache` then uses global `fetch` for URL-valued stdout/stderr without the override’s headers, so protected logs fail to load in the component.
Route URL-backed log retrieval through an authenticated request path supplied by the provider, or otherwise provide the component with the credentials needed for that request.
</issue_to_address>Sourcery assessment
Approval pending. 3 findings to address first.
Blocking findings: apps/documentation/pages/docs/providers.mdx:154, apps/documentation/pages/docs/providers.mdx:136, packages/ecc-client-ga4gh-wes/src/providers/rest-wes-provider.ts:114
This was referenced Oct 27, 2026
Closed
This was referenced Oct 28, 2026
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.
Description
The REST providers called the global
fetch()directly, so the authentication examples in the docs (subclass the provider and overridefetch()) had no effect: requests went out without the added headers, and without an error.Rest*Providerclasses now send every request through aprotected fetch(input, init)method, which calls the globalfetch()by default. Subclasses can override it to add headers such asAuthorization.RestWesProvider.baseUrlis nowprotectedinstead ofprivate, like the publicbaseUrlof the other providers.docs/providers.mdx. The old examples relied on the missingfetch(), used a wrapper class nothing called, fetched the token only once, forcedContent-Type: application/json(which would break the WES multipart upload) and passed a function as a header value. The per-package "Custom Providers" examples now work as written and are unchanged.rest-wes-provider.test.tschecks that all 6 WES methods go through an overriddenfetch(), that requests without an override carry no headers, and that the workflow upload stays multipart. Adds thetestscript to@elixir-cloud/wes.This makes authenticated requests possible for the v2 packages without per-component token properties. Part of #442; TES still needs #443.
How it was verified
npm run lint: 0 errors, no new warnings.npm run build, including the docs site.npm test: 3/3 in Chromium, Firefox and WebKit. With one WES call switched back to the globalfetch(), the override test fails.Checklist
Comments
Tests cover WES only; the other providers got the same mechanical change.
Summary by Sourcery
Make REST provider requests overridable so applications can add authentication and other request customization without changing provider behavior by default.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: