keyring_core/sample/mod.rs
1/*!
2
3# Sample Credential Store
4
5This sample store is provided for two purposes:
6
7- It provides a cross-platform way to test your client code during development.
8 (To help with this, all of its internal structures are public.)
9- It provides a template for developers who want to write credential stores.
10 (The tests as well as the source structure can be adapted.)
11
12This store is explicitly *not* for use in production apps! It's neither robust
13nor secure.
14
15# Persistence
16
17When creating an instance of this store, you specify whether you want the contents
18of the store to persist between runs (by default, they don't). There are two
19ways to specify this:
20
21- You can specify the `persist` modifier as `true`. In this case, the store will
22 be persisted in a file called `keyring-sample-store.ron` in the native platform
23 shared temporary directory.
24
25- You can specify the `backing-file` modifier with a path to a file. In this case,
26 the store will be persisted in the specified file. (If you specify the `backing-file`
27 modifier, the `persist` modifier is ignored.)
28
29_Buyer beware!_ A store's backing file is _not_ kept up to date as credentials are created,
30deleted, or modified in the store!
31The in-memory credentials are only saved to the backing file when
32explicitly requested or when a store is destroyed (that is, the last reference
33to it is released).
34The credential state saved in a backing file (if it exists from a prior run)
35is only loaded when a store using that file is first created.
36
37# Ambiguity
38
39This store supports ambiguity, that is, the ability to create
40multiple credentials associated with the same service name
41and username. If you specify the `force-create` modifier when
42creating an entry, a new credential with an empty password
43will be created immediately for the specified service name and username.
44
45* If there was _not_ an existing credential for your service name
46 and username, then the newly created credential will be the
47 only one, so the returned entry will not be ambiguous.
48* If there _was_ an existing credential for your service name and username,
49 then the returned entry will be ambiguous.
50
51In all cases, the use of the `force-create` modifier will cause
52the created credential to have two additional attributes:
53
54* *creation-date*, an HTTP-style date showing when the
55 credential was created. This cannot be updated, nor
56 can it be added to credentials that don't have it.
57* *comment*, the string value of the `target` modifier.
58 This can be updated, and it can be added to credentials
59 that don't have it.
60
61# Attributes
62
63Credentials in this store, in addition to the attributes
64described in the section on Ambiguity above, have
65a single read-only attribute `uuid` which is the
66unique ID of the credential in the store.
67
68# Search
69
70This store implements credential search. Specs can specify
71desired regular expressions for the `service` and `user` a
72credential is attached to, and for the `comment` and `uuid` attributes
73of the credential itself. (All other key/value pairs in the spec
74are ignored.) Credentials are returned only if _all_ the
75specified regular expressions match against its values.
76
77Note: Search is implemented by iterating over every credential
78in the store. This is an in-memory store, so it happens
79pretty quickly.
80
81 */
82
83pub mod credential;
84pub use credential::CredKey;
85
86pub mod store;
87pub use store::Store;
88
89#[cfg(test)]
90mod test;