Files
greptimedb/common_base/secrets/index.html
2025-12-22 06:16:12 +00:00

27 lines
7.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="`SecretBox` wrapper type for more carefully handling secret values (e.g. passwords, cryptographic keys, access tokens or other credentials)"><title>common_base::secrets - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-e56847b5.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="common_base" data-themes="" data-resource-suffix="" data-rustdoc-version="1.92.0-nightly (fa3155a64 2025-09-30)" data-channel="nightly" data-search-js="search-e256b49e.js" data-stringdex-js="stringdex-828709d0.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-ce535bd0.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module secrets</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../common_base/index.html">common_<wbr>base</a><span class="version">1.0.0-beta.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module secrets</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#goals" title="Goals">Goals</a></li><li><a href="#serde-support" title="`serde` support"><code>serde</code> support</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate common_<wbr>base</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">common_base</a></div><h1>Module <span>secrets</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/common_base/secrets.rs.html#3-234">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><a href="struct.SecretBox.html" title="struct common_base::secrets::SecretBox"><code>SecretBox</code></a> wrapper type for more carefully handling secret values
(e.g. passwords, cryptographic keys, access tokens or other credentials)</p>
<h2 id="goals"><a class="doc-anchor" href="#goals">§</a>Goals</h2>
<ul>
<li>Make secret access explicit and easy-to-audit via the
<a href="trait.ExposeSecret.html" title="trait common_base::secrets::ExposeSecret"><code>ExposeSecret</code></a> and <a href="trait.ExposeSecretMut.html" title="trait common_base::secrets::ExposeSecretMut"><code>ExposeSecretMut</code></a> traits.</li>
<li>Prevent accidental leakage of secrets via channels like debug logging</li>
<li>Ensure secrets are wiped from memory on drop securely
(using the [<code>zeroize</code>] crate)</li>
</ul>
<p>Presently this crate favors a simple, <code>no_std</code>-friendly, safe i.e.
<code>forbid(unsafe_code)</code>-based implementation and does not provide more advanced
memory protection mechanisms e.g. ones based on <code>mlock(2)</code>/<code>mprotect(2)</code>.
We may explore more advanced protection mechanisms in the future.
Those who dont mind <code>std</code> and <code>libc</code> dependencies should consider using
the <a href="https://crates.io/crates/secrets"><code>secrets</code></a> crate.</p>
<h2 id="serde-support"><a class="doc-anchor" href="#serde-support">§</a><code>serde</code> support</h2>
<p>When the <code>serde</code> feature of this crate is enabled, the <a href="struct.SecretBox.html" title="struct common_base::secrets::SecretBox"><code>SecretBox</code></a> type will
receive a <a href="https://docs.rs/serde_core/1.0.228/serde_core/de/trait.Deserialize.html" title="trait serde_core::de::Deserialize"><code>Deserialize</code></a> impl for all <code>SecretBox&lt;T&gt;</code> types where
<code>T: DeserializeOwned</code>. This allows <em>loading</em> secret values from data
deserialized from <code>serde</code> (be careful to clean up any intermediate secrets
when doing this, e.g. the unparsed input!)</p>
<p>To prevent exfiltration of secret values via <code>serde</code>, by default <code>SecretBox&lt;T&gt;</code>
does <em>not</em> receive a corresponding <a href="https://docs.rs/serde_core/1.0.228/serde_core/ser/trait.Serialize.html" title="trait serde_core::ser::Serialize"><code>Serialize</code></a> impl. If you would like
types of <code>SecretBox&lt;T&gt;</code> to be serializable with <code>serde</code>, you will need to impl
the <a href="trait.SerializableSecret.html" title="trait common_base::secrets::SerializableSecret"><code>SerializableSecret</code></a> marker trait on <code>T</code></p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.SecretBox.html" title="struct common_base::secrets::SecretBox">Secret<wbr>Box</a></dt><dd>Wrapper type for values that contains secrets.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.ExposeSecret.html" title="trait common_base::secrets::ExposeSecret">Expose<wbr>Secret</a></dt><dd>Expose a reference to an inner secret</dd><dt><a class="trait" href="trait.ExposeSecretMut.html" title="trait common_base::secrets::ExposeSecretMut">Expose<wbr>Secret<wbr>Mut</a></dt><dd>Expose a mutable reference to an inner secret</dd><dt><a class="trait" href="trait.SerializableSecret.html" title="trait common_base::secrets::SerializableSecret">Serializable<wbr>Secret</a></dt><dd>Marker trait for secret types which can be <a href="https://docs.rs/serde_core/1.0.228/serde_core/ser/trait.Serialize.html" title="trait serde_core::ser::Serialize"><code>Serialize</code></a>-d by <a href="https://docs.rs/serde/1.0.228/serde/index.html" title="mod serde"><code>serde</code></a>.</dd></dl><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><dl class="item-table"><dt><a class="type" href="type.SecretString.html" title="type common_base::secrets::SecretString">Secret<wbr>String</a></dt><dd>Wrapper type for strings that contains secrets. See also <a href="struct.SecretBox.html" title="struct common_base::secrets::SecretBox">SecretBox</a>.</dd></dl></section></div></main></body></html>