MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / match_server_identity

Function match_server_identity

atomic-remote/src/auth/mod.rs:216–230  ·  view source on GitHub ↗

Pick the identity bound to the configured server whose host is the longest dot-boundary suffix of `remote_host`. When several profiles' hosts match with the same length (e.g. the legacy `[server]` block and a named profile pointing at the same server), the **active** profile wins — the one `default_server` selects, else the legacy block. Longest-suffix still wins over active: a more specific serv

(remote_host: &str, servers: &[ServerBinding])

Source from the content-addressed store, hash-verified

214/// for hosts under both — e.g. `x.staging.atomic.storage` resolves to the
215/// staging identity, not prod.
216fn match_server_identity(remote_host: &str, servers: &[ServerBinding]) -> Option<String> {
217 servers
218 .iter()
219 .filter(|b| host_is_under(remote_host, &b.host))
220 .max_by_key(|b| (b.host.len(), b.active))
221 // An agent bound to this profile is the one that should be signing
222 // repository traffic: that is the whole reason it was created. The
223 // human binding remains the fallback, so a profile with no agent
224 // behaves exactly as before.
225 .map(|b| {
226 b.agent_identity
227 .clone()
228 .unwrap_or_else(|| b.identity.clone())
229 })
230}
231
232/// Whether `remote_host` is the server host itself or a subdomain of it,
233/// matching only on dot boundaries (so `notatomic.storage` does NOT match

Callers 1

Calls 4

host_is_underFunction · 0.85
iterMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected