authelia/internal
Amir Zarrinkafsh a9b0caf4ee
[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`
2020-06-09 08:22:41 +10:00
..
authentication [FIX] Hash Password Cmd Not Encoding Provided Salt (#999) 2020-05-14 15:55:03 +10:00
authorization [CI] Add gocritic linter (#977) 2020-05-06 10:52:06 +10:00
commands [FIX] Hash Password Cmd Not Encoding Provided Salt (#999) 2020-05-14 15:55:03 +10:00
configuration [MISC] Catch and warn on malformed configuration yaml (#1089) 2020-06-09 08:22:41 +10:00
duo [CI] Add wsl linter (#980) 2020-05-05 21:35:32 +02:00
handlers [MISC] Fix unit tests for Go 1.14+ (#1075) 2020-06-02 19:09:13 +10:00
logging [CI] Add wsl linter (#980) 2020-05-05 21:35:32 +02:00
middlewares [BUGFIX] Add path to generated links for emails (#1045) 2020-05-24 09:51:34 +10:00
mocks [SECURITY] Fix Authentication HTTP Status Codes (#959) 2020-05-06 07:27:38 +10:00
models [MISC] Implement golint recommendations (#885) 2020-04-20 23:03:38 +02:00
notification [CI] Add gocritic linter (#977) 2020-05-06 10:52:06 +10:00
regulation [CI] Add wsl linter (#980) 2020-05-05 21:35:32 +02:00
server [CI] Add PathPrefix integration test suite (#1052) 2020-05-27 13:55:44 +02:00
session [MISC] Fix linting error introduced in #1001 (#1028) 2020-05-19 07:50:50 +10:00
storage [CI] Add wsl linter (#980) 2020-05-05 21:35:32 +02:00
suites [CI] Add Codecov support (#1065) 2020-06-05 10:43:19 +10:00
templates Force TLS and valid x509 certs in SMTP Notifier by default 2020-01-10 17:37:16 +01:00
utils [FEATURE] Allow Authelia to listen on a specified path (#1027) 2020-05-21 12:20:55 +10:00