mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
fcd0b5e46a
* [FEATURE] Allow Authelia to listen on a specified path * Fix linting and add a couple typescript types * Template index.html to support base_url * Update docs and configuration template * Access base path from body attribute. * Update CSP * Fix unit test Also remove check for body as this will never get triggered, react itself is loaded inside the body so this has to always be successful. * Template index.html with ${PUBLIC_URL} * Define PUBLIC_URL in .env(s) * Add docs clarification Co-authored-by: Amir Zarrinkafsh <nightah@me.com> Co-authored-by: Clement Michaud <clement.michaud34@gmail.com>
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package validator
|
|
|
|
import (
|
|
"fmt"
|
|
"path"
|
|
"strings"
|
|
|
|
"github.com/authelia/authelia/internal/configuration/schema"
|
|
"github.com/authelia/authelia/internal/utils"
|
|
)
|
|
|
|
var defaultReadBufferSize = 4096
|
|
var defaultWriteBufferSize = 4096
|
|
|
|
// ValidateServer checks a server configuration is correct.
|
|
func ValidateServer(configuration *schema.ServerConfiguration, validator *schema.StructValidator) {
|
|
switch {
|
|
case strings.Contains(configuration.Path, "/"):
|
|
validator.Push(fmt.Errorf("server path must not contain any forward slashes"))
|
|
case !utils.IsStringAlphaNumeric(configuration.Path):
|
|
validator.Push(fmt.Errorf("server path must only be alpha numeric characters"))
|
|
case configuration.Path == "": // Don't do anything if it's blank.
|
|
default:
|
|
configuration.Path = path.Clean("/" + configuration.Path)
|
|
}
|
|
|
|
if configuration.ReadBufferSize == 0 {
|
|
configuration.ReadBufferSize = defaultReadBufferSize
|
|
} else if configuration.ReadBufferSize < 0 {
|
|
validator.Push(fmt.Errorf("server read buffer size must be above 0"))
|
|
}
|
|
|
|
if configuration.WriteBufferSize == 0 {
|
|
configuration.WriteBufferSize = defaultWriteBufferSize
|
|
} else if configuration.WriteBufferSize < 0 {
|
|
validator.Push(fmt.Errorf("server write buffer size must be above 0"))
|
|
}
|
|
}
|