diff --git a/aspnetcore/grpc/interprocess-namedpipes.md b/aspnetcore/grpc/interprocess-namedpipes.md index 70e046df7e58..7b70bd77200c 100644 --- a/aspnetcore/grpc/interprocess-namedpipes.md +++ b/aspnetcore/grpc/interprocess-namedpipes.md @@ -4,7 +4,8 @@ author: jamesnk description: Learn how to use gRPC for inter-process communication with Named pipes. monikerRange: '>= aspnetcore-8.0' ms.author: wpickett -ms.date: 01/18/2023 +ai-usage: ai-assisted +ms.date: 07/01/2025 uid: grpc/interprocess-namedpipes --- # Inter-process communication with gRPC and Named pipes @@ -47,6 +48,47 @@ The preceding example: * Calls `ListenNamedPipe` to listen to a named pipe with the specified name. * Creates a named pipe endpoint that isn't configured to use HTTPS. For information about enabling HTTPS, see [Kestrel HTTPS endpoint configuration](xref:fundamentals/servers/kestrel/endpoints#listenoptionsusehttps). +### Configuring PipeSecurity for Named Pipes + +To customize the security of the named pipe, for example, to control which users or groups can connect, use the [`NamedPipeTransportOptions`](xref:Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes.NamedPipeTransportOptions) class. This allows a custom [`PipeSecurity`](xref:System.IO.Pipes.PipeSecurity) object to be specified. + +Example: + +```csharp +using Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes; +using System.IO.Pipes; +using System.Security.AccessControl; + +var builder = WebApplication.CreateBuilder(args); +builder.WebHost.ConfigureKestrel(serverOptions => +{ + serverOptions.ListenNamedPipe("MyPipeName", listenOptions => + { + listenOptions.Protocols = HttpProtocols.Http2; + + // Configure PipeSecurity + listenOptions.UseNamedPipes(options => + { + var pipeSecurity = new PipeSecurity(); + // Grant read/write access to the Users group + pipeSecurity.AddAccessRule(new PipeAccessRule( + "Users", + PipeAccessRights.ReadWrite, + AccessControlType.Allow)); + // Add additional rules as needed + + options.PipeSecurity = pipeSecurity; + }); + }); +}); +``` + +The preceding example: + +* Uses `UseNamedPipes` to access and configure . +* Sets the property to control which users or groups can connect to the named pipe. +* Grants read/write access to the `Users` group. Additional security rules can be added as needed for the scenario. + ## Client configuration `GrpcChannel` supports making gRPC calls over custom transports. When a channel is created, it can be configured with a that has a custom . The callback allows the client to make connections over custom transports and then send HTTP requests over that transport.