Skip to content

Commit 907ed7c

Browse files
committed
gRPC:PipeSecurity for Named Pipes
1 parent 6d5dd85 commit 907ed7c

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

aspnetcore/grpc/interprocess-namedpipes.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: jamesnk
44
description: Learn how to use gRPC for inter-process communication with Named pipes.
55
monikerRange: '>= aspnetcore-8.0'
66
ms.author: wpickett
7-
ms.date: 01/18/2023
7+
ms.date: 07/01/2025
88
uid: grpc/interprocess-namedpipes
99
---
1010
# Inter-process communication with gRPC and Named pipes
@@ -47,6 +47,46 @@ The preceding example:
4747
* Calls `ListenNamedPipe` to listen to a named pipe with the specified name.
4848
* 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).
4949

50+
### Configuring PipeSecurity for Named Pipes
51+
52+
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 you to specify a custom [`PipeSecurity`](xref:System.IO.Pipes.PipeSecurity) object.
53+
54+
Example:
55+
56+
```csharp
57+
using Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes;
58+
using System.IO.Pipes;
59+
using System.Security.AccessControl;
60+
61+
var builder = WebApplication.CreateBuilder(args);
62+
builder.WebHost.ConfigureKestrel(serverOptions =>
63+
{
64+
serverOptions.ListenNamedPipe("MyPipeName", listenOptions =>
65+
{
66+
listenOptions.Protocols = HttpProtocols.Http2;
67+
68+
// Configure PipeSecurity
69+
listenOptions.UseNamedPipes(options =>
70+
{
71+
var pipeSecurity = new PipeSecurity();
72+
// Grant read/write access to the Users group
73+
pipeSecurity.AddAccessRule(new PipeAccessRule(
74+
"Users",
75+
PipeAccessRights.ReadWrite,
76+
AccessControlType.Allow));
77+
// Add additional rules as needed
78+
79+
options.PipeSecurity = pipeSecurity;
80+
});
81+
});
82+
});
83+
84+
The preceding example:
85+
86+
* Uses <xref:Microsoft.AspNetCore.Hosting.WebHostBuilderNamedPipeExtensions.UseNamedPipes> to access and configure <xref:Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes.NamedPipeTransportOptions>.
87+
* Sets the <xref:System.IO.Pipes.PipeSecurity> property to control which users or groups can connect to the named pipe.
88+
* Grants read/write access to the `Users` group. Additional security rules can be added as needed for the scenario.
89+
5090
## Client configuration
5191

5292
`GrpcChannel` supports making gRPC calls over custom transports. When a channel is created, it can be configured with a <xref:System.Net.Http.SocketsHttpHandler> that has a custom <xref:System.Net.Http.SocketsHttpHandler.ConnectCallback>. The callback allows the client to make connections over custom transports and then send HTTP requests over that transport.

0 commit comments

Comments
 (0)