Skip to content
Draft
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: 5 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ server:
bind_addr: 127.0.0.1:8069
name: "random_server"

authentication:
enabled: false
dex:
dex_url: ""

client:
bind_addr: 127.0.0.1:8070
server_addr: 127.0.0.1:8069
Expand Down
8 changes: 8 additions & 0 deletions internal/app/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func (c Client) GetRandNumber(ctx context.Context, seed int64) (int64, error) {
return reply.Number, nil
}

func registerDexHandler(router *echo.Echo) {
return
}

// HttpClient runs the client.
func HttpClient(config *config.Config) error {
// Tracing
Expand Down Expand Up @@ -109,6 +113,10 @@ func HttpClient(config *config.Config) error {
"number": randNum,
})
})
if config.Authentication.Enabled { // Register Dex authentication handler
registerDexHandler(router)
}

if err := router.Start(config.Client.BindAddr); err != nil {
log.Fatal(err)
}
Expand Down
24 changes: 19 additions & 5 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ type Server struct {
Name string `mapstructure:"name" validate:"required"`
}

// Server config
type Authentication struct {
// Enable default is false
Enabled bool `mapstructure:"enable"`

Dex Dex `mapstructure:"dex"`
}

// Dex Authentication config
type Dex struct {
DexURL string `mapstructure:"dex_url"`
}

// Client config
type Client struct {
BindAddr string `mapstructure:"bind_addr" validate:"required"`
Expand Down Expand Up @@ -46,11 +59,12 @@ type Tracing struct {

// Config struct
type Config struct {
Server Server `mapstructure:"server" validate:"required"`
Client Client `mapstructure:"client" validate:"required"`
Logs Logs `mapstructure:"logs" validate:"required"`
Metrics Metrics `mapstructure:"metrics" validate:"required"`
Tracing Tracing `mapstructure:"tracing" validate:"required"`
Server Server `mapstructure:"server" validate:"required"`
Authentication Authentication `mapstructure:"authentication" validate:"required"`
Client Client `mapstructure:"client" validate:"required"`
Logs Logs `mapstructure:"logs" validate:"required"`
Metrics Metrics `mapstructure:"metrics" validate:"required"`
Tracing Tracing `mapstructure:"tracing" validate:"required"`
}

// Load config file from given path
Expand Down