Skip to content

feat: response authentication#1197

Merged
hansl merged 23 commits intomasterfrom
es-verify-cert-fetch-root-key
Dec 1, 2020
Merged

feat: response authentication#1197
hansl merged 23 commits intomasterfrom
es-verify-cert-fetch-root-key

Conversation

@ghost
Copy link

@ghost ghost commented Nov 19, 2020

  • Update rust agent to #86
  • Update e2e tests
  • Update replica for signature consistency
  • Fetch root key for non-ic

use anyhow::anyhow;

pub async fn fetch_root_key_if_needed<'a>(env: &'a (dyn Environment + 'a)) -> DfxResult {
let must_fetch_root_key = env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename to non_ic_network or something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, naming is hard haha

if must_fetch_root_key {
let agent = env
.get_agent()
.ok_or_else(|| anyhow!("Cannot get HTTP client from environment."))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this error message was changed when moving to anyhow, it seems like it should be what CommandMustBeRunInAProject was. This error doesn't really help a user figure out what is the right environment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this from other code that gets an agent. This is one of those errors that can't actually happen, too, because the Environment is actually always an AgentEnvironment.

Copy link
Author

@ghost ghost Nov 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really I think Environment::get_agent should panic and the return type should be Agent not Option<Agent>

.ok_or_else(|| anyhow!("Cannot get HTTP client from environment."))?;
let mut runtime = Runtime::new().expect("Unable to create a runtime");

runtime.block_on(fetch_root_key_if_needed(env))?;
Copy link
Contributor

@p-shahi p-shahi Nov 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we lessen duplication and make all canister subcommand functions async, then we can move creating the tokio runtime and fetch_root_key_if_needed to: https://github.com/dfinity/sdk/blob/master/src/dfx/src/commands/canister/mod.rs#L45
(just a thought, not something actionable for this pr)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is a tech debt item, to make all command exec functions async. I didn't think we could do it only for the canister commands, though maybe it is possible?

Copy link
Contributor

@p-shahi p-shahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking this because fetch_root_key needs to always be called now.

Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericswanson-dfinity approved offline (can't approve your own PR). Unblocking this.

@ghost
Copy link
Author

ghost commented Dec 1, 2020

old school 👍

@hansl hansl merged commit 3523c16 into master Dec 1, 2020
@hansl hansl deleted the es-verify-cert-fetch-root-key branch December 1, 2020 07:27
dfinity-bot added a commit that referenced this pull request Feb 19, 2022
mergify bot pushed a commit that referenced this pull request Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants