mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	Clean old LDAP code
This commit is contained in:
		
							
								
								
									
										19
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								README.md
									
									
									
									
									
								
							@@ -32,15 +32,16 @@ More importantly, Gogs only needs one binary to setup your own project hosting o
 | 
				
			|||||||
## Features
 | 
					## Features
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Activity timeline
 | 
					- Activity timeline
 | 
				
			||||||
- SSH/HTTP(S) protocol support.
 | 
					- SSH/HTTP(S) protocol support
 | 
				
			||||||
- Register/delete/rename account.
 | 
					- SMTP authentication support
 | 
				
			||||||
- Create/migrate/mirror/delete/watch/rename/transfer public/private repository.
 | 
					- Register/delete/rename account
 | 
				
			||||||
- Repository viewer/release/issue tracker/webhooks.
 | 
					- Create/migrate/mirror/delete/watch/rename/transfer public/private repository
 | 
				
			||||||
- Add/remove repository collaborators.
 | 
					- Repository viewer/release/issue tracker/webhooks
 | 
				
			||||||
- Gravatar and cache support.
 | 
					- Add/remove repository collaborators
 | 
				
			||||||
- Mail service(register, issue).
 | 
					- Gravatar and cache support
 | 
				
			||||||
- Administration panel.
 | 
					- Mail service(register, issue)
 | 
				
			||||||
- Supports MySQL, PostgreSQL and SQLite3.
 | 
					- Administration panel
 | 
				
			||||||
 | 
					- Supports MySQL, PostgreSQL and SQLite3
 | 
				
			||||||
- Social account login(GitHub, Google, QQ, Weibo)
 | 
					- Social account login(GitHub, Google, QQ, Weibo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## System Requirements
 | 
					## System Requirements
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,8 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
 | 
				
			|||||||
## 功能特性
 | 
					## 功能特性
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- 活动时间线
 | 
					- 活动时间线
 | 
				
			||||||
- SSH/HTTP(S) 协议支持
 | 
					- 支持 SSH/HTTP(S) 协议
 | 
				
			||||||
 | 
					- 支持 SMTP 用户认证
 | 
				
			||||||
- 注册/删除/重命名用户
 | 
					- 注册/删除/重命名用户
 | 
				
			||||||
- 创建/迁移/镜像/删除/关注/重命名/转移 公开/私有 仓库
 | 
					- 创建/迁移/镜像/删除/关注/重命名/转移 公开/私有 仓库
 | 
				
			||||||
- 仓库 浏览器/发布/缺陷管理/Web 钩子
 | 
					- 仓库 浏览器/发布/缺陷管理/Web 钩子
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							@@ -17,7 +17,7 @@ import (
 | 
				
			|||||||
	"github.com/gogits/gogs/modules/base"
 | 
						"github.com/gogits/gogs/modules/base"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const APP_VER = "0.3.4.0514 Alpha"
 | 
					const APP_VER = "0.3.4.0515 Alpha"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	base.AppVer = APP_VER
 | 
						base.AppVer = APP_VER
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -312,7 +312,7 @@ func SmtpAuth(host string, port int, a smtp.Auth, useTls bool) error {
 | 
				
			|||||||
				return err
 | 
									return err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return errors.New("SMTP server unsupported TLS")
 | 
								return errors.New("SMTP server unsupports TLS")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,6 @@ import (
 | 
				
			|||||||
	"os/exec"
 | 
						"os/exec"
 | 
				
			||||||
	"path"
 | 
						"path"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"regexp"
 | 
					 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/Unknwon/com"
 | 
						"github.com/Unknwon/com"
 | 
				
			||||||
@@ -20,7 +19,6 @@ import (
 | 
				
			|||||||
	"github.com/gogits/cache"
 | 
						"github.com/gogits/cache"
 | 
				
			||||||
	"github.com/gogits/session"
 | 
						"github.com/gogits/session"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gogits/gogs/modules/auth/ldap"
 | 
					 | 
				
			||||||
	"github.com/gogits/gogs/modules/log"
 | 
						"github.com/gogits/gogs/modules/log"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -188,37 +186,6 @@ func newLogService() {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newLdapService() {
 | 
					 | 
				
			||||||
	Service.LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false)
 | 
					 | 
				
			||||||
	if !Service.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)
 | 
					 | 
				
			||||||
			ldapusessl := Cfg.MustBool(v, "usessl", false)
 | 
					 | 
				
			||||||
			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, ldapusessl, 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")
 | 
					 | 
				
			||||||
		Service.LdapAuth = false
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	log.Info("LDAP Authentication Enabled")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func newCacheService() {
 | 
					func newCacheService() {
 | 
				
			||||||
	CacheAdapter = Cfg.MustValue("cache", "ADAPTER", "memory")
 | 
						CacheAdapter = Cfg.MustValue("cache", "ADAPTER", "memory")
 | 
				
			||||||
	if EnableRedis {
 | 
						if EnableRedis {
 | 
				
			||||||
@@ -376,7 +343,6 @@ func NewConfigContext() {
 | 
				
			|||||||
func NewBaseServices() {
 | 
					func NewBaseServices() {
 | 
				
			||||||
	newService()
 | 
						newService()
 | 
				
			||||||
	newLogService()
 | 
						newLogService()
 | 
				
			||||||
	newLdapService()
 | 
					 | 
				
			||||||
	newCacheService()
 | 
						newCacheService()
 | 
				
			||||||
	newSessionService()
 | 
						newSessionService()
 | 
				
			||||||
	newMailService()
 | 
						newMailService()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user