コード例 #1
0
 public EditPostgreSqlConfigurationCommand(
     PostgreSqlConfiguration configuration,
     string databaseName,
     string uniqueRequestId)
     : base(databaseName, uniqueRequestId)
 {
     Configuration = configuration;
 }
コード例 #2
0
 public ConfigurePostgreSqlCommand(PostgreSqlConfiguration configuration)
 {
     _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
 }
コード例 #3
0
 public void Setup()
 {
     sut = PostgreSqlConfiguration.Settings;
 }
コード例 #4
0
        public async Task AddUser()
        {
            AssertCanUsePostgreSqlIntegration();

            using (Database.DocumentsStorage.ContextPool.AllocateOperationContext(out DocumentsOperationContext context))
            {
                var newUserRequest = await context.ReadForMemoryAsync(RequestBodyStream(), "PostgreSQLNewUser");

                var dto = JsonDeserializationServer.PostgreSqlUser(newUserRequest);

                await using (var writer = new AsyncBlittableJsonTextWriter(context, ResponseBodyStream()))
                {
                    if (string.IsNullOrEmpty(dto.Username))
                    {
                        HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
                        context.Write(writer, new DynamicJsonValue {
                            ["Error"] = "Username is null or empty."
                        });
                        return;
                    }

                    if (string.IsNullOrEmpty(dto.Password))
                    {
                        HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
                        context.Write(writer, new DynamicJsonValue {
                            ["Error"] = "Password is null or empty."
                        });
                        return;
                    }

                    DatabaseRecord databaseRecord;

                    using (Database.ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext transactionOperationContext))
                        using (transactionOperationContext.OpenReadTransaction())
                            databaseRecord = Database.ServerStore.Cluster.ReadDatabase(transactionOperationContext, Database.Name, out long index);

                    var newUser = new PostgreSqlUser
                    {
                        Username = dto.Username,
                        Password = dto.Password
                    };

                    var config = databaseRecord.Integrations?.PostgreSql;

                    if (config == null)
                    {
                        config = new PostgreSqlConfiguration()
                        {
                            Authentication = new PostgreSqlAuthenticationConfiguration()
                            {
                                Users = new List <PostgreSqlUser>()
                            }
                        };
                    }

                    var users = config.Authentication.Users;

                    if (users.Any(x => x.Username.Equals(dto.Username, StringComparison.OrdinalIgnoreCase)))
                    {
                        HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
                        context.Write(writer, new DynamicJsonValue {
                            ["Error"] = $"{dto.Username} username already exists."
                        });
                        return;
                    }

                    users.Add(newUser);

                    using (Database.ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext transactionOperationContext))
                        await DatabaseConfigurations(ServerStore.ModifyPostgreSqlConfiguration, transactionOperationContext, RaftIdGenerator.DontCareId, config);
                }
            }

            NoContentStatus();
        }
コード例 #5
0
        public static IdentityBuilder AddDapperIdentityForPostgreSql <TKey, TUserRole, TRoleClaim>(this IdentityBuilder builder, PostgreSqlConfiguration configurationOverride)
        {
            builder.Services.AddSingleton <SqlConfiguration>(configurationOverride);

            AddStores(builder.Services, builder.UserType, builder.RoleType, typeof(TKey), typeof(TUserRole), typeof(TRoleClaim));

            return(builder);
        }
コード例 #6
0
        public static IdentityBuilder AddDapperIdentityForPostgreSql(this IdentityBuilder builder, PostgreSqlConfiguration configurationOverride)
        {
            builder.Services.AddSingleton <SqlConfiguration>(configurationOverride);

            AddStores(builder.Services, builder.UserType, builder.RoleType);

            return(builder);
        }
コード例 #7
0
ファイル: ShopWriter.cs プロジェクト: ismailoviic/AlphaShop
 public ShopWriter(PostgreSqlConfiguration postgreSqlConfiguration) : base(postgreSqlConfiguration)
 {
 }
コード例 #8
0
 public ShopReader(PostgreSqlConfiguration postgreSqlConfiguration) : base(postgreSqlConfiguration)
 {
 }
コード例 #9
0
 public IntegrationsConfiguration()
 {
     PostgreSql = new PostgreSqlConfiguration();
 }