From 1b734501bdbec3a0ff04458944683eae0990d9ae Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 26 Apr 2014 14:14:48 +0800 Subject: bug fixed --- modules/base/conf.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/base/conf.go b/modules/base/conf.go index 57245045..04c12457 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -316,7 +316,7 @@ func NewConfigContext() { // load LDAP authentication configuration if present LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false) if LdapAuth { - log.Debug("LDAP AUTHENTICATION activated") + qlog.Debug("LDAP AUTHENTICATION activated") nbsrc := 0 for _, v := range Cfg.GetSectionList() { if matched, _ := regexp.MatchString("(?i)^LDAPSOURCE.*", v); matched { @@ -329,15 +329,15 @@ func NewConfigContext() { ldapmsadsaformat := Cfg.MustValue(v, "MSADSAFORMAT", "%s") ldap.AddSource(ldapname, ldaphost, ldapport, ldapbasedn, ldapattribute, ldapfilter, ldapmsadsaformat) nbsrc += 1 - log.Debug("%s added as LDAP source", ldapname) + qlog.Debug("%s added as LDAP source", ldapname) } } if nbsrc == 0 { - log.Debug("No valide LDAP found, LDAP AUTHENTICATION NOT activated") + qlog.Debug("No valide LDAP found, LDAP AUTHENTICATION NOT activated") LdapAuth = false } } else { - log.Debug("LDAP AUTHENTICATION NOT activated") + qlog.Debug("LDAP AUTHENTICATION NOT activated") } PictureService = Cfg.MustValue("picture", "SERVICE") -- cgit v1.2.3 From 9dfb7de3715c11e9569de62cd03b7787e58d0d91 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 26 Apr 2014 01:22:22 -0600 Subject: Fix #102 --- README.md | 5 +++ README_ZH.md | 6 ++++ doc/install_gogs_from_binary_on_ubuntu.md | 4 +-- gogs.go | 2 +- modules/base/conf.go | 58 +++++++++++++++++-------------- 5 files changed, 45 insertions(+), 30 deletions(-) (limited to 'modules') diff --git a/README.md b/README.md index 03878072..d188508e 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,11 @@ More importantly, Gogs only needs one binary to setup your own project hosting o - Supports MySQL, PostgreSQL and SQLite3. - Social account login(GitHub, Google, QQ, Weibo) +## System Requirements + +- A cheap Raspberry Pi is powerful enough to match the minimal requirement. +- 4 CPU Cores and 1GB RAM would be the baseline for teamwork. + ## Installation Make sure you install [Prerequirements](https://github.com/gogits/gogs/wiki/Prerequirements) first. diff --git a/README_ZH.md b/README_ZH.md index 6d7553a6..bbf461dd 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -33,6 +33,12 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 - 支持 MySQL、PostgreSQL 以及 SQLite3 数据库 - 社交帐号登录(GitHub、Google、QQ、微博) +## 系统要求 + +- 最低的系统硬件要求为一个廉价的树莓派 +- 如果用于团队项目,建议使用 4 核 CPU 及 1GB 内存 + + ## 安装部署 在安装 Gogs 之前,您需要先安装 [基本环境](https://github.com/gogits/gogs/wiki/Prerequirements)。 diff --git a/doc/install_gogs_from_binary_on_ubuntu.md b/doc/install_gogs_from_binary_on_ubuntu.md index 6d004106..3b406b36 100644 --- a/doc/install_gogs_from_binary_on_ubuntu.md +++ b/doc/install_gogs_from_binary_on_ubuntu.md @@ -18,8 +18,8 @@ ### install the gogs - mkdir gogs - cd gogs -- curl -L http://gobuild.io/github.com/gogits/gogs/v0.2.0/linux/amd64 -o v0.2.0.zip -- unzip v0.2.0.zip +- curl -L http://gobuild.io/github.com/gogits/gogs/v0.3.0/linux/amd64 -o v0.3.0.zip +- unzip v0.3.0.zip - ./start.sh > The up-to-date binary could be found at diff --git a/gogs.go b/gogs.go index b06c8006..caa8cf63 100644 --- a/gogs.go +++ b/gogs.go @@ -19,7 +19,7 @@ import ( // Test that go1.2 tag above is included in builds. main.go refers to this definition. const go12tag = true -const APP_VER = "0.3.0.0422 Alpha" +const APP_VER = "0.3.0.0426 Alpha" func init() { base.AppVer = APP_VER diff --git a/modules/base/conf.go b/modules/base/conf.go index 04c12457..e89c67bc 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -178,6 +178,36 @@ func newLogService() { log.Info("Log Mode: %s(%s)", strings.Title(LogMode), levelName) } +func newLdapService() { + LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false) + if !LdapAuth { + return + } + + nbsrc := 0 + for _, v := range Cfg.GetSectionList() { + if matched, _ := regexp.MatchString("(?i)^LDAPSOURCE.*", v); matched { + ldapname := Cfg.MustValue(v, "name", v) + ldaphost := Cfg.MustValue(v, "host") + ldapport := Cfg.MustInt(v, "port", 389) + ldapbasedn := Cfg.MustValue(v, "basedn", "dc=*,dc=*") + ldapattribute := Cfg.MustValue(v, "attribute", "mail") + ldapfilter := Cfg.MustValue(v, "filter", "(*)") + ldapmsadsaformat := Cfg.MustValue(v, "MSADSAFORMAT", "%s") + ldap.AddSource(ldapname, ldaphost, ldapport, ldapbasedn, ldapattribute, ldapfilter, ldapmsadsaformat) + nbsrc++ + log.Debug("%s added as LDAP source", ldapname) + } + } + if nbsrc == 0 { + log.Warn("No valide LDAP found, LDAP Authentication NOT enabled") + LdapAuth = false + return + } + + log.Info("LDAP Authentication Enabled") +} + func newCacheService() { CacheAdapter = Cfg.MustValue("cache", "ADAPTER", "memory") if EnableRedis { @@ -313,33 +343,6 @@ func NewConfigContext() { CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME") CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME") - // load LDAP authentication configuration if present - LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false) - if LdapAuth { - qlog.Debug("LDAP AUTHENTICATION activated") - nbsrc := 0 - for _, v := range Cfg.GetSectionList() { - if matched, _ := regexp.MatchString("(?i)^LDAPSOURCE.*", v); matched { - ldapname := Cfg.MustValue(v, "name", v) - ldaphost := Cfg.MustValue(v, "host") - ldapport := Cfg.MustInt(v, "port", 389) - ldapbasedn := Cfg.MustValue(v, "basedn", "dc=*,dc=*") - ldapattribute := Cfg.MustValue(v, "attribute", "mail") - ldapfilter := Cfg.MustValue(v, "filter", "(*)") - ldapmsadsaformat := Cfg.MustValue(v, "MSADSAFORMAT", "%s") - ldap.AddSource(ldapname, ldaphost, ldapport, ldapbasedn, ldapattribute, ldapfilter, ldapmsadsaformat) - nbsrc += 1 - qlog.Debug("%s added as LDAP source", ldapname) - } - } - if nbsrc == 0 { - qlog.Debug("No valide LDAP found, LDAP AUTHENTICATION NOT activated") - LdapAuth = false - } - } else { - qlog.Debug("LDAP AUTHENTICATION NOT activated") - } - PictureService = Cfg.MustValue("picture", "SERVICE") // Determine and create root git reposiroty path. @@ -357,6 +360,7 @@ func NewConfigContext() { func NewBaseServices() { newService() newLogService() + newLdapService() newCacheService() newSessionService() newMailService() -- cgit v1.2.3 From 59d0e73c3507296b31c8e741b44afc7bfe1eb695 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 26 Apr 2014 22:34:48 -0600 Subject: Batch mirror fix --- .gopmfile | 1 + CONTRIBUTING.md | 2 ++ modules/base/conf.go | 8 ++++---- modules/middleware/repo.go | 7 +++++-- public/js/app.js | 4 ++-- routers/install.go | 16 ++++++++++++++- routers/user/user.go | 8 +++++--- templates/base/footer.tmpl | 5 ++++- templates/install.tmpl | 13 ++++++------ templates/repo/single_file.tmpl | 45 +++++++++++++++++++++-------------------- tests/.travel.yml | 9 --------- tests/README.md | 13 ------------ tests/default_test.go | 17 ---------------- 13 files changed, 68 insertions(+), 80 deletions(-) delete mode 100644 tests/.travel.yml delete mode 100644 tests/README.md delete mode 100644 tests/default_test.go (limited to 'modules') diff --git a/.gopmfile b/.gopmfile index 296d0236..c58f4299 100644 --- a/.gopmfile +++ b/.gopmfile @@ -19,6 +19,7 @@ github.com/lib/pq = github.com/nfnt/resize = github.com/qiniu/log = github.com/robfig/cron = +github.com/juju2013/goldap = [res] include = templates|public|conf diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cfc6c14f..6cc88515 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,6 +10,8 @@ Want to hack on Gogs? Awesome! Here are instructions to get you started. They ar ### Pull requests are always welcome +**ALL PULL REQUESTS MUST SEND TO `DEV` BRANCH** + We are always thrilled to receive pull requests, and do our best to process them as fast as possible. Not sure if that typo is worth a pull request? Do it! We will appreciate it. If your pull request is not accepted on the first try, don't be discouraged! If there's a problem with the implementation, hopefully you received feedback on what to improve. diff --git a/modules/base/conf.go b/modules/base/conf.go index 9a9adfda..17b55316 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -53,7 +53,6 @@ var ( Domain string SecretKey string RunUser string - LdapAuth bool RepoRootPath string ScriptType string @@ -93,6 +92,7 @@ var Service struct { NotifyMail bool ActiveCodeLives int ResetPwdCodeLives int + LdapAuth bool } func ExecDir() (string, error) { @@ -179,8 +179,8 @@ func newLogService() { } func newLdapService() { - LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false) - if !LdapAuth { + Service.LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false) + if !Service.LdapAuth { return } @@ -201,7 +201,7 @@ func newLdapService() { } if nbsrc == 0 { log.Warn("No valide LDAP found, LDAP Authentication NOT enabled") - LdapAuth = false + Service.LdapAuth = false return } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 34144fe3..2d2778cb 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -26,11 +26,14 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { var displayBare bool if len(args) >= 1 { - validBranch = args[0] + // Note: argument has wrong value in Go1.3 martini. + // validBranch = args[0] + validBranch = true } if len(args) >= 2 { - displayBare = args[1] + // displayBare = args[1] + displayBare = true } var ( diff --git a/public/js/app.js b/public/js/app.js index a5c79a39..b7b5deb8 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -470,10 +470,10 @@ function initInstall() { (function () { $('#install-database').on("change", function () { var val = $(this).val(); - if (val != "sqlite") { + if (val != "SQLite3") { $('.server-sql').show(); $('.sqlite-setting').addClass("hide"); - if (val == "pgsql") { + if (val == "PostgreSQL") { $('.pgsql-setting').removeClass("hide"); } else { $('.pgsql-setting').addClass("hide"); diff --git a/routers/install.go b/routers/install.go index 12182ad3..8ffa9b5d 100644 --- a/routers/install.go +++ b/routers/install.go @@ -65,6 +65,10 @@ func GlobalInit() { checkRunMode() } +func renderDbOption(ctx *middleware.Context) { + ctx.Data["DbOptions"] = []string{"MySQL", "PostgreSQL", "SQLite3"} +} + func Install(ctx *middleware.Context, form auth.InstallForm) { if base.InstallLock { ctx.Handle(404, "install.Install", errors.New("Installation is prohibited")) @@ -104,6 +108,13 @@ func Install(ctx *middleware.Context, form auth.InstallForm) { form.AppUrl = base.AppUrl } + renderDbOption(ctx) + curDbValue := "" + if models.EnableSQLite3 { + curDbValue = "SQLite3" // Default when enabled. + } + ctx.Data["CurDbValue"] = curDbValue + auth.AssignForm(form, ctx.Data) ctx.HTML(200, "install") } @@ -117,6 +128,9 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) { ctx.Data["Title"] = "Install" ctx.Data["PageIsInstall"] = true + renderDbOption(ctx) + ctx.Data["CurDbValue"] = form.Database + if ctx.HasError() { ctx.HTML(200, "install") return @@ -129,7 +143,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) { // Pass basic check, now test configuration. // Test database setting. - dbTypes := map[string]string{"mysql": "mysql", "pgsql": "postgres", "sqlite": "sqlite3"} + dbTypes := map[string]string{"MySQL": "mysql", "PostgreSQL": "postgres", "SQLite3": "sqlite3"} models.DbCfg.Type = dbTypes[form.Database] models.DbCfg.Host = form.Host models.DbCfg.User = form.User diff --git a/routers/user/user.go b/routers/user/user.go index 75314237..fe53896e 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -91,12 +91,14 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) { var user *models.User var err error - // try to login against LDAP if defined - if base.LdapAuth { + if base.Service.LdapAuth { user, err = models.LoginUserLdap(form.UserName, form.Password) + if err != nil { + log.Error("Fail to login through LDAP: %v", err) + } } // try local if not LDAP or it's failed - if (!base.LdapAuth) || (err != nil) { + if !base.Service.LdapAuth || err != nil { user, err = models.LoginUserPlain(form.UserName, form.Password) } if err != nil { diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 6c2da63e..30f06891 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -13,7 +13,10 @@
-

+ +
+

+
diff --git a/templates/install.tmpl b/templates/install.tmpl index 2ed7e569..8fe678e5 100644 --- a/templates/install.tmpl +++ b/templates/install.tmpl @@ -9,14 +9,15 @@
-
+
@@ -49,7 +50,7 @@
-
+
-- cgit v1.2.3