Skip to content

Commit 9f74798

Browse files
committed
move code to file
1 parent ef05df4 commit 9f74798

File tree

2 files changed

+35
-37
lines changed

2 files changed

+35
-37
lines changed

aspnetcore/release-notes/aspnetcore-10/includes/httpsys.md

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
You can now specify a custom security descriptor for HTTP.sys request queues. The new [RequestQueueSecurityDescriptor](https://source.dot.net/#Microsoft.AspNetCore.Server.HttpSys/HttpSysOptions.cs,a556950881fd2d87) property on <xref:Microsoft.AspNetCore.Server.HttpSys.HttpSysOptions> enables more granular control over access rights for the request queue. This granular control lets you tailor security to your application's needs.
55

6-
#### Why use the new property?
6+
#### What you can do with the new property
77

88
A *request queue* in HTTP.sys is a kernel-level structure that temporarily stores incoming HTTP requests until your application is ready to process them. By customizing the security descriptor, you can allow or deny specific users or groups access to the request queue. This is useful in scenarios where you want to restrict or delegate HTTP.sys request handling at the operating system level.
99

@@ -12,41 +12,6 @@ A *request queue* in HTTP.sys is a kernel-level structure that temporarily store
1212
The `RequestQueueSecurityDescriptor` property applies only when creating a new request queue. The property doesn't affect existing request queues. To use this property, set it to a <xref:System.Security.AccessControl.GenericSecurityDescriptor> instance when configuring your HTTP.sys server.
1313

1414
For example, the following code allows all authenticated users but denies guests:
15-
16-
```csharp
17-
using System.Security.AccessControl;
18-
using System.Security.Principal;
19-
using Microsoft.AspNetCore.Server.HttpSys;
20-
21-
// Create a new security descriptor
22-
var securityDescriptor = new CommonSecurityDescriptor(isContainer: false, isDS: false, sddlForm: string.Empty);
23-
24-
// Create a discretionary access control list (DACL)
25-
var dacl = new DiscretionaryAcl(isContainer: false, isDS: false, capacity: 2);
26-
dacl.AddAccess(
27-
AccessControlType.Allow,
28-
new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null),
29-
-1,
30-
InheritanceFlags.None,
31-
PropagationFlags.None
32-
);
33-
dacl.AddAccess(
34-
AccessControlType.Deny,
35-
new SecurityIdentifier(WellKnownSidType.BuiltinGuestsSid, null),
36-
-1,
37-
InheritanceFlags.None,
38-
PropagationFlags.None
39-
);
40-
41-
// Assign the DACL to the security descriptor
42-
securityDescriptor.DiscretionaryAcl = dacl;
43-
44-
// Configure HTTP.sys options
45-
var builder = WebApplication.CreateBuilder();
46-
builder.WebHost.UseHttpSys(options =>
47-
{
48-
options.RequestQueueSecurityDescriptor = securityDescriptor;
49-
});
50-
```
15+
[!code-csharp[](~/release-notes/aspnetcore-10/samples/HttpSysConfig/Program.cs)]
5116

5217
For more information, see <xref:fundamentals/servers/httpsys>.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Security.AccessControl;
2+
using System.Security.Principal;
3+
using Microsoft.AspNetCore.Server.HttpSys;
4+
5+
// Create a new security descriptor
6+
var securityDescriptor = new CommonSecurityDescriptor(isContainer: false, isDS: false, sddlForm: string.Empty);
7+
8+
// Create a discretionary access control list (DACL)
9+
var dacl = new DiscretionaryAcl(isContainer: false, isDS: false, capacity: 2);
10+
dacl.AddAccess(
11+
AccessControlType.Allow,
12+
new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null),
13+
-1,
14+
InheritanceFlags.None,
15+
PropagationFlags.None
16+
);
17+
dacl.AddAccess(
18+
AccessControlType.Deny,
19+
new SecurityIdentifier(WellKnownSidType.BuiltinGuestsSid, null),
20+
-1,
21+
InheritanceFlags.None,
22+
PropagationFlags.None
23+
);
24+
25+
// Assign the DACL to the security descriptor
26+
securityDescriptor.DiscretionaryAcl = dacl;
27+
28+
// Configure HTTP.sys options
29+
var builder = WebApplication.CreateBuilder();
30+
builder.WebHost.UseHttpSys(options =>
31+
{
32+
options.RequestQueueSecurityDescriptor = securityDescriptor;
33+
});

0 commit comments

Comments
 (0)