CPIT.UsersManager
3.1.0
See the version list below for details.
dotnet add package CPIT.UsersManager --version 3.1.0
NuGet\Install-Package CPIT.UsersManager -Version 3.1.0
<PackageReference Include="CPIT.UsersManager" Version="3.1.0" />
paket add CPIT.UsersManager --version 3.1.0
#r "nuget: CPIT.UsersManager, 3.1.0"
// Install CPIT.UsersManager as a Cake Addin #addin nuget:?package=CPIT.UsersManager&version=3.1.0 // Install CPIT.UsersManager as a Cake Tool #tool nuget:?package=CPIT.UsersManager&version=3.1.0
Users Manager
User manager is a .Net library which provides a backend framework for users management. The library uses EntityFrameworkCore and Google authentication.
Before You Begin
Make sure to create a GCP project and have an active OAuth Client ID, the ID should authorize the Javascript origins which will initiate the authentication process.
How To Use
Step 1: Adding the required appsettings
You should have a "JwtSettings" section in appsettings.json file, which contains three main configurations:
- securityKey
- validIssuer
- validAudience
- expiryInMinutes Those settings can be also stored in application environment or Google secret manager, the library will be able to read them. You need also to add "GoogleAuthSettings" section in appsettings.json file, which contains three main configurations:
- clientId
Step 2: Configure dependency injection
Add the following code in your Startup file
services.AddUserAuthentication(Configuration);
Step 3: Inject the UserServices and use the supported functions
UserServices provides three main functions:
- Login
- Register
- Assign roles
Step 4: Security framework
Inherit SystemPermissions and SystemRole classes in your project, and use them as an authentication policies. Example:
public class BaseRole: SystemRole {
public const string SystemAdmin = "SystemAdmin";
}
public class BasePermissions: SystemPermissions
{
public static readonly SystemAction CanManageUsers = new(nameof(CanManageUsers), BaseRole.SystemAdmin);
}
[Authorize(Policy = nameof(BasePermissions.CanManageUsers))]
public class UsersController : ControllerBase {
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- Google.Apis.Auth (>= 1.57.0)
- Google.Apis.Drive.v3 (>= 1.57.0.2601)
- Google.Cloud.SecretManager.V1 (>= 2.0.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 6.0.4)
- Microsoft.AspNetCore.Identity (>= 2.2.0)
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 6.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.