forked from NationTech/harmony
		
	feat: add tenant credential management (#63)
Adds the foundation for managing tenant credentials, including: - `TenantCredentialScore` for scoring credential-related operations. - `TenantCredentialManager` trait for creating users. - `CredentialMetadata` struct to store credential information. - `CredentialData` enum to hold credential content. - `TenantCredentialBundle` struct to encapsulate metadata and content. This provides a starting point for implementing credential creation, storage, and retrieval within the harmony system. Reviewed-on: https://git.nationtech.io/NationTech/harmony/pulls/63 Co-authored-by: Jean-Gabriel Gill-Couture <jg@nationtech.io> Co-committed-by: Jean-Gabriel Gill-Couture <jg@nationtech.io>
This commit is contained in:
		
							parent
							
								
									246d6718c3
								
							
						
					
					
						commit
						7bebc58615
					
				
							
								
								
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @ -1422,6 +1422,7 @@ name = "harmony" | |||||||
| version = "0.1.0" | version = "0.1.0" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "async-trait", |  "async-trait", | ||||||
|  |  "chrono", | ||||||
|  "cidr", |  "cidr", | ||||||
|  "convert_case", |  "convert_case", | ||||||
|  "derive-new", |  "derive-new", | ||||||
|  | |||||||
| @ -36,6 +36,7 @@ serde-value = "0.7.0" | |||||||
| http = "1.2.0" | http = "1.2.0" | ||||||
| inquire = "0.7.5" | inquire = "0.7.5" | ||||||
| convert_case =  "0.8.0" | convert_case =  "0.8.0" | ||||||
|  | chrono = "0.4" | ||||||
| 
 | 
 | ||||||
| [workspace.dependencies.uuid] | [workspace.dependencies.uuid] | ||||||
| version = "1.11.0" | version = "1.11.0" | ||||||
|  | |||||||
| @ -42,6 +42,7 @@ dockerfile_builder = "0.1.5" | |||||||
| temp-file = "0.1.9" | temp-file = "0.1.9" | ||||||
| convert_case.workspace = true | convert_case.workspace = true | ||||||
| email_address = "0.2.9" | email_address = "0.2.9" | ||||||
|  | chrono.workspace = true | ||||||
| fqdn = { version = "0.4.6", features = [ | fqdn = { version = "0.4.6", features = [ | ||||||
|     "domain-label-cannot-start-or-end-with-hyphen", |     "domain-label-cannot-start-or-end-with-hyphen", | ||||||
|     "domain-label-length-limited-to-63", |     "domain-label-length-limited-to-63", | ||||||
|  | |||||||
							
								
								
									
										50
									
								
								harmony/src/modules/tenant/credentials.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								harmony/src/modules/tenant/credentials.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,50 @@ | |||||||
|  | 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 { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #[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 {} | ||||||
| @ -1,3 +1,6 @@ | |||||||
|  | mod credentials; | ||||||
|  | pub use credentials::*; | ||||||
|  | 
 | ||||||
| use async_trait::async_trait; | use async_trait::async_trait; | ||||||
| use serde::Serialize; | use serde::Serialize; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user