You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplify key flow: extract private key from service account key if present (#203)
* Draft implementation for extracting private key from service account key
* Add comment and update test
* Update unit tests, add separate struct for sa key credentials
* Env var and configured private key take precendence
* Fix lint
* Update documentation
* Update changelog
* Update example and fix empty private key path case
* Changes after review
@@ -118,17 +117,15 @@ Check the [authentication example](examples/authentication/authentication.go) fo
118
117
### Key flow
119
118
120
119
To use the key flow, you need to have a service account key and an RSA key-pair.
121
-
To configure it, follow this steps:
120
+
To configure it, follow these steps:
122
121
123
122
The following instructions assume that you have created a service account and assigned it the necessary permissions, e.g. project.owner.
124
123
125
124
1. In the Portal, go to the `Service Accounts` tab, choose a `Service Account` and go to `Service Account Keys` to create a key.
126
125
- You can create your own RSA key-pair or have the Portal generate one for you.
127
-
2. Save the content of the service account key and the corresponding private key by copying them or saving them in a file.
126
+
2. Save the content of the service account key by copying it and saving it in a JSON file.
128
127
129
-
**Hint:** If you have generated the RSA key-pair using the Portal, you can save the private key in a PEM encoded file by downloading the service account key as a PEM file and using `openssl storeutl -keys <path/to/sa_key_pem_file> > private.key` to extract the private key from the service account key.
130
-
131
-
The expected format of the service account key is a **json** with the following structure:
128
+
The expected format of the service account key is a **json** with the following structure:
132
129
133
130
```json
134
131
{
@@ -150,11 +147,15 @@ The expected format of the service account key is a **json** with the following
150
147
}
151
148
```
152
149
153
-
3. Configure the service account key and private key for authentication in the SDK by following one of the alternatives below:
150
+
3. Configure the service account key for authentication in the SDK by following one of the alternatives below:
154
151
- using the configuration options: `config.WithServiceAccountKey` or `config.WithServiceAccountKeyPath`, `config.WithPrivateKey` or `config.WithPrivateKeyPath`
155
-
- setting environment variables: `STACKIT_SERVICE_ACCOUNT_KEY_PATH` and `STACKIT_PRIVATE_KEY_PATH`
156
-
- setting `STACKIT_SERVICE_ACCOUNT_KEY_PATH` and `STACKIT_PRIVATE_KEY_PATH` in the credentials file (see above)
157
-
4. The SDK will search for the keys and, if valid, will use them to get access and refresh tokens which will be used to authenticate all the requests.
- setting `STACKIT_SERVICE_ACCOUNT_KEY_PATH` in the credentials file (see above)
154
+
4.**If you have provided your own RSA key-pair**, you can set it the same way (it will take precedence over the private key included in the service account key, if present):
155
+
- using the configuration options: `config.WithPrivateKey` or `config.WithPrivateKeyPath`
Copy file name to clipboardExpand all lines: core/CHANGELOG.md
+4
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
## v0.7.5 (2024-01-09)
2
+
3
+
-**Improvement:** When using the key flow, the SDK will extract the private key from the service account key and use it, if no private key is provided in the configuration, through environment variable or in the credentials file. This makes it simpler to use the key flow: if you create a service account key including the private key, you don't need to provide the private key separately anymore
4
+
1
5
## v0.7.4 (2023-12-22)
2
6
3
7
- Replace k8s.io/apimachinery with cenkalti/backoff
0 commit comments