Skip to content
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

Fix HTTP config errors #268 #287

Merged
merged 3 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions docs/conf/agent/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ server {
# here, set to default SPIRE socket path
spire_socket_path = "unix:///tmp/spire-server/private/api.sock"

# configure HTTP connection to Tornjak server
# [required] configure HTTP connection to Tornjak server
http {
enabled = true
port = 10000 # opens at port 10000
port = 10080 # opens at port 10080
}

}
Expand Down
26 changes: 8 additions & 18 deletions docs/conf/agent/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,17 @@ server {
# The server can open multiple if multiple sections included
# The server only ends when all connections error

# configure HTTP connection to Tornjak server
# [required] configure HTTP connection to Tornjak server
http {
enabled = true
port = 10000 # container port for HTTP connection
port = 10080 # container port for HTTP connection
}

# configure TLS connection to Tornjak server
tls {
enabled = true
port = 20000 # container port for TLS connection
cert = "sample-keys/tls.pem" # TLS cert
key = "sample-keys/key.pem" # TLS key
}

# configure mTLS connection to Tornjak server
mtls {
enabled = true
port = 30000 # container port for mTLS connection
cert = "sample-keys/tls.pem" # mTLS cert
key = "sample-keys/key.pem" # mTLS key
ca = "sample-keys/rootCA.pem" # mTLS CA
# [optional, recommended] configure HTTPS connection to Tornjak server
https {
port = 10443 # [required for HTTPS] container port for HTTPS connection
cert = "sample-keys/tls.pem" # [required for HTTPS] TLS cert
key = "sample-keys/key.pem" # [required for HTTPS] TLS key
ca = "sample-keys/rootCA.pem" # enables mTLS connection for HTTPS port
}

### END SERVER CONNECTION CONFIGURATION ###
Expand Down
18 changes: 5 additions & 13 deletions docs/config-tornjak-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,17 @@ server {

spire_socket_path = "unix:///tmp/spire-server/private/api.sock" # socket to communicate with SPIRE server

http {
enabled = true # if true, opens HTTP. if false, no HTTP connection opened
port = "10000" # if HTTP enabled, opens HTTP listen port at container port 10000
http { # required block
port = 10080 # if HTTP enabled, opens HTTP listen port at container port 10080
}

tls {
enabled = true # if true, opens TLS. if false, no TLS connection opened
port = "20000" # if enabled, opens TLS listen port at container port 20000
https {
port = 10443 # if enabled, opens HTTPS listen port at container port 10443
cert = "sample-keys/tls.pem" # path of certificate for TLS
key = "sample-keys/key.pem" # path of keys for TLS
ca = "sample-keys/userCA.pem" # [optional, enables mTLS] User CA
}

mtls {
enabled = true # if true, opens mTLS. if false, no mTLS connection opened
port = "30000" # if enabled, opens mTLS listen port at container port 30000
cert = "sample-keys/tls.pem" # path of certificate for mTLS
key = "sample-keys/key.pem" # path of keys for mTLS
ca = "sample-keys/rootCA.pem" # path of CA for mTLS
}
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart/tornjak-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ data:

# configure HTTP connection to Tornjak server
http {
enabled = true
port = 10000 # opens at port 10000
port = 10080 # opens at port 10080
}

}

plugins {
Expand Down
12 changes: 2 additions & 10 deletions tornjak-backend/api/agent/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ func (s *Server) HandleRequests() {
log.Print("WARNING: Please consider configuring HTTPS to ensure traffic is running on encrypted endpoint!")
}

numPorts = 1
go func() {
numPorts += 1
addr := fmt.Sprintf(":%d", serverConfig.HTTPConfig.ListenPort)
fmt.Printf("Starting to listen on %s...\n", addr)
err := http.ListenAndServe(addr, httpHandler)
Expand All @@ -633,8 +633,8 @@ func (s *Server) HandleRequests() {
}()

if serverConfig.HTTPSConfig != nil {
numPorts += 1
go func() {
numPorts += 1
if serverConfig.HTTPSConfig.ListenPort == 0 {
serverConfig.HTTPSConfig.ListenPort = 443
maia-iyer marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down Expand Up @@ -707,8 +707,6 @@ func NewAgentsDB(dbPlugin *ast.ObjectItem) (agentdb.AgentDB, error) {
return nil, errors.New("Required DataStore plugin not configured")
}

fmt.Printf("DATASTORE KEY AND DATA: %s , %+v\n", key, data)

switch key {
case "sql":
// check if data is defined
Expand Down Expand Up @@ -822,11 +820,7 @@ func (s *Server) Configure() error {

// iterate over plugin list

fmt.Printf("pluginlist: %+v\n", pluginList.Items)

for _, pluginObject := range pluginList.Items {
fmt.Printf("pluginItem: %+v\n", pluginObject)

if len(pluginObject.Keys) != 2 {
return fmt.Errorf("plugin item expected to have two keys (type then name)")
}
Expand All @@ -836,8 +830,6 @@ func (s *Server) Configure() error {
return fmt.Errorf("invalid plugin type key %q: %w", pluginObject.Keys[0].Token.Text, err)
}

fmt.Printf("pluginType: %s\n", pluginType)

// create plugin component based on type
switch pluginType {
// configure datastore
Expand Down
4 changes: 2 additions & 2 deletions tornjak-backend/api/agent/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ type HTTPConfig struct {
}

type HTTPSConfig struct {
*HTTPConfig
TLS TLSConfig `hcl:"tls"`
ListenPort int `hcl:"port"`
TLS TLSConfig `hcl:"tls"`
}

type TLSConfig struct {
Expand Down
Loading