Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
069883c
feat: gateway v2 scaffolding
sheensantoscapadngan Aug 29, 2025
1fb0a48
misc: updated proxy to start tls server instead of tcp
sheensantoscapadngan Aug 29, 2025
cda3ac3
misc: added full server certificate chain to proxy tls
sheensantoscapadngan Aug 29, 2025
6f7eda5
misc: added log
sheensantoscapadngan Aug 29, 2025
3369207
misc: updated proxy to fetch client pem chain
sheensantoscapadngan Aug 29, 2025
97b9d17
misc: added log point
sheensantoscapadngan Aug 29, 2025
ef24451
misc: added handshake forcing
sheensantoscapadngan Aug 29, 2025
a233a3f
misc: updated gateway to fetch client certificate chain
sheensantoscapadngan Aug 31, 2025
74db2f3
misc: set target host of proxy to gateway
sheensantoscapadngan Aug 31, 2025
36c069d
feat: added TCP and HTTP forward handling to gateway
sheensantoscapadngan Sep 1, 2025
f7ed054
feat: added auth injection for k8 and platform checks
sheensantoscapadngan Sep 1, 2025
dc7a438
feat: added heartbeat
sheensantoscapadngan Sep 2, 2025
2dbb176
feat: added systemd support
sheensantoscapadngan Sep 2, 2025
085de6d
misc: added proxy name validation
sheensantoscapadngan Sep 2, 2025
9909141
misc: added proxy cert auto-renewal
sheensantoscapadngan Sep 2, 2025
6d0a021
misc: updated proxy tls server handling for cert renewal
sheensantoscapadngan Sep 2, 2025
b152338
misc: corrected client handling
sheensantoscapadngan Sep 2, 2025
3bcf34c
misc: addeed tls connection accept log
sheensantoscapadngan Sep 2, 2025
9ccf30b
misc: add connection deadline for unauthenticated requests
sheensantoscapadngan Sep 2, 2025
d39ef05
misc: finalized cert renewal interval to 10 days
sheensantoscapadngan Sep 2, 2025
6065584
misc: add cert renewal to gateway server
sheensantoscapadngan Sep 2, 2025
4e6ee38
misc: used non-standard port for proxy TLS
sheensantoscapadngan Sep 3, 2025
8eaf2a5
misc: improved security posture of proxy server
sheensantoscapadngan Sep 3, 2025
ce41396
misc: added sending of error message when multiple gateway is detected
sheensantoscapadngan Sep 3, 2025
c51d31f
Revert "misc: added sending of error message when multiple gateway is…
sheensantoscapadngan Sep 3, 2025
21d61c1
misc: only close new connection for duplicate gateway
sheensantoscapadngan Sep 3, 2025
7d2276f
misc: decreased tls deadline
sheensantoscapadngan Sep 3, 2025
e5a426d
misc: addressed greptile
sheensantoscapadngan Sep 3, 2025
fcdc145
misc: removed proxy auth logging
sheensantoscapadngan Sep 3, 2025
fc62acd
misc: updated gateway logs
sheensantoscapadngan Sep 3, 2025
7e9a71a
misc: updated proxy terminology to relay and finalized command location
sheensantoscapadngan Sep 8, 2025
e79f425
misc: updated ip flag to be host instead for relay
sheensantoscapadngan Sep 8, 2025
97da198
misc: updated logs
sheensantoscapadngan Sep 8, 2025
e00b1a8
misc: updated gateway to negotiate protocol through alpn headers
sheensantoscapadngan Sep 8, 2025
61182d9
misc: addressed comments
sheensantoscapadngan Sep 10, 2025
8857179
misc: more improvements to logging
sheensantoscapadngan Sep 10, 2025
242eb0a
misc: deleted network.go file
sheensantoscapadngan Sep 10, 2025
0da9260
misc: updated cert renewal every 6 hours
sheensantoscapadngan Sep 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions packages/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ const (
operationCallRegisterGatewayIdentityV1 = "CallRegisterGatewayIdentityV1"
operationCallExchangeRelayCertV1 = "CallExchangeRelayCertV1"
operationCallGatewayHeartBeatV1 = "CallGatewayHeartBeatV1"
operationCallGatewayHeartBeatV2 = "CallGatewayHeartBeatV2"
operationCallBootstrapInstance = "CallBootstrapInstance"
operationCallRegisterInstanceRelay = "CallRegisterInstanceRelay"
operationCallRegisterOrgRelay = "CallRegisterOrgRelay"
operationCallRegisterGateway = "CallRegisterGateway"
)

func CallGetEncryptedWorkspaceKey(httpClient *resty.Client, request GetEncryptedWorkspaceKeyRequest) (GetEncryptedWorkspaceKeyResponse, error) {
Expand Down Expand Up @@ -652,6 +656,23 @@ func CallGatewayHeartBeatV1(httpClient *resty.Client) error {
return nil
}

func CallGatewayHeartBeatV2(httpClient *resty.Client) error {
response, err := httpClient.
R().
SetHeader("User-Agent", USER_AGENT).
Post(fmt.Sprintf("%v/v2/gateways/heartbeat", config.INFISICAL_URL))

if err != nil {
return NewGenericRequestError(operationCallGatewayHeartBeatV2, err)
}

if response.IsError() {
return NewAPIErrorWithResponse(operationCallGatewayHeartBeatV2, response, nil)
}

return nil
}

func CallBootstrapInstance(httpClient *resty.Client, request BootstrapInstanceRequest) (BootstrapInstanceResponse, error) {
var resBody BootstrapInstanceResponse
response, err := httpClient.
Expand All @@ -671,3 +692,63 @@ func CallBootstrapInstance(httpClient *resty.Client, request BootstrapInstanceRe

return resBody, nil
}

func CallRegisterInstanceRelay(httpClient *resty.Client, request RegisterRelayRequest) (RegisterRelayResponse, error) {
var resBody RegisterRelayResponse
response, err := httpClient.
R().
SetResult(&resBody).
SetHeader("User-Agent", USER_AGENT).
SetBody(request).
Post(fmt.Sprintf("%v/v1/relays/register-instance-relay", config.INFISICAL_URL))

if err != nil {
return RegisterRelayResponse{}, NewGenericRequestError(operationCallRegisterInstanceRelay, err)
}

if response.IsError() {
return RegisterRelayResponse{}, NewAPIErrorWithResponse(operationCallRegisterInstanceRelay, response, nil)
}

return resBody, nil
}

func CallRegisterRelay(httpClient *resty.Client, request RegisterRelayRequest) (RegisterRelayResponse, error) {
var resBody RegisterRelayResponse
response, err := httpClient.
R().
SetResult(&resBody).
SetHeader("User-Agent", USER_AGENT).
SetBody(request).
Post(fmt.Sprintf("%v/v1/relays/register-org-relay", config.INFISICAL_URL))

if err != nil {
return RegisterRelayResponse{}, NewGenericRequestError(operationCallRegisterOrgRelay, err)
}

if response.IsError() {
return RegisterRelayResponse{}, NewAPIErrorWithResponse(operationCallRegisterOrgRelay, response, nil)
}

return resBody, nil
}

func CallRegisterGateway(httpClient *resty.Client, request RegisterGatewayRequest) (RegisterGatewayResponse, error) {
var resBody RegisterGatewayResponse
response, err := httpClient.
R().
SetResult(&resBody).
SetHeader("User-Agent", USER_AGENT).
SetBody(request).
Post(fmt.Sprintf("%v/v2/gateways", config.INFISICAL_URL))

if err != nil {
return RegisterGatewayResponse{}, NewGenericRequestError(operationCallRegisterGateway, err)
}

if response.IsError() {
return RegisterGatewayResponse{}, NewAPIErrorWithResponse(operationCallRegisterGateway, response, nil)
}

return resBody, nil
}
38 changes: 38 additions & 0 deletions packages/api/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,3 +703,41 @@ type BootstrapUser struct {
Username string `json:"username"`
SuperAdmin bool `json:"superAdmin"`
}

type RegisterRelayRequest struct {
Host string `json:"host"`
Name string `json:"name"`
}

type RegisterRelayResponse struct {
PKI struct {
ServerCertificate string `json:"serverCertificate"`
ServerPrivateKey string `json:"serverPrivateKey"`
ClientCertificateChain string `json:"clientCertificateChain"`
} `json:"pki"`
SSH struct {
ServerCertificate string `json:"serverCertificate"`
ServerPrivateKey string `json:"serverPrivateKey"`
ClientCAPublicKey string `json:"clientCAPublicKey"`
} `json:"ssh"`
}

type RegisterGatewayRequest struct {
RelayName string `json:"relayName"`
Name string `json:"name"`
}

type RegisterGatewayResponse struct {
GatewayID string `json:"gatewayId"`
RelayHost string `json:"relayHost"`
PKI struct {
ServerCertificate string `json:"serverCertificate"`
ServerPrivateKey string `json:"serverPrivateKey"`
ClientCertificateChain string `json:"clientCertificateChain"`
} `json:"pki"`
SSH struct {
ClientCertificate string `json:"clientCertificate"`
ClientPrivateKey string `json:"clientPrivateKey"`
ServerCAPublicKey string `json:"serverCAPublicKey"`
} `json:"ssh"`
}
Loading
Loading