1
0
mirror of https://github.com/bitwarden/server synced 2026-02-25 17:03:22 +00:00

[PM-26378] Auto confirm events (#7017)

* implement auto confirm push notification

* fix test

* fix test

* simplify LINQ

* add event logging for auto confirm

* fix test
This commit is contained in:
Brandon Treston
2026-02-19 12:10:28 -05:00
committed by GitHub
parent 71a8116d4c
commit 31fe7b0e12
10 changed files with 246 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ public interface IEventService
Task LogOrganizationUserEventsAsync<T>(IEnumerable<(T, EventType, DateTime?)> events) where T : IOrganizationUser;
Task LogOrganizationUserEventsAsync<T>(IEnumerable<(T, EventType, EventSystemUser, DateTime?)> events) where T : IOrganizationUser;
Task LogOrganizationEventAsync(Organization organization, EventType type, DateTime? date = null);
Task LogOrganizationEventAsync(Organization organization, EventType type, EventSystemUser systemUser, DateTime? date = null);
Task LogProviderUserEventAsync(ProviderUser providerUser, EventType type, DateTime? date = null);
Task LogProviderUsersEventAsync(IEnumerable<(ProviderUser, EventType, DateTime?)> events);
Task LogProviderOrganizationEventAsync(ProviderOrganization providerOrganization, EventType type, DateTime? date = null);

View File

@@ -7,4 +7,5 @@ public enum EventSystemUser : byte
DomainVerification = 2,
PublicApi = 3,
TwoFactorDisabled = 4,
BitwardenPortal = 5,
}

View File

@@ -84,6 +84,10 @@ public enum EventType : int
Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsDisabled = 1617,
Organization_ItemOrganization_Accepted = 1618,
Organization_ItemOrganization_Declined = 1619,
Organization_AutoConfirmEnabled_Admin = 1620,
Organization_AutoConfirmDisabled_Admin = 1621,
Organization_AutoConfirmEnabled_Portal = 1622,
Organization_AutoConfirmDisabled_Portal = 1623,
Policy_Updated = 1700,

View File

@@ -309,6 +309,25 @@ public class EventService : IEventService
await _eventWriteService.CreateAsync(e);
}
public async Task LogOrganizationEventAsync(Organization organization, EventType type, EventSystemUser systemUser, DateTime? date = null)
{
if (!organization.Enabled || !organization.UseEvents)
{
return;
}
var EventMessage = new EventMessage
{
OrganizationId = organization.Id,
ProviderId = await GetProviderIdAsync(organization.Id),
Type = type,
SystemUser = systemUser,
Date = date.GetValueOrDefault(DateTime.UtcNow),
DeviceType = DeviceType.Server
};
await _eventWriteService.CreateAsync(EventMessage);
}
public async Task LogProviderUserEventAsync(ProviderUser providerUser, EventType type, DateTime? date = null)
{
await LogProviderUsersEventAsync(new[] { (providerUser, type, date) });

View File

@@ -57,6 +57,11 @@ public class NoopEventService : IEventService
return Task.FromResult(0);
}
public Task LogOrganizationEventAsync(Organization organization, EventType type, EventSystemUser systemUser, DateTime? date = null)
{
return Task.FromResult(0);
}
public Task LogProviderUserEventAsync(ProviderUser providerUser, EventType type, DateTime? date = null)
{
return Task.FromResult(0);