Skip to content

Commit 1d96820

Browse files
committed
Rename to explicitly mention REST APIs
1 parent 5d1b566 commit 1d96820

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# ByteGuard.SecurityHeaders ![NuGet Version](https://img.shields.io/nuget/v/ByteGuard.SecurityHeaders)
22

3-
**ByteGuard.SecurityHeaders** is a lightweight security-focused middleware package for adding a baseline set of security response headers to **ASP.NET Core REST APIs**.
3+
**ByteGuard.SecurityHeaders** is a lightweight security-focused middleware package for adding a baseline set of security response headers to **ASP.NET Core projects**.
44

55
It gives you:
66

7-
- A single `app.UseDefaultSecurityHeaders()` call to apply sane defaults
7+
- A single `app.UseDefaultApiSecurityHeaders()` call to apply sane defaults
88
- OWASP-inspired header values based on the REST Security Cheat Sheet
99
- An `Enforce` option to ensure the standard values are applied even if set elsewhere
1010

@@ -17,7 +17,7 @@ It gives you:
1717
- ✅ OWASP-inspired defaults for REST APIs
1818
- ✅ Non-breaking by default (does not override existing headers)
1919
- ✅ Optional **enforcement mode** to overwrite existing values
20-
- ✅ Minimal setup (`UseDefaultSecurityHeaders`)
20+
- ✅ Minimal setup (`UseDefaultApiSecurityHeaders`)
2121

2222
## Getting Started
2323

@@ -40,7 +40,7 @@ Add the middleware early in your pipeline:
4040
```csharp
4141
var app = builder.Build();
4242

43-
app.UseDefaultSecurityHeaders();
43+
app.UseDefaultApiSecurityHeaders();
4444

4545
app.MapControllers();
4646
app.Run();
@@ -51,7 +51,7 @@ app.Run();
5151
By default, the middleware will not override headers that are already present. If you want to ensure the standard values are always used (even if other middleware/controllers set them), enable enforcement:
5252

5353
```csharp
54-
app.UseDefaultSecurityHeaders(options =>
54+
app.UseDefaultApiSecurityHeaders(options =>
5555
{
5656
options.Enforce = true;
5757
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace ByteGuard.SecurityHeaders;
2+
3+
/// <summary>
4+
/// Configuration object for API security headers.
5+
/// </summary>
6+
public class ApiSecurityHeadersConfiguration
7+
{
8+
/// <summary>
9+
/// Enforce default API security headers.
10+
/// </summary>
11+
/// <remarks>
12+
/// If set to <c>true</c> the default API security headers will be enforced, removing any other potential header values.
13+
/// Will not affect any headers besides the defined API security headers.
14+
/// Defaults to <c>false</c>.
15+
/// </remarks>
16+
public bool Enforce { get; set; } = false;
17+
}

src/ByteGuard.SecurityHeaders/Configuration/SecurityHeadersConfiguration.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/ByteGuard.SecurityHeaders/SecurityHeadersMiddleware.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ namespace ByteGuard.SecurityHeaders;
88
public static class SecurityHeadersMiddleware
99
{
1010
/// <summary>
11-
/// Add default security headers middleware.
11+
/// Add default API security headers middleware.
1212
/// </summary>
1313
/// <remarks>
1414
/// Adds a small baseline set of <see href="https://cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_Sheet.html#security-headers">OWASP-inspired</see> security headers suitable for many REST APIs.
1515
/// </remarks>
1616
/// <param name="app">Application builder.</param>
17-
public static IApplicationBuilder UseDefaultSecurityHeaders(this IApplicationBuilder app) =>
18-
app.UseDefaultSecurityHeaders(_ => { });
17+
public static IApplicationBuilder UseDefaultApiSecurityHeaders(this IApplicationBuilder app) =>
18+
app.UseDefaultApiSecurityHeaders(_ => { });
1919

2020
/// <summary>
2121
/// Add default security headers middleware.
@@ -25,12 +25,12 @@ public static IApplicationBuilder UseDefaultSecurityHeaders(this IApplicationBui
2525
/// </remarks>
2626
/// <param name="app">Application builder.</param>
2727
/// <param name="configure">Security headers configuration.</param>
28-
public static IApplicationBuilder UseDefaultSecurityHeaders(this IApplicationBuilder app, Action<SecurityHeadersConfiguration> configure)
28+
public static IApplicationBuilder UseDefaultApiSecurityHeaders(this IApplicationBuilder app, Action<ApiSecurityHeadersConfiguration> configure)
2929
{
3030
ArgumentNullException.ThrowIfNull(app);
3131
ArgumentNullException.ThrowIfNull(configure);
3232

33-
var config = new SecurityHeadersConfiguration();
33+
var config = new ApiSecurityHeadersConfiguration();
3434
configure(config);
3535

3636
return app.Use(async (context, next) =>

0 commit comments

Comments
 (0)