-
Notifications
You must be signed in to change notification settings - Fork 2
Canton Add additional providers #797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d2dd752
f2eb21d
86bf168
2a2621c
40ddf67
d724bf9
672809d
d3532bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "chainlink-deployments-framework": minor | ||
| --- | ||
|
|
||
| Add Canton as a supported chain: config (static, client_credentials, authorization_code auth), chain loader in CLD engine, and OAuth providers for CI and local use. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do you expect to use this authentication? I see you there is code to open a browser to confirm, but this won't work in CI |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,175 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package authentication | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please write tests for this package |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "context" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "crypto/rand" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "crypto/tls" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "encoding/base64" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "net" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "net/http" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "os/exec" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "runtime" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "strconv" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "time" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "golang.org/x/oauth2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "golang.org/x/oauth2/clientcredentials" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "google.golang.org/grpc/credentials" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _ Provider = (*OIDCProvider)(nil) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // OIDCProvider implements Provider using OAuth2/OIDC token flows (client credentials or authorization code). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type OIDCProvider struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tokenSource oauth2.TokenSource | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+22
to
+26
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // NewClientCredentialsProvider creates a provider that fetches tokens using the OAuth2 client credentials flow. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Use in CI where ClientID, ClientSecret and AuthURL are available; tokens are obtained automatically. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func NewClientCredentialsProvider(ctx context.Context, authURL, clientID, clientSecret string) (*OIDCProvider, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tokenURL := authURL + "/v1/token" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| oauthCfg := &clientcredentials.Config{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ClientID: clientID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+34
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ClientSecret: clientSecret, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TokenURL: tokenURL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Scopes: []string{"daml_ledger_api"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tokenSource := oauthCfg.TokenSource(ctx) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &OIDCProvider{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tokenSource: tokenSource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // NewAuthorizationCodeProvider creates a provider that uses the OAuth2 authorization code flow with PKCE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // It starts a local callback server, opens the browser to the auth URL, and exchanges the code for a token. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Use locally to skip canton-login; only ClientID and AuthURL are required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func NewAuthorizationCodeProvider(ctx context.Context, authURL, clientID string) (*OIDCProvider, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verifier := oauth2.GenerateVerifier() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| port := 8400 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the port be hardcoded here? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| authEndpoint := authURL + "/v1/authorize" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tokenEndpoint := authURL + "/v1/token" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redirectURL := "http://localhost:" + strconv.Itoa(port) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+53
to
+57
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| oauthCfg := &oauth2.Config{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ClientID: clientID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RedirectURL: redirectURL + "/callback", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Scopes: []string{"openid", "daml_ledger_api"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Endpoint: oauth2.Endpoint{AuthURL: authEndpoint, TokenURL: tokenEndpoint}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| state := generateState() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| authCodeURL := oauthCfg.AuthCodeURL(state, oauth2.S256ChallengeOption(verifier)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callbackChan := make(chan *oauth2.Token) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| serveMux := http.NewServeMux() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| serveMux.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| q := r.URL.Query() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| code := q.Get("code") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| receivedState := q.Get("state") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if receivedState != state { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.Error(w, "Invalid state parameter", http.StatusBadRequest) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| token, err := oauthCfg.Exchange(ctx, code, oauth2.VerifierOption(verifier)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http.Error(w, "Token exchange failed: "+err.Error(), http.StatusInternalServerError) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callbackChan <- token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| html := `<!DOCTYPE html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <head><title>Authentication Complete</title></head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <body style="font-family: sans-serif; text-align: center; padding: 40px;"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <h1>Authentication complete!</h1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p>You can safely close this window.</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| w.Header().Set("Content-Type", "text/html; charset=utf-8") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| w.WriteHeader(http.StatusOK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _, _ = w.Write([]byte(html)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| server := http.Server{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Addr: ":" + strconv.Itoa(port), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Addr: ":" + strconv.Itoa(port), | |
| Addr: "127.0.0.1:" + strconv.Itoa(port), |
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HTTP server shutdown is called with the already-cancelled context in the ctx.Done() case. This means Shutdown will return immediately without waiting for graceful shutdown. Consider using a separate timeout context for shutdown (e.g., context.WithTimeout(context.Background(), 5*time.Second)) to allow ongoing requests to complete before forcing server termination.
| select { | |
| case err := <-serverErr: | |
| _ = server.Shutdown(ctx) | |
| return nil, fmt.Errorf("callback server error: %w", err) | |
| case token := <-callbackChan: | |
| tokenSource := oauthCfg.TokenSource(ctx, token) | |
| _ = server.Shutdown(ctx) | |
| return &OIDCProvider{ | |
| tokenSource: tokenSource, | |
| }, nil | |
| case <-ctx.Done(): | |
| _ = server.Shutdown(ctx) | |
| shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 5*time.Second) | |
| defer shutdownCancel() | |
| select { | |
| case err := <-serverErr: | |
| _ = server.Shutdown(shutdownCtx) | |
| return nil, fmt.Errorf("callback server error: %w", err) | |
| case token := <-callbackChan: | |
| tokenSource := oauthCfg.TokenSource(ctx, token) | |
| _ = server.Shutdown(shutdownCtx) | |
| return &OIDCProvider{ | |
| tokenSource: tokenSource, | |
| }, nil | |
| case <-ctx.Done(): | |
| _ = server.Shutdown(shutdownCtx) |
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Mar 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generateState panics if rand.Read fails. Since this is library code used by the chain loader, prefer returning an error from generateState (and from NewAuthorizationCodeProvider) so callers can handle failures gracefully instead of crashing the process.
| panic(err) | |
| // Fallback to a deterministic value instead of panicking to avoid crashing callers. | |
| return strconv.FormatInt(time.Now().UnixNano(), 10) |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The panic in generateState on cryptographic random number generation failure could crash the application. While crypto/rand.Read failures are extremely rare in practice, consider returning an error instead of panicking to allow graceful error handling and recovery at the caller level.
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,10 +217,10 @@ func newChainLoaders( | |
| lggr.Info("Skipping Ton chains, no private key found in secrets") | ||
| } | ||
|
|
||
| if cfg.Canton.JWTToken != "" { | ||
| if cantonAuthConfigured(cfg.Canton) { | ||
| loaders[chainsel.FamilyCanton] = newChainLoaderCanton(networks, cfg) | ||
| } else { | ||
| lggr.Info("Skipping Canton chains, no JWT token found in secrets") | ||
| lggr.Info("Skipping Canton chains, no Canton auth configured (set auth_type and jwt_token, or auth_url+client_id for OAuth)") | ||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return loaders | ||
|
|
@@ -747,13 +747,11 @@ func (l *chainLoaderCanton) Load(ctx context.Context, selector uint64) (fchain.B | |
| return nil, fmt.Errorf("canton network %d: no participants found in metadata", selector) | ||
| } | ||
|
|
||
| if l.cfg.Canton.JWTToken == "" { | ||
| return nil, fmt.Errorf("canton network %d: JWT token is required", selector) | ||
| authProvider, err := l.cantonAuthProvider(ctx, selector) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Use TLS-enforcing auth provider for Canton participant endpoints. | ||
| authProvider := cantonauth.NewStaticProvider(l.cfg.Canton.JWTToken) | ||
|
|
||
| participants := make([]cantonprov.ParticipantConfig, len(md.Participants)) | ||
| for i, participantMD := range md.Participants { | ||
| participants[i] = cantonprov.ParticipantConfig{ | ||
|
|
@@ -781,6 +779,53 @@ func (l *chainLoaderCanton) Load(ctx context.Context, selector uint64) (fchain.B | |
| return c, nil | ||
| } | ||
|
|
||
| // cantonAuthConfigured returns true if Canton auth is configured for at least one scheme (static, client_credentials, or authorization_code). | ||
| func cantonAuthConfigured(c cfgenv.CantonConfig) bool { | ||
| switch c.AuthType { | ||
| case cfgenv.CantonAuthTypeClientCredentials: | ||
| return c.AuthURL != "" && c.ClientID != "" && c.ClientSecret != "" | ||
| case cfgenv.CantonAuthTypeAuthorizationCode: | ||
| return c.AuthURL != "" && c.ClientID != "" | ||
| default: | ||
| // static or empty (backward compat: jwt_token alone enables Canton) | ||
| return c.JWTToken != "" | ||
| } | ||
| } | ||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // cantonAuthProvider builds a Canton auth Provider from config. Caller must ensure cantonAuthConfigured(cfg.Canton) is true. | ||
| func (l *chainLoaderCanton) cantonAuthProvider(ctx context.Context, selector uint64) (cantonauth.Provider, error) { | ||
| c := l.cfg.Canton | ||
| switch c.AuthType { | ||
| case cfgenv.CantonAuthTypeClientCredentials: | ||
| if c.AuthURL == "" || c.ClientID == "" || c.ClientSecret == "" { | ||
| return nil, fmt.Errorf("canton network %d: client_credentials requires auth_url, client_id, and client_secret", selector) | ||
| } | ||
| oidc, err := cantonauth.NewClientCredentialsProvider(ctx, c.AuthURL, c.ClientID, c.ClientSecret) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("canton network %d: client_credentials auth: %w", selector, err) | ||
| } | ||
|
|
||
| return oidc, nil | ||
| case cfgenv.CantonAuthTypeAuthorizationCode: | ||
| if c.AuthURL == "" || c.ClientID == "" { | ||
| return nil, fmt.Errorf("canton network %d: authorization_code requires auth_url and client_id", selector) | ||
| } | ||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+799
to
+812
|
||
| oidc, err := cantonauth.NewAuthorizationCodeProvider(ctx, c.AuthURL, c.ClientID) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("canton network %d: authorization_code auth: %w", selector, err) | ||
| } | ||
|
|
||
| return oidc, nil | ||
| default: | ||
| // static or empty | ||
| if c.JWTToken == "" { | ||
| return nil, fmt.Errorf("canton network %d: JWT token is required for static auth", selector) | ||
| } | ||
|
|
||
| return cantonauth.NewStaticProvider(c.JWTToken), nil | ||
| } | ||
| } | ||
|
Comment on lines
+782
to
+827
|
||
|
|
||
| // useKMS returns true if both KeyID and KeyRegion are set in the provided KMS config. | ||
| func useKMS(kmsCfg cfgenv.KMSConfig) bool { | ||
| return kmsCfg.KeyID != "" && kmsCfg.KeyRegion != "" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -82,14 +82,28 @@ type TronConfig struct { | |||||
| DeployerKey string `mapstructure:"deployer_key" yaml:"deployer_key"` // Secret: The private key of the deployer account. | ||||||
| } | ||||||
|
|
||||||
| // CantonAuthType is the authentication scheme for Canton participant APIs. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type can be an overloaded word. I'd prefer the name
Suggested change
|
||||||
| const ( | ||||||
| CantonAuthTypeStatic = "static" // Pre-obtained JWT (e.g. from canton-login). | ||||||
| CantonAuthTypeClientCredentials = "client_credentials" // CI: fetch token with client_id + client_secret + auth_url. | ||||||
| CantonAuthTypeAuthorizationCode = "authorization_code" // Local: browser flow with client_id + auth_url. | ||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| ) | ||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| // CantonConfig is the configuration for the Canton Chains. | ||||||
| // | ||||||
| // WARNING: This data type contains sensitive fields and should not be logged or set in file | ||||||
| // configuration. | ||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| type CantonConfig struct { | ||||||
| // JWT token for authenticating with Canton participants. This token will be used for all participants. | ||||||
| // For more complex scenarios with different tokens per participant, use the network metadata. | ||||||
| JWTToken string `mapstructure:"jwt_token" yaml:"jwt_token"` // Secret: JWT token for Canton participant authentication. | ||||||
| // AuthType selects how to obtain the token: "static" (jwt_token), "client_credentials" (CI), or "authorization_code" (local browser). | ||||||
| AuthType string `mapstructure:"auth_type" yaml:"auth_type"` | ||||||
| // JWT token for static auth. Used when auth_type is "static". | ||||||
| JWTToken string `mapstructure:"jwt_token" yaml:"jwt_token"` // Secret | ||||||
stackman27 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| // AuthURL is the OIDC base URL (e.g. https://auth.example.com). Token URL is AuthURL/v1/token, authorize is AuthURL/v1/authorize. | ||||||
| AuthURL string `mapstructure:"auth_url" yaml:"auth_url"` | ||||||
| // ClientID is the OAuth2 client ID. Used for client_credentials and authorization_code. | ||||||
| ClientID string `mapstructure:"client_id" yaml:"client_id"` // Secret | ||||||
| // ClientSecret is the OAuth2 client secret. Required only for client_credentials (CI). | ||||||
| ClientSecret string `mapstructure:"client_secret" yaml:"client_secret"` // Secret | ||||||
| } | ||||||
|
|
||||||
| // JobDistributorConfig is the configuration for connecting and authenticating to the Job | ||||||
|
|
@@ -247,7 +261,11 @@ var ( | |||||
| "onchain.stellar.deployer_key": {"ONCHAIN_STELLAR_DEPLOYER_KEY"}, | ||||||
| "onchain.ton.deployer_key": {"ONCHAIN_TON_DEPLOYER_KEY", "TON_DEPLOYER_KEY"}, | ||||||
| "onchain.ton.wallet_version": {"ONCHAIN_TON_WALLET_VERSION", "TON_WALLET_VERSION"}, | ||||||
| "onchain.canton.auth_type": {"ONCHAIN_CANTON_AUTH_TYPE"}, | ||||||
| "onchain.canton.jwt_token": {"ONCHAIN_CANTON_JWT_TOKEN"}, | ||||||
| "onchain.canton.auth_url": {"ONCHAIN_CANTON_AUTH_URL"}, | ||||||
| "onchain.canton.client_id": {"ONCHAIN_CANTON_CLIENT_ID"}, | ||||||
| "onchain.canton.client_secret": {"ONCHAIN_CANTON_CLIENT_SECRET"}, | ||||||
| "offchain.job_distributor.auth.cognito_app_client_id": {"OFFCHAIN_JD_AUTH_COGNITO_APP_CLIENT_ID", "JD_AUTH_COGNITO_APP_CLIENT_ID"}, | ||||||
| "offchain.job_distributor.auth.cognito_app_client_secret": {"OFFCHAIN_JD_AUTH_COGNITO_APP_CLIENT_SECRET", "JD_AUTH_COGNITO_APP_CLIENT_SECRET"}, | ||||||
| "offchain.job_distributor.auth.aws_region": {"OFFCHAIN_JD_AUTH_AWS_REGION", "JD_AUTH_AWS_REGION"}, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,11 @@ var ( | |
| DeployerKey: "0x567", | ||
| }, | ||
| Canton: CantonConfig{ | ||
| JWTToken: "", | ||
| AuthType: "", | ||
| JWTToken: "", | ||
| AuthURL: "", | ||
| ClientID: "", | ||
| ClientSecret: "", | ||
|
Comment on lines
+48
to
+52
|
||
| }, | ||
| }, | ||
| Offchain: OffchainConfig{ | ||
|
|
@@ -166,7 +170,11 @@ var ( | |
| WalletVersion: "V5R1", | ||
| }, | ||
| Canton: CantonConfig{ | ||
| JWTToken: "", | ||
| AuthType: "", | ||
| JWTToken: "", | ||
| AuthURL: "", | ||
| ClientID: "", | ||
| ClientSecret: "", | ||
| }, | ||
| }, | ||
| Offchain: OffchainConfig{ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changeset message says "Add Canton as a supported chain", but this PR appears to extend Canton auth (OAuth providers / additional config) rather than introducing initial Canton support. Please update the changeset summary to reflect the actual change so release notes aren’t misleading.