AuthifyPass.Client
1.0.3
dotnet add package AuthifyPass.Client --version 1.0.3
NuGet\Install-Package AuthifyPass.Client -Version 1.0.3
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="AuthifyPass.Client" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AuthifyPass.Client" Version="1.0.3" />
<PackageReference Include="AuthifyPass.Client" />
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 AuthifyPass.Client --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AuthifyPass.Client, 1.0.3"
#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 AuthifyPass.Client@1.0.3
#: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=AuthifyPass.Client&version=1.0.3
#tool nuget:?package=AuthifyPass.Client&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AuthifyPass.Client Library Documentation
Overview
The AuthifyPass.Client library to consume AuthifyPass API.
Prerequisites
To use this library, you need:
- You must register first in AuthifyPass here to get your CLIENT and SECRET.
Installation
Install the NuGet Package:
- Install the
AuthifyPass.ClientNuGet package in your project using the Package Manager or the .NET CLI:dotnet add package AuthifyPass.Client
- Install the
Configure Client:
- In your appsettings, add
"AuthifyPassOptions": { "ClientID": "", "Secret": "", "BaseUrl": "https://authifypass.com/", "UserEndpoint": "user", "ValidateCodeEndpoint": "user/validate-code", "Header": "x-authify-key" }- NOTE: If AuthifyPass API it's in other URL or change the endpoints, here is where can set. Also the Header key.
- NOTE: Because AuthifyPass is opensource, you can download the code and personalize, so here can change the values.
Register dependencies:
- Add the
IAuthifyPassClientto your dependencies.
var builder = WebApplication.CreateBuilder(args); // OR any other like var builder = WebAssemblyHostBuilder.CreateDefault(args); [...] builder.Services.AddAuthifyPassClient(); [...]- Add the
How to use
Create new QR
internal class Enable2FactorQRInteractor(IAuthifyPassClient client)
{
public async Task<AuthifyPassDto> GetQR(string userId, CancellationToken token)
{
var response = await client.RequestUser2FactorQRAsync(userId, user.Email, token);
var result = new AuthifyPassDto(response.Sharedkey, response.ImageSVG);
result.Code = userId;
return result;
}
}
Login example
internal class UserLoginInteractor(
IRepository<User> repository,
IValidator<UserRequest> validator,
IAuthifyPassClient client)
{
public async Task Login(UserRequest login)
{
bool isValidated = await validator.Validate(login);
if (isValidated)
{
User? user = await repository.GetAsync(u => u.Email == login.Email);
if (user is not null && user.PasswordHash == login.Password)
{
var result2Factor = await client.ValidateUser2FactorAsync(user.Id.ToString(), login.DoubleFactorCode);
if (!result2Factor)
throw new UnauthorizedAccessException("Two-factor authentication is enabled for this user.");
}
}
throw new UnauthorizedAccessException("Invalid email or password.");
}
}
Delete User and all QR
internal class DeleteFactorQRInteractor(IAuthifyPassClient client)
{
public async Task DeleteUserQR(string userId, CancellationToken token)
{
await client.RequestDeleteUser2FactorAsync(userId, token);
}
}
NOTES:
- UserId It's a string, can send any identityies. This identifier it's HASH in AuthifyPass API Side, so we don't have any data from user.
- When delete a User, delete all QR and no more validation will happen.
- User Client App can also delete the QR and invalidate all QR generated.
Errors
When have some error client will return a ProblemDetails model.
Models
The library includes two main models:
AuthifyPassOptions:- Represents the configuration about AuthifyPass API. Check documentation
https://authifypass.com/api/docs. - Properties:
- SectionKey
- ClientID
- Secret
- BaseUrl
- UserEndpoint
- ValidateCodeEndpoint
- Header
- Represents the configuration about AuthifyPass API. Check documentation
AuthifyPassResponse:- Represents the response when request for some new QR and Shared Key.
- Properties:
- Sharedkey
- ImageSVG: QR
Contributing
If you encounter issues or have suggestions for improvements, please submit an issue or pull request to the repository hosting this library.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.3)
- Microsoft.Extensions.Http (>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
- Microsoft.Extensions.Options (>= 10.0.3)
-
net9.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.13)
- Microsoft.Extensions.Http (>= 9.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.13)
- Microsoft.Extensions.Options (>= 9.0.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Target Net 9. Update dependencies.