Skip to content

Commit f15362d

Browse files
author
mbokan
committed
Remove unused value_key, fix default refresh_interval in docs, reorder credential lookup
1 parent ac65fc4 commit f15362d

5 files changed

Lines changed: 10 additions & 15 deletions

File tree

extension/basicauthextension/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ The extension supports fetching credentials from AWS Secrets Manager with automa
5050

5151
- `secret_arn` (required): The ARN of the secret in AWS Secrets Manager.
5252
- `region` (required): The AWS region where the secret is stored.
53-
- `refresh_interval` (optional, default: `5m`): How often to re-fetch the secret.
53+
- `refresh_interval` (optional, default: `30m`): How often to re-fetch the secret.
5454
- `username_key` (required for client_auth): The JSON key containing the username.
5555
- `password_key` (required for client_auth): The JSON key containing the password.
56-
- `value_key` (optional for htpasswd): If set, treats the secret as JSON and extracts this key. Otherwise, the raw secret string is used as htpasswd content.
5756

5857
The extension uses the AWS SDK's default credential chain (`aws-sdk-go-v2/config.LoadDefaultConfig`). This means the collector workload must have an IAM identity that grants `secretsmanager:GetSecretValue` on the target secret. If the secret is encrypted with a customer managed KMS key (CMK), the identity also needs `kms:Decrypt` on that key's ARN. In practice, attach an instance profile role (EC2), a pod identity or IRSA role (EKS), or a task role (ECS) to the workload running the collector.
5958
## Configuration
@@ -93,7 +92,6 @@ extensions:
9392
aws_secret:
9493
secret_arn: "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-htpasswd"
9594
region: "us-east-1"
96-
value_key: "htpasswd_content"
9795
refresh_interval: 5m
9896

9997
receivers:

extension/basicauthextension/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ type AWSSecretClientConfig struct {
3232
}
3333

3434
// AWSSecretHtpasswdConfig configures AWS Secrets Manager as a credential source for server auth.
35-
// The secret can be raw htpasswd content, or a JSON object with a field containing htpasswd content.
35+
// The secret value is used directly as htpasswd content.
3636
type AWSSecretHtpasswdConfig struct {
3737
SecretARN string `mapstructure:"secret_arn"`
3838
Region string `mapstructure:"region"`
39-
ValueKey string `mapstructure:"value_key"`
4039
RefreshInterval time.Duration `mapstructure:"refresh_interval"`
4140
}
4241

extension/basicauthextension/config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ func TestLoadConfig(t *testing.T) {
7171
AWSSecret: &AWSSecretHtpasswdConfig{
7272
SecretARN: "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-htpasswd",
7373
Region: "us-east-1",
74-
ValueKey: "htpasswd_content",
7574
RefreshInterval: 10 * time.Minute,
7675
},
7776
},

extension/basicauthextension/extension.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,28 +207,28 @@ func (ba *basicAuthClient) Shutdown(_ context.Context) error {
207207
}
208208

209209
func (ba *basicAuthClient) Username() string {
210-
if c := ba.creds.Load(); c != nil {
211-
return c.username
212-
}
213210
if ba.usernameResolver != nil {
214211
return ba.usernameResolver.Value()
215212
}
216-
if ba.clientAuth != nil {
213+
if ba.clientAuth != nil && ba.clientAuth.Username != "" {
217214
return ba.clientAuth.Username
218215
}
216+
if c := ba.creds.Load(); c != nil {
217+
return c.username
218+
}
219219
return ""
220220
}
221221

222222
func (ba *basicAuthClient) Password() string {
223-
if c := ba.creds.Load(); c != nil {
224-
return c.password
225-
}
226223
if ba.passwordResolver != nil {
227224
return ba.passwordResolver.Value()
228225
}
229-
if ba.clientAuth != nil {
226+
if ba.clientAuth != nil && string(ba.clientAuth.Password) != "" {
230227
return string(ba.clientAuth.Password)
231228
}
229+
if c := ba.creds.Load(); c != nil {
230+
return c.password
231+
}
232232
return ""
233233
}
234234

extension/basicauthextension/testdata/config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ basicauth/server_aws:
3232
aws_secret:
3333
secret_arn: "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-htpasswd"
3434
region: "us-east-1"
35-
value_key: "htpasswd_content"
3635
refresh_interval: 10m

0 commit comments

Comments
 (0)