{"id":13430516,"url":"https://github.com/JeepNL/Blazor-WASM-Identity-gRPC","last_synced_at":"2025-03-16T05:31:17.169Z","repository":{"id":55515423,"uuid":"273876752","full_name":"JeepNL/Blazor-WASM-Identity-gRPC","owner":"JeepNL","description":"Blazor WASM, IdentityServer4 with Multiple Roles, Additional User Claim(s) \u0026 gRPC Roles Authorization","archived":false,"fork":false,"pushed_at":"2023-07-06T09:10:05.000Z","size":349,"stargazers_count":98,"open_issues_count":0,"forks_count":16,"subscribers_count":7,"default_branch":"Main","last_synced_at":"2025-03-13T20:11:20.098Z","etag":null,"topics":["blazor","claims","efcore","grpc","grpc-web","identityserver4","kestrel","roles","sqlite","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JeepNL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-06-21T09:55:47.000Z","updated_at":"2024-10-25T13:23:47.000Z","dependencies_parsed_at":"2024-01-18T14:41:06.218Z","dependency_job_id":"9cb84d92-5e06-45c8-bb0b-ba4b726920a1","html_url":"https://github.com/JeepNL/Blazor-WASM-Identity-gRPC","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeepNL%2FBlazor-WASM-Identity-gRPC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeepNL%2FBlazor-WASM-Identity-gRPC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeepNL%2FBlazor-WASM-Identity-gRPC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeepNL%2FBlazor-WASM-Identity-gRPC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JeepNL","download_url":"https://codeload.github.com/JeepNL/Blazor-WASM-Identity-gRPC/tar.gz/refs/heads/Main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830912,"owners_count":20354848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor","claims","efcore","grpc","grpc-web","identityserver4","kestrel","roles","sqlite","wasm","webassembly"],"created_at":"2024-07-31T02:00:54.820Z","updated_at":"2025-03-16T05:31:16.573Z","avatar_url":"https://github.com/JeepNL.png","language":"C#","funding_links":[],"categories":["Sample Projects"],"sub_categories":["Authentication"],"readme":"# Blazor WASM, IdentityServer4 with Multiple Roles, Additional User Claim(s) \u0026amp; gRPC Roles Authorization\n\n![Blazor Template Screenshot](img/screenshot.jpg)\n\n![.NET Core](https://github.com/JeepNL/Blazor-WASM-Identity-gRPC/workflows/.NET%20Core/badge.svg) _(Whoa Nelly, this thing does work!)_ 😉\n\n\u003cimg src=\"https://media.giphy.com/media/TH6DTcHdotDahRuVkL/giphy.gif\" width=\"100\"\u003e\n\n### This .NET 6 Preview repo combines two repo's by **@javiercn**:\n\n1. https://github.com/javiercn/BlazorAuthRoles\n2. https://github.com/javiercn/BlazorGrpcAuth\n\n(_To run this repo you'll need **.NET 6.0 [SDK](https://dotnet.microsoft.com/download/dotnet-core)** and **Visual Studio [Preview](https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-preview)**_)\n\nI've added Role Authorization to the -[Greeter](BlazorTemplate/Client/Pages/GreeterGrpc.razor) -[gRPC](BlazorTemplate/Shared/Contracts/greeter.proto) -[Service](BlazorTemplate/Server/GrpcServices/GreeterService.cs):\n\n_Server/[Startup.cs](BlazorTemplate/Server/Startup.cs)_\n\n    endpoints\n        .MapGrpcService\u003cGreeterService\u003e()\n        .RequireAuthorization(new AuthorizeAttribute { Roles = \"Administrator\"})\n        .EnableGrpcWeb();\n        \nI've also added a _Client/[Claims.razor](BlazorTemplate/Client/Pages/Claims.razor)_ page with a list of the current user's claims.\n\nIt uses Kestrel as the default webserver, a SQLite database and is \"*CTRL-F5'able*\" without any further configuration.\n\nYou 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.\n\n1. Add-Migration InitialCreate\n2. Update-Database\n\nAt first run the app will create 2 users (_if they don't exist, see: Server/[SeedData.cs](BlazorTemplate/Server/Data/SeedData.cs)_)\n\n1. `admin@example.com` / `Qwerty1234#`\n2. `user@example.com` / `Qwerty1234#`\n\nand 2 roles: \n\n1. Users\n2. Administrators\n\nThe 'Administrators' \u0026amp; 'Users' roles will be assigned to: `admin@example.com`\n\nThe 'Users' role will be assigned to: `user@example.com`\n\n### Additional Claim(s)\n(_By George, I think I've got it_)\n\n1. I've extended ASP.NET Identity AspNetUsers table with an extra 'CustomClaim' field (_see: Server/Models/[ApplicationUser.cs](BlazorTemplate/Server/Models/ApplicationUser.cs)_).\n2. Seeded a value to that `CustomClaim` field  in: _Server/Data/[SeedData.cs](BlazorTemplate/Server/Data/SeedData.cs)_\n3. Added: _Server/[AppClaimsPrincipalFactory.cs](BlazorTemplate/Server/AppClaimsPrincipalFactory.cs)_\n4. Modified: _Server/[Startup.cs](BlazorTemplate/Server/Startup.cs)_ to use `AppClaimsPrincipalFactory.cs`\n5. When you run the app you'll see the `custom_claim` in the _Client/Pages/[Claims.razor](BlazorTemplate/Client/Pages/Claims.razor)_ page\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJeepNL%2FBlazor-WASM-Identity-gRPC","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJeepNL%2FBlazor-WASM-Identity-gRPC","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJeepNL%2FBlazor-WASM-Identity-gRPC/lists"}