Skip to content

Commit c18acc0

Browse files
[keyvault] move azkeys to security folder (Azure#20430)
* move * add security path * changes * update tests * fix yml ci * update link * Charles feedback Co-authored-by: Charles Lowell <[email protected]> --------- Co-authored-by: Charles Lowell <[email protected]>
1 parent 6cd8433 commit c18acc0

28 files changed

+5794
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Release History
2+
3+
## 0.10.0 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
* Moved from `sdk/keyvault/azkeys` to `sdk/security/keyvault/azkeys`
9+
10+
### Bugs Fixed
11+
12+
### Other Changes
13+
14+
## 0.9.0 (2022-11-08)
15+
16+
### Breaking Changes
17+
* `NewClient` returns an `error`
18+
19+
## 0.8.1 (2022-09-20)
20+
21+
### Features Added
22+
* Added `ClientOptions.DisableChallengeResourceVerification`.
23+
See https://aka.ms/azsdk/blog/vault-uri for more information.
24+
25+
## 0.8.0 (2022-09-12)
26+
27+
### Breaking Changes
28+
* Verify the challenge resource matches the vault domain.
29+
30+
## 0.7.0 (2022-08-09)
31+
32+
### Breaking Changes
33+
* Changed type of `NewClient` options parameter to `azkeys.ClientOptions`, which embeds
34+
the former type, `azcore.ClientOptions`
35+
36+
## 0.6.0 (2022-07-07)
37+
38+
### Breaking Changes
39+
* The `Client` API now corresponds more directly to the Key Vault REST API.
40+
Most method signatures and types have changed. See the
41+
[module documentation](https://aka.ms/azsdk/go/keyvault-keys/docs)
42+
for updated code examples and more details.
43+
44+
### Other Changes
45+
* Upgrade to latest `azcore`
46+
47+
## 0.5.1 (2022-05-12)
48+
49+
### Other Changes
50+
* Update to latest `azcore` and `internal` modules.
51+
52+
## 0.5.0 (2022-04-06)
53+
54+
### Features Added
55+
* Added the Name property on `Key`
56+
57+
### Breaking Changes
58+
* Requires go 1.18
59+
* `ListPropertiesOfDeletedKeysPager` has `More() bool` and `NextPage(context.Context) (ListPropertiesOfDeletedKeysPage, error)` for paging over deleted keys.
60+
* `ListPropertiesOfKeyVersionsPager` has `More() bool` and `NextPage(context.Context) (ListPropertiesOfKeyVersionsPage, error)` for paging over deleted keys.
61+
* Removing `RawResponse *http.Response` from `crypto` response types
62+
63+
## 0.4.0 (2022-03-08)
64+
65+
### Features Added
66+
* Adds the `ReleasePolicy` parameter to the `UpdateKeyPropertiesOptions` struct.
67+
* Adds the `Immutable` boolean to the `KeyReleasePolicy` model.
68+
* Added a `ToPtr` method on `KeyType` constant
69+
70+
### Breaking Changes
71+
* Requires go 1.18
72+
* Changed the `Data` to `EncodedPolicy` on the `KeyReleasePolicy` struct.
73+
* Changed the `Updated`, `Created`, and `Expires` properties to `UpdatedOn`, `CreatedOn`, and `ExpiresOn`.
74+
* Renamed `JSONWebKeyOperation` to `Operation`.
75+
* Renamed `JSONWebKeyCurveName` to `CurveName`
76+
* Prefixed all KeyType constants with `KeyType`
77+
* Changed `KeyBundle` to `KeyVaultKey` and `DeletedKeyBundle` to `DeletedKey`
78+
* Renamed `KeyAttributes` to `KeyProperties`
79+
* Renamed `ListKeyVersions` to `ListPropertiesOfKeyVersions`
80+
* Removed `Attributes` struct
81+
* Changed `CreateOCTKey`/`Response`/`Options` to `CreateOctKey`/`Response`/`Options`
82+
* Removed all `RawResponse *http.Response` fields from response structs.
83+
84+
## 0.3.0 (2022-02-08)
85+
86+
### Breaking Changes
87+
* Changed the `Tags` properties from `map[string]*string` to `map[string]string`
88+
89+
### Bugs Fixed
90+
* Fixed a bug in `UpdateKeyProperties` where the `KeyOps` would be deleted if the `UpdateKeyProperties.KeyOps` value was left empty.
91+
92+
## 0.2.0 (2022-01-12)
93+
94+
### Bugs Fixed
95+
* Fixes a bug in `crypto.NewClient` where the key version was required in the path, it is no longer required but is recommended.
96+
97+
### Other Changes
98+
* Updates `azcore` dependency from `v0.20.0` to `v0.21.0`
99+
100+
## 0.1.0 (2021-11-09)
101+
* This is the initial release of the `azkeys` library
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Azure Key Vault Keys client module for Go
2+
3+
* Cryptographic key management (this module) - create, store, and control access to the keys used to encrypt your data
4+
* Secrets management ([azsecrets](https://aka.ms/azsdk/go/keyvault-secrets/docs)) - securely store and control access to tokens, passwords, certificates, API keys, and other secrets
5+
* Certificate management ([azcertificates](https://aka.ms/azsdk/go/keyvault-certificates/docs)) - create, manage, and deploy public and private SSL/TLS certificates
6+
7+
[Source code][key_client_src] | [Package (pkg.go.dev)][goget_azkeys] | [Product documentation][keyvault_docs] | [Samples][keys_samples]
8+
9+
## Getting started
10+
11+
### Install packages
12+
13+
Install `azkeys` and `azidentity` with `go get`:
14+
```Bash
15+
go get github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys
16+
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
17+
```
18+
[azidentity][azure_identity] is used for Azure Active Directory authentication as demonstrated below.
19+
20+
### Prerequisites
21+
22+
* An [Azure subscription][azure_sub]
23+
* A supported Go version (the Azure SDK supports the two most recent Go releases)
24+
* A key vault. If you need to create one, see the Key Vault documentation for instructions on doing so in the [Azure Portal][azure_keyvault_portal] or with the [Azure CLI][azure_keyvault_cli].
25+
26+
### Authentication
27+
28+
This document demonstrates using [azidentity.NewDefaultAzureCredential][default_cred_ref] to authenticate. This credential type works in both local development and production environments. We recommend using a [managed identity][managed_identity] in production.
29+
30+
[Client][client_docs] accepts any [azidentity][azure_identity] credential. See the [azidentity][azure_identity] documentation for more information about other credential types.
31+
32+
#### Create a client
33+
34+
Constructing the client requires your vault's URL, which you can get from the Azure CLI or the Azure Portal.
35+
36+
```go
37+
import (
38+
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
39+
"github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys"
40+
)
41+
42+
func main() {
43+
cred, err := azidentity.NewDefaultAzureCredential(nil)
44+
if err != nil {
45+
// TODO: handle error
46+
}
47+
48+
client, err := azkeys.NewClient("https://<TODO: your vault name>.vault.azure.net", cred, nil)
49+
if err != nil {
50+
// TODO: handle error
51+
}
52+
}
53+
```
54+
55+
## Key concepts
56+
57+
### Keys
58+
59+
Azure Key Vault can create and store RSA and elliptic curve keys. Both can optionally be protected by hardware security modules (HSMs). Azure Key Vault can also perform cryptographic operations with them. For more information about keys and supported operations and algorithms, see the [Key Vault documentation](https://docs.microsoft.com/azure/key-vault/keys/about-keys).
60+
61+
[Client][client_docs] can create keys in the vault, get existing keys from the vault, update key metadata, and delete keys, as shown in the examples below.
62+
63+
## Examples
64+
65+
Get started with our [examples][keys_samples].
66+
67+
## Troubleshooting
68+
69+
### Error Handling
70+
71+
All methods which send HTTP requests return `*azcore.ResponseError` when these requests fail. `ResponseError` has error details and the raw response from Key Vault.
72+
73+
```go
74+
import "github.com/Azure/azure-sdk-for-go/sdk/azcore"
75+
76+
resp, err := client.GetKey(context.Background(), "keyName", nil)
77+
if err != nil {
78+
var httpErr *azcore.ResponseError
79+
if errors.As(err, &httpErr) {
80+
// TODO: investigate httpErr
81+
} else {
82+
// TODO: not an HTTP error
83+
}
84+
}
85+
```
86+
87+
### Logging
88+
89+
This module uses the logging implementation in `azcore`. To turn on logging for all Azure SDK modules, set `AZURE_SDK_GO_LOGGING` to `all`. By default the logger writes to stderr. Use the `azcore/log` package to control log output. For example, logging only HTTP request and response events, and printing them to stdout:
90+
91+
```go
92+
import azlog "github.com/Azure/azure-sdk-for-go/sdk/azcore/log"
93+
94+
// Print log events to stdout
95+
azlog.SetListener(func(cls azlog.Event, msg string) {
96+
fmt.Println(msg)
97+
})
98+
99+
// Includes only requests and responses in credential logs
100+
azlog.SetEvents(azlog.EventRequest, azlog.EventResponse)
101+
```
102+
103+
### Accessing `http.Response`
104+
105+
You can access the raw `*http.Response` returned by Key Vault using the `runtime.WithCaptureResponse` method and a context passed to any client method.
106+
107+
```go
108+
import "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
109+
110+
var response *http.Response
111+
ctx := runtime.WithCaptureResponse(context.TODO(), &response)
112+
_, err = client.GetKey(ctx, "keyName", nil)
113+
if err != nil {
114+
// TODO: handle error
115+
}
116+
// TODO: do something with response
117+
```
118+
119+
### Additional Documentation
120+
121+
For more extensive documentation on Azure Key Vault, see the [API reference documentation][reference_docs].
122+
123+
## Contributing
124+
125+
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
126+
127+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
128+
129+
This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [email protected] with any additional questions or comments.
130+
131+
132+
[azure_identity]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity
133+
[azure_keyvault_cli]: https://docs.microsoft.com/azure/key-vault/general/quick-create-cli
134+
[azure_keyvault_portal]: https://docs.microsoft.com/azure/key-vault/general/quick-create-portal
135+
[azure_sub]: https://azure.microsoft.com/free/
136+
[default_cred_ref]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity#NewDefaultAzureCredential
137+
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
138+
[keyvault_docs]: https://docs.microsoft.com/azure/key-vault/
139+
[goget_azkeys]: https://aka.ms/azsdk/go/keyvault-keys/docs
140+
[reference_docs]: https://aka.ms/azsdk/go/keyvault-keys/docs
141+
[client_docs]: https://aka.ms/azsdk/go/keyvault-keys/docs#Client
142+
[key_client_src]: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/keyvault/azkeys/client.go
143+
[keys_samples]: https://aka.ms/azsdk/go/keyvault-keys/docs#pkg-examples
144+
[managed_identity]: https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview
145+
146+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-go%2Fsdk%2Fsecurity%2Fkeyvault%2Fazkeys%2FREADME.png)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Troubleshoot Azure Key Vault Keys Client Module Issues
2+
3+
See our [Azure Key Vault SDK Troubleshooting Guide](https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/keyvault/TROUBLESHOOTING.md)
4+
to troubleshoot issues common to Azure Key Vault client modules.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"AssetsRepo": "Azure/azure-sdk-assets",
3+
"AssetsRepoPrefixPath": "go",
4+
"TagPrefix": "go/security/keyvault/azkeys",
5+
"Tag": "go/security/keyvault/azkeys_d569f3aad0"
6+
}

0 commit comments

Comments
 (0)