Beispiel #1
0
        /// <summary>
        /// Создание <see cref="PermissionInfo"/> для разрешения в RabbitMQ.
        /// </summary>
        /// <param name="user">Пользователь RabbitMQ.</param>
        /// <param name="write">Разрешение на отправку сообщений.</param>
        /// <param name="read">Разрешение на чтение сообщений.</param>
        /// <param name="configure">Разрешение возможности конфигурирования.</param>
        /// <returns>Информацию о разрешении.</returns>
        private PermissionInfo CreatePermissionInfo(User user, string write = "^$", string read = "^$", string configure = "^$")
        {
            PermissionInfo permissionInfo = new PermissionInfo(user, Vhost);

            permissionInfo.SetWrite(write);
            permissionInfo.SetRead(read);
            permissionInfo.SetConfigure(configure);

            return(permissionInfo);
        }
Beispiel #2
0
        protected internal override void Apply(IManagementClient managementClient)
        {
            _log.Info($"Declaring permission for user '{User}' on vhost '{VirtualHost}'");
            _log.Info($"    Read Regex = {ReadRegex}");
            _log.Info($"    WriteRegex = {WriteRegex}");
            _log.Info($"    ConfigureRegex = {ConfigureRegex} ");

            var user           = managementClient.GetUser(User);
            var virtualHost    = managementClient.GetVhost(VirtualHost);
            var permissionInfo = new PermissionInfo(user, virtualHost);

            permissionInfo.SetConfigure(ConfigureRegex);
            permissionInfo.SetRead(ReadRegex);
            permissionInfo.SetWrite(WriteRegex);

            managementClient.CreatePermission(permissionInfo);

            _log.Info($"Finished declaring permission for user '{User}' on vhost '{VirtualHost}'");
        }