summaryrefslogtreecommitdiff
path: root/internal/config
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-06-03 15:40:38 +0200
committerLibravatar GitHub <noreply@github.com>2022-06-03 15:40:38 +0200
commit327d3f001f1cc219c4a718edf23b976c29c19487 (patch)
tree7fbc505601461f22eeeea6e966b9df5a43b4cafc /internal/config
parent[chore] Adds Issue templates to Github (#626) (diff)
downloadgotosocial-327d3f001f1cc219c4a718edf23b976c29c19487.tar.xz
[feature] Start adding advanced configuration options, starting with `samesite` (#628)
* fix incorrect port being used for db * start adding advanced config flags * use samesite lax by default
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go2
-rw-r--r--internal/config/defaults.go2
-rw-r--r--internal/config/flags.go3
-rw-r--r--internal/config/helpers.gen.go25
4 files changed, 32 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 431fbbe4d..573f2b3a2 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -114,6 +114,8 @@ type Configuration struct {
AdminAccountEmail string `name:"email" usage:"the email address of this account"`
AdminAccountPassword string `name:"password" usage:"the password to set for this account"`
AdminTransPath string `name:"path" usage:"the path of the file to import from/export to"`
+
+ AdvancedCookiesSamesite string `name:"advanced-cookies-samesite" usage:"'strict' or 'lax', see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite"`
}
// MarshalMap will marshal current Configuration into a map structure (useful for JSON).
diff --git a/internal/config/defaults.go b/internal/config/defaults.go
index 75af21222..f9f0bdba9 100644
--- a/internal/config/defaults.go
+++ b/internal/config/defaults.go
@@ -87,4 +87,6 @@ var Defaults = Configuration{
SyslogEnabled: false,
SyslogProtocol: "udp",
SyslogAddress: "localhost:514",
+
+ AdvancedCookiesSamesite: "lax",
}
diff --git a/internal/config/flags.go b/internal/config/flags.go
index 0be372551..6f946f1d6 100644
--- a/internal/config/flags.go
+++ b/internal/config/flags.go
@@ -109,6 +109,9 @@ func AddServerFlags(cmd *cobra.Command) {
cmd.Flags().Bool(SyslogEnabledFlag(), cfg.SyslogEnabled, fieldtag("SyslogEnabled", "usage"))
cmd.Flags().String(SyslogProtocolFlag(), cfg.SyslogProtocol, fieldtag("SyslogProtocol", "usage"))
cmd.Flags().String(SyslogAddressFlag(), cfg.SyslogAddress, fieldtag("SyslogAddress", "usage"))
+
+ // Advanced flags
+ cmd.Flags().String(AdvancedCookiesSamesiteFlag(), cfg.AdvancedCookiesSamesite, fieldtag("AdvancedCookiesSamesite", "usage"))
})
}
diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go
index a90199495..a48828059 100644
--- a/internal/config/helpers.gen.go
+++ b/internal/config/helpers.gen.go
@@ -1492,3 +1492,28 @@ func GetAdminTransPath() string { return global.GetAdminTransPath() }
// SetAdminTransPath safely sets the value for global configuration 'AdminTransPath' field
func SetAdminTransPath(v string) { global.SetAdminTransPath(v) }
+
+// GetAdvancedCookiesSamesite safely fetches the Configuration value for state's 'AdvancedCookiesSamesite' field
+func (st *ConfigState) GetAdvancedCookiesSamesite() (v string) {
+ st.mutex.Lock()
+ v = st.config.AdvancedCookiesSamesite
+ st.mutex.Unlock()
+ return
+}
+
+// SetAdvancedCookiesSamesite safely sets the Configuration value for state's 'AdvancedCookiesSamesite' field
+func (st *ConfigState) SetAdvancedCookiesSamesite(v string) {
+ st.mutex.Lock()
+ defer st.mutex.Unlock()
+ st.config.AdvancedCookiesSamesite = v
+ st.reloadToViper()
+}
+
+// AdvancedCookiesSamesiteFlag returns the flag name for the 'AdvancedCookiesSamesite' field
+func AdvancedCookiesSamesiteFlag() string { return "advanced-cookies-samesite" }
+
+// GetAdvancedCookiesSamesite safely fetches the value for global configuration 'AdvancedCookiesSamesite' field
+func GetAdvancedCookiesSamesite() string { return global.GetAdvancedCookiesSamesite() }
+
+// SetAdvancedCookiesSamesite safely sets the value for global configuration 'AdvancedCookiesSamesite' field
+func SetAdvancedCookiesSamesite(v string) { global.SetAdvancedCookiesSamesite(v) }