This commit is contained in:
2020-01-28 19:43:22 +00:00
parent 270be50322
commit 20a887612d
4 changed files with 91 additions and 8 deletions

View File

@@ -7,12 +7,6 @@ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNTcxODU5OTU0IiwiZXhwIjoiMTU3MjQ
TODO: License.cs using httpclient directly albeit trying to do it right`
- Change to use httpclientfactory injected service:
- https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1
TODO: Need route to gather all object role rights in a format useful to display in UI so that a biz manager can see at a glance the rights for different roles to objects
- This way it's dynamic and picked up from the code itself which is always the source of truth so no need to put in the manual
- Would likely want to display multiple ways: for a specific object or role or selected user maybe too in the user info form ("effective roles")

View File

@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authorization;
using AyaNova.Models;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Biz;
namespace AyaNova.Api.Controllers
{
/// <summary>
/// Enum pick list controller
/// </summary>
[ApiController]
[ApiVersion("8.0")]
[Route("api/v{version:apiVersion}/[controller]")]
[Produces("application/json")]
[Authorize]
public class AuthorizationRolesController : ControllerBase
{
private readonly AyContext ct;
private readonly ILogger<AyaTypeController> log;
private readonly ApiServerState serverState;
/// <summary>
/// ctor
/// </summary>
/// <param name="dbcontext"></param>
/// <param name="logger"></param>
/// <param name="apiServerState"></param>
public AuthorizationRolesController(AyContext dbcontext, ILogger<AyaTypeController> logger, ApiServerState apiServerState)
{
ct = dbcontext;
log = logger;
serverState = apiServerState;
}
/// <summary>
/// Get roles
/// </summary>
/// <returns>Dictionary list of AyaNova object types and their authorization role rights in AyaNova</returns>
[HttpGet("list")]
public ActionResult GetRoles()
{
if (!serverState.IsOpen)
{
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
}
return Ok(ApiOkResponse.Response(BizRoles.roles, true));
}
// /// <summary>
// /// Get all possible enumerated values picklist key names
// /// </summary>
// /// <returns>List of AyaNova enumerated type list key names that can be fetched from the AyaEnumPickList/GetPickListRoute</returns>
// [HttpGet("listkeys")]
// public ActionResult GetTypesList()
// {
// if (!serverState.IsOpen)
// {
// return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
// }
// List<KeyValuePair<string, string>> ret = new List<KeyValuePair<string, string>>();
// ret.Add(new KeyValuePair<string, string>("usertypes", "AyaNova user account types"));
// ret.Add(new KeyValuePair<string, string>("authorizationroles", "AyaNova user account role types"));
// ret.Add(new KeyValuePair<string, string>("AyaType", "All AyaNova object types, use the AyaTypeController route to fetch these"));
// ret.Add(new KeyValuePair<string, string>("datatypes", "Types of data used in AyaNova for display and formatting UI purposes"));
// return Ok(ApiOkResponse.Response(ret, true));
// }
}//eoc
}//ens

View File

@@ -413,7 +413,7 @@ namespace AyaNova
// ******************** TESTING WIPE DB *****************************
//
//Set this to true to wipe the db and reinstall a trial license and re-seed the data
var TESTING_REFRESH_DB = true;//#######################################################################################
var TESTING_REFRESH_DB = false;//#######################################################################################
#if (DEBUG)

View File

@@ -12,7 +12,7 @@ namespace AyaNova.Biz
internal static class BizRoles
{
static Dictionary<AyaType, BizRoleSet> roles = new Dictionary<AyaType, BizRoleSet>();
internal static Dictionary<AyaType, BizRoleSet> roles = new Dictionary<AyaType, BizRoleSet>();
static BizRoles()
{