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
<PackageReference Include="Ellersoft.Authentication.PostgreSQL" Version="1.1.4" />
<PackageVersion Include="Ellersoft.Authentication.PostgreSQL" Version="1.1.4" />
<PackageReference Include="Ellersoft.Authentication.PostgreSQL" />
paket add Ellersoft.Authentication.PostgreSQL --version 1.1.4
#r "nuget: Ellersoft.Authentication.PostgreSQL, 1.1.4"
#:package Ellersoft.Authentication.PostgreSQL@1.1.4
#addin nuget:?package=Ellersoft.Authentication.PostgreSQL&version=1.1.4
#tool nuget:?package=Ellersoft.Authentication.PostgreSQL&version=1.1.4
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 | Versions 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. |
-
.NETCoreApp 3.1
- Ellersoft.Authentication.Core (>= 1.1.3)
- Npgsql (>= 5.0.2)
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 |