Current implementation does not allow for passing in a bearer token
|
impl Auth { |
|
fn into_auth(self, reference: &Reference) -> anyhow::Result<RegistryAuth> { |
|
match (self.username, self.password) { |
|
(Some(username), Some(password)) => Ok(RegistryAuth::Basic(username, password)), |
|
(None, None) => { |
|
let server_url = Self::get_docker_config_auth_key(reference); |
|
match docker_credential::get_credential(server_url) { |
|
Ok(DockerCredential::UsernamePassword(username, password)) => { |
|
return Ok(RegistryAuth::Basic(username, password)); |
|
} |
|
Ok(DockerCredential::IdentityToken(_)) => { |
|
return Err(anyhow::anyhow!("identity tokens not supported")); |
|
} |
|
Err(err) => { |
|
tracing::debug!( |
|
"Failed to look up OCI credentials with key `{server_url}`: {err}" |
|
); |
|
} |
|
} |
|
Ok(RegistryAuth::Anonymous) |
|
} |
|
_ => Err(anyhow::anyhow!("Must provide both a username and password")), |
|
} |
|
} |
|
|
|
/// Translate the registry into a key for the auth lookup. |
|
fn get_docker_config_auth_key(reference: &Reference) -> &str { |
|
match reference.resolve_registry() { |
|
"index.docker.io" => "https://index.docker.io/v1/", // Default registry uses this key. |
|
other => other, // All other registries are keyed by their domain name without the `https://` prefix or any path suffix. |
|
} |
|
} |
|
} |
And oras config files are not checked:
|
match docker_credential::get_credential(server_url) { |
Current implementation does not allow for passing in a bearer token
wasm-pkg-tools/crates/wkg/src/oci.rs
Lines 35 to 67 in dfa2e17
And
orasconfig files are not checked:wasm-pkg-tools/crates/wkg/src/oci.rs
Line 41 in dfa2e17