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

Function resolve_identity_from_url

atomic-cli/src/commands/auth.rs:91–110  ·  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

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

Calls 3

match_server_identityFunction · 0.85
extract_subdomainFunction · 0.85
is_emptyMethod · 0.45

Tested by 1