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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use std::fmt::Debug;
use futures_util::io::{AsyncRead, AsyncWrite};
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use fluvio_controlplane_metadata::extended::ObjectType;
use fluvio_socket::InnerFlvSocket;
use super::AuthError;
#[derive(Debug, Clone, PartialEq, Hash, Eq, Deserialize, Serialize)]
pub enum TypeAction {
Create,
Read,
}
pub enum InstanceAction {
Delete,
}
#[async_trait]
pub trait AuthContext {
async fn allow_type_action(
&self,
ty: ObjectType,
action: TypeAction,
) -> Result<bool, AuthError>;
async fn allow_instance_action(
&self,
ty: ObjectType,
action: InstanceAction,
key: &str,
) -> Result<bool, AuthError>;
}
#[async_trait]
pub trait Authorization {
type Stream: AsyncRead + AsyncWrite + Unpin + Send;
type Context: AuthContext;
async fn create_auth_context(
&self,
socket: &mut InnerFlvSocket<Self::Stream>,
) -> Result<Self::Context, AuthError>;
}