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

Function resolve_identity_from_url

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

Pure identity resolution from a URL plus the configured server bindings. userinfo → server-host match (longest suffix, active wins ties) → 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: &[ServerBinding])

Source from the content-addressed store, hash-verified

183/// subdomain. Split from the config-loading wrapper so it can be unit-tested
184/// without a config file on disk.
185fn resolve_identity_from_url(remote_url: &str, servers: &[ServerBinding]) -> Option<String> {
186 let url = Url::parse(remote_url).ok()?;
187
188 // 1. Explicit in the URL: http://bob@host/...
189 let username = url.username();
190 if !username.is_empty() {
191 return Some(username.to_string());
192 }
193
194 let host = url.host_str()?;
195
196 // 2. Configured server binding: identity follows the server (apex), so any
197 // tenant under it resolves to the same identity.
198 if let Some(identity) = match_server_identity(host, servers) {
199 return Some(identity);
200 }
201
202 // 3. Legacy: treat the first DNS label as the identity name.
203 extract_subdomain(host)
204}
205
206/// Pick the identity bound to the configured server whose host is the longest
207/// dot-boundary suffix of `remote_host`. When several profiles' hosts match

Calls 5

match_server_identityFunction · 0.85
extract_subdomainFunction · 0.85
parseFunction · 0.50
okMethod · 0.45
is_emptyMethod · 0.45

Tested by 1