mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-09 17:37:20 -06:00
Allows an LDAP auth source to list multiple comma-separated servers in the Host field so logins continue working when one server is unreachable. Entries can be plain hosts using the configured Port and Security Protocol fields or `ldap://`, `ldaps://`, or `ldap+starttls://` URLs with their own port and protocol (as proposed in https://github.com/go-gitea/gitea/pull/31649#issuecomment-2505555133), with TLS protocol consistency enforced so an entry cannot silently downgrade encryption. Hosts are tried in order with a 250 ms head start each so an unresponsive server does not block logins for the full 60 s connect timeout, and only connection failures fail over to the next host so failed binds are not retried across servers. Existing single-host configurations continue to work unchanged without a migration. Docs: https://gitea.com/gitea/docs/pulls/635 Fixes https://github.com/go-gitea/gitea/issues/6898 /claim #6898 --------- Co-authored-by: silverwind <me@silverwind.io>
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package ldap
|
|
|
|
// SecurityProtocol protocol type
|
|
type SecurityProtocol int
|
|
|
|
// Note: new type must be added at the end of list to maintain compatibility.
|
|
const (
|
|
SecurityProtocolUnencrypted SecurityProtocol = iota
|
|
SecurityProtocolLDAPS
|
|
SecurityProtocolStartTLS
|
|
)
|
|
|
|
// String returns the name of the SecurityProtocol
|
|
func (s SecurityProtocol) String() string {
|
|
return SecurityProtocolNames[s]
|
|
}
|
|
|
|
// Int returns the int value of the SecurityProtocol
|
|
func (s SecurityProtocol) Int() int {
|
|
return int(s)
|
|
}
|
|
|
|
// SecurityProtocolNames contains the name of SecurityProtocol values.
|
|
var SecurityProtocolNames = map[SecurityProtocol]string{
|
|
SecurityProtocolUnencrypted: "Unencrypted",
|
|
SecurityProtocolLDAPS: "LDAPS",
|
|
SecurityProtocolStartTLS: "StartTLS",
|
|
}
|
|
|
|
var urlSecurityProtocols = map[string]SecurityProtocol{
|
|
"ldap": SecurityProtocolUnencrypted,
|
|
"ldaps": SecurityProtocolLDAPS,
|
|
"ldap+starttls": SecurityProtocolStartTLS,
|
|
}
|