summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2018-12-18 17:05:48 +0000
committertechknowlogick <hello@techknowlogick.com>2018-12-18 12:05:48 -0500
commit2a660a1de17daf58b8f7d58dea4b82b107b47536 (patch)
treec25a824142ce6bfa0da191b7c711b7665807ae88 /modules
parentfe55ab2a6806b6a7c114378c0436bc59a31646d0 (diff)
downloadgitea-2a660a1de17daf58b8f7d58dea4b82b107b47536.tar.gz
gitea-2a660a1de17daf58b8f7d58dea4b82b107b47536.zip
Support reverse proxy providing email (#5554)
This PR implements #2347
Diffstat (limited to 'modules')
-rw-r--r--modules/auth/auth.go9
-rw-r--r--modules/setting/setting.go22
2 files changed, 21 insertions, 10 deletions
diff --git a/modules/auth/auth.go b/modules/auth/auth.go
index 0d703084da..4b0d4559c9 100644
--- a/modules/auth/auth.go
+++ b/modules/auth/auth.go
@@ -105,9 +105,16 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (*models.User, bool)
// Check if enabled auto-registration.
if setting.Service.EnableReverseProxyAutoRegister {
+ email := gouuid.NewV4().String() + "@localhost"
+ if setting.Service.EnableReverseProxyEmail {
+ webAuthEmail := ctx.Req.Header.Get(setting.ReverseProxyAuthEmail)
+ if len(webAuthEmail) > 0 {
+ email = webAuthEmail
+ }
+ }
u := &models.User{
Name: webAuthUser,
- Email: gouuid.NewV4().String() + "@localhost",
+ Email: email,
Passwd: webAuthUser,
IsActive: true,
}
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index f7da6baac4..c10f165c8e 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -157,15 +157,16 @@ var (
}
// Security settings
- InstallLock bool
- SecretKey string
- LogInRememberDays int
- CookieUserName string
- CookieRememberName string
- ReverseProxyAuthUser string
- MinPasswordLength int
- ImportLocalPaths bool
- DisableGitHooks bool
+ InstallLock bool
+ SecretKey string
+ LogInRememberDays int
+ CookieUserName string
+ CookieRememberName string
+ ReverseProxyAuthUser string
+ ReverseProxyAuthEmail string
+ MinPasswordLength int
+ ImportLocalPaths bool
+ DisableGitHooks bool
// Database settings
UseSQLite3 bool
@@ -950,6 +951,7 @@ func NewContext() {
CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
+ ReverseProxyAuthEmail = sec.Key("REVERSE_PROXY_AUTHENTICATION_EMAIL").MustString("X-WEBAUTH-EMAIL")
MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
DisableGitHooks = sec.Key("DISABLE_GIT_HOOKS").MustBool(false)
@@ -1216,6 +1218,7 @@ var Service struct {
EnableNotifyMail bool
EnableReverseProxyAuth bool
EnableReverseProxyAutoRegister bool
+ EnableReverseProxyEmail bool
EnableCaptcha bool
CaptchaType string
RecaptchaSecret string
@@ -1247,6 +1250,7 @@ func newService() {
Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
+ Service.EnableReverseProxyEmail = sec.Key("ENABLE_REVERSE_PROXY_EMAIL").MustBool()
Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool(false)
Service.CaptchaType = sec.Key("CAPTCHA_TYPE").MustString(ImageCaptcha)
Service.RecaptchaSecret = sec.Key("RECAPTCHA_SECRET").MustString("")