First step in a direction to better orchestrate the core flow, even though it feels weird to move this logic into the `Score`. We'll refactor this as soon as we have a better solution. Co-authored-by: Ian Letourneau <letourneau.ian@gmail.com> Reviewed-on: #100
51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
use async_trait::async_trait;
|
|
use chrono::{DateTime, Utc};
|
|
use serde::Serialize;
|
|
|
|
use crate::{interpret::InterpretError, score::Score, topology::Topology};
|
|
|
|
/// Create and manage Tenant Credentials.
|
|
///
|
|
/// This is meant to be used by cluster administrators who need to provide their tenant users and
|
|
/// services with credentials to access their resources.
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct TenantCredentialScore;
|
|
|
|
impl<T: Topology + TenantCredentialManager> Score<T> for TenantCredentialScore {
|
|
fn create_interpret(&self) -> Box<dyn crate::interpret::Interpret<T>> {
|
|
todo!()
|
|
}
|
|
|
|
fn name(&self) -> String {
|
|
"TenantCredentialScore".into()
|
|
}
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait TenantCredentialManager {
|
|
async fn create_user(&self) -> Result<TenantCredentialBundle, InterpretError>;
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct CredentialMetadata {
|
|
pub tenant_id: String,
|
|
pub credential_id: String,
|
|
pub description: String,
|
|
pub created_at: DateTime<Utc>,
|
|
pub expires_at: Option<DateTime<Utc>>,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum CredentialData {
|
|
/// Used to store login instructions destined to a human. Akin to AWS login instructions email
|
|
/// upon new console user creation.
|
|
PlainText(String),
|
|
}
|
|
|
|
pub struct TenantCredentialBundle {
|
|
_metadata: CredentialMetadata,
|
|
_content: CredentialData,
|
|
}
|
|
|
|
impl TenantCredentialBundle {}
|