question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Example Request] gRPC authorization with IdentityServer4 (and roles)

See original GitHub issue

For my Blazor (3.2.0) WASM project (.NET 5.0 Preview latest) I’m now using IdentityServer4 (default Visual Studio Template) and gRPC (EF Core/SQLite) data services.

I would like to protect the gRPC services against unauthorized access much like the Ticketer example with [Authorize] on the service, and use it with IdentityServer4 roles [Authorize (Roles=Administrator)] See: Microsoft Docs, Secure an ASP.NET Core Blazor WebAssembly hosted app with Identity Server / Name and role claim with API authorization

Maybe it’s an idea to add an example to the samples gallery at https://github.com/grpc/grpc-dotnet/tree/master/examples

I tried to figure it out myself, but I’m stuck. I got the two (IdentityServer4 & Ticketer) working separately but I’m stuck combining gRPC authorization with IdentityServer4/Roles.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
javiercncommented, Jun 18, 2020

@JeepNL I wrote a sample for GRPC+Auth that you can find here.

Its lacking roles, but you can add that piece following the docs if that helps you.

This is the main piece to enable roles on the GRPC service (I believe)

                endpoints
                    .MapGrpcService<GreeterService>()
                    .RequireAuthorization(new AuthorizeAttribute { Roles = "Administrator"})
                    .EnableGrpcWeb();
1reaction
JeepNLcommented, Jul 2, 2020

I got everything working now so if someone wants to close this issue …

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authentication and authorization in gRPC for ASP.NET Core
Authenticate users calling a gRPC service. gRPC can be used with ASP.NET Core authentication to associate a user with each call. The following ......
Read more >
Handling authorization with IdentityServer4
User logs in, selects a tenant from a list of tenants that they have access to, and then they are redirected to the...
Read more >
Authenticate gRPC calls in ASP.NET Core
We set the Roles property of [Authorize] to Admin. Recollect that IdentityServer's TestUser user1 has role configured to Admin (see ...
Read more >
Blazor WebAssembly with gRPC and API secured by ...
This article will walk you through the following Configure IdentityServer4 Secure Web API using IdentityServer4 Adding gRPC service and ...
Read more >
Securing gRPC-based Microservices in .NET Core
TL;DR: This tutorial will show you how to integrate authentication and authorization in a .NET Core microservice scenario based on gRPC.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found