Skip to content

Commit

Permalink
Remove admin task config API
Browse files Browse the repository at this point in the history
  • Loading branch information
mendess committed Sep 20, 2023
1 parent 35c2f47 commit 34abb61
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
12 changes: 0 additions & 12 deletions daphne_worker/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ pub(crate) struct DaphneWorkerConfig {
/// Default DAP version to use if not specified by the API URL
pub(crate) default_version: DapVersion,

/// Admin bearer token. If configured, it is used to authorize requests from the administrator.
pub(crate) admin_token: Option<BearerToken>,

/// Helper: Time to wait before deleting an instance of HelperStateStore. This field is not
/// configured by the Leader.
pub(crate) helper_state_store_garbage_collect_after_secs: Option<Duration>,
Expand Down Expand Up @@ -262,14 +259,6 @@ impl DaphneWorkerConfig {
None
};

let admin_token = match env.secret("DAP_ADMIN_BEARER_TOKEN") {
Ok(raw) => Some(BearerToken::from(raw.to_string())),
Err(err) => {
trace!("DAP_ADMIN_BEARER_TOKEN not configured: {err:?}");
None
}
};

let helper_state_store_garbage_collect_after_secs = if !is_leader {
Some(Duration::from_secs(
env.var("DAP_HELPER_STATE_STORE_GARBAGE_COLLECT_AFTER_SECS")?
Expand Down Expand Up @@ -333,7 +322,6 @@ impl DaphneWorkerConfig {
is_leader,
taskprov,
default_version,
admin_token,
helper_state_store_garbage_collect_after_secs,
processed_alarm_safety_interval,
metrics_push_config,
Expand Down
26 changes: 2 additions & 24 deletions daphne_worker/src/router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub mod test_routes;

use std::str::FromStr;

use daphne::auth::BearerToken;
use daphne::roles::DapAggregator;
use serde::Deserialize;
use tracing::{info_span, Instrument};
Expand Down Expand Up @@ -78,8 +77,8 @@ pub(super) fn create_router<'s>(
state: &'s DaphneWorkerRequestState<'s>,
opts: RouterOptions,
) -> Result<DapRouter<'s>> {
let router = Router::with_data(state)
.get_async("/:version/hpke_config", |req, ctx| async move {
let router =
Router::with_data(state).get_async("/:version/hpke_config", |req, ctx| async move {
let daph = ctx.data.handler(&ctx.env);
let req = daph.worker_request_to_dap(req, &ctx).await?;

Expand All @@ -89,27 +88,6 @@ pub(super) fn create_router<'s>(
Ok(req) => dap_response_to_worker(req),
Err(e) => daph.state.dap_abort_to_worker_response(e),
}
})
.post_async("/task", |mut req, ctx| async move {
let daph = ctx.data.handler(&ctx.env);
let admin_token = req
.headers()
.get("X-Daphne-Worker-Admin-Bearer-Token")?
.map(BearerToken::from);

if daph.config().admin_token.is_none() {
return Response::error("admin not configured", 400);
}

if admin_token.is_none() || admin_token != daph.config().admin_token {
return Response::error("missing or invalid bearer token for admin", 401);
}

let cmd: test_routes::InternalTestAddTask = req.json().await?;
daph.internal_add_task(daph.config().default_version, cmd)
.instrument(info_span!("task"))
.await?;
Response::empty()
});

let router = match opts.role {
Expand Down

0 comments on commit 34abb61

Please sign in to comment.