Ellersoft.Authentication.MSSQL
1.1.4
dotnet add package Ellersoft.Authentication.MSSQL --version 1.1.4
NuGet\Install-Package Ellersoft.Authentication.MSSQL -Version 1.1.4
<PackageReference Include="Ellersoft.Authentication.MSSQL" Version="1.1.4" />
<PackageVersion Include="Ellersoft.Authentication.MSSQL" Version="1.1.4" />
<PackageReference Include="Ellersoft.Authentication.MSSQL" />
paket add Ellersoft.Authentication.MSSQL --version 1.1.4
#r "nuget: Ellersoft.Authentication.MSSQL, 1.1.4"
#:package Ellersoft.Authentication.MSSQL@1.1.4
#addin nuget:?package=Ellersoft.Authentication.MSSQL&version=1.1.4
#tool nuget:?package=Ellersoft.Authentication.MSSQL&version=1.1.4
Ellersoft.Authentication.MSSQL
Provides authentication with an MSSQL 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:
MssqlAuthentication
: the authentication provider for the Microsoft SQL Server;MssqlColumn
: represents a column in an MSSQL database;
Example Usage
To use the MSSQL provider, first create an instance of MssqlAuthentication
:
var saltLength = 16;
var iterationCount = 40000;
var cryptoParams = new Rfc2898DeriveBytes(saltLength, iterationCount);
var schema = "dbo";
var table = "Users";
var idColumn = new MssqlColumn("Id", SqlDbType.UniqueIdentifier);
var nameColumn = new MssqlColumn("Email", SqlDbType.NVarChar);
var passwordColumn = new MssqlColumn("Password", SqlDbType.Binary, 64);
var cryptographyColumn = new MssqlColumn("Salt", SqlDbType.VarBinary, 32);
IAuthentication provider = new MssqlAuthentication(
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)
- System.Data.SqlClient (>= 4.8.0)
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 | 494 | 1/29/2021 |