Add tests and implement StubBearer authentication for Signer endpoints
- Created SignerEndpointsTests to validate the SignDsse and VerifyReferrers endpoints. - Implemented StubBearerAuthenticationDefaults and StubBearerAuthenticationHandler for token-based authentication. - Developed ConcelierExporterClient for managing Trivy DB settings and export operations. - Added TrivyDbSettingsPageComponent for UI interactions with Trivy DB settings, including form handling and export triggering. - Implemented styles and HTML structure for Trivy DB settings page. - Created NotifySmokeCheck tool for validating Redis event streams and Notify deliveries.
This commit is contained in:
31
src/StellaOps.Notify.Connectors.Shared/ConnectorHashing.cs
Normal file
31
src/StellaOps.Notify.Connectors.Shared/ConnectorHashing.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace StellaOps.Notify.Connectors.Shared;
|
||||
|
||||
/// <summary>
|
||||
/// Common hashing helpers for Notify connector metadata.
|
||||
/// </summary>
|
||||
public static class ConnectorHashing
|
||||
{
|
||||
/// <summary>
|
||||
/// Computes a lowercase hex SHA-256 hash and truncates it to the requested number of bytes.
|
||||
/// </summary>
|
||||
public static string ComputeSha256Hash(string value, int lengthBytes = 8)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw new ArgumentException("Value must not be null or whitespace.", nameof(value));
|
||||
}
|
||||
|
||||
if (lengthBytes <= 0 || lengthBytes > 32)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(lengthBytes), "Length must be between 1 and 32 bytes.");
|
||||
}
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(value.Trim());
|
||||
var hash = SHA256.HashData(bytes);
|
||||
return Convert.ToHexString(hash.AsSpan(0, lengthBytes)).ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user