aboutsummaryrefslogtreecommitdiff
path: root/lockchain-core/src/users/rights.rs
blob: b9ea6cdf7375217b6e9e843452285c4c24cab84f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! Permission and access system for lockchain

use traits::AutoEncoder;

/// Specifies access to a resource
#[derive(Hash, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub enum Access {
    /// A key that is only used to re-encrypt sub-keys
    Root,
    /// Allows access to vault metadata & index files
    Vault(Role),
    /// Allows access to a record resource inside a vault
    Record(Role, String),
}

impl AutoEncoder for Access {}

/// Specifies the capabilities of a user
#[derive(Hash, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub enum Role {
    /// Only has read access
    Reader,
    /// Can edit any field in a record
    Editor,
    /// Can modify base structure, squash and delete records
    Admin,
}

impl AutoEncoder for Role {}