diff --git a/cmd/authelia-gen/cmd_code.go b/cmd/authelia-gen/cmd_code.go index 2d3e931ad..1359298c5 100644 --- a/cmd/authelia-gen/cmd_code.go +++ b/cmd/authelia-gen/cmd_code.go @@ -30,7 +30,19 @@ func newCodeCmd() *cobra.Command { DisableAutoGenTag: true, } - cmd.AddCommand(newCodeKeysCmd(), newCodeScriptsCmd()) + cmd.AddCommand(newCodeKeysCmd(), newCodeServerCmd(), newCodeScriptsCmd()) + + return cmd +} + +func newCodeServerCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: cmdUseServer, + Short: "Generate the Authelia server files", + RunE: codeServerRunE, + + DisableAutoGenTag: true, + } return cmd } @@ -59,6 +71,38 @@ func newCodeKeysCmd() *cobra.Command { return cmd } +func codeServerRunE(cmd *cobra.Command, args []string) (err error) { + data := TemplateCSP{ + PlaceholderNONCE: codeCSPNonce, + TemplateDefault: buildCSP(codeCSPProductionDefaultSrc, codeCSPValuesCommon, codeCSPValuesProduction), + TemplateDevelopment: buildCSP(codeCSPDevelopmentDefaultSrc, codeCSPValuesCommon, codeCSPValuesDevelopment), + } + + var outputPath string + + if outputPath, err = getPFlagPath(cmd.Flags(), cmdFlagRoot, cmdFlagFileServerGenerated); err != nil { + return err + } + + var f *os.File + + if f, err = os.Create(outputPath); err != nil { + return fmt.Errorf("failed to create file '%s': %w", outputPath, err) + } + + if err = tmplServer.Execute(f, data); err != nil { + _ = f.Close() + + return fmt.Errorf("failed to write output file '%s': %w", outputPath, err) + } + + if err = f.Close(); err != nil { + return fmt.Errorf("failed to close output file '%s': %w", outputPath, err) + } + + return nil +} + func codeScriptsRunE(cmd *cobra.Command, args []string) (err error) { var ( root, pathScriptsGen string @@ -129,11 +173,6 @@ func codeScriptsRunE(cmd *cobra.Command, args []string) (err error) { return nil } -// GitHubTagsJSON represents the JSON struct for the GitHub Tags API. -type GitHubTagsJSON struct { - Name string `json:"name"` -} - func codeKeysRunE(cmd *cobra.Command, args []string) (err error) { var ( pathCodeConfigKeys, root string diff --git a/cmd/authelia-gen/cmd_docs.go b/cmd/authelia-gen/cmd_docs.go index 2902b8aa0..54d1135f1 100644 --- a/cmd/authelia-gen/cmd_docs.go +++ b/cmd/authelia-gen/cmd_docs.go @@ -13,7 +13,7 @@ func newDocsCmd() *cobra.Command { DisableAutoGenTag: true, } - cmd.AddCommand(newDocsCLICmd(), newDocsDateCmd(), newDocsKeysCmd()) + cmd.AddCommand(newDocsCLICmd(), newDocsDataCmd(), newDocsDateCmd()) return cmd } diff --git a/cmd/authelia-gen/cmd_docs_cli.go b/cmd/authelia-gen/cmd_docs_cli.go index e41b6f189..178583749 100644 --- a/cmd/authelia-gen/cmd_docs_cli.go +++ b/cmd/authelia-gen/cmd_docs_cli.go @@ -27,45 +27,39 @@ func newDocsCLICmd() *cobra.Command { } func docsCLIRunE(cmd *cobra.Command, args []string) (err error) { - var root, pathDocsCLIReference string + var outputPath string - if root, err = cmd.Flags().GetString(cmdFlagRoot); err != nil { + if outputPath, err = getPFlagPath(cmd.Flags(), cmdFlagRoot, cmdFlagDocs, cmdFlagDocsContent, cmdFlagDocsCLIReference); err != nil { return err } - if pathDocsCLIReference, err = cmd.Flags().GetString(cmdFlagDocsCLIReference); err != nil { - return err - } - - fullPathDocsCLIReference := filepath.Join(root, pathDocsCLIReference) - - if err = os.MkdirAll(fullPathDocsCLIReference, 0775); err != nil { + if err = os.MkdirAll(outputPath, 0775); err != nil { if !os.IsExist(err) { return err } } - if err = genCLIDoc(commands.NewRootCmd(), filepath.Join(fullPathDocsCLIReference, "authelia")); err != nil { + if err = genCLIDoc(commands.NewRootCmd(), filepath.Join(outputPath, "authelia")); err != nil { return err } - if err = genCLIDocWriteIndex(fullPathDocsCLIReference, "authelia"); err != nil { + if err = genCLIDocWriteIndex(outputPath, "authelia"); err != nil { return err } - if err = genCLIDoc(cmdscripts.NewRootCmd(), filepath.Join(fullPathDocsCLIReference, "authelia-scripts")); err != nil { + if err = genCLIDoc(cmdscripts.NewRootCmd(), filepath.Join(outputPath, "authelia-scripts")); err != nil { return err } - if err = genCLIDocWriteIndex(fullPathDocsCLIReference, "authelia-scripts"); err != nil { + if err = genCLIDocWriteIndex(outputPath, "authelia-scripts"); err != nil { return err } - if err = genCLIDoc(newRootCmd(), filepath.Join(fullPathDocsCLIReference, cmdUseRoot)); err != nil { + if err = genCLIDoc(newRootCmd(), filepath.Join(outputPath, cmdUseRoot)); err != nil { return err } - if err = genCLIDocWriteIndex(fullPathDocsCLIReference, cmdUseRoot); err != nil { + if err = genCLIDocWriteIndex(outputPath, cmdUseRoot); err != nil { return err } diff --git a/cmd/authelia-gen/cmd_docs_data.go b/cmd/authelia-gen/cmd_docs_data.go new file mode 100644 index 000000000..b0eddf21b --- /dev/null +++ b/cmd/authelia-gen/cmd_docs_data.go @@ -0,0 +1,132 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "reflect" + "strings" + + "github.com/spf13/cobra" + + "github.com/authelia/authelia/v4/internal/configuration" + "github.com/authelia/authelia/v4/internal/configuration/schema" +) + +func newDocsDataCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: cmdUseDocsData, + Short: "Generate docs data files", + RunE: rootSubCommandsRunE, + + DisableAutoGenTag: true, + } + + cmd.AddCommand(newDocsDataMiscCmd(), newDocsDataKeysCmd()) + + return cmd +} + +func newDocsDataMiscCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: cmdUseDocsDataMisc, + Short: "Generate docs data file misc.json", + RunE: docsDataMiscRunE, + + DisableAutoGenTag: true, + } + + return cmd +} + +func docsDataMiscRunE(cmd *cobra.Command, args []string) (err error) { + data := DocsDataMisc{ + CSP: TemplateCSP{ + PlaceholderNONCE: codeCSPNonce, + TemplateDefault: buildCSP(codeCSPProductionDefaultSrc, codeCSPValuesCommon, codeCSPValuesProduction), + TemplateDevelopment: buildCSP(codeCSPDevelopmentDefaultSrc, codeCSPValuesCommon, codeCSPValuesDevelopment), + }, + } + + data.CSP.TemplateDefault = strings.ReplaceAll(data.CSP.TemplateDefault, "%s", codeCSPNonce) + data.CSP.TemplateDevelopment = strings.ReplaceAll(data.CSP.TemplateDevelopment, "%s", codeCSPNonce) + + var ( + outputPath string + dataJSON []byte + ) + + if outputPath, err = getPFlagPath(cmd.Flags(), cmdFlagRoot, cmdFlagDocs, cmdFlagDocsData, cmdFlagDocsDataMisc); err != nil { + return err + } + + if dataJSON, err = json.Marshal(data); err != nil { + return err + } + + if err = os.WriteFile(outputPath, dataJSON, 0600); err != nil { + return fmt.Errorf("failed to write file '%s': %w", outputPath, err) + } + + return nil +} + +func newDocsDataKeysCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: cmdUseKeys, + Short: "Generate the docs data file for configuration keys", + RunE: docsKeysRunE, + + DisableAutoGenTag: true, + } + + return cmd +} + +func docsKeysRunE(cmd *cobra.Command, args []string) (err error) { + //nolint:prealloc + var ( + data []ConfigurationKey + ) + + keys := readTags("", reflect.TypeOf(schema.Configuration{})) + + for _, key := range keys { + if strings.Contains(key, "[]") { + continue + } + + ck := ConfigurationKey{ + Path: key, + Secret: configuration.IsSecretKey(key), + } + + switch { + case ck.Secret: + ck.Env = configuration.ToEnvironmentSecretKey(key, configuration.DefaultEnvPrefix, configuration.DefaultEnvDelimiter) + default: + ck.Env = configuration.ToEnvironmentKey(key, configuration.DefaultEnvPrefix, configuration.DefaultEnvDelimiter) + } + + data = append(data, ck) + } + + var ( + dataJSON []byte + outputPath string + ) + + if outputPath, err = getPFlagPath(cmd.Flags(), cmdFlagRoot, cmdFlagDocs, cmdFlagDocsData, cmdFlagDocsDataKeys); err != nil { + return err + } + + if dataJSON, err = json.Marshal(data); err != nil { + return err + } + + if err = os.WriteFile(outputPath, dataJSON, 0600); err != nil { + return fmt.Errorf("failed to write file '%s': %w", outputPath, err) + } + + return nil +} diff --git a/cmd/authelia-gen/cmd_docs_date.go b/cmd/authelia-gen/cmd_docs_date.go index 2f752db4b..9eea8ccad 100644 --- a/cmd/authelia-gen/cmd_docs_date.go +++ b/cmd/authelia-gen/cmd_docs_date.go @@ -32,14 +32,10 @@ func newDocsDateCmd() *cobra.Command { func docsDateRunE(cmd *cobra.Command, args []string) (err error) { var ( - root, pathDocsContent, cwd, commitUtil, commitSince, commitFilter string + pathDocsContent, cwd, commitUtil, commitSince, commitFilter string ) - if root, err = cmd.Flags().GetString(cmdFlagRoot); err != nil { - return err - } - - if pathDocsContent, err = cmd.Flags().GetString(cmdFlagDocsContent); err != nil { + if pathDocsContent, err = getPFlagPath(cmd.Flags(), cmdFlagRoot, cmdFlagDocs, cmdFlagDocsContent); err != nil { return err } @@ -59,7 +55,7 @@ func docsDateRunE(cmd *cobra.Command, args []string) (err error) { commitFilter = fmt.Sprintf("%s...%s", commitUtil, commitSince) } - return filepath.Walk(filepath.Join(root, pathDocsContent), func(path string, info fs.FileInfo, err error) error { + return filepath.Walk(pathDocsContent, func(path string, info fs.FileInfo, err error) error { if err != nil { return err } diff --git a/cmd/authelia-gen/cmd_docs_keys.go b/cmd/authelia-gen/cmd_docs_keys.go deleted file mode 100644 index df6763acb..000000000 --- a/cmd/authelia-gen/cmd_docs_keys.go +++ /dev/null @@ -1,81 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "os" - "path/filepath" - "reflect" - "strings" - - "github.com/spf13/cobra" - - "github.com/authelia/authelia/v4/internal/configuration" - "github.com/authelia/authelia/v4/internal/configuration/schema" -) - -func newDocsKeysCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: cmdUseKeys, - Short: "Generate the docs data file for configuration keys", - RunE: docsKeysRunE, - - DisableAutoGenTag: true, - } - - return cmd -} - -func docsKeysRunE(cmd *cobra.Command, args []string) (err error) { - //nolint:prealloc - var ( - pathDocsConfigKeys, root string - data []ConfigurationKey - ) - - keys := readTags("", reflect.TypeOf(schema.Configuration{})) - - for _, key := range keys { - if strings.Contains(key, "[]") { - continue - } - - ck := ConfigurationKey{ - Path: key, - Secret: configuration.IsSecretKey(key), - } - - switch { - case ck.Secret: - ck.Env = configuration.ToEnvironmentSecretKey(key, configuration.DefaultEnvPrefix, configuration.DefaultEnvDelimiter) - default: - ck.Env = configuration.ToEnvironmentKey(key, configuration.DefaultEnvPrefix, configuration.DefaultEnvDelimiter) - } - - data = append(data, ck) - } - - var ( - dataJSON []byte - ) - - if root, err = cmd.Flags().GetString(cmdFlagRoot); err != nil { - return err - } - - if pathDocsConfigKeys, err = cmd.Flags().GetString(cmdFlagFileDocsKeys); err != nil { - return err - } - - fullPathDocsConfigKeys := filepath.Join(root, pathDocsConfigKeys) - - if dataJSON, err = json.Marshal(data); err != nil { - return err - } - - if err = os.WriteFile(fullPathDocsConfigKeys, dataJSON, 0600); err != nil { - return fmt.Errorf("failed to write file '%s': %w", fullPathDocsConfigKeys, err) - } - - return nil -} diff --git a/cmd/authelia-gen/cmd_locales.go b/cmd/authelia-gen/cmd_locales.go index 6948ac7b4..0fcc390c3 100644 --- a/cmd/authelia-gen/cmd_locales.go +++ b/cmd/authelia-gen/cmd_locales.go @@ -46,7 +46,7 @@ func localesRunE(cmd *cobra.Command, args []string) (err error) { return err } - if pathDocsDataLanguages, err = cmd.Flags().GetString(cmdFlagDocsDataLanguages); err != nil { + if pathDocsDataLanguages, err = getPFlagPath(cmd.Flags(), cmdFlagRoot, cmdFlagDocs, cmdFlagDocsData, cmdFlagDocsDataLanguages); err != nil { return err } diff --git a/cmd/authelia-gen/cmd_root.go b/cmd/authelia-gen/cmd_root.go index 1ce6cf2dc..d0809957c 100644 --- a/cmd/authelia-gen/cmd_root.go +++ b/cmd/authelia-gen/cmd_root.go @@ -33,12 +33,16 @@ func newRootCmd() *cobra.Command { cmd.PersistentFlags().String(cmdFlagDirLocales, dirLocales, "The locales directory in relation to the root") cmd.PersistentFlags().String(cmdFlagFileWebI18N, fileWebI18NIndex, "The i18n typescript configuration file in relation to the root") cmd.PersistentFlags().String(cmdFlagDocsDataLanguages, fileDocsDataLanguages, "The languages docs data file in relation to the docs data folder") + cmd.PersistentFlags().String(cmdFlagDocsDataMisc, fileDocsDataMisc, "The misc docs data file in relation to the docs data folder") cmd.PersistentFlags().String(cmdFlagDocsCLIReference, dirDocsCLIReference, "The directory to store the markdown in") + cmd.PersistentFlags().String(cmdFlagDocs, dirDocs, "The directory with the docs") cmd.PersistentFlags().String(cmdFlagDocsContent, dirDocsContent, "The directory with the docs content") + cmd.PersistentFlags().String(cmdFlagDocsData, dirDocsData, "The directory with the docs data") cmd.PersistentFlags().String(cmdFlagFileConfigKeys, fileCodeConfigKeys, "Sets the path of the keys file") - cmd.PersistentFlags().String(cmdFlagFileDocsKeys, fileDocsConfigKeys, "Sets the path of the docs keys file") + cmd.PersistentFlags().String(cmdFlagDocsDataKeys, fileDocsDataConfigKeys, "Sets the path of the docs keys file") cmd.PersistentFlags().String(cmdFlagPackageConfigKeys, pkgConfigSchema, "Sets the package name of the keys file") cmd.PersistentFlags().String(cmdFlagFileScriptsGen, fileScriptsGen, "Sets the path of the authelia-scripts gen file") + cmd.PersistentFlags().String(cmdFlagFileServerGenerated, fileServerGenerated, "Sets the path of the server generated file") cmd.PersistentFlags().String(cmdFlagPackageScriptsGen, pkgScriptsGen, "Sets the package name of the authelia-scripts gen file") cmd.PersistentFlags().String(cmdFlagFileConfigCommitLint, fileCICommitLintConfig, "The commit lint javascript configuration file in relation to the root") cmd.PersistentFlags().String(cmdFlagFileDocsCommitMsgGuidelines, fileDocsCommitMessageGuidelines, "The commit message guidelines documentation file in relation to the root") diff --git a/cmd/authelia-gen/const.go b/cmd/authelia-gen/const.go index 53f01051e..f68364e9e 100644 --- a/cmd/authelia-gen/const.go +++ b/cmd/authelia-gen/const.go @@ -12,14 +12,18 @@ const ( fileDocsCommitMessageGuidelines = "docs/content/en/contributing/guidelines/commit-message.md" - fileDocsConfigKeys = "docs/data/configkeys.json" - fileCodeConfigKeys = "internal/configuration/schema/keys.go" - fileScriptsGen = "cmd/authelia-scripts/cmd/gen.go" + fileCodeConfigKeys = "internal/configuration/schema/keys.go" + fileServerGenerated = "internal/server/gen.go" + fileScriptsGen = "cmd/authelia-scripts/cmd/gen.go" - dirDocsContent = "docs/content" - dirDocsCLIReference = dirDocsContent + "/en/reference/cli" + dirDocs = "docs" + dirDocsContent = "content" + dirDocsData = "data" + dirDocsCLIReference = "en/reference/cli" - fileDocsDataLanguages = "docs/data/languages.json" + fileDocsDataLanguages = "languages.json" + fileDocsDataMisc = "misc.json" + fileDocsDataConfigKeys = "configkeys.json" fileGitHubIssueTemplateFR = ".github/ISSUE_TEMPLATE/feature-request.yml" fileGitHubIssueTemplateBR = ".github/ISSUE_TEMPLATE/bug-report.yml" @@ -48,6 +52,8 @@ const ( cmdUseDocs = "docs" cmdUseDocsDate = "date" cmdUseDocsCLI = "cli" + cmdUseDocsData = "data" + cmdUseDocsDataMisc = "misc" cmdUseGitHub = "github" cmdUseGitHubIssueTemplates = "issue-templates" cmdUseGitHubIssueTemplatesFR = "feature-request" @@ -57,6 +63,7 @@ const ( cmdUseCode = "code" cmdUseCodeScripts = "scripts" cmdUseKeys = "keys" + cmdUseServer = "server" ) const ( @@ -66,11 +73,15 @@ const ( cmdFlagDirLocales = "dir.locales" cmdFlagDocsCLIReference = "dir.docs.cli-reference" cmdFlagDocsContent = "dir.docs.content" + cmdFlagDocsData = "dir.docs.data" + cmdFlagDocs = "dir.docs" cmdFlagDocsDataLanguages = "file.docs.data.languages" + cmdFlagDocsDataMisc = "file.docs.data.misc" + cmdFlagDocsDataKeys = "file.docs.data.keys" cmdFlagCwd = "cwd" cmdFlagFileConfigKeys = "file.configuration-keys" - cmdFlagFileDocsKeys = "file.docs-keys" cmdFlagFileScriptsGen = "file.scripts.gen" + cmdFlagFileServerGenerated = "file.server.generated" cmdFlagFileConfigCommitLint = "file.commit-lint-config" cmdFlagFileDocsCommitMsgGuidelines = "file.docs-commit-msg-guidelines" cmdFlagFileWebI18N = "file.web-i18n" @@ -79,3 +90,24 @@ const ( cmdFlagPackageConfigKeys = "package.configuration.keys" cmdFlagPackageScriptsGen = "package.scripts.gen" ) + +const ( + codeCSPProductionDefaultSrc = "'self'" + codeCSPDevelopmentDefaultSrc = "'self' 'unsafe-eval'" + codeCSPNonce = "${NONCE}" +) + +var ( + codeCSPValuesCommon = []CSPValue{ + {Name: "default-src", Value: ""}, + {Name: "frame-src", Value: "'none'"}, + {Name: "object-src", Value: "'none'"}, + {Name: "style-src", Value: "'self' 'nonce-%s'"}, + {Name: "frame-ancestors", Value: "'none'"}, + {Name: "base-uri", Value: "'self'"}, + } + + codeCSPValuesProduction = []CSPValue{} + + codeCSPValuesDevelopment = []CSPValue{} +) diff --git a/cmd/authelia-gen/helpers.go b/cmd/authelia-gen/helpers.go new file mode 100644 index 000000000..09ac84e8f --- /dev/null +++ b/cmd/authelia-gen/helpers.go @@ -0,0 +1,48 @@ +package main + +import ( + "fmt" + "path/filepath" + "strings" + + "github.com/spf13/pflag" +) + +func getPFlagPath(flags *pflag.FlagSet, flagNames ...string) (fullPath string, err error) { + if len(flagNames) == 0 { + return "", fmt.Errorf("no flag names") + } + + var p string + + for i, flagName := range flagNames { + if p, err = flags.GetString(flagName); err != nil { + return "", fmt.Errorf("failed to lookup flag '%s': %w", flagName, err) + } + + if i == 0 { + fullPath = p + } else { + fullPath = filepath.Join(fullPath, p) + } + } + + return fullPath, nil +} + +func buildCSP(defaultSrc string, ruleSets ...[]CSPValue) string { + var rules []string + + for _, ruleSet := range ruleSets { + for _, rule := range ruleSet { + switch rule.Name { + case "default-src": + rules = append(rules, fmt.Sprintf("%s %s", rule.Name, defaultSrc)) + default: + rules = append(rules, fmt.Sprintf("%s %s", rule.Name, rule.Value)) + } + } + } + + return strings.Join(rules, "; ") +} diff --git a/cmd/authelia-gen/templates.go b/cmd/authelia-gen/templates.go index 4f65a4b18..794add4b3 100644 --- a/cmd/authelia-gen/templates.go +++ b/cmd/authelia-gen/templates.go @@ -24,6 +24,7 @@ var ( tmplDotCommitLintRC = template.Must(newTMPL("dot_commitlintrc.js")) tmplDocsCommitMessageGuidelines = template.Must(newTMPL("docs-contributing-development-commitmsg.md")) tmplScriptsGen = template.Must(newTMPL("cmd-authelia-scripts-gen.go")) + tmplServer = template.Must(newTMPL("server_gen.go")) ) func fmJoinX(elems []string, sep string, n int, p string) string { diff --git a/cmd/authelia-gen/templates/server_gen.go.tmpl b/cmd/authelia-gen/templates/server_gen.go.tmpl new file mode 100644 index 000000000..b1d96e86c --- /dev/null +++ b/cmd/authelia-gen/templates/server_gen.go.tmpl @@ -0,0 +1,13 @@ +// Code generated by go generate. DO NOT EDIT. +// +// Run the following command to generate this file: +// go run ./cmd/authelia-gen code server +// + +package server + +const ( + placeholderCSPNonce = "{{ .PlaceholderNONCE }}" + tmplCSPDefault = "{{ .TemplateDefault }}" + tmplCSPDevelopment = "{{ .TemplateDevelopment }}" +) diff --git a/cmd/authelia-gen/types.go b/cmd/authelia-gen/types.go index 7c47772e8..99e13fd45 100644 --- a/cmd/authelia-gen/types.go +++ b/cmd/authelia-gen/types.go @@ -25,6 +25,23 @@ type tmplScriptsGEnData struct { VersionSwaggerUI string } +// GitHubTagsJSON represents the JSON struct for the GitHub Tags API. +type GitHubTagsJSON struct { + Name string `json:"name"` +} + +// DocsDataMisc represents the docs misc data schema. +type DocsDataMisc struct { + CSP TemplateCSP `json:"csp"` +} + +// TemplateCSP represents the CSP template vars. +type TemplateCSP struct { + TemplateDefault string `json:"default"` + TemplateDevelopment string `json:"development"` + PlaceholderNONCE string `json:"nonce"` +} + // ConfigurationKey is the docs json model for the Authelia configuration keys. type ConfigurationKey struct { Path string `json:"path"` @@ -121,3 +138,8 @@ var labelTypeDescriptions = [...]string{ func (t labelType) String() string { return fmt.Sprintf("%s/%s", labelAreaPrefixType, labelTypeDescriptions[t]) } + +type CSPValue struct { + Name string + Value string +} diff --git a/docs/content/en/configuration/miscellaneous/server.md b/docs/content/en/configuration/miscellaneous/server.md index 4d6202c26..65ba79629 100644 --- a/docs/content/en/configuration/miscellaneous/server.md +++ b/docs/content/en/configuration/miscellaneous/server.md @@ -161,11 +161,11 @@ or intermediate certificates. If no item is provided mutual TLS is disabled. {{< confkey type="string" required="no" >}} -This customizes the value of the Content-Security-Policy header. It will replace all instances of `${NONCE}` with the -nonce value of the Authelia react bundle. This is an advanced option to customize and you should do sufficient research -about how browsers utilize and understand this header before attempting to customize it. +This customizes the value of the Content-Security-Policy header. It will replace all instances of the below placeholder +with the nonce value of the Authelia react bundle. This is an advanced option to customize and you should do sufficient +research about how browsers utilize and understand this header before attempting to customize it. -For example, the default CSP template is `default-src 'self'; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-${NONCE}'; frame-ancestors 'none'; base-uri 'self'`. +{{< csp >}} ### buffers diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen.md index b373fc18b..1dc7be5b0 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen.md @@ -24,8 +24,10 @@ authelia-gen [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -33,10 +35,12 @@ authelia-gen [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") -h, --help help for authelia-gen --package.configuration.keys string Sets the package name of the keys file (default "schema") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_code.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_code.md index 7ef95dbcb..65adbfe01 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_code.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_code.md @@ -30,8 +30,10 @@ authelia-gen code [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen code [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") @@ -54,4 +58,5 @@ authelia-gen code [flags] * [authelia-gen](authelia-gen.md) - Authelia's generator tooling * [authelia-gen code keys](authelia-gen_code_keys.md) - Generate the list of valid configuration keys * [authelia-gen code scripts](authelia-gen_code_scripts.md) - Generate the generated portion of the authelia-scripts command +* [authelia-gen code server](authelia-gen_code_server.md) - Generate the Authelia server files diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_keys.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_keys.md index 15166ede3..2b0a9ea98 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_keys.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_keys.md @@ -30,8 +30,10 @@ authelia-gen code keys [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen code keys [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_scripts.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_scripts.md index be30fd2fa..b482188e3 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_scripts.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_scripts.md @@ -30,8 +30,10 @@ authelia-gen code scripts [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen code scripts [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_server.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_server.md new file mode 100644 index 000000000..75d4b7c7c --- /dev/null +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_code_server.md @@ -0,0 +1,59 @@ +--- +title: "authelia-gen code server" +description: "Reference for the authelia-gen code server command." +lead: "" +date: 2022-06-15T17:51:47+10:00 +draft: false +images: [] +menu: + reference: + parent: "cli-authelia-gen" +weight: 330 +toc: true +--- + +## authelia-gen code server + +Generate the Authelia server files + +``` +authelia-gen code server [flags] +``` + +### Options + +``` + -h, --help help for server +``` + +### Options inherited from parent commands + +``` + -C, --cwd string Sets the CWD for git commands + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") + --dir.locales string The locales directory in relation to the root (default "internal/server/locales") + -d, --dir.root string The repository root (default "./") + -X, --exclude strings Sets the names of excluded generators + --file.bug-report string Sets the path of the bug report issue template file (default ".github/ISSUE_TEMPLATE/bug-report.yml") + --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") + --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") + --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") + --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") + --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") + --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") + --package.configuration.keys string Sets the package name of the keys file (default "schema") + --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") + --versions int the maximum number of minor versions to list in output templates (default 5) +``` + +### SEE ALSO + +* [authelia-gen code](authelia-gen_code.md) - Generate code + diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_commit-lint.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_commit-lint.md index 5868626f9..c559fd142 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_commit-lint.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_commit-lint.md @@ -30,8 +30,10 @@ authelia-gen commit-lint [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen commit-lint [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs.md index 03c9d55d0..5c28d1603 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs.md @@ -30,8 +30,10 @@ authelia-gen docs [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen docs [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") @@ -53,6 +57,6 @@ authelia-gen docs [flags] * [authelia-gen](authelia-gen.md) - Authelia's generator tooling * [authelia-gen docs cli](authelia-gen_docs_cli.md) - Generate CLI docs +* [authelia-gen docs data](authelia-gen_docs_data.md) - Generate docs data files * [authelia-gen docs date](authelia-gen_docs_date.md) - Generate doc dates -* [authelia-gen docs keys](authelia-gen_docs_keys.md) - Generate the docs data file for configuration keys diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_cli.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_cli.md index 164df34ee..8f4dfa7b6 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_cli.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_cli.md @@ -30,8 +30,10 @@ authelia-gen docs cli [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen docs cli [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_data.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_data.md new file mode 100644 index 000000000..2ba5ed90a --- /dev/null +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_data.md @@ -0,0 +1,61 @@ +--- +title: "authelia-gen docs data" +description: "Reference for the authelia-gen docs data command." +lead: "" +date: 2022-09-16T14:21:05+10:00 +draft: false +images: [] +menu: + reference: + parent: "cli-authelia-gen" +weight: 330 +toc: true +--- + +## authelia-gen docs data + +Generate docs data files + +``` +authelia-gen docs data [flags] +``` + +### Options + +``` + -h, --help help for data +``` + +### Options inherited from parent commands + +``` + -C, --cwd string Sets the CWD for git commands + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") + --dir.locales string The locales directory in relation to the root (default "internal/server/locales") + -d, --dir.root string The repository root (default "./") + -X, --exclude strings Sets the names of excluded generators + --file.bug-report string Sets the path of the bug report issue template file (default ".github/ISSUE_TEMPLATE/bug-report.yml") + --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") + --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") + --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") + --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") + --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") + --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") + --package.configuration.keys string Sets the package name of the keys file (default "schema") + --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") + --versions int the maximum number of minor versions to list in output templates (default 5) +``` + +### SEE ALSO + +* [authelia-gen docs](authelia-gen_docs.md) - Generate docs +* [authelia-gen docs data keys](authelia-gen_docs_data_keys.md) - Generate the docs data file for configuration keys +* [authelia-gen docs data misc](authelia-gen_docs_data_misc.md) - Generate docs data file misc.json + diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_keys.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_data_keys.md similarity index 70% rename from docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_keys.md rename to docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_data_keys.md index f16322dc9..82932eedd 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_keys.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_data_keys.md @@ -1,6 +1,6 @@ --- -title: "authelia-gen docs keys" -description: "Reference for the authelia-gen docs keys command." +title: "authelia-gen docs data keys" +description: "Reference for the authelia-gen docs data keys command." lead: "" date: 2022-09-16T14:21:05+10:00 draft: false @@ -12,12 +12,12 @@ weight: 330 toc: true --- -## authelia-gen docs keys +## authelia-gen docs data keys Generate the docs data file for configuration keys ``` -authelia-gen docs keys [flags] +authelia-gen docs data keys [flags] ``` ### Options @@ -30,8 +30,10 @@ authelia-gen docs keys [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen docs keys [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") @@ -51,5 +55,5 @@ authelia-gen docs keys [flags] ### SEE ALSO -* [authelia-gen docs](authelia-gen_docs.md) - Generate docs +* [authelia-gen docs data](authelia-gen_docs_data.md) - Generate docs data files diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_data_misc.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_data_misc.md new file mode 100644 index 000000000..cdcb1042e --- /dev/null +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_data_misc.md @@ -0,0 +1,59 @@ +--- +title: "authelia-gen docs data misc" +description: "Reference for the authelia-gen docs data misc command." +lead: "" +date: 2022-06-15T17:51:47+10:00 +draft: false +images: [] +menu: + reference: + parent: "cli-authelia-gen" +weight: 330 +toc: true +--- + +## authelia-gen docs data misc + +Generate docs data file misc.json + +``` +authelia-gen docs data misc [flags] +``` + +### Options + +``` + -h, --help help for misc +``` + +### Options inherited from parent commands + +``` + -C, --cwd string Sets the CWD for git commands + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") + --dir.locales string The locales directory in relation to the root (default "internal/server/locales") + -d, --dir.root string The repository root (default "./") + -X, --exclude strings Sets the names of excluded generators + --file.bug-report string Sets the path of the bug report issue template file (default ".github/ISSUE_TEMPLATE/bug-report.yml") + --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") + --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") + --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") + --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") + --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") + --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") + --package.configuration.keys string Sets the package name of the keys file (default "schema") + --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") + --versions int the maximum number of minor versions to list in output templates (default 5) +``` + +### SEE ALSO + +* [authelia-gen docs data](authelia-gen_docs_data.md) - Generate docs data files + diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_date.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_date.md index 1ef854d4a..4110ca86c 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_date.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_docs_date.md @@ -32,8 +32,10 @@ authelia-gen docs date [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -41,10 +43,12 @@ authelia-gen docs date [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_github.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_github.md index 5948e57a3..432b603e9 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_github.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_github.md @@ -30,8 +30,10 @@ authelia-gen github [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen github [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates.md index ee4b8d234..bc855e6f0 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates.md @@ -30,8 +30,10 @@ authelia-gen github issue-templates [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen github issue-templates [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates_bug-report.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates_bug-report.md index 55390f914..0f6c5be4e 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates_bug-report.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates_bug-report.md @@ -30,8 +30,10 @@ authelia-gen github issue-templates bug-report [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen github issue-templates bug-report [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates_feature-request.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates_feature-request.md index 0ac91c4ae..63ca5cb17 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates_feature-request.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_github_issue-templates_feature-request.md @@ -30,8 +30,10 @@ authelia-gen github issue-templates feature-request [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen github issue-templates feature-request [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/content/en/reference/cli/authelia-gen/authelia-gen_locales.md b/docs/content/en/reference/cli/authelia-gen/authelia-gen_locales.md index 5cd715185..69d169ec1 100644 --- a/docs/content/en/reference/cli/authelia-gen/authelia-gen_locales.md +++ b/docs/content/en/reference/cli/authelia-gen/authelia-gen_locales.md @@ -30,8 +30,10 @@ authelia-gen locales [flags] ``` -C, --cwd string Sets the CWD for git commands - --dir.docs.cli-reference string The directory to store the markdown in (default "docs/content/en/reference/cli") - --dir.docs.content string The directory with the docs content (default "docs/content") + --dir.docs string The directory with the docs (default "docs") + --dir.docs.cli-reference string The directory to store the markdown in (default "en/reference/cli") + --dir.docs.content string The directory with the docs content (default "content") + --dir.docs.data string The directory with the docs data (default "data") --dir.locales string The locales directory in relation to the root (default "internal/server/locales") -d, --dir.root string The repository root (default "./") -X, --exclude strings Sets the names of excluded generators @@ -39,10 +41,12 @@ authelia-gen locales [flags] --file.commit-lint-config string The commit lint javascript configuration file in relation to the root (default "web/.commitlintrc.js") --file.configuration-keys string Sets the path of the keys file (default "internal/configuration/schema/keys.go") --file.docs-commit-msg-guidelines string The commit message guidelines documentation file in relation to the root (default "docs/content/en/contributing/guidelines/commit-message.md") - --file.docs-keys string Sets the path of the docs keys file (default "docs/data/configkeys.json") - --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "docs/data/languages.json") + --file.docs.data.keys string Sets the path of the docs keys file (default "configkeys.json") + --file.docs.data.languages string The languages docs data file in relation to the docs data folder (default "languages.json") + --file.docs.data.misc string The misc docs data file in relation to the docs data folder (default "misc.json") --file.feature-request string Sets the path of the feature request issue template file (default ".github/ISSUE_TEMPLATE/feature-request.yml") --file.scripts.gen string Sets the path of the authelia-scripts gen file (default "cmd/authelia-scripts/cmd/gen.go") + --file.server.generated string Sets the path of the server generated file (default "internal/server/gen.go") --file.web-i18n string The i18n typescript configuration file in relation to the root (default "web/src/i18n/index.ts") --package.configuration.keys string Sets the package name of the keys file (default "schema") --package.scripts.gen string Sets the package name of the authelia-scripts gen file (default "cmd") diff --git a/docs/data/misc.json b/docs/data/misc.json new file mode 100644 index 000000000..dc84fbe39 --- /dev/null +++ b/docs/data/misc.json @@ -0,0 +1 @@ +{"csp":{"default":"default-src 'self'; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-${NONCE}'; frame-ancestors 'none'; base-uri 'self'; require-trusted-types-for 'script'","development":"default-src 'self' 'unsafe-eval'; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-${NONCE}'; frame-ancestors 'none'; base-uri 'self'","nonce":"${NONCE}"}} \ No newline at end of file diff --git a/docs/layouts/shortcodes/csp.html b/docs/layouts/shortcodes/csp.html new file mode 100644 index 000000000..b5465737e --- /dev/null +++ b/docs/layouts/shortcodes/csp.html @@ -0,0 +1,2 @@ +

Placeholder Value: {{ $.Site.Data.misc.csp.nonce }}

+

Default Template: {{ $.Site.Data.misc.csp.default }}

diff --git a/internal/server/const.go b/internal/server/const.go index 4d7a636b2..f4a774674 100644 --- a/internal/server/const.go +++ b/internal/server/const.go @@ -72,8 +72,7 @@ X_AUTHELIA_HEALTHCHECK_PATH=%s ` const ( - cspDefaultTemplate = "default-src 'self'%s; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-%s'; frame-ancestors 'none'; base-uri 'self'" - cspNoncePlaceholder = "${NONCE}" + tmplCSPSwagger = "default-src 'self'; img-src 'self' https://validator.swagger.io data:; object-src 'none'; script-src 'self' 'unsafe-inline' 'nonce-%s'; style-src 'self' 'nonce-%s'; base-uri 'self'" ) const ( diff --git a/internal/server/gen.go b/internal/server/gen.go new file mode 100644 index 000000000..9f7333090 --- /dev/null +++ b/internal/server/gen.go @@ -0,0 +1,13 @@ +// Code generated by go generate. DO NOT EDIT. +// +// Run the following command to generate this file: +// go run ./cmd/authelia-gen code server +// + +package server + +const ( + placeholderCSPNonce = "${NONCE}" + tmplCSPDefault = "default-src 'self'; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-%s'; frame-ancestors 'none'; base-uri 'self'; require-trusted-types-for 'script'" + tmplCSPDevelopment = "default-src 'self' 'unsafe-eval'; frame-src 'none'; object-src 'none'; style-src 'self' 'nonce-%s'; frame-ancestors 'none'; base-uri 'self'" +) diff --git a/internal/server/template.go b/internal/server/template.go index 3f1d914f9..0042f8856 100644 --- a/internal/server/template.go +++ b/internal/server/template.go @@ -75,13 +75,13 @@ func ServeTemplatedFile(publicDir, file, assetPath, duoSelfEnrollment, rememberM switch { case publicDir == assetsSwagger: - ctx.Response.Header.Add(fasthttp.HeaderContentSecurityPolicy, fmt.Sprintf("base-uri 'self'; default-src 'self'; img-src 'self' https://validator.swagger.io data:; object-src 'none'; script-src 'self' 'unsafe-inline' 'nonce-%s'; style-src 'self' 'nonce-%s'", nonce, nonce)) + ctx.Response.Header.Add(fasthttp.HeaderContentSecurityPolicy, fmt.Sprintf(tmplCSPSwagger, nonce, nonce)) case ctx.Configuration.Server.Headers.CSPTemplate != "": - ctx.Response.Header.Add(fasthttp.HeaderContentSecurityPolicy, strings.ReplaceAll(ctx.Configuration.Server.Headers.CSPTemplate, cspNoncePlaceholder, nonce)) + ctx.Response.Header.Add(fasthttp.HeaderContentSecurityPolicy, strings.ReplaceAll(ctx.Configuration.Server.Headers.CSPTemplate, placeholderCSPNonce, nonce)) case os.Getenv("ENVIRONMENT") == dev: - ctx.Response.Header.Add(fasthttp.HeaderContentSecurityPolicy, fmt.Sprintf(cspDefaultTemplate, " 'unsafe-eval'", nonce)) + ctx.Response.Header.Add(fasthttp.HeaderContentSecurityPolicy, fmt.Sprintf(tmplCSPDevelopment, nonce)) default: - ctx.Response.Header.Add(fasthttp.HeaderContentSecurityPolicy, fmt.Sprintf(cspDefaultTemplate, "", nonce)) + ctx.Response.Header.Add(fasthttp.HeaderContentSecurityPolicy, fmt.Sprintf(tmplCSPDefault, nonce)) } err := tmpl.Execute(ctx.Response.BodyWriter(), struct{ Base, BaseURL, CSPNonce, DuoSelfEnrollment, LogoOverride, RememberMe, ResetPassword, ResetPasswordCustomURL, Session, Theme string }{Base: base, BaseURL: baseURL, CSPNonce: nonce, DuoSelfEnrollment: duoSelfEnrollment, LogoOverride: logoOverride, RememberMe: rememberMe, ResetPassword: resetPassword, ResetPasswordCustomURL: resetPasswordCustomURL, Session: session, Theme: theme})