tape: impl access permissions for encryption key config

This commit is contained in:
Dietmar Maurer 2021-03-03 12:21:55 +01:00
parent 8cd63df0dc
commit ccdf327ac8

View File

@ -7,12 +7,17 @@ use proxmox::{
ApiMethod, ApiMethod,
Router, Router,
RpcEnvironment, RpcEnvironment,
Permission,
}, },
tools::fs::open_file_locked, tools::fs::open_file_locked,
}; };
use crate::{ use crate::{
config::{ config::{
acl::{
PRIV_TAPE_AUDIT,
PRIV_TAPE_MODIFY,
},
tape_encryption_keys::{ tape_encryption_keys::{
TAPE_KEYS_LOCKFILE, TAPE_KEYS_LOCKFILE,
load_keys, load_keys,
@ -44,6 +49,9 @@ use crate::{
type: Array, type: Array,
items: { type: KeyInfo }, items: { type: KeyInfo },
}, },
access: {
permission: &Permission::Privilege(&["tape", "pool"], PRIV_TAPE_AUDIT, false),
},
)] )]
/// List existing keys /// List existing keys
pub fn list_keys( pub fn list_keys(
@ -93,6 +101,9 @@ pub fn list_keys(
}, },
}, },
}, },
access: {
permission: &Permission::Privilege(&["tape", "pool"], PRIV_TAPE_MODIFY, false),
},
)] )]
/// Change the encryption key's password (and password hint). /// Change the encryption key's password (and password hint).
pub fn change_passphrase( pub fn change_passphrase(
@ -161,6 +172,9 @@ pub fn change_passphrase(
returns: { returns: {
schema: TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA, schema: TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
}, },
access: {
permission: &Permission::Privilege(&["tape", "pool"], PRIV_TAPE_MODIFY, false),
},
)] )]
/// Create a new encryption key /// Create a new encryption key
pub fn create_key( pub fn create_key(
@ -198,6 +212,9 @@ pub fn create_key(
returns: { returns: {
type: KeyInfo, type: KeyInfo,
}, },
access: {
permission: &Permission::Privilege(&["tape", "pool"], PRIV_TAPE_AUDIT, false),
},
)] )]
/// Get key config (public key part) /// Get key config (public key part)
pub fn read_key( pub fn read_key(
@ -232,6 +249,9 @@ pub fn read_key(
}, },
}, },
}, },
access: {
permission: &Permission::Privilege(&["tape", "pool"], PRIV_TAPE_MODIFY, false),
},
)] )]
/// Remove a encryption key from the database /// Remove a encryption key from the database
/// ///