mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
b12d9d405f
CSP is used to avoid some attacks where the hacker tries to execute untrusted code in the browser. The policy is to use assets hosted on the the original website and in order to make CSP work with material UI, a nonce is generated at each request of index.html and injected in the template as well as provided in the Content-Security-Policy header (https://material-ui.com/styles/advanced/#how-does-one-implement-csp) Fix #815
67 lines
1.3 KiB
Go
67 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/authelia/authelia/internal/utils"
|
|
)
|
|
|
|
func buildAutheliaBinary() {
|
|
cmd := utils.CommandWithStdout("go", "build", "-o", "../../"+OutputDir+"/authelia")
|
|
cmd.Dir = "cmd/authelia"
|
|
cmd.Env = append(os.Environ(),
|
|
"GOOS=linux", "GOARCH=amd64", "CGO_ENABLED=1")
|
|
|
|
err := cmd.Run()
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func buildFrontend() {
|
|
// Install npm dependencies
|
|
cmd := utils.CommandWithStdout("yarn", "install")
|
|
cmd.Dir = "web"
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
// Then build the frontend
|
|
cmd = utils.CommandWithStdout("yarn", "build")
|
|
cmd.Dir = "web"
|
|
cmd.Env = append(os.Environ(), "INLINE_RUNTIME_CHUNK=false")
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if err := os.Rename("web/build", OutputDir+"/public_html"); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// Build build Authelia
|
|
func Build(cobraCmd *cobra.Command, args []string) {
|
|
log.Info("Building Authelia...")
|
|
|
|
Clean(cobraCmd, args)
|
|
|
|
log.Debug("Creating `" + OutputDir + "` directory")
|
|
err := os.MkdirAll(OutputDir, os.ModePerm)
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
log.Debug("Building Authelia Go binary...")
|
|
buildAutheliaBinary()
|
|
|
|
log.Debug("Building Authelia frontend...")
|
|
buildFrontend()
|
|
}
|