Skip to content

Commit 690655c

Browse files
committed
feat: add file-based authentication support for ClusterTriggerAuthentication
We're using a custom secret solution that decrypts credentials via an init container and writes the resulting credentials to a shared emptyDir. The current `AuthenticationRef` is limiting as it forces us to store the credential in a `Secret`/`ConfigMap` instead and we'd like to avoid doing that due to the fact that we cannot use these safely in our environment. Happy to discuss viable alternatives but for now the implementation looks as follows: • Add optional FilePath field to AuthenticationRef for reading auth params from mounted files • Implement readAuthParamsFromFile helper to parse JSON credentials • Modify resolveAuthRef to handle file-based auth when FilePath is specified • Add comprehensive tests for new functionality • Maintain backward compatibility with existing authentication methods Fix #7083 Signed-off-by: Jonas-Taha El Sesiy <[email protected]>
1 parent e5397c8 commit 690655c

File tree

12 files changed

+327
-15
lines changed

12 files changed

+327
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
6565

6666
- **General**: Add error and event for mismatching input property ([#6721](https://github.com/kedacore/keda/issues/6721))
6767
- **General**: Add fallback support for triggers of `Value` metric type ([#6655](https://github.com/kedacore/keda/pull/6655))
68+
- **General**: Add file-based authentication support for ClusterTriggerAuthentication ([#7083](https://github.com/kedacore/keda/issues/7083))
6869
- **General**: Add support for pause scale in annotation ([#6902](https://github.com/kedacore/keda/issues/6902))
6970
- **General**: Enable support on s390x for KEDA ([#6543](https://github.com/kedacore/keda/issues/6543))
7071
- **General**: Introduce new Solace Direct Messaging scaler ([#6545](https://github.com/kedacore/keda/issues/6545))

apis/keda/v1alpha1/scaletriggers_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ type AuthenticationRef struct {
4646
// Kind of the resource being referred to. Defaults to TriggerAuthentication.
4747
// +optional
4848
Kind string `json:"kind,omitempty"`
49+
// FilePath specifies a file containing auth parameters as JSON map[string]string.
50+
// When set, auth params are read directly from this file instead of fetching TriggerAuthentication.
51+
// +optional
52+
FilePath string `json:"filePath,omitempty"`
4953
}
5054

5155
// ValidateTriggers checks that general trigger metadata are valid, it checks:

apis/keda/v1alpha1/scaletriggers_types_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package v1alpha1
22

33
import (
4+
"encoding/json"
45
"testing"
56

67
"github.com/stretchr/testify/assert"
@@ -103,3 +104,22 @@ func TestValidateTriggers(t *testing.T) {
103104
})
104105
}
105106
}
107+
108+
func TestAuthenticationRef_WithFilePath(t *testing.T) {
109+
authRef := AuthenticationRef{
110+
Name: "test-auth",
111+
Kind: "ClusterTriggerAuthentication",
112+
FilePath: "/mnt/auth/creds.json",
113+
}
114+
// Test JSON marshaling/unmarshaling
115+
data, err := json.Marshal(authRef)
116+
assert.NoError(t, err)
117+
assert.Contains(t, string(data), `"filePath":"/mnt/auth/creds.json"`)
118+
119+
var unmarshaled AuthenticationRef
120+
err = json.Unmarshal(data, &unmarshaled)
121+
assert.NoError(t, err)
122+
assert.Equal(t, "/mnt/auth/creds.json", unmarshaled.FilePath)
123+
assert.Equal(t, "test-auth", unmarshaled.Name)
124+
assert.Equal(t, "ClusterTriggerAuthentication", unmarshaled.Kind)
125+
}

config/crd/bases/eventing.keda.sh_cloudeventsources.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ spec:
4949
AuthenticationRef points to the TriggerAuthentication or ClusterTriggerAuthentication object that
5050
is used to authenticate the scaler with the environment
5151
properties:
52+
filePath:
53+
description: |-
54+
FilePath specifies a file containing auth parameters as JSON map[string]string.
55+
When set, auth params are read directly from this file instead of fetching TriggerAuthentication.
56+
type: string
5257
kind:
5358
description: Kind of the resource being referred to. Defaults
5459
to TriggerAuthentication.

config/crd/bases/eventing.keda.sh_clustercloudeventsources.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ spec:
4747
AuthenticationRef points to the TriggerAuthentication or ClusterTriggerAuthentication object that
4848
is used to authenticate the scaler with the environment
4949
properties:
50+
filePath:
51+
description: |-
52+
FilePath specifies a file containing auth parameters as JSON map[string]string.
53+
When set, auth params are read directly from this file instead of fetching TriggerAuthentication.
54+
type: string
5055
kind:
5156
description: Kind of the resource being referred to. Defaults
5257
to TriggerAuthentication.

config/crd/bases/keda.sh_scaledjobs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8506,6 +8506,11 @@ spec:
85068506
AuthenticationRef points to the TriggerAuthentication or ClusterTriggerAuthentication object that
85078507
is used to authenticate the scaler with the environment
85088508
properties:
8509+
filePath:
8510+
description: |-
8511+
FilePath specifies a file containing auth parameters as JSON map[string]string.
8512+
When set, auth params are read directly from this file instead of fetching TriggerAuthentication.
8513+
type: string
85098514
kind:
85108515
description: Kind of the resource being referred to. Defaults
85118516
to TriggerAuthentication.

config/crd/bases/keda.sh_scaledobjects.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ spec:
284284
AuthenticationRef points to the TriggerAuthentication or ClusterTriggerAuthentication object that
285285
is used to authenticate the scaler with the environment
286286
properties:
287+
filePath:
288+
description: |-
289+
FilePath specifies a file containing auth parameters as JSON map[string]string.
290+
When set, auth params are read directly from this file instead of fetching TriggerAuthentication.
291+
type: string
287292
kind:
288293
description: Kind of the resource being referred to. Defaults
289294
to TriggerAuthentication.

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ require (
9797
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.35.0
9898
go.opentelemetry.io/otel/metric v1.35.0
9999
go.temporal.io/sdk v1.33.1
100-
go.uber.org/atomic v1.11.0
101100
go.uber.org/automaxprocs v1.6.0
102101
go.uber.org/mock v0.5.0
103102
golang.org/x/crypto v0.37.0
@@ -212,7 +211,7 @@ require (
212211
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
213212
github.com/fatih/color v1.18.0 // indirect
214213
github.com/felixge/httpsnoop v1.0.4 // indirect
215-
github.com/fsnotify/fsnotify v1.9.0 // indirect
214+
github.com/fsnotify/fsnotify v1.9.0
216215
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
217216
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
218217
github.com/go-errors/errors v1.5.1 // indirect
@@ -286,7 +285,7 @@ require (
286285
github.com/mattn/go-colorable v0.1.13 // indirect
287286
github.com/mattn/go-isatty v0.0.20 // indirect
288287
github.com/mattn/go-runewidth v0.0.15 // indirect
289-
github.com/microsoft/go-mssqldb v1.8.0 // indirect
288+
github.com/microsoft/go-mssqldb v1.8.0
290289
github.com/mitchellh/go-homedir v1.1.0 // indirect
291290
github.com/moby/spdystream v0.5.0 // indirect
292291
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -341,6 +340,7 @@ require (
341340
go.opentelemetry.io/otel/trace v1.35.0 // indirect
342341
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
343342
go.temporal.io/api v1.44.1 // indirect
343+
go.uber.org/atomic v1.11.0 // indirect
344344
go.uber.org/multierr v1.11.0 // indirect
345345
go.uber.org/zap v1.27.0
346346
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect

go.sum

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -635,15 +635,12 @@ github.com/Azure/azure-amqp-common-go/v4 v4.2.0/go.mod h1:GD3m/WPPma+621UaU6KNjK
635635
github.com/Azure/azure-kusto-go v0.16.1 h1:vCBWcQghmC1qIErUUgVNWHxGhZVStu1U/hki6iBA14k=
636636
github.com/Azure/azure-kusto-go v0.16.1/go.mod h1:9F2zvXH8B6eWzgI1S4k1ZXAIufnBZ1bv1cW1kB1n3D0=
637637
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible h1:fcYLmCpyNYRnvJbPerq7U0hS+6+I79yEDJBqVNcqUzU=
638-
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw=
639638
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 h1:Gt0j3wceWMwPmiazCa8MzMA0MfhmPIz0Qp0FJ6qcM0U=
640639
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM=
641-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0=
642640
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys=
643641
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE=
644642
github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY=
645643
github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8=
646-
github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8=
647644
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.0 h1:Bg8m3nq/X1DeePkAbCfb6ml6F3F0IunEhE8TMh+lY48=
648645
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.0/go.mod h1:j2chePtV91HrC22tGoRX3sGY42uF13WzmmV80/OdVAA=
649646
github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventgrid v0.5.0 h1:ANFaLubuHo9lLoee/1La180t1frTwd+0FcaQh2GTlg8=
@@ -662,6 +659,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.
662659
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0/go.mod h1:5kakwfW5CjC9KK+Q4wjXAg+ShuIm2mBMua0ZFj2C8PE=
663660
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0 h1:PiSrjRPpkQNjrM8H0WwKMnZUdu1RGMtd/LdGKUrOo+c=
664661
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0/go.mod h1:oDrbWx4ewMylP7xHivfgixbfGBT6APAwsSoHRKotnIc=
662+
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1 h1:MyVTgWR8qd/Jw1Le0NZebGBUCLbtak3bJ3z1OlqZBpw=
663+
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1/go.mod h1:GpPjLhVR9dnUoJMyHWSPy71xY9/lcmpzIPZXmF0FCVY=
665664
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.3.1 h1:mrkDCdkMsD4l9wjFGhofFHFrV43Y3c53RSLKOCJ5+Ow=
666665
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.3.1/go.mod h1:hPv41DbqMmnxcGralanA/kVlfdH5jv3T4LxGku2E1BY=
667666
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.1 h1:bFWuoEKg+gImo7pvkiQEFAc8ocibADgXeiLAxWhWmkI=
@@ -901,7 +900,6 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
901900
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
902901
github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U=
903902
github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE=
904-
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
905903
github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk=
906904
github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
907905
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
@@ -1054,7 +1052,6 @@ github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXe
10541052
github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
10551053
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
10561054
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
1057-
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
10581055
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
10591056
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
10601057
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
@@ -1419,7 +1416,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
14191416
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
14201417
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
14211418
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
1422-
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
14231419
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0=
14241420
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
14251421
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
@@ -1476,7 +1472,6 @@ github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk
14761472
github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
14771473
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
14781474
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
1479-
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
14801475
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
14811476
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
14821477
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
@@ -1748,7 +1743,6 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
17481743
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
17491744
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
17501745
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
1751-
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
17521746
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
17531747
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
17541748
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -1876,7 +1870,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
18761870
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
18771871
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
18781872
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
1879-
golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
18801873
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
18811874
golang.org/x/net v0.0.0-20210913180222-943fd674d43e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
18821875
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=

pkg/scaling/resolver/scale_resolvers.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ package resolver
1919
import (
2020
"bytes"
2121
"context"
22+
"encoding/json"
2223
"fmt"
24+
"os"
2325
"strconv"
2426
"strings"
2527

@@ -241,6 +243,19 @@ func resolveAuthRef(ctx context.Context, client client.Client, logger logr.Logge
241243
podIdentity := kedav1alpha1.AuthPodIdentity{Provider: kedav1alpha1.PodIdentityProviderNone}
242244
var err error
243245

246+
if triggerAuthRef != nil && triggerAuthRef.FilePath != "" {
247+
if triggerAuthRef.Kind != "ClusterTriggerAuthentication" {
248+
return nil, kedav1alpha1.AuthPodIdentity{Provider: kedav1alpha1.PodIdentityProviderNone},
249+
fmt.Errorf("filePath is only supported for ClusterTriggerAuthentication, got kind: %s", triggerAuthRef.Kind)
250+
}
251+
authParams, err := readAuthParamsFromFile(triggerAuthRef.FilePath)
252+
if err != nil {
253+
logger.Error(err, "error reading auth params from file", "filePath", triggerAuthRef.FilePath)
254+
return nil, kedav1alpha1.AuthPodIdentity{Provider: kedav1alpha1.PodIdentityProviderNone}, err
255+
}
256+
return authParams, kedav1alpha1.AuthPodIdentity{Provider: kedav1alpha1.PodIdentityProviderNone}, nil
257+
}
258+
244259
if namespace != "" && triggerAuthRef != nil && triggerAuthRef.Name != "" {
245260
triggerAuthSpec, triggerNamespace, err := getTriggerAuthSpec(ctx, client, triggerAuthRef, namespace)
246261
if err != nil {
@@ -614,6 +629,18 @@ func resolveAuthSecret(ctx context.Context, client client.Client, logger logr.Lo
614629
return string(result)
615630
}
616631

632+
func readAuthParamsFromFile(filePath string) (map[string]string, error) {
633+
data, err := os.ReadFile(filePath)
634+
if err != nil {
635+
return nil, fmt.Errorf("failed to read auth file %s: %w", filePath, err)
636+
}
637+
var params map[string]string
638+
if err := json.Unmarshal(data, &params); err != nil {
639+
return nil, fmt.Errorf("failed to unmarshal auth params from %s: %w", filePath, err)
640+
}
641+
return params, nil
642+
}
643+
617644
func resolveBoundServiceAccountToken(ctx context.Context, client client.Client, logger logr.Logger, namespace string, bsat *kedav1alpha1.BoundServiceAccountToken, acs *authentication.AuthClientSet) string {
618645
serviceAccountName := bsat.ServiceAccountName
619646
if serviceAccountName == "" {

0 commit comments

Comments
 (0)