Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ldk-node-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ jobs:
cd vss-server
RUSTFLAGS="--cfg noop_authorizer" cargo build --no-default-features
./target/debug/vss-server server/vss-server-config.toml&
- name: Pin packages to allow for MSRV
- name: Pin ldk-node packages to allow for MSRV
if: "matrix.toolchain == '1.85.0'"
env:
# Use MSRV-aware resolver for ldk-node
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: fallback
run: |
cd ldk-node
cargo update -p idna_adapter --precise "1.2.0" --verbose # idna_adapter 1.2.1 uses ICU4X 2.2.0, requiring 1.86 and newer
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[workspace]
resolver = "2"
resolver = "3"
members = ["server", "api", "impls", "auth-impls"]
default-members = ["server"]

[workspace.package]
version = "0.1.0-alpha.0"
rust-version = "1.85.0"
edition = "2021"
edition = "2024"
authors = ["Leo Nash <hello@leonash.net>", "Elias Rohrer <dev@tnull.de>"]
license = "MIT OR Apache-2.0"
homepage = "https://lightningdevkit.org/"
Expand Down
2 changes: 1 addition & 1 deletion api/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait Authorizer: Send + Sync {
/// Returns [`AuthResponse`] for an authenticated and authorized user or [`VssError::AuthError`]
/// for an unauthorized request.
async fn verify(&self, headers_map: &HashMap<String, String>)
-> Result<AuthResponse, VssError>;
-> Result<AuthResponse, VssError>;
}

/// A no-operation authorizer, which lets any user-request go through.
Expand Down
12 changes: 6 additions & 6 deletions api/src/kv_store_tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::error::VssError;
use crate::kv_store::{KvStore, GLOBAL_VERSION_KEY};
use crate::kv_store::{GLOBAL_VERSION_KEY, KvStore};
use crate::types::{
DeleteObjectRequest, GetObjectRequest, KeyValue, ListKeyVersionsRequest,
ListKeyVersionsResponse, PutObjectRequest,
};
use async_trait::async_trait;
use bytes::Bytes;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use rand::{Rng, thread_rng};

/// Defines KvStoreTestSuite which is required for an implementation to be VSS protocol compliant.
#[macro_export]
Expand Down Expand Up @@ -150,8 +150,8 @@ pub trait KvStoreTestSuite {
Ok(())
}

async fn put_multi_object_should_fail_when_single_key_version_mismatched(
) -> Result<(), VssError> {
async fn put_multi_object_should_fail_when_single_key_version_mismatched()
-> Result<(), VssError> {
let kv_store = Self::create_store().await;
let ctx = TestContext::new(&kv_store);

Expand Down Expand Up @@ -467,8 +467,8 @@ pub trait KvStoreTestSuite {
Ok(())
}

async fn list_should_return_zero_global_version_when_global_versioning_not_enabled(
) -> Result<(), VssError> {
async fn list_should_return_zero_global_version_when_global_versioning_not_enabled()
-> Result<(), VssError> {
let kv_store = Self::create_store().await;
let ctx = TestContext::new(&kv_store);

Expand Down
8 changes: 4 additions & 4 deletions auth-impls/src/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use api::auth::{AuthResponse, Authorizer};
use api::error::VssError;
use async_trait::async_trait;
use base64::engine::general_purpose::{STANDARD, URL_SAFE_NO_PAD};
use base64::Engine;
use base64::engine::general_purpose::{STANDARD, URL_SAFE_NO_PAD};
use openssl::hash::MessageDigest;
use openssl::pkey::Public;
use openssl::pkey::{Id, PKey};
Expand Down Expand Up @@ -87,7 +87,7 @@ impl JWTAuthorizer {
_ => {
return Err(VssError::AuthError(String::from(
"Token does not have three parts",
)))
)));
},
};

Expand Down Expand Up @@ -241,7 +241,7 @@ mod tests {
-----END PRIVATE KEY-----";

fn create_token<T: Serialize>(encoding_key: &str, claims: T) -> String {
use jsonwebtoken::{encode, Algorithm, EncodingKey, Header};
use jsonwebtoken::{Algorithm, EncodingKey, Header, encode};
let valid_encoding_key = EncodingKey::from_rsa_pem(encoding_key.as_bytes())
.expect("Failed to create Encoding Key.");
encode(&Header::new(Algorithm::RS256), &claims, &valid_encoding_key).unwrap()
Expand Down Expand Up @@ -280,7 +280,7 @@ mod tests {
}

fn jsonwebtoken_decode<T: DeserializeOwned>(token: &str, rsa_pem: &str) -> Result<T, VssError> {
use jsonwebtoken::{decode, Algorithm, DecodingKey, Validation};
use jsonwebtoken::{Algorithm, DecodingKey, Validation, decode};
let jwt_issuer_key = DecodingKey::from_rsa_pem(rsa_pem.as_bytes()).unwrap();
let claims = decode::<T>(token, &jwt_issuer_key, &Validation::new(Algorithm::RS256))
.map_err(|e| VssError::AuthError(format!("Authentication failure. {}", e)))?
Expand Down
2 changes: 1 addition & 1 deletion auth-impls/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Authorizer for SignatureValidatingAuthorizer {

#[cfg(test)]
mod tests {
use crate::signature::{SignatureValidatingAuthorizer, SIGNING_CONSTANT};
use crate::signature::{SIGNING_CONSTANT, SignatureValidatingAuthorizer};
use api::auth::Authorizer;
use api::error::VssError;
use secp256k1::{Message, PublicKey, SecretKey};
Expand Down
8 changes: 4 additions & 4 deletions impls/src/postgres_store.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::migrations::*;

use api::error::VssError;
use api::kv_store::{KvStore, GLOBAL_VERSION_KEY, INITIAL_RECORD_VERSION};
use api::kv_store::{GLOBAL_VERSION_KEY, INITIAL_RECORD_VERSION, KvStore};
use api::types::{
DeleteObjectRequest, DeleteObjectResponse, GetObjectRequest, GetObjectResponse, KeyValue,
ListKeyVersionsRequest, ListKeyVersionsResponse, PutObjectRequest, PutObjectResponse,
Expand All @@ -15,7 +15,7 @@ use std::cmp::min;
use std::io::{self, Error, ErrorKind};
use tokio::sync::Mutex;
use tokio_postgres::tls::{MakeTlsConnect, TlsConnect};
use tokio_postgres::{error, Client, NoTls, Socket, Transaction};
use tokio_postgres::{Client, NoTls, Socket, Transaction, error};

use log::{debug, info, warn};

Expand Down Expand Up @@ -693,7 +693,7 @@ where

let key_like = format!("{}%", key_prefix.as_deref().unwrap_or_default());

let rows = if let Some(ref token) = page_token {
let rows = if let Some(token) = page_token {
let page_sort_order = decode_page_token(token)?;
let stmt = "SELECT key, version, sort_order FROM vss_db WHERE user_token = $1 AND store_id = $2 AND sort_order < $3 AND key LIKE $4 AND key != $5 ORDER BY sort_order DESC LIMIT $6";
let params: Vec<&(dyn tokio_postgres::types::ToSql + Sync)> = vec![
Expand Down Expand Up @@ -743,7 +743,7 @@ where

#[cfg(test)]
mod tests {
use super::{decode_page_token, drop_database, encode_page_token, DUMMY_MIGRATION, MIGRATIONS};
use super::{DUMMY_MIGRATION, MIGRATIONS, decode_page_token, drop_database, encode_page_token};
use crate::postgres_store::PostgresPlaintextBackend;
use api::define_kv_store_tests;
use api::kv_store::KvStore;
Expand Down
5 changes: 1 addition & 4 deletions server/src/vss_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ async fn handle_list_object_request(
let request_id: u64 = rand::random();
trace!(
"Handling ListKeyVersionsRequest {} for key_prefix {:?}, page_size {:?}, page_token {:?}",
request_id,
request.key_prefix,
request.page_size,
request.page_token
request_id, request.key_prefix, request.page_size, request.page_token
);
let result = store.list_key_versions(user_token, request).await;
if let Err(ref e) = result {
Expand Down
Loading