From 9a6d0e93f82e55fe4acdb6337e7d0bb71a9406f1 Mon Sep 17 00:00:00 2001 From: Conner Turnbull Date: Mon, 10 Mar 2025 15:37:39 -0400 Subject: [PATCH] Initial stubbing out of the phishing service --- src/Api/Startup.cs | 1 + src/Api/Utilities/ServiceCollectionExtensions.cs | 6 ++++++ src/Core/Services/IPhishingDomainService.cs | 6 ++++++ .../Implementations/PhishingDomainService.cs | 13 +++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 src/Core/Services/IPhishingDomainService.cs create mode 100644 src/Core/Services/Implementations/PhishingDomainService.cs diff --git a/src/Api/Startup.cs b/src/Api/Startup.cs index 5849bfb634..5a2e1f8024 100644 --- a/src/Api/Startup.cs +++ b/src/Api/Startup.cs @@ -177,6 +177,7 @@ public class Startup services.AddBillingOperations(); services.AddReportingServices(); services.AddImportServices(); + services.AddPhishingDomainService(); // Authorization Handlers services.AddAuthorizationHandlers(); diff --git a/src/Api/Utilities/ServiceCollectionExtensions.cs b/src/Api/Utilities/ServiceCollectionExtensions.cs index feeac03e54..09f4a97eef 100644 --- a/src/Api/Utilities/ServiceCollectionExtensions.cs +++ b/src/Api/Utilities/ServiceCollectionExtensions.cs @@ -2,6 +2,7 @@ using Bit.Api.Vault.AuthorizationHandlers.Collections; using Bit.Core.AdminConsole.OrganizationFeatures.Groups.Authorization; using Bit.Core.IdentityServer; +using Bit.Core.Services; using Bit.Core.Settings; using Bit.Core.Utilities; using Bit.Core.Vault.Authorization.SecurityTasks; @@ -106,4 +107,9 @@ public static class ServiceCollectionExtensions services.AddScoped(); services.AddScoped(); } + + public static void AddPhishingDomainService(this IServiceCollection services) + { + services.AddSingleton(); + } } diff --git a/src/Core/Services/IPhishingDomainService.cs b/src/Core/Services/IPhishingDomainService.cs new file mode 100644 index 0000000000..efce7e4070 --- /dev/null +++ b/src/Core/Services/IPhishingDomainService.cs @@ -0,0 +1,6 @@ +namespace Bit.Core.Services; + +public interface IPhishingDomainService +{ + Task> GetPhishingDomainsAsync(); +} diff --git a/src/Core/Services/Implementations/PhishingDomainService.cs b/src/Core/Services/Implementations/PhishingDomainService.cs new file mode 100644 index 0000000000..ba8f8e7d2e --- /dev/null +++ b/src/Core/Services/Implementations/PhishingDomainService.cs @@ -0,0 +1,13 @@ +using System.Collections.Concurrent; + +namespace Bit.Core.Services; + +public class PhishingDomainService : IPhishingDomainService +{ + private readonly ConcurrentDictionary _phishingDomains = new(); + + public Task> GetPhishingDomainsAsync() + { + return Task.FromResult(_phishingDomains.Keys.AsEnumerable()); + } +}