mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
chore: add config option to disable user registrations (resolve #113)
This commit is contained in:
parent
22260ceb0d
commit
d728426b45
@ -40,6 +40,7 @@ ENV WAKAPI_DB_NAME=/data/wakapi.db
|
|||||||
ENV WAKAPI_PASSWORD_SALT ''
|
ENV WAKAPI_PASSWORD_SALT ''
|
||||||
ENV WAKAPI_LISTEN_IPV4 '0.0.0.0'
|
ENV WAKAPI_LISTEN_IPV4 '0.0.0.0'
|
||||||
ENV WAKAPI_INSECURE_COOKIES 'true'
|
ENV WAKAPI_INSECURE_COOKIES 'true'
|
||||||
|
ENV WAKAPI_ALLOW_SIGNUP 'true
|
||||||
|
|
||||||
COPY --from=build-env /app .
|
COPY --from=build-env /app .
|
||||||
|
|
||||||
|
@ -28,4 +28,5 @@ db:
|
|||||||
security:
|
security:
|
||||||
password_salt: # CHANGE !
|
password_salt: # CHANGE !
|
||||||
insecure_cookies: false
|
insecure_cookies: false
|
||||||
cookie_max_age: 172800
|
cookie_max_age: 172800
|
||||||
|
allow_signup: true
|
@ -48,6 +48,7 @@ type appConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type securityConfig struct {
|
type securityConfig struct {
|
||||||
|
AllowSignup bool `yaml:"allow_signup" default:"true" env:"WAKAPI_ALLOW_SIGNUP"`
|
||||||
// this is actually a pepper (https://en.wikipedia.org/wiki/Pepper_(cryptography))
|
// this is actually a pepper (https://en.wikipedia.org/wiki/Pepper_(cryptography))
|
||||||
PasswordSalt string `yaml:"password_salt" default:"" env:"WAKAPI_PASSWORD_SALT"`
|
PasswordSalt string `yaml:"password_salt" default:"" env:"WAKAPI_PASSWORD_SALT"`
|
||||||
InsecureCookies bool `yaml:"insecure_cookies" default:"false" env:"WAKAPI_INSECURE_COOKIES"`
|
InsecureCookies bool `yaml:"insecure_cookies" default:"false" env:"WAKAPI_INSECURE_COOKIES"`
|
||||||
|
@ -121,6 +121,12 @@ func (h *LoginHandler) PostSignup(w http.ResponseWriter, r *http.Request) {
|
|||||||
loadTemplates()
|
loadTemplates()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !h.config.IsDev() && !h.config.Security.AllowSignup {
|
||||||
|
w.WriteHeader(http.StatusForbidden)
|
||||||
|
templates[conf.SignupTemplate].Execute(w, h.buildViewModel(r).WithError("registration is disabled on this server"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if cookie, err := r.Cookie(models.AuthCookieKey); err == nil && cookie.Value != "" {
|
if cookie, err := r.Cookie(models.AuthCookieKey); err == nil && cookie.Value != "" {
|
||||||
http.Redirect(w, r, fmt.Sprintf("%s/summary", h.config.Server.BasePath), http.StatusFound)
|
http.Redirect(w, r, fmt.Sprintf("%s/summary", h.config.Server.BasePath), http.StatusFound)
|
||||||
return
|
return
|
||||||
|
@ -1 +1 @@
|
|||||||
1.22.4
|
1.22.5
|
Loading…
Reference in New Issue
Block a user