Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KeyVault Certificate Functions #334

Merged
merged 12 commits into from
Nov 16, 2021

Conversation

Billy-Sheppard
Copy link
Contributor

@Billy-Sheppard Billy-Sheppard commented Jul 30, 2021

Apologies if this was already worked on or out of spec, adapted directly from secret.rs, welcome any improvements.

  • moved enum RecoveryLevel to the key_vault lib.rs
  • added certificate.rs based directly off secret.rs
  • potentially fn _update_certificate_policy() is not needed/required
  • documentation may not be suitable

@ghost
Copy link

ghost commented Jul 30, 2021

CLA assistant check
All CLA requirements met.

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

Overall, the implementation looks good. Most of the requested changes are to align with our other SDKs, since we consistency after idiomacy (and naming - apart from casing - is rarely idiomatic). The biggest change, though, is to define a CertificateProperties and use that in various structs and methods, which actually makes calling the code much easier and tested well in UX studies. This is fairly consistent across our SDKs - even beyond Key Vault.

sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
@Billy-Sheppard
Copy link
Contributor Author

Thanks for your comments Heath, I (think) I've addressed all but the CertificateClient issue - do you have a rust code example I can build off, otherwise I'll decipher from the MS docs.

Let me know if anything else needs changing, potentially (probably) there are some cleaner ways to address some of the fixes I've implemented.

Thanks again.

@Billy-Sheppard
Copy link
Contributor Author

Apologies for the messy history, it took me a while to understand the ins and outs of the code, especially the tests, sorry, but I think I have resolved all the changes requested.

However, I am unsure on how to mark them properly? Is marking comments as resolved incorrect?

Cheers

@rylev rylev requested a review from heaths October 4, 2021 13:27
@Billy-Sheppard
Copy link
Contributor Author

@rylev

Hi, I'm pretty keen to get this reviewed, as we're currently using a fork in production, I understand @heaths is busy with a bunch of projects, are you (Ryan) able to review this?

Thanks

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

So sorry. I started reviewing this a while ago, probably got distracted, and it fell off my radar.

I like the changes, but there's a few things I'd like to see changed first. I've noted some other places where it would great if you could clarify (all the auth in the client) or just open tracking issues, but only a couple likely small code changes to this PR. The others are more things I think we need to discuss further, so tracking issues are okay.

I'll keep a keen eye out for updates. Again, so sorry this fell off my radar. Feel free to ping if ever that happens.

sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/certificate.rs Outdated Show resolved Hide resolved
/// let creds = DefaultCredential::default();
/// let client = CertificateClient::new("test-key-vault.vault.azure.net", &creds).unwrap();
/// ```
pub fn new(vault_url: &str, token_credential: &'a T) -> Result<Self, Error> {
Copy link
Member

Choose a reason for hiding this comment

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

I believe we are using a URI structure now. @rylev @cataggar ?

Ok(client)
}

pub(crate) async fn refresh_token(&mut self) -> Result<(), Error> {
Copy link
Member

Choose a reason for hiding this comment

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

Note: Perhaps not now unless azure_identity is already doing this, but the TokenCredential and our challenge-based auth policy - which we may not yet have for KV - should handle this.

/cc @MindFlavor

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, looking further below, there's a lot of auth going on here that has me concerned about duplication. I wouldn't hold up the PR for this, but could you clarify or maybe open an issue if this is solving some deficiency in azure_identity? Apart from challenge-based auth with Key Vault and Managed HSM need (as well as Attestation and a couple other services we'll be onboarding for other languages), no auth - apart from attaching headers/etc - should be done in clients.

sdk/key_vault/src/client.rs Outdated Show resolved Hide resolved
sdk/key_vault/src/lib.rs Outdated Show resolved Hide resolved
@Billy-Sheppard
Copy link
Contributor Author

  • I've removed those two types. I believe they were leftover from an older version of the file.
  • I've also removed the max_results parameters.
  • I can change the vault_url parameter to take a specific type if required
  • re the Client stuff, I think I just built it to mirror the client code from secret, I can remove portions of it if required
  • I have not considered a new_with_options function but could relatively easily implement one if required, potentially should be a separate PR/issue
  • Changed RecoveryLevel to be a String rather than an enum

@cataggar cataggar added the KeyVault Key Vault label Oct 26, 2021
@heaths
Copy link
Member

heaths commented Oct 27, 2021

@Billy-Sheppard just a tip: when resolving comments (with or without change, though in the latter please explain why) it helps to resolve the conversation (comment) so I can tell what/how each PR comment is resolved.

I'm in a bit of a crunch this week but will look at this soon and resolve with remaining open comments.

@Billy-Sheppard
Copy link
Contributor Author

Thanks Heath,

I've marked the ones I fixed as resolved. I'll await further discussion on the remaining points.

@heaths
Copy link
Member

heaths commented Oct 29, 2021

Could you resolve the conflicts and I'll take a look? I expect a few significant changes.

@Billy-Sheppard
Copy link
Contributor Author

@heaths - are you able to complete this/provide further feedback? Do the remaining tasks require any further improvement? I also opened issue: #516.

Thanks

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

Thank you.

@heaths heaths merged commit 4781508 into Azure:main Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KeyVault Key Vault
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants