Skip to main content

Credentials

Trait Credentials 

Source
pub trait Credentials: Send + Sync {
    // Required methods
    fn get(&self, key: &str) -> Option<String>;
    fn set(&self, key: &str, value: &str) -> Result<(), String>;
    fn clear(&self, key: &str);
}
Expand description

Where an addon keeps its own credentials (ADR-0013, FR-046).

§Why there is no addon parameter

Because there used to be, and it was a hole. nobble-core’s SecretStore reads fn get(&self, addon: &str, key: &str), and every addon was handed the same live handle to it — so any addon could read any other addon’s credentials by passing a different string. get("spotify", "refresh_token") from inside an unrelated addon returned the token.

That could not be fixed by narrowing the trait while addons shared an address space: a handle to the store is the capability, and asking a third party not to use one they hold is not a control. It is fixed by taking the namespace out of the caller’s hands entirely. An addon says which key it wants and never which addon it is; whoever hands out the handle decides that, and in the daemon it is bound to the addon the handle was made for.

The result is a type in which the old mistake cannot be written down. ADR-0016.

Required Methods§

Source

fn get(&self, key: &str) -> Option<String>

Read one of this addon’s credentials.

Source

fn set(&self, key: &str, value: &str) -> Result<(), String>

Store one.

§Errors

If the platform store refused it.

Source

fn clear(&self, key: &str)

Forget one. Absent is the outcome, so forgetting nothing is success.

Implementors§