feat(user-agent): add VaultGate for sealed vault authentication
This commit is contained in:
@@ -13,6 +13,7 @@ pub mod bootstrap;
|
||||
pub mod evm;
|
||||
pub mod flow_coordinator;
|
||||
pub mod vault;
|
||||
pub mod useragent_registry;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum SpawnError {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
use alloy::primitives::map::HashMap;
|
||||
use arbiter_crypto::authn;
|
||||
use kameo::{error::Infallible, prelude::*};
|
||||
|
||||
use crate::{db::DatabasePool, peers::user_agent::{Credentials, UserAgentSession}};
|
||||
|
||||
use super::vault::{Vault, events as vault_events};
|
||||
|
||||
pub struct Args {
|
||||
pub vault: ActorRef<Vault>,
|
||||
pub pool: DatabasePool,
|
||||
}
|
||||
|
||||
pub struct UserAgentRegistry {
|
||||
vault: ActorRef<Vault>,
|
||||
pool: DatabasePool,
|
||||
connected: HashMap<Credentials, ActorRef<UserAgentSession>>,
|
||||
}
|
||||
|
||||
impl Message<vault_events::Bootstrapped> for UserAgentRegistry {
|
||||
type Reply = ();
|
||||
|
||||
async fn handle(
|
||||
&mut self,
|
||||
msg: vault_events::Bootstrapped,
|
||||
ctx: &mut Context<Self, Self::Reply>,
|
||||
) -> Self::Reply {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Message<vault_events::Unsealed> for UserAgentRegistry {
|
||||
type Reply = ();
|
||||
|
||||
async fn handle(
|
||||
&mut self,
|
||||
msg: vault_events::Unsealed,
|
||||
ctx: &mut Context<Self, Self::Reply>,
|
||||
) -> Self::Reply {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
impl Actor for UserAgentRegistry {
|
||||
type Args = Args;
|
||||
|
||||
type Error = Infallible;
|
||||
|
||||
async fn on_start(args: Self::Args, actor_ref: ActorRef<Self>) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
vault: args.vault,
|
||||
pool: args.pool,
|
||||
connected: HashMap::default(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -25,10 +25,10 @@ use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
||||
pub mod events {
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct VaultBootstrapped;
|
||||
pub struct Bootstrapped;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct VaultUnsealed;
|
||||
pub struct Unsealed;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct VaultResealed;
|
||||
@@ -213,7 +213,7 @@ impl Vault {
|
||||
});
|
||||
|
||||
info!("Vault bootstrapped successfully");
|
||||
self.events.tell(Publish(events::VaultBootstrapped)).await;
|
||||
self.events.tell(Publish(events::Bootstrapped)).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -269,7 +269,7 @@ impl Vault {
|
||||
});
|
||||
|
||||
info!("Vault unsealed successfully");
|
||||
self.events.tell(Publish(events::VaultUnsealed)).await;
|
||||
self.events.tell(Publish(events::Unsealed)).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user