console: turn authentication into a proper component

This commit is contained in:
Vincent Bernat
2022-06-09 19:55:57 +02:00
parent 9e620f2c91
commit b65d78ab1b
13 changed files with 100 additions and 197 deletions

View File

@@ -10,6 +10,7 @@ import (
"akvorado/common/http"
"akvorado/common/reporter"
"akvorado/console"
"akvorado/console/authentication"
)
// ConsoleConfiguration represents the configuration file for the console command.
@@ -18,6 +19,7 @@ type ConsoleConfiguration struct {
HTTP http.Configuration
Console console.Configuration
ClickHouse clickhousedb.Configuration
Auth authentication.Configuration
}
// DefaultConsoleConfiguration is the default configuration for the console command.
@@ -27,6 +29,7 @@ func DefaultConsoleConfiguration() ConsoleConfiguration {
Reporting: reporter.DefaultConfiguration(),
Console: console.DefaultConfiguration(),
ClickHouse: clickhousedb.DefaultConfiguration(),
Auth: authentication.DefaultConfiguration(),
}
}
@@ -85,6 +88,10 @@ func consoleStart(r *reporter.Reporter, config ConsoleConfiguration, checkOnly b
if err != nil {
return fmt.Errorf("unable to initialize ClickHouse component: %w", err)
}
authenticationComponent, err := authentication.New(r, config.Auth)
if err != nil {
return fmt.Errorf("unable to initialize authentication component: %w", err)
}
consoleComponent, err := console.New(r, config.Console, console.Dependencies{
Daemon: daemonComponent,
HTTP: httpComponent,
@@ -107,6 +114,7 @@ func consoleStart(r *reporter.Reporter, config ConsoleConfiguration, checkOnly b
components := []interface{}{
httpComponent,
clickhouseComponent,
authenticationComponent,
consoleComponent,
}
return StartStopComponents(r, daemonComponent, components)