conf: remove legacy options (#6267)

* conf: remove legacy options

* Update tests
pull/6268/head
ᴜɴᴋɴᴡᴏɴ 2020-08-22 22:25:21 +08:00 committed by GitHub
parent 05477f1d29
commit f0761eb7ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 136 deletions

View File

@ -4,6 +4,31 @@ All notable changes to Gogs are documented in this file.
## 0.13.0+dev (`master`)
### Added
### Changed
### Fixed
### Removed
- Configuration section `[mailer]` is no longer used.
- Configuration section `[service]` is no longer used.
- Configuration option `APP_NAME` is no longer used.
- Configuration option `[security] REVERSE_PROXY_AUTHENTICATION_USER` is no longer used.
- Configuration option `[database] PASSWD` is no longer used.
- Configuration option `[auth] ACTIVE_CODE_LIVE_MINUTES` is no longer used.
- Configuration option `[auth] RESET_PASSWD_CODE_LIVE_MINUTES` is no longer used.
- Configuration option `[auth] ENABLE_CAPTCHA` is no longer used.
- Configuration option `[auth] ENABLE_NOTIFY_MAIL` is no longer used.
- Configuration option `[auth] REGISTER_EMAIL_CONFIRM` is no longer used.
- Configuration option `[session] GC_INTERVAL_TIME` is no longer used.
- Configuration option `[session] SESSION_LIFE_TIME` is no longer used.
- Configuration option `[server] ROOT_URL` is no longer used.
- Configuration option `[server] LANDING_PAGE` is no longer used.
- Configuration option `[database] DB_TYPE` is no longer used.
- Configuration option `[database] PASSWD` is no longer used.
## 0.12.0
### Added

View File

@ -214,10 +214,6 @@ func Init(customConf string) error {
if err = File.Section("email").MapTo(&Email); err != nil {
return errors.Wrap(err, "mapping [email] section")
}
// LEGACY [0.13]: In case there are values with old section name.
if err = File.Section("mailer").MapTo(&Email); err != nil {
return errors.Wrap(err, "mapping [mailer] section")
}
if Email.Enabled {
if Email.From == "" {
@ -238,10 +234,6 @@ func Init(customConf string) error {
if err = File.Section("auth").MapTo(&Auth); err != nil {
return errors.Wrap(err, "mapping [auth] section")
}
// LEGACY [0.13]: In case there are values with old section name.
if err = File.Section("service").MapTo(&Auth); err != nil {
return errors.Wrap(err, "mapping [service] section")
}
// *************************
// ----- User settings -----

View File

@ -41,9 +41,6 @@ var (
BrandName string
RunUser string
RunMode string
// Deprecated: Use BrandName instead, will be removed in 0.13.
AppName string
}
// SSH settings
@ -103,9 +100,6 @@ var (
CookieSecure bool
EnableLoginStatusCookie bool
LoginStatusCookieName string
// Deprecated: Use Auth.ReverseProxyAuthenticationHeader instead, will be removed in 0.13.
ReverseProxyAuthenticationUser string
}
// Email settings
@ -130,9 +124,6 @@ var (
// Derived from other static values
FromEmail string `ini:"-"` // Parsed email address of From without person's name.
// Deprecated: Use Password instead, will be removed in 0.13.
Passwd string
}
// Authentication settings
@ -147,17 +138,6 @@ var (
EnableReverseProxyAuthentication bool
EnableReverseProxyAutoRegistration bool
ReverseProxyAuthenticationHeader string
// Deprecated: Use ActivateCodeLives instead, will be removed in 0.13.
ActiveCodeLiveMinutes int
// Deprecated: Use ResetPasswordCodeLives instead, will be removed in 0.13.
ResetPasswdCodeLiveMinutes int
// Deprecated: Use RequireEmailConfirmation instead, will be removed in 0.13.
RegisterEmailConfirm bool
// Deprecated: Use EnableRegistrationCaptcha instead, will be removed in 0.13.
EnableCaptcha bool
// Deprecated: Use User.EnableEmailNotification instead, will be removed in 0.13.
EnableNotifyMail bool
}
// User settings
@ -174,11 +154,6 @@ var (
GCInterval int64 `ini:"GC_INTERVAL"`
MaxLifeTime int64
CSRFCookieName string `ini:"CSRF_COOKIE_NAME"`
// Deprecated: Use GCInterval instead, will be removed in 0.13.
GCIntervalTime int64 `ini:"GC_INTERVAL_TIME"`
// Deprecated: Use MaxLifeTime instead, will be removed in 0.13.
SessionLifeTime int64
}
// Cache settings
@ -382,11 +357,6 @@ type ServerOpts struct {
Subpath string `ini:"-"` // Subpath found the ExternalURL. Should be empty when not found.
SubpathDepth int `ini:"-"` // The number of slashes found in the Subpath.
UnixSocketMode os.FileMode `ini:"-"` // Parsed file mode of UnixSocketPermission.
// Deprecated: Use ExternalURL instead, will be removed in 0.13.
RootURL string `ini:"ROOT_URL"`
// Deprecated: Use LandingURL instead, will be removed in 0.13.
LangdingPage string `ini:"LANDING_PAGE"`
}
// Server settings
@ -402,11 +372,6 @@ type DatabaseOpts struct {
Path string
MaxOpenConns int
MaxIdleConns int
// Deprecated: Use Type instead, will be removed in 0.13.
DbType string
// Deprecated: Use Password instead, will be removed in 0.13.
Passwd string
}
// Database settings
@ -440,68 +405,11 @@ var I18n *i18nConf
// handleDeprecated transfers deprecated values to the new ones when set.
func handleDeprecated() {
if App.AppName != "" {
App.BrandName = App.AppName
App.AppName = ""
}
if Server.RootURL != "" {
Server.ExternalURL = Server.RootURL
Server.RootURL = ""
}
if Server.LangdingPage == "explore" {
Server.LandingURL = "/explore"
Server.LangdingPage = ""
}
if Database.DbType != "" {
Database.Type = Database.DbType
Database.DbType = ""
}
if Database.Passwd != "" {
Database.Password = Database.Passwd
Database.Passwd = ""
}
if Email.Passwd != "" {
Email.Password = Email.Passwd
Email.Passwd = ""
}
if Auth.ActiveCodeLiveMinutes > 0 {
Auth.ActivateCodeLives = Auth.ActiveCodeLiveMinutes
Auth.ActiveCodeLiveMinutes = 0
}
if Auth.ResetPasswdCodeLiveMinutes > 0 {
Auth.ResetPasswordCodeLives = Auth.ResetPasswdCodeLiveMinutes
Auth.ResetPasswdCodeLiveMinutes = 0
}
if Auth.RegisterEmailConfirm {
Auth.RequireEmailConfirmation = true
Auth.RegisterEmailConfirm = false
}
if Auth.EnableCaptcha {
Auth.EnableRegistrationCaptcha = true
Auth.EnableCaptcha = false
}
if Security.ReverseProxyAuthenticationUser != "" {
Auth.ReverseProxyAuthenticationHeader = Security.ReverseProxyAuthenticationUser
Security.ReverseProxyAuthenticationUser = ""
}
if Auth.EnableNotifyMail {
User.EnableEmailNotification = true
Auth.EnableNotifyMail = false
}
if Session.GCIntervalTime > 0 {
Session.GCInterval = Session.GCIntervalTime
Session.GCIntervalTime = 0
}
if Session.SessionLifeTime > 0 {
Session.MaxLifeTime = Session.SessionLifeTime
Session.SessionLifeTime = 0
}
// Add fallback logic here, example:
// if App.AppName != "" {
// App.BrandName = App.AppName
// App.AppName = ""
// }
}
// HookMode indicates whether program starts as Git server-side hook callback.

View File

@ -1,7 +1,6 @@
BRAND_NAME=Testing
RUN_USER=git
RUN_MODE=test
APP_NAME=
[server]
EXTERNAL_URL=http://localhost:3080/
@ -20,8 +19,6 @@ ENABLE_GZIP=false
APP_DATA_PATH=/tmp/data
LOAD_ASSETS_FROM_DISK=false
LANDING_URL=/explore
ROOT_URL=
LANDING_PAGE=
DISABLE_SSH=false
SSH_DOMAIN=localhost
SSH_PORT=22
@ -68,8 +65,6 @@ SSL_MODE=disable
PATH=/tmp/gogs.db
MAX_OPEN_CONNS=30
MAX_IDLE_CONNS=30
DB_TYPE=
PASSWD=
[security]
INSTALL_LOCK=false
@ -80,11 +75,10 @@ COOKIE_USERNAME=gogs_awesome
COOKIE_SECURE=false
ENABLE_LOGIN_STATUS_COOKIE=false
LOGIN_STATUS_COOKIE_NAME=login_status
REVERSE_PROXY_AUTHENTICATION_USER=
[email]
ENABLED=true
SUBJECT_PREFIX=[Gogs]
SUBJECT_PREFIX=[Testing]
HOST=smtp.mailgun.org:587
FROM=noreply@gogs.localhost
USER=noreply@gogs.localhost
@ -97,7 +91,6 @@ CERT_FILE=custom/email/cert.pem
KEY_FILE=custom/email/key.pem
USE_PLAIN_TEXT=false
ADD_PLAIN_TEXT_ALT=false
PASSWD=
[auth]
ACTIVATE_CODE_LIVES=10
@ -109,11 +102,6 @@ ENABLE_REGISTRATION_CAPTCHA=true
ENABLE_REVERSE_PROXY_AUTHENTICATION=false
ENABLE_REVERSE_PROXY_AUTO_REGISTRATION=false
REVERSE_PROXY_AUTHENTICATION_HEADER=X-FORWARDED-FOR
ACTIVE_CODE_LIVE_MINUTES=0
RESET_PASSWD_CODE_LIVE_MINUTES=0
REGISTER_EMAIL_CONFIRM=false
ENABLE_CAPTCHA=false
ENABLE_NOTIFY_MAIL=false
[user]
ENABLE_EMAIL_NOTIFICATION=true
@ -126,8 +114,6 @@ COOKIE_SECURE=false
GC_INTERVAL=10
MAX_LIFE_TIME=10
CSRF_COOKIE_NAME=_csrf
GC_INTERVAL_TIME=0
SESSION_LIFE_TIME=0
[attachment]
ENABLED=true

View File

@ -1,13 +1,13 @@
APP_NAME = Testing
BRAND_NAME = Testing
RUN_MODE = test
[server]
ROOT_URL = http://localhost:3080/
EXTERNAL_URL = http://localhost:3080/
APP_DATA_PATH = /tmp/data
SSH_ROOT_PATH = /tmp
SSH_KEY_TEST_PATH = /tmp/ssh-key-test
MINIMUM_KEY_SIZE_CHECK = true
LANDING_PAGE = explore
LANDING_URL = /explore
[repository]
ROOT = /tmp/gogs-repositories
@ -16,27 +16,28 @@ ROOT = /tmp/gogs-repositories
TEMP_PATH = /tmp/uploads
[database]
DB_TYPE = sqlite
PASSWD = 12345678
TYPE = sqlite
PASSWORD = 12345678
PATH = /tmp/gogs.db
[security]
REVERSE_PROXY_AUTHENTICATION_USER=X-FORWARDED-FOR
[email]
ENABLED = true
PASSWD = 87654321
PASSWORD = 87654321
[auth]
ACTIVE_CODE_LIVE_MINUTES = 10
RESET_PASSWD_CODE_LIVE_MINUTES = 10
REGISTER_EMAIL_CONFIRM = true
ACTIVATE_CODE_LIVES = 10
RESET_PASSWORD_CODE_LIVES = 10
REQUIRE_EMAIL_CONFIRMATION = true
ENABLE_CAPTCHA = true
ENABLE_NOTIFY_MAIL = true
REVERSE_PROXY_AUTHENTICATION_HEADER=X-FORWARDED-FOR
[user]
ENABLE_EMAIL_NOTIFICATION = true
[session]
GC_INTERVAL_TIME = 10
SESSION_LIFE_TIME = 10
GC_INTERVAL = 10
MAX_LIFE_TIME = 10
[attachment]
PATH = /tmp/attachments

View File

@ -364,8 +364,8 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
}
}
// Send confirmation email, no need for social account.
if conf.Auth.RegisterEmailConfirm && u.ID > 1 {
// Send confirmation email.
if conf.Auth.RequireEmailConfirmation && u.ID > 1 {
email.SendActivateAccountMail(c.Context, db.NewMailerUser(u))
c.Data["IsSendRegisterMail"] = true
c.Data["Email"] = u.Email