feat(gateway): add HostPattern::Env for self-hosted connector hosts - #374
Open
nbmorgan wants to merge 1 commit into
Open
feat(gateway): add HostPattern::Env for self-hosted connector hosts#374nbmorgan wants to merge 1 commit into
nbmorgan wants to merge 1 commit into
Conversation
Adds a third HostPattern variant that matches a provider's host against the value of a named environment variable, read at match time. This lets operators configure deployment-specific hostnames for self-hosted services without a binary change. - Case-insensitive match; never matches when the var is unset or empty. - The existing credential_host_field gate still applies on top as a per-connection security layer. - Unit test covers unset/empty/match/case-insensitive/other-host. - Documents the mechanism in docs/self-hosted-connectors.md. The variant carries #[allow(dead_code)] until its first consumer (the AFFiNE connector) lands in a follow-up PR. Closes onecli#354 Co-Authored-By: Claude Opus 4.8 <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.
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Feature (gateway).
What is the current behavior?
The gateway matches incoming requests to providers using a compiled host-pattern table (
HostPattern::Exact/HostPattern::Suffix), both of which require the hostname to be known at build time. There is no supported way to route a self-hosted service whose hostname is deployment-specific (e.g.affine.mycompany.com).Closes #354.
What is the new behavior?
Adds a third variant,
HostPattern::Env(&'static str), that matches a provider's host against the value of a named environment variable, read at match time:credential_host_fieldgate still applies on top as a per-connection security layer, so a token cannot leak to a different host even if the env var is repointed.docs/self-hosted-connectors.md.This satisfies the acceptance criteria in #354.
Additional context
The variant carries
#[allow(dead_code)]because it has no provider consumer in this PR. Its first consumer — the AFFiNE connector (#373) — lands in a follow-up PR stacked on this one, which removes the attribute.Local checks pass:
pnpm check(lint + types + format, includingcargo fmt --checkandcargo clippy -- -D warnings) and the gateway test suite.