mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Security protocols
This commit is contained in:
		@@ -20,9 +20,9 @@ type SecurityProtocol int
 | 
			
		||||
 | 
			
		||||
// Note: new type must be added at the end of list to maintain compatibility.
 | 
			
		||||
const (
 | 
			
		||||
	SECURITY_PROTOCOL_UNENCRYPTED SecurityProtocol = iota
 | 
			
		||||
	SECURITY_PROTOCOL_LDAPS
 | 
			
		||||
	SECURITY_PROTOCOL_START_TLS
 | 
			
		||||
	SecurityProtocolUnencrypted SecurityProtocol = iota
 | 
			
		||||
	SecurityProtocolLdaps
 | 
			
		||||
	SecurityProtocolStartTls
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Basic LDAP authentication service
 | 
			
		||||
@@ -118,7 +118,7 @@ func dial(ls *Source) (*ldap.Conn, error) {
 | 
			
		||||
		ServerName:         ls.Host,
 | 
			
		||||
		InsecureSkipVerify: ls.SkipVerify,
 | 
			
		||||
	}
 | 
			
		||||
	if ls.SecurityProtocol == SECURITY_PROTOCOL_LDAPS {
 | 
			
		||||
	if ls.SecurityProtocol == SecurityProtocolLdaps {
 | 
			
		||||
		return ldap.DialTLS("tcp", fmt.Sprintf("%s:%d", ls.Host, ls.Port), tlsCfg)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -127,7 +127,7 @@ func dial(ls *Source) (*ldap.Conn, error) {
 | 
			
		||||
		return nil, fmt.Errorf("Dial: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ls.SecurityProtocol == SECURITY_PROTOCOL_START_TLS {
 | 
			
		||||
	if ls.SecurityProtocol == SecurityProtocolStartTls {
 | 
			
		||||
		if err = conn.StartTLS(tlsCfg); err != nil {
 | 
			
		||||
			conn.Close()
 | 
			
		||||
			return nil, fmt.Errorf("StartTLS: %v", err)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user