Ellersoft.Authentication.PostgreSQL 1.1.4

dotnet add package Ellersoft.Authentication.PostgreSQL --version 1.1.4
                    
NuGet\Install-Package Ellersoft.Authentication.PostgreSQL -Version 1.1.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ellersoft.Authentication.PostgreSQL" Version="1.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ellersoft.Authentication.PostgreSQL" Version="1.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Ellersoft.Authentication.PostgreSQL" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ellersoft.Authentication.PostgreSQL --version 1.1.4
                    
#r "nuget: Ellersoft.Authentication.PostgreSQL, 1.1.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ellersoft.Authentication.PostgreSQL@1.1.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ellersoft.Authentication.PostgreSQL&version=1.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Ellersoft.Authentication.PostgreSQL&version=1.1.4
                    
Install as a Cake Tool

Ellersoft.Authentication.PostgreSQL

Provides authentication with a PostgreSQL database. The database can be generated with any ORM, or build raw. This authentication method uses raw read/write queries to load and save users to the database.

The following types exist:

  • PostgreSqlAuthentication: the authentication provider for the PostgreSQL Server;
  • PostgreSqlColumn: represents a column in a PostgreSQL database;

Example Usage

To use the PostgreSQL provider, first create an instance of PostgreSqlAuthentication:

var saltLength = 16;
var iterationCount = 40000;
var cryptoParams = new Rfc2898DeriveBytes(saltLength, iterationCount);

var schema = "public";
var table = "Users";
var idColumn = new PostgreSqlColumn("Id", NpgsqlDbType.Uuid);
var nameColumn = new PostgreSqlColumn("Email", NpgsqlDbType.Text);
var passwordColumn = new PostgreSqlColumn("Password", NpgsqlDbType.Bytea, 64);
var cryptographyColumn = new PostgreSqlColumn("Salt", NpgsqlDbType.Bytea, 32);
IAuthentication provider = new PostgreSqlAuthentication(
    connectionString,
    schema,
    table,
    idColumn,
    nameColumn,
    passwordColumn,
    cryptographyColumn,
    cryptoParams);

Next, when ready to register a user, call the Register<TId>(IAuthenticationParameters, AuthenticationResult<TId>) method:

var user = new UsernamePassword("test@example.com", "password123");
var result = new AuthenticationResult<Guid>(Guid.NewGuid());
provider.Register(user, result);

This will insert the user and the ID into the database.

To authenticate a user, use the Authenticate<TId>(IAuthenticationParameters) method:

var user = new UsernamePassword("test@example.com", "password123");
var result = provider.Authenticate(user);
if (result == null) {
    // TODO: Error: authentication failed. User does not exist or password is incorrect.
}

To change a user password, use the ChangePassword<TId>(IAuthenticationParameters, AuthenticationResult<TId>) method:

var user = new UsernamePassword(null, "password123");
var result = new AuthenticationResult<Guid>(userGuid);
provider.ChangePassword(user, result);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.4 482 1/29/2021