This commit is contained in:
2022-04-09 19:53:26 +01:00
parent df55836c58
commit 1befc2e053
38 changed files with 427 additions and 309 deletions

View File

@ -1,6 +1,6 @@
namespace isnd
{
public static class Constants
public static class IsndConstants
{
public const string AdministratorRoleName = "Admin";
public const string RequireAdminPolicyName = "RequireAdministratorRole";

View File

@ -245,9 +245,9 @@ namespace isnd.Controllers
{
var user = await _userManager.FindByNameAsync(username);
var roles = await _userManager.GetRolesAsync(user);
if (!roles.Contains(Constants.AdministratorRoleName))
if (!roles.Contains(IsndConstants.AdministratorRoleName))
{
await _userManager.AddToRoleAsync(user, Constants.AdministratorRoleName);
await _userManager.AddToRoleAsync(user, IsndConstants.AdministratorRoleName);
}
return Ok();

View File

@ -9,7 +9,7 @@ namespace isnd.Controllers
// TODO Web hook CI
public class NewUpdateController : Controller
{
[Authorize(Policy = Constants.RequireAdminPolicyName)]
[Authorize(Policy = IsndConstants.RequireAdminPolicyName)]
public IActionResult NewRelease(NewReleaseInfo version)
{
throw new NotImplementedException("web hook");

View File

@ -15,6 +15,7 @@ using isnd.Services;
using isnd.ViewModels;
using System.Threading.Tasks;
using isnd.Interfaces;
using isn.Abstract;
namespace isnd.Controllers
{
@ -54,7 +55,7 @@ namespace isnd.Controllers
[HttpGet(_pkgRootPrefix + ApiConfig.Base)]
public IActionResult ApiIndex()
{
return Ok(new { version = "3.0.0", resources = _resources });
return Ok(new ApiIndexViewModel{ Version = "3.0.0", Resources = _resources });
}
// GET /autocomplete?id=isn.protocol&prerelease=true

View File

@ -1,17 +0,0 @@
using Newtonsoft.Json;
namespace isnd.Controllers
{
public class Resource
{
[JsonProperty("@id")]
public string Id {get; set; }
[JsonProperty("@type")]
public string Type {get; set; }
[JsonProperty("comment")]
public string Comment {get; set; }
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using isn.Abstract;
using isnd.Controllers;
using isnd.Data;
using isnd.Data.Catalog;

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using isn.abst;
using isn.Abstract;
using isnd.Controllers;
using isnd.Data;
using isnd.Data.Catalog;
@ -41,7 +43,7 @@ namespace isnd.Services
new Resource
{
Id = extUrl + ApiConfig.Publish,
Type = "PackagePublish/2.0.0",
Type = Constants.PublishCommandId,
Comment = "Package Publish service"
});
// under dev, only leash in release mode

View File

@ -58,9 +58,9 @@ namespace isnd
services.AddAuthorization(options =>
{
options.AddPolicy(Constants.RequireAdminPolicyName,
policy => policy.RequireRole(Constants.AdministratorRoleName));
options.AddPolicy(Constants.RequireValidApiKey, policy =>
options.AddPolicy(IsndConstants.RequireAdminPolicyName,
policy => policy.RequireRole(IsndConstants.AdministratorRoleName));
options.AddPolicy(IsndConstants.RequireValidApiKey, policy =>
policy.Requirements.Add(new ValidApiKeyRequirement()));
})

View File

@ -25,6 +25,10 @@
<PackageReference Include="unleash.client" Version="1.6.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../isn.abst/isn.abst.csproj" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.1.0-preview1-final" />