From d03d436c618114f89c39a756596a23fd56b2e979 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 15 Oct 2026 20:23:00 -0500 Subject: suppress data protection keys --- .../Core/Security/DataProtectionKeyRepository.cs | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/slskd/Core/Security/DataProtectionKeyRepository.cs (limited to 'src/slskd/Core/Security/DataProtectionKeyRepository.cs') diff --git a/src/slskd/Core/Security/DataProtectionKeyRepository.cs b/src/slskd/Core/Security/DataProtectionKeyRepository.cs new file mode 100644 index 00000000..4d962190 --- /dev/null +++ b/src/slskd/Core/Security/DataProtectionKeyRepository.cs @@ -0,0 +1,63 @@ +// +// ▄▄▄▄ ▄▄▄▄ ▄▄▄▄ +// ▄▄▄▄▄▄█ █▄▄▄▄▄█ █▄▄▄▄▄█ █ +// █__ --█ █__ --█ ◄█ - █ +// █▄▄▄▄▄█▄▄█▄▄▄▄▄█▄▄█▄▄█▄▄▄▄▄█ +// ┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━ ━ ━┉ ┉ ┉ +// │ Copyright (c) JP Dillingham. +// │ +// │ This program 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, version 3. +// │ +// │ This program 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/. +// │ +// │ This program is distributed with Additional Terms pursuant to Section 7 +// │ of the AGPLv3. See the LICENSE file in the root directory of this +// │ project for the complete terms and conditions. +// │ +// │ https://slskd.org +// │ +// ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ╌ ╌╌╌╌ ╌ +// │ SPDX-FileCopyrightText: JP Dillingham +// │ SPDX-License-Identifier: AGPL-3.0-only +// ╰───────────────────────────────────────────╶──── ─ ─── ─ ── ──┈ ┈ +// + +namespace slskd +{ + using System.Collections.Generic; + using System.Xml.Linq; + using Microsoft.AspNetCore.DataProtection.Repositories; + + /// + /// An that keeps data protection keys in memory, so that they are never written to disk. + /// + public class DataProtectionKeyRepository : IXmlRepository + { + private List Elements { get; } = new(); + private object SyncRoot { get; } = new(); + + public IReadOnlyCollection GetAllElements() + { + lock (SyncRoot) + { + return Elements.ConvertAll(element => new XElement(element)); + } + } + + public void StoreElement(XElement element, string friendlyName) + { + lock (SyncRoot) + { + Elements.Add(new XElement(element)); + } + } + } +} -- cgit v1.2.3