Path: redb/redb.Postgres/Providers/PostgresUserProvider.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Postgres/Providers/PostgresUserProvider.cs
----
using redb.Core.Query;
using redb.Core.Data;
using redb.Core.Models.Contracts;
using redb.Core.Providers.Base;
using redb.Core.Security;
using redb.Postgres.Sql;
using Microsoft.Extensions.Logging;
namespace redb.Postgres.Providers;
///
/// PostgreSQL implementation of user provider.
/// Inherits all business logic from UserProviderBase.
/// Only provides PostgreSQL-specific SQL dialect and password hasher.
///
/// Usage:
/// services.AddScoped<IUserProvider, PostgresUserProvider>();
///
public class PostgresUserProvider : UserProviderBase
{
///
/// Creates a new PostgreSQL user provider.
///
/// Database context for executing queries
/// Security context for authorization
/// Optional logger for diagnostics
///
/// Configured dialect. Optional so hand-construction keeps working, but DI supplies the
/// singleton built from RedbServiceConfiguration, and that is how StringCollation
/// reaches user search. This provider is the only one that needs it: its base class is the sole
/// caller of FormatCaseInsensitiveLike. The other Postgres providers construct a bare
/// dialect deliberately, because they use it only for pagination, quoting and literals.
///
public PostgresUserProvider(
IRedbContext context,
IRedbSecurityContext securityContext,
ILogger? logger = null,
ISqlDialect? dialect = null)
: base(context, securityContext, dialect ?? new PostgreSqlDialect(), new BcryptPasswordHasher(), logger)
{
}
///
/// Creates a new PostgreSQL user provider with custom password hasher.
///
/// Database context for executing queries
/// Security context for authorization
/// Custom password hasher implementation
/// Optional logger for diagnostics
public PostgresUserProvider(
IRedbContext context,
IRedbSecurityContext securityContext,
IPasswordHasher passwordHasher,
ILogger? logger = null,
ISqlDialect? dialect = null)
: base(context, securityContext, dialect ?? new PostgreSqlDialect(), passwordHasher, logger)
{
}
// All business logic is inherited from UserProviderBase.
// PostgreSQL-specific SQL is provided by PostgreSqlDialect.
// Password hashing defaults to BcryptPasswordHasher (a custom IPasswordHasher can be injected).
}