GithubHelp home page GithubHelp logo

yaghmori / blazor-wasm-identity-grpc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeepnl/blazor-wasm-identity-grpc

0.0 0.0 0.0 349 KB

Blazor WASM, IdentityServer4, Kestrel Web Server, Entity Framework Code First SQLite Database with Multiple Roles, Additional User Claims & gRPC with Roles Authorization.

License: MIT License

C# 66.92% CSS 5.06% HTML 28.02%

blazor-wasm-identity-grpc's Introduction

Blazor WASM, IdentityServer4 with Multiple Roles, Additional User Claim(s) & gRPC Roles Authorization

Blazor Template Screenshot

.NET Core (Whoa Nelly, this thing does work!) ๐Ÿ˜‰

This .NET 6 Preview repo combines two repo's by @javiercn:

  1. https://github.com/javiercn/BlazorAuthRoles
  2. https://github.com/javiercn/BlazorGrpcAuth

(To run this repo you'll need .NET 6.0 SDK and Visual Studio Preview)

I've added Role Authorization to the -Greeter -gRPC -Service:

Server/Startup.cs

endpoints
    .MapGrpcService<GreeterService>()
    .RequireAuthorization(new AuthorizeAttribute { Roles = "Administrator"})
    .EnableGrpcWeb();

I've also added a Client/Claims.razor page with a list of the current user's claims.

It uses Kestrel as the default webserver, a SQLite database and is "CTRL-F5'able" without any further configuration.

You can delete de SQLite database and migrations folder if you want and use the following commands in Visual Studio's Package Manager Console to re-create the db.

  1. Add-Migration InitialCreate
  2. Update-Database

At first run the app will create 2 users (if they don't exist, see: Server/SeedData.cs)

  1. [email protected] / Qwerty1234#
  2. [email protected] / Qwerty1234#

and 2 roles:

  1. Users
  2. Administrators

The 'Administrators' & 'Users' roles will be assigned to: [email protected]

The 'Users' role will be assigned to: [email protected]

Additional Claim(s)

(By George, I think I've got it)

  1. I've extended ASP.NET Identity AspNetUsers table with an extra 'CustomClaim' field (see: Server/Models/ApplicationUser.cs).
  2. Seeded a value to that CustomClaim field in: Server/Data/SeedData.cs
  3. Added: Server/AppClaimsPrincipalFactory.cs
  4. Modified: Server/Startup.cs to use AppClaimsPrincipalFactory.cs
  5. When you run the app you'll see the custom_claim in the Client/Pages/Claims.razor page

blazor-wasm-identity-grpc's People

Contributors

arjunkrishna avatar dependabot[bot] avatar jeepnl 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.