diff --git a/assets/assets.qtpl.go b/assets/assets.qtpl.go index 62aee1e..a4bdb1b 100644 --- a/assets/assets.qtpl.go +++ b/assets/assets.qtpl.go @@ -70,6 +70,10 @@ GeminiCertificatePath = /home/wiki/gemcerts [Authorization] UseFixedAuth = true FixedAuthCredentialsPath = /home/wiki/mycocredentials.json + +UseRegistration = true +RegistrationCredentialsPath = /home/wiki/mycoregistration.json +LimitRegistration = 10 `) //line assets/assets.qtpl:6 qw422016.N().S(` diff --git a/assets/config.ini b/assets/config.ini index 0ad67b9..b6d3c5e 100644 --- a/assets/config.ini +++ b/assets/config.ini @@ -14,3 +14,7 @@ GeminiCertificatePath = /home/wiki/gemcerts [Authorization] UseFixedAuth = true FixedAuthCredentialsPath = /home/wiki/mycocredentials.json + +UseRegistration = true +RegistrationCredentialsPath = /home/wiki/mycoregistration.json +LimitRegistration = 10 diff --git a/flag.go b/flag.go index b3be793..8dec37d 100644 --- a/flag.go +++ b/flag.go @@ -15,16 +15,6 @@ import ( var printExampleConfig bool func init() { - // flag.StringVar(&util.URL, "url", "http://0.0.0.0:$port", "URL at which your wiki can be found. Used to generate feeds and social media previews") - // flag.StringVar(&util.ServerPort, "port", "1737", "Port to serve the wiki at using HTTP") - // flag.StringVar(&util.HomePage, "home", "home", "The home page name") - // flag.StringVar(&util.SiteNavIcon, "icon", "🍄", "What to show in the navititle in the beginning, before the colon") - // flag.StringVar(&util.SiteName, "name", "wiki", "What is the name of your wiki") - // flag.StringVar(&util.UserHypha, "user-hypha", "u", "Hypha which is a superhypha of all user pages") - // flag.StringVar(&util.AuthMethod, "auth-method", "none", "What auth method to use. Variants: \"none\", \"fixed\"") - // flag.StringVar(&util.FixedCredentialsPath, "fixed-credentials-path", "mycocredentials.json", "Used when -auth-method=fixed. Path to file with user credentials.") - // flag.StringVar(&util.HeaderLinksHypha, "header-links-hypha", "", "Optional hypha that overrides the header links") - // flag.StringVar(&util.GeminiCertPath, "gemini-cert-path", "", "Directory where you store Gemini certificates. Leave empty if you don't want to use Gemini.") flag.StringVar(&util.ConfigFilePath, "config-path", "", "Path to a configuration file. Leave empty if you don't want to use it.") flag.BoolVar(&printExampleConfig, "print-example-config", false, "If true, print an example configuration file contents and exit. You can save the output to a file and base your own configuration on it.") flag.Usage = func() { @@ -68,8 +58,8 @@ func parseCliArgs() { util.HomePage = util.CanonicalName(util.HomePage) util.UserHypha = util.CanonicalName(util.UserHypha) util.HeaderLinksHypha = util.CanonicalName(util.HeaderLinksHypha) - user.AuthUsed = util.UseFixedAuth - if user.AuthUsed && util.FixedCredentialsPath != "" { + user.AuthUsed = util.UseFixedAuth || util.UseRegistration + if user.AuthUsed && (util.FixedCredentialsPath != "" || util.RegistrationCredentialsPath != "") { user.ReadUsersFromFilesystem() } } diff --git a/util/config.go b/util/config.go index 0cf2687..c70f37b 100644 --- a/util/config.go +++ b/util/config.go @@ -7,6 +7,7 @@ import ( "github.com/go-ini/ini" ) +// See https://mycorrhiza.lesarbr.es/hypha/configuration/fields type Config struct { WikiName string NaviTitleIcon string @@ -30,6 +31,10 @@ type Network struct { type Authorization struct { UseFixedAuth bool FixedAuthCredentialsPath string + + UseRegistration bool + RegistrationCredentialsPath string + LimitRegistration uint64 } func ReadConfigFile(path string) { @@ -49,6 +54,10 @@ func ReadConfigFile(path string) { Authorization: Authorization{ UseFixedAuth: false, FixedAuthCredentialsPath: "", + + UseRegistration: false, + RegistrationCredentialsPath: "", + LimitRegistration: 0, }, } @@ -60,6 +69,7 @@ func ReadConfigFile(path string) { } } + // Map the struct to the global variables SiteName = cfg.WikiName SiteNavIcon = cfg.NaviTitleIcon HomePage = cfg.HomeHypha @@ -70,4 +80,7 @@ func ReadConfigFile(path string) { GeminiCertPath = cfg.GeminiCertificatePath UseFixedAuth = cfg.UseFixedAuth FixedCredentialsPath = cfg.FixedAuthCredentialsPath + UseRegistration = cfg.UseRegistration + RegistrationCredentialsPath = cfg.RegistrationCredentialsPath + LimitRegistration = cfg.LimitRegistration } diff --git a/util/util.go b/util/util.go index 1c42d40..a88cba3 100644 --- a/util/util.go +++ b/util/util.go @@ -22,11 +22,14 @@ var ( URL string GeminiCertPath string - UseFixedAuth bool - FixedCredentialsPath string - WikiDir string ConfigFilePath string + + UseFixedAuth bool + FixedCredentialsPath string + UseRegistration bool + RegistrationCredentialsPath string + LimitRegistration uint64 ) // LettersNumbersOnly keeps letters and numbers only in the given string.