Skip to content

feat: add development mode handling for gateway registration and host key validation#52

Merged
victorvhs017 merged 2 commits intomainfrom
fix/enable-local-development
Nov 5, 2025
Merged

feat: add development mode handling for gateway registration and host key validation#52
victorvhs017 merged 2 commits intomainfrom
fix/enable-local-development

Conversation

@victorvhs017
Copy link
Contributor

Description 📣

Enables the relay and gateway commands on localhost using a local instance of infisical on the --domain flag.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

Run the gateway and relay commands like:

 go run main.go relay start \
   --host=host.docker.internal \
   --name=local-relay \
   --auth-method=universal-auth \
   --client-id=... \
   --client-secret=... \
   --domain=http://localhost:8080

go run main.go gateway start --name=local-gateway --relay=local-relay --domain=http://localhost:8080 --token=...


Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

Adds development mode support for testing gateway and relay commands against localhost Infisical instances.

  • Overrides relay host to 127.0.0.1 when CLI_VERSION == "devel" (set at build time via ldflags)
  • Skips SSH host certificate validation in development mode for easier local testing
  • Enables developers to test gateway/relay functionality without production infrastructure

Confidence Score: 4/5

  • Safe to merge with low risk - changes only affect development builds
  • The changes are well-scoped and only activate in development mode when CLI_VERSION == "devel". In production builds, CLI_VERSION is set via ldflags during the build process, so these code paths won't execute. The security bypass (skipping host cert validation) is appropriately gated and won't affect production usage.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/gateway-v2/gateway.go 4/5 Adds development mode handling for localhost testing by overriding relay host and skipping host certificate validation when CLI_VERSION == "devel"

Sequence Diagram

sequenceDiagram
    participant G as Gateway
    participant API as Infisical API
    participant R as Relay Server
    
    Note over G: Start Gateway Command
    G->>API: Register Gateway Request
    API-->>G: Registration Response (RelayHost, Certificates)
    
    alt CLI_VERSION == "devel"
        Note over G: Override RelayHost to 127.0.0.1
        G->>G: certResp.RelayHost = "127.0.0.1"
    end
    
    G->>G: Setup TLS Config with Certs
    G->>R: SSH Connection to RelayHost:2222
    
    alt SSH Host Key Validation
        R-->>G: Host Certificate
        alt CLI_VERSION == "devel"
            Note over G: Skip validation in dev mode
            G->>G: return nil (no validation)
        else Production Mode
            G->>G: validateHostCertificate()
        end
    end
    
    G-->>R: Connection Established
    Note over G,R: Handle Incoming Channels
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@victorvhs017 victorvhs017 requested a review from varonix0 November 5, 2025 14:25
@victorvhs017 victorvhs017 requested a review from varonix0 November 5, 2025 19:02
@victorvhs017 victorvhs017 merged commit 3506b3e into main Nov 5, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants