summaryrefslogtreecommitdiff
path: root/cmd/authelia
diff options
context:
space:
mode:
authorAmir Zarrinkafsh <nightah@me.com>2020-06-09 08:22:41 +1000
committerGitHub <noreply@github.com>2020-06-09 08:22:41 +1000
commita9b0caf4ee9569436cf285151e1bdcff97a04bfc (patch)
tree7e2992bf5b9bb445b14069973341dd8246b35bee /cmd/authelia
parent7bd775f851078b2247f49104857fd846954de77f (diff)
[MISC] Catch and warn on malformed configuration yaml (#1089)
If the configuration yaml is poorly indented or special values are not appropriately escaped Authelia attempts to load said configuration and fails. This attempts to unmarshal the config into an empty interface to catch and warn on malformed yaml. Using the example from issue https://github.com/authelia/authelia/issues/1053#issuecomment-634791662 ```yaml host: 0.0.0.0 port: 9091 log_level: debug jwt_secret: RUtG9TnbXrOl1XLLmDgySw1DGgx9QcrtepIf1uDDBlBVKFZxkVBruYKBi32PvaU default_redirection_url: example.com totp: issuer: example.com period: 30 skew: 1 authentication_backend: file: path: /etc/authelia/users_database.yml access_control: default_policy: deny rules: - domain: example.com policy: bypass - domain: "*.example.com" policy: one_factor session: name: authelia_session secret: TVPMIcDFbBwhnW3kLJzKhdjeHhtqisr7m28FgRY8oLh2A4lwuV2jV2ZGdGbh4aa expiration: 3600 inactivity: 300 domain: example.com regulation: max_retries: 3 find_time: 120 ban_time: 300 storage: mysql: host: example.com port: 3306 database: authelia username: authelia password: example.com notifier: smtp: username: example.com password: example.com host: smtp.gmail.com port: 465 sender: example.com ``` We would actually get a more meaningful error which helps pinpoint the issue: `Error malformed yaml: line 23: did not find expected alphabetic or numeric character`
Diffstat (limited to 'cmd/authelia')
-rw-r--r--cmd/authelia/coverage_test.go (renamed from cmd/authelia/main_test.go)2
-rw-r--r--cmd/authelia/main.go7
2 files changed, 2 insertions, 7 deletions
diff --git a/cmd/authelia/main_test.go b/cmd/authelia/coverage_test.go
index f50e49adb..26d7fe020 100644
--- a/cmd/authelia/main_test.go
+++ b/cmd/authelia/coverage_test.go
@@ -10,7 +10,7 @@ import (
"testing"
)
-func TestAuthelia(t *testing.T) {
+func TestCoverage(t *testing.T) {
var (
args []string
)
diff --git a/cmd/authelia/main.go b/cmd/authelia/main.go
index 6ada8e1a7..64cdd02d0 100644
--- a/cmd/authelia/main.go
+++ b/cmd/authelia/main.go
@@ -1,7 +1,6 @@
package main
import (
- "errors"
"fmt"
"log"
"os"
@@ -27,10 +26,6 @@ var configPathFlag string
//nolint:gocyclo // TODO: Consider refactoring/simplifying, time permitting
func startServer() {
- if configPathFlag == "" {
- log.Fatal(errors.New("No config file path provided"))
- }
-
config, errs := configuration.Read(configPathFlag)
if len(errs) > 0 {
@@ -38,7 +33,7 @@ func startServer() {
logging.Logger().Error(err)
}
- panic(errors.New("Some errors have been reported"))
+ os.Exit(1)
}
if err := logging.InitializeLogger(config.LogFilePath); err != nil {