/* * Copyright (c) 2023 Vaughn Nugent * * Library: VNLib * Package: VNLib.Data.Caching.Extensions * File: ClientCacheConfiguration.cs * * ClientCacheConfiguration.cs is part of VNLib.Data.Caching.Extensions which is part of the larger * VNLib collection of libraries and utilities. * * VNLib.Data.Caching.Extensions is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * VNLib.Data.Caching.Extensions is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ using System; using System.Collections.Generic; using VNLib.Hashing; using VNLib.Hashing.IdentityUtility; namespace VNLib.Data.Caching.Extensions { /// /// Provides authentication services for cache clients and /// servers. /// public interface ICacheAuthManager { /// /// Gets the JWT header to use for signing messages with the /// given key /// /// The JWT header collection IReadOnlyDictionary GetJwtHeader(); /// /// Signs the given JWT /// /// The message to sign void SignJwt(JsonWebToken jwt); /// /// Verifies the given JWT /// /// The message to verify authenticity /// A value indicating if the message is from a known node /// True of the JWT could be verified, false otherwise bool VerifyJwt(JsonWebToken jwt, bool isPeer); /// /// Signs the given message hash /// /// The message hash to sign /// The algorithm used to sign the message hash /// The signature of the hash byte[] SignMessageHash(byte[] hash, HashAlg alg); /// /// Verifies the given message hash against the signature. /// /// The message hash to compare /// The algorithm used to produce the message hash /// The message signature to verify the message against /// A value indicating if the message is from a known node /// True of the signature could be verified bool VerifyMessageHash(ReadOnlySpan hash, HashAlg alg, ReadOnlySpan signature, bool isPeer); } }