refactor: Centralize platform credential handling in CredentialConfig#300
Draft
kinyoklion wants to merge 1 commit into
Draft
refactor: Centralize platform credential handling in CredentialConfig#300kinyoklion wants to merge 1 commit into
kinyoklion wants to merge 1 commit into
Conversation
Platform credential variance now lives in the per-platform CredentialConfig, the same way the per-platform path templates absorb endpoint differences: base headers (user-agent naming and whether the credential rides along), authentication query parameters for transports that cannot carry custom headers, and the environment ID fallback for connections without response headers. The client header setup and the streaming data source consume the helpers instead of switching on the credential type inline. Behavior is unchanged on every platform; the query parameter and environment ID helpers gain their FDv2 consumers in a later change.
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 this changes
Platform credential variance moves into the per-platform
CredentialConfig, the same way the per-platform path templates already absorb endpoint differences. The consumers lose their inline credential-type switches:baseHeaders(credential, userAgent)— io sends the user agent underuser-agentand carries the credential in theauthorizationheader; web sends the user agent underx-launchdarkly-user-agentand carries no authorization header (FDv1 client-side authentication is URL-based, and the events service CORS configuration does not permit the header from browsers)._makeHttpPropertiesbecomes a singleaddAll.environmentIdFallback(credential)— a client-side ID identifies the environment directly, so it serves as the environment ID when a connection exposes no response headers; a mobile key does not. The FDv1 streaming data source consumes this instead of checking the credential type inline.authQueryParameters(credential)— authentication for transports that cannot carry custom headers (the browser's native EventSource):auth=<credential>on web, empty on io. No consumer yet; the FDv2 streaming sources (a later PR) use it, since the FDv2 endpoint paths do not embed the credential the way the FDv1 client-side paths do.The web
NetworkConfig.restrictedHeadersno longer blocksauthorization— only the browser-forbiddenuser-agent. The data acquisition services allow the header cross-origin and header authentication is preferred where the transport supports custom headers; nothing on web sends it yet. The comment records why it must stay out of the web base headers (events CORS).Behavior is unchanged on every platform: io requests carry the same headers as before, web requests carry the same headers as before, and the environment ID fallback produces the same values.
Testing
Covered by the existing suite — the header construction and the streaming environment ID fallback paths are exercised by the current client and data source tests, which pass unchanged.
SDK-2188