Refactor some LDAP code (#32849)

This commit is contained in:
wxiaoguang 2024-12-15 19:59:18 +08:00 committed by GitHub
parent 33e8e82c4b
commit b01b0b99a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 264 additions and 178 deletions

View file

@ -56,8 +56,7 @@ type Source struct {
UserUID string // User Attribute listed in Group
SkipLocalTwoFA bool `json:",omitempty"` // Skip Local 2fa for users authenticated with this source
// reference to the authSource
authSource *auth.Source
authSource *auth.Source // reference to the authSource
}
// FromDB fills up a LDAPConfig from serialized format.
@ -107,7 +106,7 @@ func (source *Source) UseTLS() bool {
// ProvidesSSHKeys returns if this source provides SSH Keys
func (source *Source) ProvidesSSHKeys() bool {
return len(strings.TrimSpace(source.AttributeSSHPublicKey)) > 0
return strings.TrimSpace(source.AttributeSSHPublicKey) != ""
}
// SetAuthSource sets the related AuthSource