Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
Xelit3 edited this page Nov 5, 2020 · 15 revisions

Description of the tool

ChustaSoft.Authorization is a tool based on Microsoft ASPNETCore Identity thought to have an easy and clear implementation and configuration of the tool inside a project with JWT authentication, and splitted into several packages in order to have the most decoupled and flexible possible tool.

ChustaSoft.Authorization is also prepared to manage extended contexts, so if the target project requieres additional properties or relations it will also be able to handle it, otherwise, you also have the possibility of just use the default implementation inside.

From version 2.0, the tool is now compatible with .NET Core 3.1, and is divided in two different packages:

  • [NuGet] ChustaSoft.Tools.Authorization: Main package, it contains the services, models and database context using Microsoft AspNet Identity features, isolating and extending in different services.
  • [NuGet] ChustaSoft.Tools.Authorization.AspNet: Package for adding controllers to the target project exposing main functionalities like Login or Register in a REST Controller.

From version 3.0, the tool grown up, having a decoupled SqlServer package, an Abstractions package, and a frontend JavaScript connector

  • [NuGet] ChustaSoft.Tools.Authorization.Abstractions: Core abstractions package non dependant on infrastructure
  • [NuGet] ChustaSoft.Tools.Authorization.SqlServer: Package containing EFCore with Identity implementation for SqlServer, and the cofiguration Extension Methods
  • [npm] @chustasoft/cs-authorization-connector: npm package for frontend packages, developed in TypeScript, providing the required services for consuming the API

Understanding the tool

There are two different ways to use it, the default one, and the custom:

Default implementation

If the project doesn't requiere any additional functionality or information stored in the context provided by the Authorization tool, it is possible to use the default implementation provided internally by the tool. As a level services, the tool can provide of the different services. All this functionalities are using internal base User and Role:

  • ISessionService

    • Task AuthenticateAsync(Credentials credentials)
    • Task RegisterAsync(Credentials credentials)
  • IProviderService

    • AuthenticationProperties GetExternalProperties(string provider, string loginCallbackUrl)
  • IUserService

    • Task GetAsync(Guid userId)
    • Task GetAsync(string username, string password)
    • Task SignByUsername(string username, string password)
    • Task SignByEmail(string email, string password)
    • Task SignByPhone(string phone, string password)
    • Task ConfirmEmail(string email, string token)
    • Task ConfirmPhone(string phone, string token)
    • Task CreateAsync(User user, string password)
    • Task UpdateAsync(TUser user)
    • Task ExistAsync(string userEmail)
  • IRoleService

    • Task Get(Guid roleId)
    • Task ExistAsync(string roleName)
    • Task SaveAsync(string roleName)

Custom extended implementation

Just Take into account that, User and Role, are the parent one types for the project, default services are managing directly this one, but, for custom implementations defining custom User or Role is managed here returning and receiving the custom ones instead of the parent User/Role objects.

  • IUserService where TUser : User
  • IRoleService where TRole : Role
Clone this wiki locally