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 path for retrieving the public key #5

Merged
merged 2 commits into from
Dec 12, 2018
Merged

Conversation

sethvargo
Copy link
Contributor

Adds a new path for retrieving the public key.

The docs changes will actually need to go over to the main Vault repo. I wish there was a way to pull both the plugin and its docs into Vault's build instead of having the docs live separately.

Once this is merged, I can open another PR to update the docs.

@sethvargo
Copy link
Contributor Author

@kalafut

},

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: withFieldValidator(b.pathPubkeyRead),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be an Update operation instead since you're requiring key_version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I actually think it should be GET. It's possible to have params for get requests (they turn into URL params). I'm going to fix the curl command because vault write gcpkms/pubkey/my-key key_verison=1 doesn't feel right.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that read feels correct, though as is now the key_version would be a query parameter which is uncommon in Vault (AFAIK), and a little odd with it being required. Maybe it could be a path element, which is a pattern that would match: https://www.vaultproject.io/api/secret/transit/index.html#export-key

@briankassouf Might have some thoughts on the API conventions here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As in vault read gcpkms/pubkey/my-key/1? I'm not opposed to that, but can @briankassouf weight in quickly before I make that change?

Choose a reason for hiding this comment

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

Using a GET parameter is fine, it's not a common pattern because it wasn't part of our framework implementation until recently. The kv version 2 API uses get parameters to retrieve a specific version of a secret. This aligns with that same usecase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay let's keep it as-is then 😄- thanks bk. @kalafut what other changes do we need to merge this

Copy link
Contributor

@kalafut kalafut Dec 11, 2018

Choose a reason for hiding this comment

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

Hey @sethvargo one last question. The KVV2 API defaults to the latest key version if version isn't provided. Does that same concept make sense here? I briefly skimmed the Google docs but it wasn't totally clear to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it, but it would involve an extra API call (we'd have to list the key versions from the KMS api and grab the latest one). Two problems arise:

  1. What is "latest"? Is it the latest active key or the most recently created key?
  2. What if the user doesn't have permission to list all the keys.

That's why I opted to keep it required.


| Method | Path | Produces |
| :------- | :--------------------------| :------------------------ |
| `GET` | `gcpkms/pubkey/:key` | `200 application/json` |
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to POST if the code review comments re: Update are made. Your curl example is already correct though 🙂.

@sethvargo
Copy link
Contributor Author

I can't merge, but 👍

@briankassouf briankassouf merged commit 6cd9918 into master Dec 12, 2018
@briankassouf briankassouf deleted the sethvargo/public_key branch December 12, 2018 18:25
@sethvargo
Copy link
Contributor Author

Thanks!

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