Skip to content

Commit

Permalink
Rename admins_keys to admin_keys across the codebase (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen authored Sep 18, 2024
1 parent 3f2d99f commit c157393
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion prover/src/auth/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub async fn register(
_claims: Claims,
Json(payload): Json<AddKeyRequest>,
) -> Result<impl IntoResponse, ProverError> {
if !state.admins_keys.contains(&payload.authority) {
if !state.admin_keys.contains(&payload.authority) {
return Err(ProverError::Auth(AuthError::Unauthorized));
}
payload
Expand Down
8 changes: 4 additions & 4 deletions prover/src/auth/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ mod tests {
thread_pool: Arc::new(Mutex::new(ThreadPool::new(1))),
nonces,
authorizer: Authorizer::Open,
admins_keys: vec![generate_verifying_key(&generate_signing_key())],
admin_keys: vec![generate_verifying_key(&generate_signing_key())],
sse_tx: Arc::new(Mutex::new(tokio::sync::broadcast::channel(100).0)),
};

Expand Down Expand Up @@ -162,7 +162,7 @@ mod tests {
thread_pool: Arc::new(Mutex::new(ThreadPool::new(1))),
nonces,
authorizer: Authorizer::Open,
admins_keys: vec![generate_verifying_key(&generate_signing_key())],
admin_keys: vec![generate_verifying_key(&generate_signing_key())],
sse_tx: Arc::new(Mutex::new(tokio::sync::broadcast::channel(100).0)),
};

Expand Down Expand Up @@ -202,7 +202,7 @@ mod tests {
thread_pool: Arc::new(Mutex::new(ThreadPool::new(1))),
nonces,
authorizer: Authorizer::Open,
admins_keys: vec![generate_verifying_key(&generate_signing_key())],
admin_keys: vec![generate_verifying_key(&generate_signing_key())],
sse_tx: Arc::new(Mutex::new(tokio::sync::broadcast::channel(100).0)),
};

Expand Down Expand Up @@ -243,7 +243,7 @@ mod tests {
thread_pool: Arc::new(Mutex::new(ThreadPool::new(1))),
nonces,
authorizer: Authorizer::Open,
admins_keys: vec![generate_verifying_key(&generate_signing_key())],
admin_keys: vec![generate_verifying_key(&generate_signing_key())],
sse_tx: Arc::new(Mutex::new(tokio::sync::broadcast::channel(100).0)),
};

Expand Down
2 changes: 1 addition & 1 deletion prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ pub struct Args {
#[arg(long, env, default_value = "4")]
pub num_workers: usize,
#[arg(long, env, value_delimiter = ',')]
pub admins_keys: Vec<String>,
pub admin_keys: Vec<String>,
}
10 changes: 5 additions & 5 deletions prover/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct AppState {
pub jwt_secret_key: String,
pub nonces: Arc<Mutex<HashMap<NonceString, VerifyingKey>>>,
pub authorizer: Authorizer,
pub admins_keys: Vec<VerifyingKey>,
pub admin_keys: Vec<VerifyingKey>,
pub sse_tx: Arc<Mutex<Sender<String>>>,
}

Expand All @@ -49,12 +49,12 @@ pub async fn start(args: Args) -> Result<(), ProverError> {

let authorizer =
Authorizer::Persistent(FileAuthorizer::new(args.authorized_keys_path.clone()).await?);
let mut admins_keys = Vec::new();
for key in args.admins_keys {
let mut admin_keys = Vec::new();
for key in args.admin_keys {
let verifying_key_bytes = prefix_hex::decode::<Vec<u8>>(key)
.map_err(|e| AuthorizerError::PrefixHexConversionError(e.to_string()))?;
let verifying_key = VerifyingKey::from_bytes(&verifying_key_bytes.try_into()?)?;
admins_keys.push(verifying_key);
admin_keys.push(verifying_key);
authorizer.authorize(verifying_key).await?;
}

Expand All @@ -73,7 +73,7 @@ pub async fn start(args: Args) -> Result<(), ProverError> {
authorizer,
job_store: JobStore::default(),
thread_pool: Arc::new(Mutex::new(ThreadPool::new(args.num_workers))),
admins_keys,
admin_keys,
sse_tx: Arc::new(Mutex::new(sse_tx)),
};

Expand Down
4 changes: 2 additions & 2 deletions scripts/e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ $CONTAINER_ENGINE run -d --name http_prover_test $REPLACE_FLAG \
--message-expiration-time 3600 \
--session-expiration-time 3600 \
--authorized-keys $PUBLIC_KEY,$ADMIN_PUBLIC_KEY1,$ADMIN_PUBLIC_KEY2 \
--admins-keys $ADMIN_PUBLIC_KEY1,$ADMIN_PUBLIC_KEY2
--admin-keys $ADMIN_PUBLIC_KEY1,$ADMIN_PUBLIC_KEY2

start_time=$(date +%s)

PRIVATE_KEY=$PRIVATE_KEY PROVER_URL="http://localhost:3040" ADMIN_PRIVATE_KEY_1=$ADMIN_PRIVATE_KEY1 ADMIN_PRIVATE_KEY_2=$ADMIN_PRIVATE_KEY2 cargo test --no-fail-fast --workspace --verbose
Expand Down

0 comments on commit c157393

Please sign in to comment.