Got at least one data fetching method working; turns out, we can't use a patched LogicStack to get the data

This commit is contained in:
2026-01-14 22:11:11 +01:00
parent 40a8431464
commit 3f7122d30a
350 changed files with 41444 additions and 119 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
namespace EmbedIO.Authentication
{
/// <summary>
/// Simple HTTP basic authentication module that stores credentials
/// in a <seealso cref="ConcurrentDictionary{TKey,TValue}"/>.
/// </summary>
public class BasicAuthenticationModule : BasicAuthenticationModuleBase
{
/// <summary>
/// Initializes a new instance of the <see cref="BasicAuthenticationModule"/> class.
/// </summary>
/// <param name="baseRoute">The base route.</param>
/// <param name="realm">The authentication realm.</param>
/// <remarks>
/// <para>If <paramref name="realm"/> is <see langword="null"/> or the empty string,
/// the <see cref="BasicAuthenticationModuleBase.Realm">Realm</see> property will be set equal to
/// <see cref="IWebModule.BaseRoute">BaseRoute</see>.</para>
/// </remarks>
public BasicAuthenticationModule(string baseRoute, string? realm = null)
: base(baseRoute, realm)
{
}
/// <summary>
/// Gets a dictionary of valid user names and passwords.
/// </summary>
/// <value>
/// The accounts.
/// </value>
public ConcurrentDictionary<string, string> Accounts { get; } = new ConcurrentDictionary<string, string>(StringComparer.InvariantCulture);
/// <inheritdoc />
protected override Task<bool> VerifyCredentialsAsync(string path, string userName, string password, CancellationToken cancellationToken)
=> Task.FromResult(VerifyCredentialsInternal(userName, password));
private bool VerifyCredentialsInternal(string userName, string password)
=> userName != null
&& Accounts.TryGetValue(userName, out var storedPassword)
&& string.Equals(password, storedPassword, StringComparison.Ordinal);
}
}