Skip to content

Commit

Permalink
feat(rust): add TRUST_CONTEXT_ID_UTF8 for type-safety
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjoDeundiak committed Aug 24, 2023
1 parent d743363 commit 540c7d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ use crate::kafka::outlet_controller::KafkaOutletController;
use crate::kafka::portal_worker::KafkaPortalWorker;
use crate::kafka::protocol_aware::OutletInterceptorImpl;
use crate::kafka::{KAFKA_OUTLET_BOOTSTRAP_ADDRESS, KAFKA_OUTLET_INTERCEPTOR_ADDRESS};
use ockam::identity::{SecureChannels, TRUST_CONTEXT_ID};
use ockam::identity::{SecureChannels, TRUST_CONTEXT_ID_UTF8};
use ockam::{Any, Context, Result, Routed, Worker};
use ockam_abac::AbacAccessControl;
use ockam_core::flow_control::{FlowControlId, FlowControlOutgoingAccessControl, FlowControls};
use ockam_core::Address;
use ockam_node::WorkerBuilder;
use std::str::from_utf8;
use std::sync::Arc;

/// This service handles the central component which is responsible for creating connections
Expand Down Expand Up @@ -50,7 +49,7 @@ impl OutletManagerService {
outlet_controller: KafkaOutletController::new(),
incoming_access_control: Arc::new(AbacAccessControl::create(
secure_channels.identities().repository(),
from_utf8(TRUST_CONTEXT_ID).unwrap(),
TRUST_CONTEXT_ID_UTF8,
trust_context_id,
)),
flow_control_id: flow_control_id.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::DefaultAddress;
use minicbor::Decoder;
use ockam::identity::{
DecryptionRequest, DecryptionResponse, EncryptionRequest, EncryptionResponse,
SecureChannelRegistryEntry, SecureChannels, TRUST_CONTEXT_ID,
SecureChannelRegistryEntry, SecureChannels, TRUST_CONTEXT_ID_UTF8,
};
use ockam_abac::AbacAccessControl;
use ockam_core::api::{Request, Response, Status};
Expand All @@ -22,7 +22,6 @@ use ockam_multiaddr::MultiAddr;
use ockam_node::compat::tokio::sync::Mutex;
use ockam_node::compat::tokio::sync::MutexGuard;
use ockam_node::Context;
use std::str::from_utf8;

pub(crate) struct KafkaEncryptedContent {
/// The encrypted content
Expand Down Expand Up @@ -213,7 +212,7 @@ impl<F: ForwarderCreator> KafkaSecureChannelControllerImpl<F> {
) -> KafkaSecureChannelControllerImpl<F> {
let access_control = AbacAccessControl::create(
secure_channels.identities().repository(),
from_utf8(TRUST_CONTEXT_ID).unwrap(),
TRUST_CONTEXT_ID_UTF8,
&trust_context_id,
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::time::Duration;
use minicbor::Decoder;
use tracing::trace;
use super::super::models::{Attributes, CredentialAndPurposeKey, Identifier, SchemaId};
use super::super::utils::AttributesBuilder;
use super::super::{Credentials, IdentitiesRepository, IdentitySecureChannelLocalInfo};

use ockam_core::api::{Method, Request, Response};
use ockam_core::compat::boxed::Box;
Expand All @@ -11,14 +11,17 @@ use ockam_core::compat::vec::Vec;
use ockam_core::{api, Result, Route, Routed, Worker};
use ockam_node::{Context, RpcClient};

use super::super::models::{Attributes, CredentialAndPurposeKey, Identifier, SchemaId};
use super::super::utils::AttributesBuilder;
use super::super::{Credentials, IdentitiesRepository, IdentitySecureChannelLocalInfo};
use core::time::Duration;
use minicbor::Decoder;
use tracing::trace;

/// Name of the attribute identifying the trust context for that attribute, meaning
/// from which set of trusted authorities the attribute comes from
pub const TRUST_CONTEXT_ID: &[u8] = b"trust_context_id";

/// The same as above but in string format
pub const TRUST_CONTEXT_ID_UTF8: &str = "trust_context_id";

/// Identifier for the schema of a project credential
pub const PROJECT_MEMBER_SCHEMA: SchemaId = SchemaId(1);

Expand Down

0 comments on commit 540c7d8

Please sign in to comment.