housekeeping(server): fixed clippy warns
Some checks failed
ci/woodpecker/push/server-audit Pipeline was successful
ci/woodpecker/push/server-lint Pipeline was successful
ci/woodpecker/push/server-vet Pipeline failed
ci/woodpecker/push/server-test Pipeline was successful
ci/woodpecker/push/useragent-analyze Pipeline failed
Some checks failed
ci/woodpecker/push/server-audit Pipeline was successful
ci/woodpecker/push/server-lint Pipeline was successful
ci/woodpecker/push/server-vet Pipeline failed
ci/woodpecker/push/server-test Pipeline was successful
ci/woodpecker/push/useragent-analyze Pipeline failed
This commit was merged in pull request #36.
This commit is contained in:
@@ -22,4 +22,4 @@ steps:
|
|||||||
- apt-get update && apt-get install -y pkg-config
|
- apt-get update && apt-get install -y pkg-config
|
||||||
- mise install rust
|
- mise install rust
|
||||||
- mise install protoc
|
- mise install protoc
|
||||||
- mise exec rust -- cargo clippy --all-targets --all-features -- -D warnings
|
- mise exec rust -- cargo clippy --all -- -D warnings
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
use alloy::transports::Transport;
|
|
||||||
use arbiter_proto::transport::Bi;
|
use arbiter_proto::transport::Bi;
|
||||||
use diesel::{ExpressionMethods as _, OptionalExtension as _, QueryDsl, update};
|
use diesel::{ExpressionMethods as _, OptionalExtension as _, QueryDsl, update};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
@@ -8,7 +7,7 @@ use super::Error;
|
|||||||
use crate::{
|
use crate::{
|
||||||
actors::{
|
actors::{
|
||||||
bootstrap::ConsumeToken,
|
bootstrap::ConsumeToken,
|
||||||
user_agent::{AuthPublicKey, OutOfBand, UserAgentConnection, auth::Outbound},
|
user_agent::{AuthPublicKey, UserAgentConnection, auth::Outbound},
|
||||||
},
|
},
|
||||||
db::schema,
|
db::schema,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
use alloy::primitives::Address;
|
|
||||||
use arbiter_proto::transport::{Bi, Sender};
|
|
||||||
use kameo::actor::Spawn as _;
|
|
||||||
use tracing::{error, info};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
actors::{GlobalActors, evm},
|
actors::GlobalActors,
|
||||||
db::{self, models::KeyType},
|
db::{self, models::KeyType},
|
||||||
evm::policies::SharedGrantSettings,
|
|
||||||
evm::policies::{Grant, SpecificGrant},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstraction over Ed25519 / ECDSA-secp256k1 / RSA public keys used during the auth handshake.
|
/// Abstraction over Ed25519 / ECDSA-secp256k1 / RSA public keys used during the auth handshake.
|
||||||
@@ -56,20 +50,20 @@ impl TryFrom<(KeyType, Vec<u8>)> for AuthPublicKey {
|
|||||||
KeyType::Ed25519 => {
|
KeyType::Ed25519 => {
|
||||||
let bytes: [u8; 32] = bytes.try_into().map_err(|_| "invalid Ed25519 key length")?;
|
let bytes: [u8; 32] = bytes.try_into().map_err(|_| "invalid Ed25519 key length")?;
|
||||||
let key = ed25519_dalek::VerifyingKey::from_bytes(&bytes)
|
let key = ed25519_dalek::VerifyingKey::from_bytes(&bytes)
|
||||||
.map_err(|e| "invalid Ed25519 key")?;
|
.map_err(|_e| "invalid Ed25519 key")?;
|
||||||
Ok(AuthPublicKey::Ed25519(key))
|
Ok(AuthPublicKey::Ed25519(key))
|
||||||
}
|
}
|
||||||
KeyType::EcdsaSecp256k1 => {
|
KeyType::EcdsaSecp256k1 => {
|
||||||
let point =
|
let point =
|
||||||
k256::EncodedPoint::from_bytes(&bytes).map_err(|e| "invalid ECDSA key")?;
|
k256::EncodedPoint::from_bytes(&bytes).map_err(|_e| "invalid ECDSA key")?;
|
||||||
let key = k256::ecdsa::VerifyingKey::from_encoded_point(&point)
|
let key = k256::ecdsa::VerifyingKey::from_encoded_point(&point)
|
||||||
.map_err(|e| "invalid ECDSA key")?;
|
.map_err(|_e| "invalid ECDSA key")?;
|
||||||
Ok(AuthPublicKey::EcdsaSecp256k1(key))
|
Ok(AuthPublicKey::EcdsaSecp256k1(key))
|
||||||
}
|
}
|
||||||
KeyType::Rsa => {
|
KeyType::Rsa => {
|
||||||
use rsa::pkcs8::DecodePublicKey as _;
|
use rsa::pkcs8::DecodePublicKey as _;
|
||||||
let key = rsa::RsaPublicKey::from_public_key_der(&bytes)
|
let key = rsa::RsaPublicKey::from_public_key_der(&bytes)
|
||||||
.map_err(|e| "invalid RSA key")?;
|
.map_err(|_e| "invalid RSA key")?;
|
||||||
Ok(AuthPublicKey::Rsa(key))
|
Ok(AuthPublicKey::Rsa(key))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
use std::{borrow::Cow, convert::Infallible};
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use arbiter_proto::transport::Sender;
|
use arbiter_proto::transport::Sender;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use ed25519_dalek::VerifyingKey;
|
use ed25519_dalek::VerifyingKey;
|
||||||
use kameo::{Actor, messages, prelude::Context};
|
use kameo::{Actor, messages};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tokio::{select, sync::watch};
|
use tokio::sync::watch;
|
||||||
use tracing::{error, info};
|
use tracing::error;
|
||||||
|
|
||||||
use crate::actors::{
|
use crate::actors::{
|
||||||
router::RegisterUserAgent,
|
router::RegisterUserAgent,
|
||||||
@@ -36,6 +36,7 @@ impl Error {
|
|||||||
pub struct UserAgentSession {
|
pub struct UserAgentSession {
|
||||||
props: UserAgentConnection,
|
props: UserAgentConnection,
|
||||||
state: UserAgentStateMachine<DummyContext>,
|
state: UserAgentStateMachine<DummyContext>,
|
||||||
|
#[allow(dead_code, reason = "The session keeps ownership of the outbound transport even before the state-machine flow starts using it directly")]
|
||||||
sender: Box<dyn Sender<OutOfBand>>,
|
sender: Box<dyn Sender<OutOfBand>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,13 +83,15 @@ impl UserAgentSession {
|
|||||||
|
|
||||||
#[messages]
|
#[messages]
|
||||||
impl UserAgentSession {
|
impl UserAgentSession {
|
||||||
#[message(ctx)]
|
#[message]
|
||||||
pub async fn request_new_client_approval(
|
pub async fn request_new_client_approval(
|
||||||
&mut self,
|
&mut self,
|
||||||
client_pubkey: VerifyingKey,
|
client_pubkey: VerifyingKey,
|
||||||
mut cancel_flag: watch::Receiver<()>,
|
cancel_flag: watch::Receiver<()>,
|
||||||
ctx: &mut Context<Self, Result<bool, ()>>,
|
|
||||||
) -> Result<bool, ()> {
|
) -> Result<bool, ()> {
|
||||||
|
// temporary use to make clippy happy while we refactor this flow
|
||||||
|
dbg!(client_pubkey);
|
||||||
|
dbg!(cancel_flag);
|
||||||
todo!("Think about refactoring it to state-machine based flow, as we already have one")
|
todo!("Think about refactoring it to state-machine based flow, as we already have one")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,10 @@ use crate::{
|
|||||||
Generate, ListWallets, UseragentCreateGrant, UseragentDeleteGrant, UseragentListGrants,
|
Generate, ListWallets, UseragentCreateGrant, UseragentDeleteGrant, UseragentListGrants,
|
||||||
},
|
},
|
||||||
keyholder::{self, Bootstrap, TryUnseal},
|
keyholder::{self, Bootstrap, TryUnseal},
|
||||||
user_agent::{
|
user_agent::session::{
|
||||||
OutOfBand,
|
|
||||||
session::{
|
|
||||||
UserAgentSession,
|
UserAgentSession,
|
||||||
state::{UnsealContext, UserAgentEvents, UserAgentStates},
|
state::{UnsealContext, UserAgentEvents, UserAgentStates},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
},
|
||||||
safe_cell::SafeCellHandle as _,
|
safe_cell::SafeCellHandle as _,
|
||||||
};
|
};
|
||||||
@@ -139,7 +136,7 @@ impl UserAgentSession {
|
|||||||
self.transition(UserAgentEvents::ReceivedInvalidKey)?;
|
self.transition(UserAgentEvents::ReceivedInvalidKey)?;
|
||||||
return Err(UnsealError::InvalidKey);
|
return Err(UnsealError::InvalidKey);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(_err) => {
|
||||||
return Err(Error::internal("Failed to take unseal secret").into());
|
return Err(Error::internal("Failed to take unseal secret").into());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -263,7 +260,7 @@ impl UserAgentSession {
|
|||||||
Ok(state) => state,
|
Ok(state) => state,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(?err, actor = "useragent", "keyholder.query.failed");
|
error!(?err, actor = "useragent", "keyholder.query.failed");
|
||||||
return Err(Error::internal("Vault is in broken state").into());
|
return Err(Error::internal("Vault is in broken state"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -276,13 +273,13 @@ impl UserAgentSession {
|
|||||||
#[message]
|
#[message]
|
||||||
pub(crate) async fn handle_evm_wallet_create(&mut self) -> Result<Address, Error> {
|
pub(crate) async fn handle_evm_wallet_create(&mut self) -> Result<Address, Error> {
|
||||||
match self.props.actors.evm.ask(Generate {}).await {
|
match self.props.actors.evm.ask(Generate {}).await {
|
||||||
Ok(address) => return Ok(address),
|
Ok(address) => Ok(address),
|
||||||
Err(SendError::HandlerError(err)) => Err(Error::internal(format!(
|
Err(SendError::HandlerError(err)) => Err(Error::internal(format!(
|
||||||
"EVM wallet generation failed: {err}"
|
"EVM wallet generation failed: {err}"
|
||||||
))),
|
))),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(?err, "EVM actor unreachable during wallet create");
|
error!(?err, "EVM actor unreachable during wallet create");
|
||||||
return Err(Error::internal("EVM actor unreachable"));
|
Err(Error::internal("EVM actor unreachable"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ pub async fn start(conn: ClientConnection, mut bi: GrpcBi<ClientRequest, ClientR
|
|||||||
);
|
);
|
||||||
let _ = transport.send(Err(e.clone())).await;
|
let _ = transport.send(Err(e.clone())).await;
|
||||||
warn!(error = ?e, "Authentication failed");
|
warn!(error = ?e, "Authentication failed");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,13 @@ use arbiter_proto::{
|
|||||||
},
|
},
|
||||||
transport::grpc::GrpcBi,
|
transport::grpc::GrpcBi,
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc;
|
|
||||||
use tokio_stream::wrappers::ReceiverStream;
|
use tokio_stream::wrappers::ReceiverStream;
|
||||||
use tonic::{Request, Response, Status, async_trait};
|
use tonic::{Request, Response, Status, async_trait};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
DEFAULT_CHANNEL_SIZE,
|
|
||||||
actors::{client::ClientConnection, user_agent::UserAgentConnection},
|
actors::{client::ClientConnection, user_agent::UserAgentConnection},
|
||||||
grpc::{self, user_agent::start},
|
grpc::user_agent::start,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ pub mod grpc;
|
|||||||
pub mod safe_cell;
|
pub mod safe_cell;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
|
#[allow(dead_code, reason = "Reserved as the shared default channel size while server wiring is still being consolidated")]
|
||||||
const DEFAULT_CHANNEL_SIZE: usize = 1000;
|
const DEFAULT_CHANNEL_SIZE: usize = 1000;
|
||||||
|
|
||||||
pub struct Server {
|
pub struct Server {
|
||||||
|
|||||||
Reference in New Issue
Block a user