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:
46
Vendor/EmbedIO-3.5.2/Authentication/BasicAuthenticationModule.cs
vendored
Normal file
46
Vendor/EmbedIO-3.5.2/Authentication/BasicAuthenticationModule.cs
vendored
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user