- Fix GraphQL authorization attributes to use string[] instead of string for roles - Remove admin role requirement from ImportNovel endpoint - Add comprehensive OIDC configuration validation with specific error messages - Validate Authority, ClientId, and Audience are properly configured - Ensure HTTPS requirement except for localhost development Co-authored-by: conco <conco@users.noreply.local>
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System.Data;
|
|
using FictionArchive.Service.SchedulerService.Models;
|
|
using FictionArchive.Service.SchedulerService.Services;
|
|
using HotChocolate.Authorization;
|
|
using HotChocolate.Types;
|
|
using Quartz;
|
|
|
|
namespace FictionArchive.Service.SchedulerService.GraphQL;
|
|
|
|
public class Mutation
|
|
{
|
|
[Error<DuplicateNameException>]
|
|
[Error<FormatException>]
|
|
[Authorize(Roles = new[] { "admin" })]
|
|
public async Task<SchedulerJob> ScheduleEventJob(string key, string description, string eventType, string eventData, string cronSchedule, JobManagerService jobManager)
|
|
{
|
|
return await jobManager.ScheduleEventJob(key, description, eventType, eventData, cronSchedule);
|
|
}
|
|
|
|
[Error<JobPersistenceException>]
|
|
[Authorize(Roles = new[] { "admin" })]
|
|
public async Task<bool> RunJob(string jobKey, JobManagerService jobManager)
|
|
{
|
|
return await jobManager.TriggerJob(jobKey);
|
|
}
|
|
|
|
[Error<KeyNotFoundException>]
|
|
[Authorize(Roles = new[] { "admin" })]
|
|
public async Task<bool> DeleteJob(string jobKey, JobManagerService jobManager)
|
|
{
|
|
bool deleted = await jobManager.DeleteJob(jobKey);
|
|
if (!deleted)
|
|
{
|
|
throw new KeyNotFoundException($"Job with key '{jobKey}' was not found");
|
|
}
|
|
|
|
return true;
|
|
}
|
|
} |