mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
[AC-2972] AC Team ownership: Events (2/2) (#4675)
This commit is contained in:
@ -1,49 +0,0 @@
|
||||
using Bit.Core.Exceptions;
|
||||
|
||||
namespace Bit.Api.Models.Public.Request;
|
||||
|
||||
public class EventFilterRequestModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The start date. Must be less than the end date.
|
||||
/// </summary>
|
||||
public DateTime? Start { get; set; }
|
||||
/// <summary>
|
||||
/// The end date. Must be greater than the start date.
|
||||
/// </summary>
|
||||
public DateTime? End { get; set; }
|
||||
/// <summary>
|
||||
/// The unique identifier of the user that performed the event.
|
||||
/// </summary>
|
||||
public Guid? ActingUserId { get; set; }
|
||||
/// <summary>
|
||||
/// The unique identifier of the related item that the event describes.
|
||||
/// </summary>
|
||||
public Guid? ItemId { get; set; }
|
||||
/// <summary>
|
||||
/// A cursor for use in pagination.
|
||||
/// </summary>
|
||||
public string ContinuationToken { get; set; }
|
||||
|
||||
public Tuple<DateTime, DateTime> ToDateRange()
|
||||
{
|
||||
if (!End.HasValue || !Start.HasValue)
|
||||
{
|
||||
End = DateTime.UtcNow.Date.AddDays(1).AddMilliseconds(-1);
|
||||
Start = DateTime.UtcNow.Date.AddDays(-30);
|
||||
}
|
||||
else if (Start.Value > End.Value)
|
||||
{
|
||||
var newEnd = Start;
|
||||
Start = End;
|
||||
End = newEnd;
|
||||
}
|
||||
|
||||
if ((End.Value - Start.Value) > TimeSpan.FromDays(367))
|
||||
{
|
||||
throw new BadRequestException("Date range must be < 367 days.");
|
||||
}
|
||||
|
||||
return new Tuple<DateTime, DateTime>(Start.Value, End.Value);
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Public.Response;
|
||||
|
||||
/// <summary>
|
||||
/// An event log.
|
||||
/// </summary>
|
||||
public class EventResponseModel : IResponseModel
|
||||
{
|
||||
public EventResponseModel(IEvent ev)
|
||||
{
|
||||
if (ev == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(ev));
|
||||
}
|
||||
|
||||
Type = ev.Type;
|
||||
ItemId = ev.CipherId;
|
||||
CollectionId = ev.CollectionId;
|
||||
GroupId = ev.GroupId;
|
||||
PolicyId = ev.PolicyId;
|
||||
MemberId = ev.OrganizationUserId;
|
||||
ActingUserId = ev.ActingUserId;
|
||||
Date = ev.Date;
|
||||
Device = ev.DeviceType;
|
||||
IpAddress = ev.IpAddress;
|
||||
InstallationId = ev.InstallationId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String representing the object's type. Objects of the same type share the same properties.
|
||||
/// </summary>
|
||||
/// <example>event</example>
|
||||
[Required]
|
||||
public string Object => "event";
|
||||
/// <summary>
|
||||
/// The type of event.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public EventType Type { get; set; }
|
||||
/// <summary>
|
||||
/// The unique identifier of the related item that the event describes.
|
||||
/// </summary>
|
||||
/// <example>3767a302-8208-4dc6-b842-030428a1cfad</example>
|
||||
public Guid? ItemId { get; set; }
|
||||
/// <summary>
|
||||
/// The unique identifier of the related collection that the event describes.
|
||||
/// </summary>
|
||||
/// <example>bce212a4-25f3-4888-8a0a-4c5736d851e0</example>
|
||||
public Guid? CollectionId { get; set; }
|
||||
/// <summary>
|
||||
/// The unique identifier of the related group that the event describes.
|
||||
/// </summary>
|
||||
/// <example>f29a2515-91d2-4452-b49b-5e8040e6b0f4</example>
|
||||
public Guid? GroupId { get; set; }
|
||||
/// <summary>
|
||||
/// The unique identifier of the related policy that the event describes.
|
||||
/// </summary>
|
||||
/// <example>f29a2515-91d2-4452-b49b-5e8040e6b0f4</example>
|
||||
public Guid? PolicyId { get; set; }
|
||||
/// <summary>
|
||||
/// The unique identifier of the related member that the event describes.
|
||||
/// </summary>
|
||||
/// <example>e68b8629-85eb-4929-92c0-b84464976ba4</example>
|
||||
public Guid? MemberId { get; set; }
|
||||
/// <summary>
|
||||
/// The unique identifier of the user that performed the event.
|
||||
/// </summary>
|
||||
/// <example>a2549f79-a71f-4eb9-9234-eb7247333f94</example>
|
||||
public Guid? ActingUserId { get; set; }
|
||||
/// <summary>
|
||||
/// The Unique identifier of the Installation that performed the event.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Guid? InstallationId { get; set; }
|
||||
/// <summary>
|
||||
/// The date/timestamp when the event occurred.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime Date { get; set; }
|
||||
/// <summary>
|
||||
/// The type of device used by the acting user when the event occurred.
|
||||
/// </summary>
|
||||
public DeviceType? Device { get; set; }
|
||||
/// <summary>
|
||||
/// The IP address of the acting user.
|
||||
/// </summary>
|
||||
/// <example>172.16.254.1</example>
|
||||
public string IpAddress { get; set; }
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Api.Models.Response;
|
||||
|
||||
public class EventResponseModel : ResponseModel
|
||||
{
|
||||
public EventResponseModel(IEvent ev)
|
||||
: base("event")
|
||||
{
|
||||
if (ev == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(ev));
|
||||
}
|
||||
|
||||
Type = ev.Type;
|
||||
UserId = ev.UserId;
|
||||
OrganizationId = ev.OrganizationId;
|
||||
ProviderId = ev.ProviderId;
|
||||
CipherId = ev.CipherId;
|
||||
CollectionId = ev.CollectionId;
|
||||
GroupId = ev.GroupId;
|
||||
PolicyId = ev.PolicyId;
|
||||
OrganizationUserId = ev.OrganizationUserId;
|
||||
ProviderUserId = ev.ProviderUserId;
|
||||
ProviderOrganizationId = ev.ProviderOrganizationId;
|
||||
ActingUserId = ev.ActingUserId;
|
||||
Date = ev.Date;
|
||||
DeviceType = ev.DeviceType;
|
||||
IpAddress = ev.IpAddress;
|
||||
InstallationId = ev.InstallationId;
|
||||
SystemUser = ev.SystemUser;
|
||||
DomainName = ev.DomainName;
|
||||
SecretId = ev.SecretId;
|
||||
ServiceAccountId = ev.ServiceAccountId;
|
||||
}
|
||||
|
||||
public EventType Type { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public Guid? OrganizationId { get; set; }
|
||||
public Guid? ProviderId { get; set; }
|
||||
public Guid? CipherId { get; set; }
|
||||
public Guid? CollectionId { get; set; }
|
||||
public Guid? GroupId { get; set; }
|
||||
public Guid? PolicyId { get; set; }
|
||||
public Guid? OrganizationUserId { get; set; }
|
||||
public Guid? ProviderUserId { get; set; }
|
||||
public Guid? ProviderOrganizationId { get; set; }
|
||||
public Guid? ActingUserId { get; set; }
|
||||
public Guid? InstallationId { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public DeviceType? DeviceType { get; set; }
|
||||
public string IpAddress { get; set; }
|
||||
public EventSystemUser? SystemUser { get; set; }
|
||||
public string DomainName { get; set; }
|
||||
public Guid? SecretId { get; set; }
|
||||
public Guid? ServiceAccountId { get; set; }
|
||||
}
|
Reference in New Issue
Block a user