2020-11-19 08:50:34 +07:00
|
|
|
package server
|
|
|
|
|
2022-07-25 17:43:50 +07:00
|
|
|
import (
|
|
|
|
"github.com/valyala/fasthttp"
|
|
|
|
)
|
|
|
|
|
2021-11-15 15:37:58 +07:00
|
|
|
const (
|
|
|
|
embeddedAssets = "public_html/"
|
|
|
|
swaggerAssets = embeddedAssets + "api/"
|
|
|
|
apiFile = "openapi.yml"
|
|
|
|
indexFile = "index.html"
|
|
|
|
logoFile = "logo.png"
|
|
|
|
)
|
|
|
|
|
2022-04-04 06:58:01 +07:00
|
|
|
var (
|
2022-04-04 09:15:26 +07:00
|
|
|
rootFiles = []string{"manifest.json", "robots.txt"}
|
2022-04-04 06:58:01 +07:00
|
|
|
swaggerFiles = []string{
|
|
|
|
"favicon-16x16.png",
|
|
|
|
"favicon-32x32.png",
|
|
|
|
"index.css",
|
|
|
|
"oauth2-redirect.html",
|
|
|
|
"swagger-initializer.js",
|
|
|
|
"swagger-ui-bundle.js",
|
|
|
|
"swagger-ui-bundle.js.map",
|
|
|
|
"swagger-ui-es-bundle-core.js",
|
|
|
|
"swagger-ui-es-bundle-core.js.map",
|
|
|
|
"swagger-ui-es-bundle.js",
|
|
|
|
"swagger-ui-es-bundle.js.map",
|
|
|
|
"swagger-ui-standalone-preset.js",
|
|
|
|
"swagger-ui-standalone-preset.js.map",
|
|
|
|
"swagger-ui.css",
|
|
|
|
"swagger-ui.css.map",
|
|
|
|
"swagger-ui.js",
|
|
|
|
"swagger-ui.js.map",
|
|
|
|
}
|
|
|
|
|
|
|
|
// Directories excluded from the not found handler proceeding to the next() handler.
|
|
|
|
httpServerDirs = []struct {
|
|
|
|
name, prefix string
|
|
|
|
}{
|
|
|
|
{name: "/api", prefix: "/api/"},
|
|
|
|
{name: "/.well-known", prefix: "/.well-known/"},
|
|
|
|
{name: "/static", prefix: "/static/"},
|
2022-04-07 07:58:51 +07:00
|
|
|
{name: "/locales", prefix: "/locales/"},
|
2022-04-04 06:58:01 +07:00
|
|
|
}
|
|
|
|
)
|
2021-01-03 11:28:46 +07:00
|
|
|
|
2021-12-01 10:32:58 +07:00
|
|
|
const (
|
2022-04-07 07:58:51 +07:00
|
|
|
dev = "dev"
|
|
|
|
f = "false"
|
|
|
|
t = "true"
|
|
|
|
localhost = "localhost"
|
|
|
|
schemeHTTP = "http"
|
|
|
|
schemeHTTPS = "https"
|
2021-12-01 10:32:58 +07:00
|
|
|
)
|
2021-08-05 11:02:07 +07:00
|
|
|
|
2022-07-25 17:43:50 +07:00
|
|
|
var (
|
|
|
|
headerETag = []byte(fasthttp.HeaderETag)
|
|
|
|
headerIfNoneMatch = []byte(fasthttp.HeaderIfNoneMatch)
|
|
|
|
headerCacheControl = []byte(fasthttp.HeaderCacheControl)
|
|
|
|
|
|
|
|
headerValueCacheControlETaggedAssets = []byte("public, max-age=0, must-revalidate")
|
|
|
|
)
|
|
|
|
|
2021-08-05 11:02:07 +07:00
|
|
|
const healthCheckEnv = `# Written by Authelia Process
|
|
|
|
X_AUTHELIA_HEALTHCHECK=1
|
|
|
|
X_AUTHELIA_HEALTHCHECK_SCHEME=%s
|
|
|
|
X_AUTHELIA_HEALTHCHECK_HOST=%s
|
|
|
|
X_AUTHELIA_HEALTHCHECK_PORT=%d
|
|
|
|
X_AUTHELIA_HEALTHCHECK_PATH=%s
|
|
|
|
`
|
2022-02-21 06:14:09 +07:00
|
|
|
|
|
|
|
const (
|
2022-07-09 09:00:21 +07:00
|
|
|
cspDefaultTemplate = "default-src 'self'%s; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-%s'; frame-ancestors 'none'; base-uri 'self'"
|
|
|
|
cspNoncePlaceholder = "${NONCE}"
|
2022-02-21 06:14:09 +07:00
|
|
|
)
|