• Stars
    star
    224
  • Rank 177,792 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Example code for Authorization articles

PermissionAccessControl

This is a GitHub repo containing example code that goes with two articles

It contains a ASP.NET Core applications with extra code to implement feature or data authorization. All the ASP.NET Core applications use in-memory databases which are seeded on startup so it should run anywhere.

MIT licence.

Here is a example of the first application, TestWebApp, that covers feature authorization.

permission access

Feature authorization

The TestWebApp is the application you can run to try out the feature authorization code in the article A better way to handle authorization in ASP.NET Core.

Select the TestWebApp as your startup application. When you run it you will see a list of users that you can log in as. Here are some comments on these:

  • [email protected]:
    • This user can read the data in the Color controller, but can't change it (you get a "Access denied" error)
    • This user has "bought" access to Feature1, so a "Feature1" link is added to the nav block when they log in.
  • [email protected]:
    • This user can read and write the data in the Color controller.
    • This user hasn't "bought" access to Feature1, so no "Feature1" link appears for them (and they get an "Access denied" error if you try to access it).

Data authorization

The DataAuthWebApp is the application you can run to try out the data authorization code in the article Handling data authorization ASP.NET Core and Entity Framework Core.

Select the DataAuthWebApp as your startup application. When you run it you will see a list of users that you can log in as. Here are some comments on these:

  • Any user:
    • If you log in you can create some personal data via the "Personal Data" link in the nav block. That data is protected so only the user that created it can see it.
      Remember - its a in-memory database so it loses anything you put in when you stop the application.
  • Users [email protected], [email protected], [email protected], and [email protected]
    • These users can each access to the shops Dress4U, Shirt4U, Tie4U and DressPower respectively. You can list the shop's stock via the "Shop Stock" link in the nav bar.
  • [email protected]:
    • This user is a district manager for the three ...4U shops (but not the DressPower shop) When that user list the stock via the "Shop Stock" link they get the stock of all three shops that they are a manager of. This shows how hierarchical access can be implemented.

More Repositories

1

AuthPermissions.AspNetCore

This library provides extra authorization and multi-tenant features to an ASP.NET Core application.
C#
774
star
2

EfCore.GenericServices

A library to help you quickly code CRUD accesses for a web/mobile/desktop application using EF Core.
C#
598
star
3

EfCoreinAction-SecondEdition

Supporting repo to go with book "Entity Framework Core in Action", second edition
C#
397
star
4

EfCore.TestSupport

Tools for helping in unit testing applications that use Entity Framework Core
C#
353
star
5

EfCoreInAction

Supporting code to go with the book "Entity Framework Core in Action"
340
star
6

PermissionAccessControl2

Version 2 of example application to go with articles on feature and data authorization
C#
276
star
7

GenericServices

GenericServices helps with building a service/application layer in a .NET based application using EF6.x
C#
245
star
8

NetCore.AutoRegisterDi

Extension method to find/register classes in an assembly into the Microsoft DI provider
C#
234
star
9

EfCore.GenericBizRunner

Library to run business logic when using Entity Framework Core for database accesses
C#
216
star
10

AspNetReactSamples

Template/Sample ASP.NET projects to develop/build/test React.js apps
JavaScript
174
star
11

EfCore.SoftDeleteServices

Services to provide simple soft delete and cascade soft delete in EF Core
C#
114
star
12

EfCore.SchemaCompare

Library to compare EF Core's Model of the database against a database's schema.
C#
106
star
13

Net.DistributedFileStoreCache

NET distributed cache using a json file as the shared resourse with very fast Get
C#
96
star
14

SampleMvcWebApp

A Sample MVC5 web application showing the use of GenericServices for CRUD operations
C#
75
star
15

EfCore.GenericEventRunner

A library to allow developer use events to update their database via Entity Framework Core (EF Core)
C#
67
star
16

EfCoreSqlAndCosmos

Example CQRS application using Cosmos DB with EF Core
C#
66
star
17

BookApp.All

Example of applying an modular monolith approach to building apps. This version contains the whole app in one solution
C#
50
star
18

EfCore.GenericServices.AspNetCore

Converts EFCore.GenericServices and EfCore.GenericBizRunner statuses to ASP.NET Core formats
C#
49
star
19

EfSchemaCompare

EfSchemaCompare.EF6 allows you to compare Entity Framework's database modal with an actual SQL database.
C#
44
star
20

RunStartupMethodsSequentially

A .NET library that runs methods within a locked state on startup. This is useful if you want to migrate or seed a database on an web application that has multiple instances.
C#
32
star
21

EfCore.SoftDeleteServices-Old

Services to provide simple soft delete and cascade soft delete in EF Core
C#
29
star
22

GenericServices.StatusGeneric

Implements the "return a status" pattern - useful for code that can return errors
C#
28
star
23

SampleMvcWebAppComplex

A more complex MVC application showing the use of GenericServices with the AdventureWorksLT2012 database.
C#
26
star
24

Net.LocalizeMessagesAndErrors

This library provides extra code to make it easier to support in different languages in your .NET application
C#
18
star
25

MvcUsingBower

Applying Visual Studio's Bower/Grunt tools to a ASP.NET MVC application. See
JavaScript
16
star
26

PermissionsOnlyApp

C#
15
star
27

DDDExampleCode

Example code to go with my talk and article on DDD
C#
13
star
28

MultiProgPackTool

https://www.thereformedprogrammer.net/evolving-modular-monoliths-2-breaking-up-your-app-into-multiple-solutions/#how-to-create-a-nuget-packages
C#
9
star
29

SimpleMessageBroker

C#
5
star
30

Ef6BookApp

C#
4
star
31

AspNetCore.MultipleHostedService

C#
3
star
32

AuthP.CustomDatabaseExamples

C#
2
star
33

BookApp.Books

Part of the evolving Modular Monalith
C#
2
star
34

TryAspNetCoreMigrate

C#
2
star
35

BookApp.Main

C#
2
star
36

TestSupportSchema

C#
1
star