]> source.dussan.org Git - gitea.git/commitdiff
fix #165
authorUnknwon <joe2010xtmf@163.com>
Fri, 5 Dec 2014 22:54:57 +0000 (17:54 -0500)
committerUnknwon <joe2010xtmf@163.com>
Fri, 5 Dec 2014 22:54:57 +0000 (17:54 -0500)
conf/app.ini
gogs.go
modules/auth/auth.go
modules/setting/setting.go
templates/.VERSION

index 0fec297bc5969f845dfa2edde09403b7cb17f18c..4043cbb63118103316e20c19a6b3b3c25a5029ae 100644 (file)
@@ -77,6 +77,7 @@ ENABLE_CACHE_AVATAR = false
 ENABLE_NOTIFY_MAIL = false
 ; More detail: https://github.com/gogits/gogs/issues/165
 ENABLE_REVERSE_PROXY_AUTHENTICATION = false
+ENABLE_REVERSE_PROXY_AUTO_REGISTERATION = false
 
 [webhook]
 ; Cron task interval in minutes
diff --git a/gogs.go b/gogs.go
index ec8fa486951a9165c20961b5ac1c76c5221ed496..5097309e44484aee9729aa2237c1783f12eb67f0 100644 (file)
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
        "github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.5.8.1130 Beta"
+const APP_VER = "0.5.8.1205 Beta"
 
 func init() {
        runtime.GOMAXPROCS(runtime.NumCPU())
index 302620dbc84892643f16e9c4f098bd95e70d5c52..5b7276b48a6f54595921cdc56458ab593425bdf7 100644 (file)
@@ -60,6 +60,7 @@ func SignedInId(req *http.Request, sess session.Store) int64 {
 }
 
 // SignedInUser returns the user object of signed user.
+// It returns a bool value to indicate whether user uses basic auth or not.
 func SignedInUser(req *http.Request, sess session.Store) (*models.User, bool) {
        if !models.HasEngine {
                return nil, false
@@ -75,8 +76,25 @@ func SignedInUser(req *http.Request, sess session.Store) (*models.User, bool) {
                                if err != nil {
                                        if err != models.ErrUserNotExist {
                                                log.Error(4, "GetUserByName: %v", err)
+                                               return nil, false
+                                       }
+
+                                       // Check if enabled auto-registeration.
+                                       if setting.Service.EnableReverseProxyAutoRegister {
+                                               u := &models.User{
+                                                       Name:     webAuthUser,
+                                                       Email:    webAuthUser + "@gogs.io",
+                                                       Passwd:   webAuthUser,
+                                                       IsActive: true,
+                                               }
+                                               if err = models.CreateUser(u); err != nil {
+                                                       // FIXME: should I create a system notice?
+                                                       log.Error(4, "CreateUser: %v", err)
+                                                       return nil, false
+                                               } else {
+                                                       return u, false
+                                               }
                                        }
-                                       return nil, false
                                }
                                return u, false
                        }
index 476fc6affa10dd93f9f9bd542df1c202f8f9d9ab..b1efc9c7a88ffd844be9564fbcc84055507467ef 100644 (file)
@@ -300,15 +300,15 @@ func NewConfigContext() {
 }
 
 var Service struct {
-       RegisterEmailConfirm   bool
-       DisableRegistration    bool
-       RequireSignInView      bool
-       EnableCacheAvatar      bool
-       EnableNotifyMail       bool
-       EnableReverseProxyAuth bool
-       LdapAuth               bool
-       ActiveCodeLives        int
-       ResetPwdCodeLives      int
+       RegisterEmailConfirm           bool
+       DisableRegistration            bool
+       RequireSignInView              bool
+       EnableCacheAvatar              bool
+       EnableNotifyMail               bool
+       EnableReverseProxyAuth         bool
+       EnableReverseProxyAutoRegister bool
+       ActiveCodeLives                int
+       ResetPwdCodeLives              int
 }
 
 func newService() {
@@ -318,6 +318,7 @@ func newService() {
        Service.RequireSignInView = Cfg.MustBool("service", "REQUIRE_SIGNIN_VIEW")
        Service.EnableCacheAvatar = Cfg.MustBool("service", "ENABLE_CACHE_AVATAR")
        Service.EnableReverseProxyAuth = Cfg.MustBool("service", "ENABLE_REVERSE_PROXY_AUTHENTICATION")
+       Service.EnableReverseProxyAutoRegister = Cfg.MustBool("service", "ENABLE_REVERSE_PROXY_AUTO_REGISTERATION")
 }
 
 var logLevels = map[string]string{
index 27cf20dd2f3750206400b7ff053ec6b2778ddaa1..9808b629711f925fe201596dfcc54532744781fa 100644 (file)
@@ -1 +1 @@
-0.5.8.1130 Beta
\ No newline at end of file
+0.5.8.1205 Beta
\ No newline at end of file