vaultmanager/modules/VaultManagerLDAP.py
def ldap_manage_ldap_users(self):
        """
        Method running the manage-ldap-users function of LDAP module
        Manage users in Vault LDAP configuration
        """
        self.logger.debug("LDAP manage-ldap-users starting")
        self.logger.info("Managing users in Vault LDAP '%s' config" %
                         self.kwargs.manage_ldap_users)
        self.logger.debug("Managing users to Vault LDAP configuration")
        raw_vault_ldap_users = self.vault_client.list('/auth/ldap/users')
        self.logger.debug("Users found: " + str(raw_vault_ldap_users))
        existing_users = []
        if len(raw_vault_ldap_users):
            existing_users = raw_vault_ldap_users["keys"]

        for user in self.ldap_users:
            groups_of_user = list(
                set(self.conf["groups"]["groups_to_add"]).intersection(
                    self.ldap_users[user]))
            if not len(groups_of_user):
                continue
            if user in existing_users:
                existing_users.remove(user)
            policies = ["user_" + user + "_policy"]
            if "root" in self.conf["general"]["group"] and \
                    user in self.conf["general"]["user"]["root"]:
                policies.append("root")
            self.logger.info("Adding polices %s to user %s" %
                             (str(policies), user))
            self.logger.info("Adding groups %s to user %s" %
                             (str(groups_of_user), user))
            self.vault_client.write(
                "/auth/ldap/users/" + user,
                {
                    "policies": utils.list_to_string(self.logger, policies,
                                                     separator=""),
                    "groups": utils.list_to_string(self.logger, groups_of_user,
                                                   separator="")
                }
            )
        self.logger.debug("Removing users %s from Vault LDAP conf" %
                          str(existing_users))
        for user in existing_users:
            self.logger.info("Removing user %s from Vault LDAP conf" % user)
            self.vault_client.delete('/auth/ldap/users/' + user)
        self.logger.info("Creating k8s secrets paths for each user")
        self.create_kubernetes_policies()

        Method running the manage-ldap-users function of LDAP module
        Manage users in Vault LDAP configuration
        
Method running the manage-ldap-users function of LDAP module
Manage users in Vault LDAP configuration
Method running the manage - ldap - users function of LDAP module Manage users in Vault LDAP configuration
def ldap_manage_ldap_users(self):
        self.logger.debug("LDAP manage-ldap-users starting")
        self.logger.info("Managing users in Vault LDAP '%s' config" %
                         self.kwargs.manage_ldap_users)
        self.logger.debug("Managing users to Vault LDAP configuration")
        raw_vault_ldap_users = self.vault_client.list('/auth/ldap/users')
        self.logger.debug("Users found: " + str(raw_vault_ldap_users))
        existing_users = []
        if len(raw_vault_ldap_users):
            existing_users = raw_vault_ldap_users["keys"]
        for user in self.ldap_users:
            groups_of_user = list(
                set(self.conf["groups"]["groups_to_add"]).intersection(
                    self.ldap_users[user]))
            if not len(groups_of_user):
                continue
            if user in existing_users:
                existing_users.remove(user)
            policies = ["user_" + user + "_policy"]
            if "root" in self.conf["general"]["group"] and \
                    user in self.conf["general"]["user"]["root"]:
                policies.append("root")
            self.logger.info("Adding polices %s to user %s" %
                             (str(policies), user))
            self.logger.info("Adding groups %s to user %s" %
                             (str(groups_of_user), user))
            self.vault_client.write(
                "/auth/ldap/users/" + user,
                {
                    "policies": utils.list_to_string(self.logger, policies,
                                                     separator=""),
                    "groups": utils.list_to_string(self.logger, groups_of_user,
                                                   separator="")
                }
            )
        self.logger.debug("Removing users %s from Vault LDAP conf" %
                          str(existing_users))
        for user in existing_users:
            self.logger.info("Removing user %s from Vault LDAP conf" % user)
            self.vault_client.delete('/auth/ldap/users/' + user)
        self.logger.info("Creating k8s secrets paths for each user")
        self.create_kubernetes_policies()
def ldap_manage_ldap_users ( self ) : self . logger . debug ( "LDAP manage-ldap-users starting" ) self . logger . info ( "Managing users in Vault LDAP '%s' config" % self . kwargs . manage_ldap_users ) self . logger . debug ( "Managing users to Vault LDAP configuration" ) raw_vault_ldap_users = self . vault_client . list ( '/auth/ldap/users' ) self . logger . debug ( "Users found: " + str ( raw_vault_ldap_users ) ) existing_users = [ ] if len ( raw_vault_ldap_users ) : existing_users = raw_vault_ldap_users [ "keys" ] for user in self . ldap_users : groups_of_user = list ( set ( self . conf [ "groups" ] [ "groups_to_add" ] ) . intersection ( self . ldap_users [ user ] ) ) if not len ( groups_of_user ) : continue if user in existing_users : existing_users . remove ( user ) policies = [ "user_" + user + "_policy" ] if "root" in self . conf [ "general" ] [ "group" ] and user in self . conf [ "general" ] [ "user" ] [ "root" ] : policies . append ( "root" ) self . logger . info ( "Adding polices %s to user %s" % ( str ( policies ) , user ) ) self . logger . info ( "Adding groups %s to user %s" % ( str ( groups_of_user ) , user ) ) self . vault_client . write ( "/auth/ldap/users/" + user , { "policies" : utils . list_to_string ( self . logger , policies , separator = "" ) , "groups" : utils . list_to_string ( self . logger , groups_of_user , separator = "" ) } ) self . logger . debug ( "Removing users %s from Vault LDAP conf" % str ( existing_users ) ) for user in existing_users : self . logger . info ( "Removing user %s from Vault LDAP conf" % user ) self . vault_client . delete ( '/auth/ldap/users/' + user ) self . logger . info ( "Creating k8s secrets paths for each user" ) self . create_kubernetes_policies ( )
Method running the manage-ldap-users function of LDAP module
Manage users in Vault LDAP configuration
Method running the manage - ldap - users function of LDAP module Manage users in Vault LDAP configuration
"""
        Method running the manage-ldap-users function of LDAP module
        Manage users in Vault LDAP configuration
        """
self