EasyAuthentication 1.2.1
See the version list below for details.
dotnet add package EasyAuthentication --version 1.2.1
NuGet\Install-Package EasyAuthentication -Version 1.2.1
<PackageReference Include="EasyAuthentication" Version="1.2.1" />
<PackageVersion Include="EasyAuthentication" Version="1.2.1" />
<PackageReference Include="EasyAuthentication" />
paket add EasyAuthentication --version 1.2.1
#r "nuget: EasyAuthentication, 1.2.1"
#:package EasyAuthentication@1.2.1
#addin nuget:?package=EasyAuthentication&version=1.2.1
#tool nuget:?package=EasyAuthentication&version=1.2.1
About EasyAuthentication :
EasyAuthentication is the clean and realy clear authentication and authorization service. In this project I use Clean architecture and also use MediateR, FluentValidation, AutoMapper and JWT to implement this structure. Totally I developed it after some years of expriences and use a lots of diffrent authentication that we can use Mobile authentication and Email authentication.
How to use :
In the "Configurations" folder and IdentityServicesRegistration we have JwtSettings and IdentityConnectionString that they read from appsettings on your project like following codes:
"ConnectionStrings": {
"IdentityConnectionString": "Data Source= <DB_IP> ; User Id = <DB_USER> ; Password = <DB_PASSWORD> ; Initial Catalog= <DB_NAME> ;TrustServerCertificate=True"
},
"JwtSettings": {
"Key": "<YOUR_KEY>",
"Issuer": "<YOUR_ISSUER>",
"Audience": "<YOUR_AUDIENCE>",
"DurationInMinutes": 43200//for 30 days
},
Add this config to your program.cs
builder.Services.AddDbContext<IdentityDbContext>(options =>
{
options.UseSqlServer(configuration
.GetConnectionString("<YOUR_CONNECTIONSTRING>"), b => b.MigrationsAssembly("<YOUR_PROJECTLAYER>"));
});
builder.Services.ConfigureIdentityServices(builder.Configuration);
How to use AuthenticationFeatures :
// register
await _mediator.Send(new RegisterRequest()
{
RegisterDto = new RegisterDto()
{
Email = "",
MobileNumber = "",
}
});
// send auth code to mobile
await _mediator.Send(new SendAuthCodeRequest()
{
SendAuthCode = new SendAuthCode()
{
MobileNumber = ""
}
});
// login by auth code
await _mediator.Send(new LoginByAuthCodeRequest()
{
LoginByAuthCode = new LoginByAuthCode()
{
MobileNumber = "",
ActivationCode = ""
}
});
// login by pass
await _mediator.Send(new LoginByPassRequest()
{
LoginByPass = new LoginByPass()
{
Email = "",
MobileNumber = "",
Password = ""
}
});
// set pass
await _mediator.Send(new SetPassRequest()
{
SetPass = new SetPass()
{
UserId = Guid.Empty,
Pass = "",
RePass = ""
}
});
// change pass
await _mediator.Send(new ChangePassRequest()
{
ChangePass = new ChangePass()
{
ReNewPass = "",
NewPass = "",
CurrentPass = "",
UserId = Guid.Empty
}
});
How to use RoleFeatures :
await _mediator.Send(new GetRoleListRequest(){});
await _mediator.Send(new GetRoleRequest() { Id = 1 });
await _mediator.Send(new GetUserRolesRequest() { Id = Guid.Empty});
// add or update role
await _mediator.Send(new UpsertRoleRequest()
{
RoleDto = new RoleDto()
{
Title = "role"
}
});
// pass roleId
await _mediator.Send(new DeleteRoleRequest(){Id = 1});
// pass userRoleId
await _mediator.Send(new DeleteRoleFromUserRequest(){Id = 1});
await _mediator.Send(new AddRoleToUserRequest(){UserId = Guid.Empty , RoleId = 1});
How to use UserFeatures :
await _mediator.Send(new GetUserListRequest());
await _mediator.Send(new GetUserProfileRequest(){UserId = Guid.Empty});
await _mediator.Send(new GetUserRequest(){Id = Guid.Empty});
await _mediator.Send(new UpsertUserProfileRequest(){UserDto = new UserDto()});
await _mediator.Send(new UpdateUserProfileRequest(){UserProfileDto = new UpdateUserProfileDto()});
await _mediator.Send(new DeleteUserProfileRequest(){RemoveUserDto = new RemoveUserDto(){UserId = Guid.Empty}});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
-
net8.0
- AutoMapper.Extensions.Microsoft.DependencyInjection (>= 12.0.1)
- FluentValidation.DependencyInjectionExtensions (>= 11.9.0)
- MediatR (>= 12.2.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.1)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- RestSharp (>= 110.2.0)
- System.IdentityModel.Tokens.Jwt (>= 7.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Add new mthods (get user by email or mobile )