Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Removing sensitive data from connection configuration (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagojez authored May 6, 2024
1 parent 9641d87 commit 6e029ab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "integrationos-domain"
description = "Shared library for IntegrationOS"
license = "GPL-3.0"
version = "3.1.0"
version = "3.1.1"
edition = "2021"
repository = "https://github.com/integration-os/integrationos-domain"

Expand Down
37 changes: 33 additions & 4 deletions src/domain/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ pub mod connection_model_schema;
pub mod connection_oauth_definition;
pub mod db_model_config;

use std::{hash::Hash, sync::Arc};

use crate::id::Id;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::{hash::Hash, sync::Arc};
use strum::{AsRefStr, Display, EnumString};

use crate::id::Id;

use self::{
connection_model_definition::ConnectionModelDefinition,
connection_oauth_definition::ConnectionOAuthDefinition, db_model_config::DbModelConfig,
Expand Down Expand Up @@ -52,6 +51,36 @@ pub struct Connection {
pub record_metadata: RecordMetadata,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SanitizedConnection {
#[serde(rename = "_id")]
pub id: Id,
pub platform_version: String,
pub connection_definition_id: Id,
pub r#type: ConnectionType,
pub name: String,
pub key: Arc<str>,
pub group: String,
pub environment: Environment,
pub platform: Arc<str>,
pub secrets_service_id: String,
pub event_access_id: Id,
pub settings: Settings,
pub throughput: Throughput,
pub ownership: Ownership,
#[serde(default)]
pub oauth: Option<OAuth>,
#[serde(flatten, default)]
pub record_metadata: RecordMetadata,
}

impl SanitizedConnection {
pub fn to_value(&self) -> Value {
serde_json::to_value(self).unwrap_or(Value::Null)
}
}

impl Hash for Connection {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.id.hash(state);
Expand Down

0 comments on commit 6e029ab

Please sign in to comment.