Skip to content

refactor: Centralize platform credential handling in CredentialConfig#300

Draft
kinyoklion wants to merge 1 commit into
mainfrom
rlamb/sdk-2188/credential-config
Draft

refactor: Centralize platform credential handling in CredentialConfig#300
kinyoklion wants to merge 1 commit into
mainfrom
rlamb/sdk-2188/credential-config

Conversation

@kinyoklion

Copy link
Copy Markdown
Member

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 under user-agent and carries the credential in the authorization header; web sends the user agent under x-launchdarkly-user-agent and carries no authorization header (FDv1 client-side authentication is URL-based, and the events service CORS configuration does not permit the header from browsers). _makeHttpProperties becomes a single addAll.
  • 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.restrictedHeaders no longer blocks authorization — only the browser-forbidden user-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

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