Skip to content

Commit 6a8655d

Browse files
committed
Also add client_id to make it more explicit
1 parent 534e3b1 commit 6a8655d

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
1111
## Unreleased
1212
- [#38](https://github.com/thanos-io/objstore/pull/38) GCS: Upgrade cloud.google.com/go/storage version to `v1.43.0`.
1313
- [#145](https://github.com/thanos-io/objstore/pull/145) Include content length in the response of Get and GetRange.
14-
- [#157](https://github.com/thanos-io/objstore/pull/157) Azure: Add `tenant_id` and `client_secret` configs.
14+
- [#157](https://github.com/thanos-io/objstore/pull/157) Azure: Add `tenant_id`, `client_id` and `client_secret` configs.
1515

1616
### Fixed
1717
- [#153](https://github.com/thanos-io/objstore/pull/153) Metrics: Fix `objstore_bucket_operation_duration_seconds_*` for `get` and `get_range` operations.

providers/azure/azure.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var DefaultConfig = Config{
4646

4747
// Config Azure storage configuration.
4848
type Config struct {
49+
ClientID string `yaml:"client_id"`
4950
ClientSecret string `yaml:"client_secret"`
5051
TenantID string `yaml:"tenant_id"`
5152
StorageAccountName string `yaml:"storage_account"`
@@ -86,8 +87,12 @@ func (conf *Config) validate() error {
8687
errMsg = append(errMsg, "user_assigned_id cannot be set when using storage_connection_string authentication")
8788
}
8889

89-
if (conf.TenantID != "" || conf.ClientSecret != "") && (conf.TenantID == "" || conf.ClientSecret == "") {
90-
errMsg = append(errMsg, "tenant_id, user_assigned_id, and client_secret must be set together")
90+
if conf.UserAssignedID != "" && conf.ClientID != "" {
91+
errMsg = append(errMsg, "user_assigned_id cannot be set when using client_id authentication")
92+
}
93+
94+
if (conf.TenantID != "" || conf.ClientSecret != "" || conf.ClientID != "") && (conf.TenantID == "" || conf.ClientSecret == "" || conf.ClientID == "") {
95+
errMsg = append(errMsg, "tenant_id, client_id, and client_secret must be set together")
9196
}
9297

9398
if conf.StorageAccountKey != "" && conf.StorageConnectionString != "" {

providers/azure/azure_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ container: "MyContainer"`),
149149
config: []byte(`storage_account: "myAccount"
150150
storage_account_key: ""
151151
tenant_id: "1234-56578678-655"
152-
user_assigned_id: "1234-56578678-655"
152+
client_id: "1234-56578678-655"
153153
client_secret: "1234-56578678-655"
154154
container: "MyContainer"`),
155155
wantFailParse: false,
@@ -159,7 +159,7 @@ container: "MyContainer"`),
159159
name: "Valid ClientID and ClientSecret but missing TenantID",
160160
config: []byte(`storage_account: "myAccount"
161161
storage_account_key: ""
162-
user_assigned_id: "1234-56578678-655"
162+
client_id: "1234-56578678-655"
163163
client_secret: "1234-56578678-655"
164164
container: "MyContainer"`),
165165
wantFailParse: false,

providers/azure/helpers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ func getTokenCredential(conf Config) (azcore.TokenCredential, error) {
8989
return azidentity.NewDefaultAzureCredential(nil)
9090
}
9191

92-
if conf.ClientSecret != "" && conf.TenantID != "" {
93-
return azidentity.NewClientSecretCredential(conf.TenantID, conf.UserAssignedID, conf.ClientSecret, &azidentity.ClientSecretCredentialOptions{})
92+
if conf.ClientSecret != "" && conf.TenantID != "" && conf.ClientID != "" {
93+
return azidentity.NewClientSecretCredential(conf.TenantID, conf.ClientID, conf.ClientSecret, &azidentity.ClientSecretCredentialOptions{})
9494
}
9595

9696
msiOpt := &azidentity.ManagedIdentityCredentialOptions{}

0 commit comments

Comments
 (0)