mirror of
https://github.com/bitwarden/server.git
synced 2025-07-05 18:12:48 -05:00
[PM-1198] Modify AuthRequest
Purge Job (#3048)
* Add PasswordlessAuth Settings * Update Repository Method to Take TimeSpan * Update AuthRequest_DeleteIfExpired - Take Configurable Expiration - Add Special Cases for AdminApproval AuthRequests * Add AuthRequestRepositoryTests * Run Formatting * Remove Comment * Fix Bug in EF Repo * Add Test Covering Expired Rejected AuthRequest * Use Longer Param Names * Use Longer Names in Test Helpers
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using Bit.Core;
|
||||
using Bit.Core.Jobs;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Settings;
|
||||
using Quartz;
|
||||
|
||||
namespace Bit.Admin.Auth.Jobs;
|
||||
@ -8,20 +9,26 @@ namespace Bit.Admin.Auth.Jobs;
|
||||
public class DeleteAuthRequestsJob : BaseJob
|
||||
{
|
||||
private readonly IAuthRequestRepository _authRepo;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
|
||||
public DeleteAuthRequestsJob(
|
||||
IAuthRequestRepository authrepo,
|
||||
IGlobalSettings globalSettings,
|
||||
ILogger<DeleteAuthRequestsJob> logger)
|
||||
: base(logger)
|
||||
{
|
||||
_authRepo = authrepo;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
protected async override Task ExecuteJobAsync(IJobExecutionContext context)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Execute job task: DeleteAuthRequestsJob: Start");
|
||||
var count = await _authRepo.DeleteExpiredAsync();
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, $"{count} records deleted from AuthRequests.");
|
||||
var count = await _authRepo.DeleteExpiredAsync(
|
||||
_globalSettings.PasswordlessAuth.UserRequestExpiration,
|
||||
_globalSettings.PasswordlessAuth.AdminRequestExpiration,
|
||||
_globalSettings.PasswordlessAuth.AfterAdminApprovalExpiration);
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "{Count} records deleted from AuthRequests.", count);
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Execute job task: DeleteAuthRequestsJob: End");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user