Skip to content

Minimal Onion architecture implementation with .Net Core 2.0 and JWT Bearer Authentification

Notifications You must be signed in to change notification settings

bouraine/onion.architecture.dotnetcore2.0

Repository files navigation

Foreword

Thanks for every member of C.L.I.C team (LGM Group)

Onion.architecture.dotnetcore2.0

Onion architecture implementation with dotnet core 2.X

I recommand Visual studio 2017 "Full Rename Project" extention to rename projets to meet your needs : https://marketplace.visualstudio.com/items?itemName=KuanyshNabiyev.FullRenameProject

After projects renaming using Full Name Project extension, you have to change obj/project.assets.json of each project.

Prerequisites

Before starting

  • Run this entity framework command on PM console to create database : Update-Database
  • Change Application Url and launchUrl in Properties/launchSettings.json file : launchSettings.json

Sammary

Onion Architecture sets a clear dependency rule between layers, making it a more restrictive variant of Layered and Hexagonal Architectures. At the very center of our application sits a domain model, surrounded by domain services and application services. Those 3 layers form the application core – no relevant application logic should reside outside of it and it should be independent of all peripheral concerns like UI or databases (Grzegorz Ziemoński).

Onion architecture

Onion.DAL.Entities

  • BaseEntity
  • Domain Entities

Onion.DAL.Persistance

  • Datebase Context
  • DBSets
  • EntityConfiguration (Fluent API)
  • EF Migrations
  • Eventual Seeds

Onion.BLL.IService

  • Business layer service interfaces

Onion.BLL.Service

  • Business layer service implementations

Onion.Web.API

  • ASPNET Core WebApi
  • View Models / View Model Builders
  • JWT Bearer Authentication (Startup.cs)
  • IOC (inversion of control)

Test authentication with Postman

1- Authentication with login and password :

  • Select raw option and set content-Type to JSON(application/json)
  • Insert json value (login/password/clientID)

login

2- Call the api with the above generated token :

  • Add Authorisation header key
  • Type Bearer then space then the above generated token

api_call

Releases

No releases published

Packages

No packages published

Languages