Skip to content

Commit 4226c9f

Browse files
committed
align k8s auth conf parameters (encode jwt, trim v2 endpoint
Signed-off-by: Kobbi Gal <[email protected]>
1 parent 4bf9472 commit 4226c9f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

secretstores/akeyless/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ The Akeyless secret store component supports the following configuration options
1717

1818
| Field | Required | Description | Example |
1919
|-------|----------|-------------|---------|
20-
| `gatewayUrl` | No | The Akeyless Gateway URL. Default is https://api.akeyless.io. | `https://your-gateway.akeyless.io` |
20+
| `gatewayUrl` | No | The Akeyless Gateway API URL. Default is https://api.akeyless.io. | `https://gw.akeyless.svc.cluster.local:8000/api/v2` |
2121
| `gatewayTLSCA` | No | The `base64`-encoded PEM certificate of the Akeyless Gateway. Use this when connecting to a gateway with a self-signed or custom CA certificate. | `LS0tLS1CRUdJTi...` |
2222
| `accessId` | Yes | The Akeyless authentication access ID. | `p-123456780wm` |
2323
| `jwt` | No | If using an OAuth2.0/JWT access ID, specify the JSON Web Token | `eyJ...` |
2424
| `accessKey` | No | If using an API Key access ID, specify the API key | `ABCD123...=` |
2525
| `k8sAuthConfigName` | No | If using the k8s auth method, specify the name of the k8s auth config. | `k8s-auth-config` |
2626
| `k8sGatewayUrl` | No | The gateway URL that where the k8s auth config is located. | `http://gw.akeyless.svc.cluster.local:8000` |
2727
| `k8sServiceAccountToken` | No | If using the k8s auth method, specify the service account token. If not specified,
28-
we will try to read it from the default service account token file. | `eyJ...` |
28+
we will try to read it from the default service account token file `/var/run/secrets/kubernetes.io/serviceaccount/token`. | `eyJ...` |
2929

3030

3131

@@ -108,7 +108,7 @@ spec:
108108
- name: gatewayUrl
109109
value: "http://unified.akeyless.svc.cluster.local:8000/api/v2"
110110
- name: accessId
111-
value: "p-1234Abcdwm"
111+
value: "p-1234Abcdkm"
112112
- name: k8sAuthConfigName
113113
value: "us-east-1-prod-akeyless-k8s-conf"
114114
- name: k8sGatewayUrl

secretstores/akeyless/utils.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,20 @@ func setK8SAuthConfiguration(metadata akeylessMetadata, authRequest *akeyless.Au
209209
}
210210
metadata.K8sServiceAccountToken = string(token)
211211
}
212+
213+
// base64 encode the token if it's not already encoded
214+
if _, err := base64.StdEncoding.DecodeString(metadata.K8sServiceAccountToken); err != nil {
215+
a.logger.Info("k8sServiceAccountToken is not base64 encoded, encoding it...")
216+
metadata.K8sServiceAccountToken = base64.StdEncoding.EncodeToString([]byte(metadata.K8sServiceAccountToken))
217+
}
218+
authRequest.SetK8sServiceAccountToken(metadata.K8sServiceAccountToken)
219+
212220
if metadata.K8SGatewayURL == "" {
213221
a.logger.Debug("k8s gateway url is missing, using gatewayUrl")
214222
metadata.K8SGatewayURL = metadata.GatewayURL
215223
}
224+
metadata.K8SGatewayURL = strings.TrimSuffix(metadata.K8SGatewayURL, "/api/v2")
216225
authRequest.SetGatewayUrl(metadata.K8SGatewayURL)
217-
authRequest.SetK8sServiceAccountToken(metadata.K8sServiceAccountToken)
218226
return nil
219227
}
220228

0 commit comments

Comments
 (0)