Add migration to update ApiClients with centralized authorization scopes

This migration updates the ScopesJson for the ApiClient with Id 91000000-0000-0000-0000-000000000001 to include additional authorization scopes for improved API access control. The Down method reverts the changes if necessary.
This commit is contained in:
Torsten Brendgen
2026-07-09 23:49:01 +02:00
parent dc93ea0813
commit dfd9c16f61
27 changed files with 5617 additions and 34 deletions

View File

@@ -1,5 +1,7 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.SelfService.Portal.Core.API.Authorization;
using Microsoft.SelfService.Portal.Core.API.Dto.Template.Add;
using Microsoft.SelfService.Portal.Core.API.Dto.Template.Edit;
using Microsoft.SelfService.Portal.Core.API.Dto.Template.Get;
@@ -16,6 +18,7 @@ namespace Microsoft.SelfService.Portal.Core.API.Controllers
{
[Route("api/[controller]")]
[ApiController]
[Authorize(Policy = ApiPolicies.TemplateRead)]
public class TemplateController : Controller
{
private readonly ITemplateInterface _templateInterface;
@@ -61,6 +64,7 @@ namespace Microsoft.SelfService.Portal.Core.API.Controllers
}
[HttpPost]
[Authorize(Policy = ApiPolicies.TemplateWrite)]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
public IActionResult AddTemplateById([FromBody] AddTemplateDto template)
@@ -97,6 +101,7 @@ namespace Microsoft.SelfService.Portal.Core.API.Controllers
}
[HttpPut("{Id}")]
[Authorize(Policy = ApiPolicies.TemplateWrite)]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
[ProducesResponseType(404)]
@@ -139,6 +144,7 @@ namespace Microsoft.SelfService.Portal.Core.API.Controllers
}
[HttpDelete("{Id}")]
[Authorize(Policy = ApiPolicies.TemplateWrite)]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
[ProducesResponseType(404)]
@@ -186,6 +192,7 @@ namespace Microsoft.SelfService.Portal.Core.API.Controllers
}
[HttpPost("{Id}/Versions")]
[Authorize(Policy = ApiPolicies.TemplateWrite)]
[ProducesResponseType(200, Type = typeof(Guid))]
[ProducesResponseType(400)]
[ProducesResponseType(404)]
@@ -262,6 +269,7 @@ namespace Microsoft.SelfService.Portal.Core.API.Controllers
}
[HttpPost("{Id}/Versions/{VersionId}/Revisions")]
[Authorize(Policy = ApiPolicies.TemplateWrite)]
[ProducesResponseType(200, Type = typeof(Guid))]
[ProducesResponseType(400)]
[ProducesResponseType(404)]
@@ -298,6 +306,7 @@ namespace Microsoft.SelfService.Portal.Core.API.Controllers
}
[HttpPost("{Id}/Versions/{VersionId}/Publish")]
[Authorize(Policy = ApiPolicies.TemplateWrite)]
[ProducesResponseType(204)]
[ProducesResponseType(404)]
public IActionResult PublishTemplateVersion(Guid Id, Guid VersionId)