Skip to content

Commit f2ff7d3

Browse files
authored
rename env (#1033)
1 parent ca31efb commit f2ff7d3

7 files changed

Lines changed: 66 additions & 12 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"chainlink-deployments-framework": patch
3+
---
4+
5+
Accept `ONCHAIN_CANTON_OKTA_*` environment variables as legacy aliases for Canton OAuth config and infer `client_credentials` when OAuth secrets are set without `ONCHAIN_CANTON_AUTH_STRATEGY`.

engine/cld/chains/chains.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,14 +786,31 @@ func (l *chainLoaderCanton) Load(ctx context.Context, selector uint64) (fchain.B
786786
return c, nil
787787
}
788788

789+
// cantonEffectiveAuthStrategy resolves the auth strategy from explicit config or available credentials.
790+
// When auth_strategy is unset, OAuth client credentials are inferred if auth_url, client_id, and
791+
// client_secret are all present (e.g. ONCHAIN_CANTON_OKTA_* from chainlink-deployments CI secrets).
792+
func cantonEffectiveAuthStrategy(c cfgenv.CantonConfig) string {
793+
if c.AuthStrategy != "" {
794+
return c.AuthStrategy
795+
}
796+
if c.AuthURL != "" && c.ClientID != "" && c.ClientSecret != "" {
797+
return cfgenv.CantonAuthStrategyClientCredentials
798+
}
799+
if c.AuthURL != "" && c.ClientID != "" {
800+
return cfgenv.CantonAuthStrategyAuthorizationCode
801+
}
802+
803+
return cfgenv.CantonAuthStrategyStatic
804+
}
805+
789806
// cantonAuthConfigured returns true if Canton auth is configured for at least one strategy.
790807
func cantonAuthConfigured(c cfgenv.CantonConfig) bool {
791-
switch c.AuthStrategy {
808+
switch cantonEffectiveAuthStrategy(c) {
792809
case cfgenv.CantonAuthStrategyClientCredentials:
793810
return c.AuthURL != "" && c.ClientID != "" && c.ClientSecret != ""
794811
case cfgenv.CantonAuthStrategyAuthorizationCode:
795812
return c.AuthURL != "" && c.ClientID != ""
796-
case "", cfgenv.CantonAuthStrategyStatic:
813+
case cfgenv.CantonAuthStrategyStatic:
797814
return c.JWTToken != ""
798815
default:
799816
return false
@@ -803,7 +820,7 @@ func cantonAuthConfigured(c cfgenv.CantonConfig) bool {
803820
// cantonAuthProvider builds a Canton auth Provider from config.
804821
func (l *chainLoaderCanton) cantonAuthProvider(ctx context.Context, selector uint64, insecureTransport bool) (cantonauth.Provider, error) {
805822
c := l.cfg.Canton
806-
switch c.AuthStrategy {
823+
switch cantonEffectiveAuthStrategy(c) {
807824
case cfgenv.CantonAuthStrategyClientCredentials:
808825
provider, err := cantonclientcreds.NewDiscoveryProvider(ctx, c.AuthURL, c.ClientID, c.ClientSecret)
809826
if err != nil {

engine/cld/chains/chains_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,11 @@ func Test_cantonAuthConfigured(t *testing.T) {
13991399
config: cfgenv.CantonConfig{AuthStrategy: cfgenv.CantonAuthStrategyClientCredentials, AuthURL: "https://auth.example.com", ClientID: "id", ClientSecret: "secret"},
14001400
want: true,
14011401
},
1402+
{
1403+
name: "client credentials inferred without strategy",
1404+
config: cfgenv.CantonConfig{AuthURL: "https://auth.example.com", ClientID: "id", ClientSecret: "secret"},
1405+
want: true,
1406+
},
14021407
{
14031408
name: "client credentials missing secret",
14041409
config: cfgenv.CantonConfig{AuthStrategy: cfgenv.CantonAuthStrategyClientCredentials, AuthURL: "https://auth.example.com", ClientID: "id"},

engine/cld/config/env/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ var (
283283
"onchain.ton.wallet_version": {"ONCHAIN_TON_WALLET_VERSION", "TON_WALLET_VERSION"},
284284
"onchain.canton.auth_strategy": {"ONCHAIN_CANTON_AUTH_STRATEGY"},
285285
"onchain.canton.jwt_token": {"ONCHAIN_CANTON_JWT_TOKEN"},
286-
"onchain.canton.auth_url": {"ONCHAIN_CANTON_AUTH_URL"},
287-
"onchain.canton.client_id": {"ONCHAIN_CANTON_CLIENT_ID"},
288-
"onchain.canton.client_secret": {"ONCHAIN_CANTON_CLIENT_SECRET"},
286+
"onchain.canton.auth_url": {"ONCHAIN_CANTON_AUTH_URL", "ONCHAIN_CANTON_OKTA_AUTHORIZER"},
287+
"onchain.canton.client_id": {"ONCHAIN_CANTON_CLIENT_ID", "ONCHAIN_CANTON_OKTA_CLIENT_ID"},
288+
"onchain.canton.client_secret": {"ONCHAIN_CANTON_CLIENT_SECRET", "ONCHAIN_CANTON_OKTA_CLIENT_SECRET"},
289289
"offchain.job_distributor.auth.cognito_app_client_id": {"OFFCHAIN_JD_AUTH_COGNITO_APP_CLIENT_ID", "JD_AUTH_COGNITO_APP_CLIENT_ID"},
290290
"offchain.job_distributor.auth.cognito_app_client_secret": {"OFFCHAIN_JD_AUTH_COGNITO_APP_CLIENT_SECRET", "JD_AUTH_COGNITO_APP_CLIENT_SECRET"},
291291
"offchain.job_distributor.auth.aws_region": {"OFFCHAIN_JD_AUTH_AWS_REGION", "JD_AUTH_AWS_REGION"},

engine/cld/config/env/config_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,21 @@ func Test_LoadEnv_Legacy(t *testing.T) { //nolint:paralleltest // see comment in
354354
assert.Equal(t, envCfg, got)
355355
}
356356

357+
func Test_LoadEnv_CantonOktaLegacyBindings(t *testing.T) { //nolint:paralleltest // see comment in setupEnvVars
358+
t.Setenv("ONCHAIN_CANTON_OKTA_AUTHORIZER", "https://smartcontract.okta.com/oauth2/ausspv7t7qurBgkou5d7")
359+
t.Setenv("ONCHAIN_CANTON_OKTA_CLIENT_ID", "0oat4r1zfzm83nL2m5d7")
360+
t.Setenv("ONCHAIN_CANTON_OKTA_CLIENT_SECRET", "test-client-secret")
361+
362+
got, err := LoadEnv()
363+
require.NoError(t, err)
364+
365+
assert.Equal(t, CantonConfig{
366+
AuthURL: "https://smartcontract.okta.com/oauth2/ausspv7t7qurBgkou5d7",
367+
ClientID: "0oat4r1zfzm83nL2m5d7",
368+
ClientSecret: "test-client-secret",
369+
}, got.Onchain.Canton)
370+
}
371+
357372
func Test_LoadEnv_BindsCREFromEnv(t *testing.T) { //nolint:paralleltest // see comment in setupEnvVars
358373
t.Setenv("CRE_API_KEY", "api-key-1")
359374
t.Setenv("CRE_TENANT_ID", "tenant-1")

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ require (
3333
github.com/smartcontractkit/ccip-owner-contracts v0.1.0
3434
github.com/smartcontractkit/chain-selectors v1.0.101
3535
github.com/smartcontractkit/chainlink-aptos v0.0.0-20260428085939-5c70de12dbfc
36-
github.com/smartcontractkit/chainlink-canton v0.0.0-20260602133237-99f834640c9d
37-
github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260512180815-d7a89b0a5784
36+
github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320
37+
github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260608180601-efa81bfdfda9
3838
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260129103204-4c8453dd8139
3939
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260129103204-4c8453dd8139
4040
github.com/smartcontractkit/chainlink-protos/job-distributor v0.18.0
4141
github.com/smartcontractkit/chainlink-protos/op-catalog v0.1.0
42-
github.com/smartcontractkit/chainlink-testing-framework/framework v0.16.4
42+
github.com/smartcontractkit/chainlink-testing-framework/framework v0.16.5
4343
github.com/smartcontractkit/chainlink-testing-framework/seth v1.51.5
4444
github.com/smartcontractkit/chainlink-ton v1.0.5-0.20260514223130-48bc90aca745
4545
github.com/smartcontractkit/chainlink-tron/relayer v0.0.11-0.20251014143056-a0c6328c91e9
4646
github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad
4747
github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba
4848
github.com/smartcontractkit/libocr v0.0.0-20260304194147-a03701e2c02e
49-
github.com/smartcontractkit/mcms v0.47.0
49+
github.com/smartcontractkit/mcms v0.47.1-0.20260609163952-0b2bf692ba6a
5050
github.com/spf13/cobra v1.10.2
5151
github.com/spf13/pflag v1.0.10
5252
github.com/spf13/viper v1.21.0
@@ -145,7 +145,7 @@ require (
145145
github.com/aws/aws-sdk-go-v2/service/sso v1.30.13 // indirect
146146
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.17 // indirect
147147
github.com/aws/aws-sdk-go-v2/service/sts v1.41.9 // indirect
148-
github.com/aws/smithy-go v1.27.0 // indirect
148+
github.com/aws/smithy-go v1.27.1 // indirect
149149
github.com/bahlo/generic-list-go v0.2.0 // indirect
150150
github.com/benbjohnson/clock v1.3.5 // indirect
151151
github.com/beorn7/perks v1.0.1 // indirect
@@ -194,7 +194,7 @@ require (
194194
github.com/go-ole/go-ole v1.3.0 // indirect
195195
github.com/go-playground/locales v0.14.1 // indirect
196196
github.com/go-playground/universal-translator v0.18.1 // indirect
197-
github.com/go-playground/validator/v10 v10.30.2 // indirect
197+
github.com/go-playground/validator/v10 v10.30.3 // indirect
198198
github.com/go-viper/mapstructure/v2 v2.5.0
199199
github.com/gofrs/flock v0.12.1 // indirect
200200
github.com/gogo/protobuf v1.3.2 // indirect

go.sum

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)