Role Based Authorization in ASP.NET Core 6

Beachdog

I'm developing an ASP.NET Core 6 web application.

  • The application will run via IIS on a standalone machine
  • There will be no Register or login functionality.
  • The application will support and have functionality for two Users "KioskAdmin" and "KioskUser". Those two Users are machine accounts of the host machine running the application. So a User logs into the machine as "KioskAdmin" and the person has access to the administrative functionality of the application. If a person logs into the host machine as "KioskUser" the person has access to non-admin functionality.

I'd like to use Role based authorization where I can do

[Authorize(Roles ="Admin")]
public class IndexModel : PageModel

I've read about Claims-based authorization and cookie authentication and creating an Identity User, but not sure how to implement it. Plus the machine account username for both KioskAdmin and KioskUser is going to be different for every machine the application is eventually deployed on.

Is there a way to tie [Authorize(Roles ="Admin")] to some custom method where I implement my own code/logic and return some value that would signal the Authorization was valid?

Beachdog

I found something that works for me. Implement custom Authorize attribute. custom AuthorizeAttribute in ASP.NET Core

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Asp.NET Core MVC Role based Authorization

Role based authorization in ASP.NET Core 3.1 with Identity and ExternalLogin

Role based authorization using Keycloak and .NET core

Asp.Net Core 6 Role based Navigation

ASP.NET Core Custom Role Based Authorization (Custom User.IsInRole)?

IdentityServer4 and ASP.NET Core5.0 Identity - Role based Authorization

IdentityServer4 Role Based Authorization for Web API with ASP.NET Core Identity

asp.net core 2.0 app crashes when role based authorization faild

ASP.Net Core 3.0 Windows Authentication with Custom Role Based Authorization

asp.net core 2.0 windows role based authorization always returns 403

ASP.NET Core 2.1 Identity: Role-based authorization -> Access Denied

IdentityServer4 Role Based Authorization for ASP.NET Core Identity = Access Denied

ASP.NET Core 3.1 Web API Role based authorization not working

Asp.net core mvc role-based authorization with Azure AD

ASP.NET Core 3.1 MVC Access Denied role based authorization - Conflict with custom UserClaimsPrincipalFactory

Claim based authorization in ASP.NET Core

Asp.NET Core Claim based Authorization

Claims based authorization in ASP.NET Core

.NET Core 3.1 role based authorization fails, getting 403 exception

Windows Authentication Asp.net core 2 database role authorization

ASP.NET Web Api with Role based authorization

UnauthorizedAccessException behavior in ASP.NET Core policy based authorization

ASP.NET Core Custom Policy Based Authorization - unclear

How to implement permission based authorization in ASP.net core Identity?

Policy based Authorization not working in asp.net core

Rights-based authorization with ASP.NET Core 2.1 Identity

asp.net core 2.0 - Claims and policy based Authorization

ASP.NET Web API role based authorization based on route parameter

MiniProfiler ASP.NET Core - ShouldProfile based on user role

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    pump.io port in URL

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  14. 14

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  15. 15

    How to use merge windows unallocated space into Ubuntu using GParted?

  16. 16

    flutter: dropdown item programmatically unselect problem

  17. 17

    Pandas - check if dataframe has negative value in any column

  18. 18

    Nuget add packages gives access denied errors

  19. 19

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  20. 20

    Generate random UUIDv4 with Elm

  21. 21

    Client secret not provided in request error with Keycloak

HotTag

Archive