Exemple #1
0
    def validate_user_policies(self):
        """
        Check required policies are present in user policies or not. Required policies are kept in the settings AWS_POLICIES_REQUIRED

        Returns:
            boolean: True if all policies are present else False
        """
        access_key, secret_key = Settings.AWS_ACCESS_KEY, Settings.AWS_SECRET_KEY
        current_aws_user = iam.get_current_user(access_key, secret_key)
        user_name = current_aws_user.user_name

        if user_name:
            # warning_message = "Policies (" + ", ".join(Settings.AWS_POLICIES_REQUIRED) + ") are required"
            # self.show_step_inner_warning(warning_message)

            if self._check_user_policies(access_key, secret_key, user_name):
                return True

            if self._check_group_policies(access_key, secret_key, user_name):
                return True

            yes_or_no = input("\n\t%s: " %
                              self._input_message_in_color(K.POLICY_YES_NO))

            if yes_or_no.lower() == "yes":
                return True

            return False
        elif "root" in current_aws_user.arn:
            return True
        else:
            False
Exemple #2
0
    def validate_user_policies(self):
        """
        Check required policies are present in user policies or not. Required policies are kept in the settings AWS_POLICIES_REQUIRED

        Returns:
            boolean: True if all policies are present else False
        """
        current_aws_user = iam.get_current_user(Settings.AWS_AUTH_CRED)
        user_name = current_aws_user.user_name

        if user_name:
            if self._check_user_policies(user_name) or self._check_group_policies(user_name):
                return True
        elif "root" in current_aws_user.arn:
            return True

        False