1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-11 21:10:26 +00:00

Add fields related to registration to the config

This commit is contained in:
bouncepaw 2021-04-12 19:26:49 +05:00
parent 15a0b62e1c
commit 9eff38fdc4
5 changed files with 29 additions and 15 deletions

View File

@ -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(`

View File

@ -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

14
flag.go
View File

@ -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()
}
}

View File

@ -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
}

View File

@ -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.