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

Function resolve_identity_from_url

atomic-cli/src/commands/auth.rs:98–117  ·  view source on GitHub ↗

Pure identity resolution from a URL plus the configured server bindings. userinfo → server-host match (longest suffix) → first-label subdomain. Split from the config-loading wrapper so it can be unit-tested without a config file on disk.

(remote_url: &str, servers: &[(String, String)])

Source from the content-addressed store, hash-verified

96/// Split from the config-loading wrapper so it can be unit-tested without a
97/// config file on disk.
98fn resolve_identity_from_url(remote_url: &str, servers: &[(String, String)]) -> Option<String> {
99 let url = Url::parse(remote_url).ok()?;
100
101 // 1. Explicit in the URL: http://bob@host/...
102 let username = url.username();
103 if !username.is_empty() {
104 return Some(username.to_string());
105 }
106
107 let host = url.host_str()?;
108
109 // 2. Configured server binding: identity follows the server (apex), so any
110 // tenant under it resolves to the same identity.
111 if let Some(identity) = match_server_identity(host, servers) {
112 return Some(identity);
113 }
114
115 // 3. Legacy: treat the first DNS label as the identity name.
116 extract_subdomain(host)
117}
118
119/// Pick the identity bound to the configured server whose host is the longest
120/// dot-boundary suffix of `remote_host`.

Calls 4

parseFunction · 0.85
match_server_identityFunction · 0.85
extract_subdomainFunction · 0.85
is_emptyMethod · 0.45

Tested by 1