mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 05:20:26 +00:00
Add fields related to registration to the config
This commit is contained in:
parent
15a0b62e1c
commit
9eff38fdc4
@ -70,6 +70,10 @@ GeminiCertificatePath = /home/wiki/gemcerts
|
|||||||
[Authorization]
|
[Authorization]
|
||||||
UseFixedAuth = true
|
UseFixedAuth = true
|
||||||
FixedAuthCredentialsPath = /home/wiki/mycocredentials.json
|
FixedAuthCredentialsPath = /home/wiki/mycocredentials.json
|
||||||
|
|
||||||
|
UseRegistration = true
|
||||||
|
RegistrationCredentialsPath = /home/wiki/mycoregistration.json
|
||||||
|
LimitRegistration = 10
|
||||||
`)
|
`)
|
||||||
//line assets/assets.qtpl:6
|
//line assets/assets.qtpl:6
|
||||||
qw422016.N().S(`
|
qw422016.N().S(`
|
||||||
|
@ -14,3 +14,7 @@ GeminiCertificatePath = /home/wiki/gemcerts
|
|||||||
[Authorization]
|
[Authorization]
|
||||||
UseFixedAuth = true
|
UseFixedAuth = true
|
||||||
FixedAuthCredentialsPath = /home/wiki/mycocredentials.json
|
FixedAuthCredentialsPath = /home/wiki/mycocredentials.json
|
||||||
|
|
||||||
|
UseRegistration = true
|
||||||
|
RegistrationCredentialsPath = /home/wiki/mycoregistration.json
|
||||||
|
LimitRegistration = 10
|
||||||
|
14
flag.go
14
flag.go
@ -15,16 +15,6 @@ import (
|
|||||||
var printExampleConfig bool
|
var printExampleConfig bool
|
||||||
|
|
||||||
func init() {
|
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.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.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() {
|
flag.Usage = func() {
|
||||||
@ -68,8 +58,8 @@ func parseCliArgs() {
|
|||||||
util.HomePage = util.CanonicalName(util.HomePage)
|
util.HomePage = util.CanonicalName(util.HomePage)
|
||||||
util.UserHypha = util.CanonicalName(util.UserHypha)
|
util.UserHypha = util.CanonicalName(util.UserHypha)
|
||||||
util.HeaderLinksHypha = util.CanonicalName(util.HeaderLinksHypha)
|
util.HeaderLinksHypha = util.CanonicalName(util.HeaderLinksHypha)
|
||||||
user.AuthUsed = util.UseFixedAuth
|
user.AuthUsed = util.UseFixedAuth || util.UseRegistration
|
||||||
if user.AuthUsed && util.FixedCredentialsPath != "" {
|
if user.AuthUsed && (util.FixedCredentialsPath != "" || util.RegistrationCredentialsPath != "") {
|
||||||
user.ReadUsersFromFilesystem()
|
user.ReadUsersFromFilesystem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/go-ini/ini"
|
"github.com/go-ini/ini"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// See https://mycorrhiza.lesarbr.es/hypha/configuration/fields
|
||||||
type Config struct {
|
type Config struct {
|
||||||
WikiName string
|
WikiName string
|
||||||
NaviTitleIcon string
|
NaviTitleIcon string
|
||||||
@ -30,6 +31,10 @@ type Network struct {
|
|||||||
type Authorization struct {
|
type Authorization struct {
|
||||||
UseFixedAuth bool
|
UseFixedAuth bool
|
||||||
FixedAuthCredentialsPath string
|
FixedAuthCredentialsPath string
|
||||||
|
|
||||||
|
UseRegistration bool
|
||||||
|
RegistrationCredentialsPath string
|
||||||
|
LimitRegistration uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadConfigFile(path string) {
|
func ReadConfigFile(path string) {
|
||||||
@ -49,6 +54,10 @@ func ReadConfigFile(path string) {
|
|||||||
Authorization: Authorization{
|
Authorization: Authorization{
|
||||||
UseFixedAuth: false,
|
UseFixedAuth: false,
|
||||||
FixedAuthCredentialsPath: "",
|
FixedAuthCredentialsPath: "",
|
||||||
|
|
||||||
|
UseRegistration: false,
|
||||||
|
RegistrationCredentialsPath: "",
|
||||||
|
LimitRegistration: 0,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +69,7 @@ func ReadConfigFile(path string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map the struct to the global variables
|
||||||
SiteName = cfg.WikiName
|
SiteName = cfg.WikiName
|
||||||
SiteNavIcon = cfg.NaviTitleIcon
|
SiteNavIcon = cfg.NaviTitleIcon
|
||||||
HomePage = cfg.HomeHypha
|
HomePage = cfg.HomeHypha
|
||||||
@ -70,4 +80,7 @@ func ReadConfigFile(path string) {
|
|||||||
GeminiCertPath = cfg.GeminiCertificatePath
|
GeminiCertPath = cfg.GeminiCertificatePath
|
||||||
UseFixedAuth = cfg.UseFixedAuth
|
UseFixedAuth = cfg.UseFixedAuth
|
||||||
FixedCredentialsPath = cfg.FixedAuthCredentialsPath
|
FixedCredentialsPath = cfg.FixedAuthCredentialsPath
|
||||||
|
UseRegistration = cfg.UseRegistration
|
||||||
|
RegistrationCredentialsPath = cfg.RegistrationCredentialsPath
|
||||||
|
LimitRegistration = cfg.LimitRegistration
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,14 @@ var (
|
|||||||
URL string
|
URL string
|
||||||
GeminiCertPath string
|
GeminiCertPath string
|
||||||
|
|
||||||
UseFixedAuth bool
|
|
||||||
FixedCredentialsPath string
|
|
||||||
|
|
||||||
WikiDir string
|
WikiDir string
|
||||||
ConfigFilePath string
|
ConfigFilePath string
|
||||||
|
|
||||||
|
UseFixedAuth bool
|
||||||
|
FixedCredentialsPath string
|
||||||
|
UseRegistration bool
|
||||||
|
RegistrationCredentialsPath string
|
||||||
|
LimitRegistration uint64
|
||||||
)
|
)
|
||||||
|
|
||||||
// LettersNumbersOnly keeps letters and numbers only in the given string.
|
// LettersNumbersOnly keeps letters and numbers only in the given string.
|
||||||
|
Loading…
Reference in New Issue
Block a user