Skip to content

Bug: c.Insecure field is incorrectly assigned KeycloackEnable value in NewClient #434

@Priyanshubhartistm

Description

@Priyanshubhartistm

Describe the bug

In pkg/connectors/microcks_client.go, the NewClient function incorrectly assigns configCtx.Server.KeycloackEnable (a boolean flag indicating whether Keycloak authentication is enabled) to the c.Insecure field (which semantically should represent TLS insecurity, i.e., skip-verify).

// pkg/connectors/microcks_client.go, lines 127-129
c.ServerAddr = configCtx.Server.Server
c.Insecure = configCtx.Server.KeycloackEnable  // ← BUG: assigns Keycloak-enabled flag to Insecure
c.InsecureTLS = configCtx.Server.InsecureTLS

The microcksClient struct has two separate boolean fields for TLS-related concerns:

type microcksClient struct {
    // ...
    InsecureTLS  bool   // skip TLS verification
    Insecure     bool   // field with ambiguous purpose, incorrectly populated
    // ...
}

KeycloackEnable indicates whether the server uses Keycloak for authentication - it has nothing to do with TLS security posture. Setting c.Insecure = configCtx.Server.KeycloackEnable means:

  • When Keycloak is enabled, c.Insecure is set to true
  • When Keycloak is disabled, c.Insecure is set to false

This is semantically backwards and incorrect.

Proposed fix:

// Before (incorrect):
c.Insecure = configCtx.Server.KeycloackEnable

// After (correct):
c.InsecureTLS = configCtx.Server.InsecureTLS
// Remove c.Insecure entirely if it is unused, or assign correctly:
// c.Insecure = configCtx.Server.InsecureTLS

Expected behavior

c.Insecure should either:

  1. Be assigned from configCtx.Server.InsecureTLS (same as c.InsecureTLS), OR
  2. Be removed if it is redundant with InsecureTLS

Actual behavior

c.Insecure is set based on whether Keycloak is enabled - a completely unrelated concern.

How to Reproduce?

  1. Login to a Microcks server that has Keycloak enabled:
    microcks login http://localhost:8080
    
  2. Observe the saved config - keycloakEnable: true is persisted for this server context.
  3. Run any command using the saved context (e.g., microcks import):
    • NewClient is called and reads the context
    • c.Insecure is set to true (from KeycloackEnable: true) - even if no --insecure-tls flag was used

Microcks version or git rev

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

No response

Additional information

The c.Insecure field is declared in the microcksClient struct but is never subsequently read in any method - making this either dead assignment or a field that was intended to propagate TLS config but is being set from the wrong source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions