Skip to content

Commit 831f2b6

Browse files
committed
2.32.0 Initial basic auth impl
1 parent 8cd7ad4 commit 831f2b6

22 files changed

Lines changed: 1096 additions & 404 deletions

NpgsqlRest/Auth/AuthHandler.cs

Lines changed: 338 additions & 64 deletions
Large diffs are not rendered by default.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace NpgsqlRest.Auth;
2+
3+
public class EndpointBasicAuthOptions
4+
{
5+
public bool Enabled { get; set; } = false;
6+
public string? Realm { get; set; } = null;
7+
public string? Username { get; set; } = null;
8+
public string? Password { get; set; } = null;
9+
public string? ChallengeCommand { get; set; } = null;
10+
}
11+
12+
public class BasicAuthOptions : EndpointBasicAuthOptions
13+
{
14+
public bool UseDefaultPasswordHasher { get; set; } = true;
15+
public Location PasswordHashLocation { get; set; } = Location.Server;
16+
public bool UseDefaultPasswordEncryptionOnClient { get; set; } = false;
17+
public bool UseDefaultPasswordEncryptionOnServer { get; set; } = false;
18+
}

NpgsqlRest/Auth/NpgsqlRestAuthenticationOptions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
using Microsoft.AspNetCore.DataProtection;
3+
24
namespace NpgsqlRest.Auth;
35

46
/// <summary>
@@ -165,4 +167,14 @@ public class NpgsqlRestAuthenticationOptions
165167
/// When this option is not null, the IP address will be set to the parameter when <see cref="UseUserContext"/> is enabled and even when user is not authenticated.
166168
/// </summary>
167169
public string? IpAddressParameterName { get; set; } = "_ip_address";
170+
171+
/// <summary>
172+
/// Default options for Basic Authentication.
173+
/// </summary>
174+
public BasicAuthOptions BasicAuth { get; set; } = new();
175+
176+
/// <summary>
177+
/// Default data protector used to encrypt and decrypt data.
178+
/// </summary>
179+
public IDataProtector? DefaultDataProtector { get; set; } = null;
168180
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Security.Cryptography;
22

3-
namespace NpgsqlRest;
3+
namespace NpgsqlRest.Auth;
44

55
public interface IPasswordHasher
66
{

0 commit comments

Comments
 (0)