github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/config/identity/ldap/legacy.go (about) 1 // Copyright (c) 2015-2021 MinIO, Inc. 2 // 3 // This file is part of MinIO Object Storage stack 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package ldap 19 20 import ( 21 "github.com/minio/minio/internal/config" 22 ) 23 24 // LegacyConfig contains AD/LDAP server connectivity information from old config 25 // V33. 26 type LegacyConfig struct { 27 Enabled bool `json:"enabled"` 28 29 // E.g. "ldap.minio.io:636" 30 ServerAddr string `json:"serverAddr"` 31 32 // User DN search parameters 33 UserDNSearchBaseDistName string `json:"userDNSearchBaseDN"` 34 UserDNSearchBaseDistNames []string `json:"-"` // Generated field 35 UserDNSearchFilter string `json:"userDNSearchFilter"` 36 37 // Group search parameters 38 GroupSearchBaseDistName string `json:"groupSearchBaseDN"` 39 GroupSearchBaseDistNames []string `json:"-"` // Generated field 40 GroupSearchFilter string `json:"groupSearchFilter"` 41 42 // Lookup bind LDAP service account 43 LookupBindDN string `json:"lookupBindDN"` 44 LookupBindPassword string `json:"lookupBindPassword"` 45 } 46 47 // SetIdentityLDAP - One time migration code needed, for migrating from older config to new for LDAPConfig. 48 func SetIdentityLDAP(s config.Config, ldapArgs LegacyConfig) { 49 if !ldapArgs.Enabled { 50 // ldap not enabled no need to preserve it in new settings. 51 return 52 } 53 s[config.IdentityLDAPSubSys][config.Default] = config.KVS{ 54 config.KV{ 55 Key: ServerAddr, 56 Value: ldapArgs.ServerAddr, 57 }, 58 config.KV{ 59 Key: GroupSearchFilter, 60 Value: ldapArgs.GroupSearchFilter, 61 }, 62 config.KV{ 63 Key: GroupSearchBaseDN, 64 Value: ldapArgs.GroupSearchBaseDistName, 65 }, 66 } 67 }