Coder Social home page Coder Social logo

uzbekdev1 / role-policy-authorization-sample Goto Github PK

View Code? Open in Web Editor NEW

This project forked from referbruv/role-policy-authorization-sample

0.0 0.0 0.0 25 KB

A sample application to demonstrate the implementation of Role based and Policy based Authorization in ASP.NET Core

Home Page: https://referbruv.com/blog/posts/role-based-and-claims-based-authorization-in-aspnet-core-using-policies-hands-on

License: MIT License

C# 100.00%

role-policy-authorization-sample's Introduction

role-policy-authorization-sample

Let's talk about two important use cases of authorizing APIs basing on an user role defined by the system and authorizing a user basing on an incoming request claims from the user token.

What is a Policy?

An authorization policy is a set of requirements and handlers. These requirements define what a request user need to satisfy inorder to proceed further. The respective handlers define how these requirements are processed when a request is made and what action needs to be presented if a rule is satisfied or failed. These requirements and handlers are registered in the Startup when the application bootstraps.

Once a policy is defined and registered, the runtime applies these policies for validation at the endpoints where the policies are decorated with. When we have these policies in force, we can ensure that the APIs are further secured on top of Authentication and only the set of Authorized users who satisfy these policies are allowed access, else are forbidden (403) from access.

About the Solution

The solution is a .NET 5 Web API project with seperated tiers for Web, Core and Contracts.

What to Expect

  • Clean Architecture with separated tiers for better encapsulation
  • Declared repositories for encapsulating the database logic
  • Demonstrated Requirements and Authorization Handlers
  • Mechanism to authenticate and generate JWT Token with Role claim
  • Updated to latest stable .NET 5

Read the complete article to learn more:

https://referbruv.com/blog/posts/role-based-and-claims-based-authorization-in-aspnet-core-using-policies-hands-on

Leave a Star if you find the solution useful. If you find the article helpful, support me by:

Buy Me A Coffee

For more detailed articles and how-to guides, visit https://referbruv.com

role-policy-authorization-sample's People

Contributors

referbruv avatar sriramkumarm1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.