Fixed build errors after porting updated/new files over
This commit is contained in:
Родитель
14be55f3d8
Коммит
9ad9cc1ce7
|
@ -252,7 +252,8 @@ namespace WebApplication.Controllers
|
|||
//filter the list by permitted roles
|
||||
if (!CanPerformCurrentActionGlobally())
|
||||
{
|
||||
var requiredRoles = GetPermittedRolesForCurrentAction();
|
||||
//TODO: Test that the change from GetPermittedRolesForCurrentAction didnt' break this
|
||||
var requiredRoles = GetPermittedGroupsForCurrentAction();
|
||||
|
||||
var filteredTaskGroups =
|
||||
from tg in _context.TaskGroup
|
||||
|
|
|
@ -23,22 +23,16 @@ namespace WebApplication.Controllers
|
|||
public class WizardsController : BaseController
|
||||
{
|
||||
private readonly AdsGoFastContext _context;
|
||||
private readonly Services.IMicrosoftGraphService _graphService;
|
||||
private readonly IEmailService _emailService;
|
||||
private readonly ProcessingFunctionClient _processingClient;
|
||||
private readonly IMicrosoftGraphService _graphService;
|
||||
|
||||
public WizardsController(AdsGoFastContext context,
|
||||
Services.ISecurityAccessProvider securityProvider,
|
||||
Services.IEntityRoleProvider roleProvider,
|
||||
Services.IMicrosoftGraphService graphService,
|
||||
Services.IEmailService emailService,
|
||||
ProcessingFunctionClient processingClient)
|
||||
IMicrosoftGraphService graphService)
|
||||
: base(securityProvider, roleProvider)
|
||||
{
|
||||
_context = context;
|
||||
_graphService = graphService;
|
||||
_emailService = emailService;
|
||||
_processingClient = processingClient;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
@ -64,7 +58,7 @@ namespace WebApplication.Controllers
|
|||
//ViewBag.PhnZones = new SelectList(new List<PhnZone>(phnZones)
|
||||
// .OrderBy(x => x.Name), "Id", "Name");
|
||||
|
||||
var users = await GetPHNUsers();
|
||||
var users = await GetUsers();
|
||||
ViewBag.PHNUsers = new SelectList(users.OrderBy(x => x.DisplayName),
|
||||
"UserId", "DisplayName");
|
||||
}
|
||||
|
@ -162,8 +156,11 @@ namespace WebApplication.Controllers
|
|||
{
|
||||
// notify all phn users whose roles are set throgh the form by email
|
||||
string[] stewards = PIA.DataStewards.Select(ds => ds.UserId).ToArray();
|
||||
await _emailService.SendNotificationToPHNUsers(PIA.DataOwner.UserId, PIA.DataCustodian.UserId, stewards);
|
||||
await _processingClient.QueueSubjectAreaProvisioning(PIA.SubjectAreaId);
|
||||
|
||||
SendNotificationToSubjectAreaUsers();
|
||||
|
||||
DoProcessingAndAutomationForSubjectArea();
|
||||
|
||||
// Redirect out of wizard and
|
||||
return RedirectToAction("Details", "SubjectArea", new { id = PIA.SubjectAreaId });
|
||||
}
|
||||
|
@ -184,6 +181,17 @@ namespace WebApplication.Controllers
|
|||
return View(nameof(PIAWizard), PIA);
|
||||
}
|
||||
|
||||
private void DoProcessingAndAutomationForSubjectArea()
|
||||
{
|
||||
// TODO:
|
||||
// If there are any automation steps like setting up security access / Azure AD security groups etc
|
||||
}
|
||||
|
||||
private void SendNotificationToSubjectAreaUsers()
|
||||
{
|
||||
//TODO: Send emails to PIA.DataOwner.UserId, PIA.DataCustodian.UserId, and stewards
|
||||
}
|
||||
|
||||
private async Task<SubjectAreaForm> UpdatePIAData(PIAWizardViewModel PIA)
|
||||
{
|
||||
var subjectArea = await _context.SubjectArea.FindAsync(PIA.SubjectAreaId);
|
||||
|
@ -223,10 +231,9 @@ namespace WebApplication.Controllers
|
|||
[HttpPost]
|
||||
public async Task<IActionResult> AddDataSteward([Bind("DataStewards")] PIAWizardViewModel pia)
|
||||
{
|
||||
var testData = await GetPHNUsers();
|
||||
var users = await GetUsers();
|
||||
|
||||
ViewBag.PHNUsers = new SelectList(testData,
|
||||
"UserId", "DisplayName");
|
||||
ViewBag.PHNUsers = new SelectList(users, "UserId", "DisplayName");
|
||||
|
||||
var dataSteward = new UserReference();
|
||||
|
||||
|
@ -238,9 +245,9 @@ namespace WebApplication.Controllers
|
|||
[HttpPost]
|
||||
public async Task<IActionResult> RemoveDataSteward([Bind("DataStewards")] PIAWizardViewModel pia)
|
||||
{
|
||||
var PHNUsers = await GetPHNUsers();
|
||||
var users = await GetUsers();
|
||||
|
||||
ViewBag.PHNUsers = new SelectList(PHNUsers,
|
||||
ViewBag.PHNUsers = new SelectList(users,
|
||||
"UserId", "DisplayName"); // find better way to do this
|
||||
|
||||
if (pia.DataStewards.Count > 1)
|
||||
|
@ -251,7 +258,7 @@ namespace WebApplication.Controllers
|
|||
return PartialView("_DataStewards", pia);
|
||||
}
|
||||
|
||||
private async Task<List<UserReference>> GetPHNUsers()
|
||||
private async Task<List<UserReference>> GetUsers()
|
||||
{
|
||||
var members = await _graphService.GetMembers();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace WebApplication.Models.Forms
|
||||
namespace WebApplication.Models
|
||||
{
|
||||
public class UserReference
|
||||
{
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using SharedZone.Client.Model;
|
||||
|
||||
namespace WebApplication.Services
|
||||
{
|
||||
public class EmailService : IEmailService
|
||||
{
|
||||
private readonly IMicrosoftGraphService _graphService;
|
||||
private readonly ISharedZoneService _sharedZoneService;
|
||||
|
||||
public EmailService(IMicrosoftGraphService graphService, ISharedZoneService sharedZoneService)
|
||||
{
|
||||
_graphService = graphService;
|
||||
_sharedZoneService = sharedZoneService;
|
||||
}
|
||||
|
||||
public async Task SendDatasetAccessApprovalNotification(string requestor, SubjectArea subjectArea)
|
||||
{
|
||||
var sendToEmail = await _graphService.GetUserMailIdentity(requestor);
|
||||
await _sharedZoneService.PostEmailToQueue(Guid.NewGuid().ToString(), default, sendToEmail, "DataSetAccessRequestAccepted", new
|
||||
{
|
||||
RequestorName = sendToEmail.name,
|
||||
SubjectAreaName = subjectArea.SubjectAreaName,
|
||||
});
|
||||
}
|
||||
|
||||
public async Task SendDatasetAccessRejectionNotification(string requestor, SubjectArea subjectArea)
|
||||
{
|
||||
var sendToEmail = await _graphService.GetUserMailIdentity(requestor);
|
||||
await _sharedZoneService.PostEmailToQueue(Guid.NewGuid().ToString(), default, sendToEmail, "DataSetAccessRequestRejected", new
|
||||
{
|
||||
RequestorName = sendToEmail.name,
|
||||
SubjectAreaName = subjectArea.SubjectAreaName,
|
||||
});
|
||||
}
|
||||
|
||||
public async Task SendDatasetAccessRequestNotification(string recipient, string requestor, SubjectArea subjectArea)
|
||||
{
|
||||
var sendToEmail = await _graphService.GetUserMailIdentity(recipient);
|
||||
var requestingUser = await _graphService.GetUserMailIdentity(requestor);
|
||||
|
||||
await _sharedZoneService.PostEmailToQueue(Guid.NewGuid().ToString(), default, sendToEmail, "DataSetAccessRequestCreated", new
|
||||
{
|
||||
RequestorName = requestingUser.name,
|
||||
RecipientName = sendToEmail.name,
|
||||
dataSetName = subjectArea.SubjectAreaName
|
||||
});
|
||||
}
|
||||
|
||||
public async Task SendNotificationToPHNUsers(string owner, string custodian, string[] stewards)
|
||||
{
|
||||
//todo: this doesnt' do anything, but where it's being called doesn't actually calculate the delta
|
||||
//we should change this to send out the email when syncing teh AD groups - so if you are added to the AD group you
|
||||
//get an email.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -28,8 +28,8 @@ namespace WebApplication.Services
|
|||
return await LoadSubjectAreaRoles(x.SubjectAreaId, groups);
|
||||
case SubjectAreaForm x:
|
||||
return await LoadSubjectAreaFormRoles(x.SubjectAreaFormId, groups);
|
||||
case TaskGroup x when x.SubjectAreaId.HasValue:
|
||||
return await LoadSubjectAreaRoles(x.SubjectAreaId.Value, groups);
|
||||
case TaskGroup x:
|
||||
return await LoadSubjectAreaRoles(x.SubjectAreaId, groups);
|
||||
case TaskInstance x:
|
||||
return await LoadTaskInstanceRoles(x.TaskInstanceId, groups);
|
||||
case TaskInstanceExecution x:
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
using System.Threading.Tasks;
|
||||
using SharedZone.Client.Model;
|
||||
|
||||
namespace WebApplication.Services
|
||||
{
|
||||
public interface IEmailService
|
||||
{
|
||||
Task SendDatasetAccessRejectionNotification(string requestor, SubjectArea subjectArea);
|
||||
Task SendDatasetAccessApprovalNotification(string requestor, SubjectArea subjectArea);
|
||||
Task SendDatasetAccessRequestNotification(string recipient, string requestor, SubjectArea subjectArea);
|
||||
Task SendNotificationToPHNUsers(string owner, string custodian, string[] stewards);
|
||||
}
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using WebApplication.Forms.PIAWizard;
|
||||
using WebApplication.Models;
|
||||
using WebApplication.Models.Forms;
|
||||
|
||||
namespace WebApplication.Services
|
||||
{
|
||||
public interface IMicrosoftGraphService
|
||||
{
|
||||
Task<IEnumerable<UserReference>> GetMembers();
|
||||
Task<(string name, string email)> GetUserMailIdentity(string upn);
|
||||
}
|
||||
}
|
|
@ -1,16 +1,13 @@
|
|||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Graph;
|
||||
using Microsoft.Graph.Auth;
|
||||
using Microsoft.Identity.Client;
|
||||
using Microsoft.Identity.Web;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WebApplication.Forms.PIAWizard;
|
||||
using WebApplication.Models;
|
||||
using WebApplication.Models.Options;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace WebApplication.Services
|
||||
{
|
||||
|
@ -31,8 +28,9 @@ namespace WebApplication.Services
|
|||
.WithClientSecret(_azureOptions.Value.ClientSecret)
|
||||
.Build();
|
||||
|
||||
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClient);
|
||||
_graphServiceClient = new GraphServiceClient(authProvider);
|
||||
//TODO: Fix the graph serice client auth (we removed the obsolete Graph.Auth package dependency
|
||||
//ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClient);
|
||||
//_graphServiceClient = new GraphServiceClient();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<UserReference>> GetMembers()
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Azure.Storage.Queues;
|
||||
using Azure.Storage.Queues.Specialized;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Identity.Client;
|
||||
using WebApplication.Models.Options;
|
||||
|
||||
namespace WebApplication.Services
|
||||
{
|
||||
public class ProcessingFunctionClient
|
||||
{
|
||||
private readonly IConfiguration _config;
|
||||
private readonly string QueueName = "subjectareaprocessing";
|
||||
|
||||
public ProcessingFunctionClient(HttpClient httpClient, IConfiguration config)
|
||||
{
|
||||
_config = config;
|
||||
|
||||
}
|
||||
|
||||
public async Task QueueSubjectAreaProvisioning(int subjectAreaId)
|
||||
{
|
||||
var connectionString = GetConnectionStringOrSetting(_config, "AzureWebJobsStorage");
|
||||
QueueClient queue = new QueueClient(connectionString, QueueName, new QueueClientOptions()
|
||||
{
|
||||
MessageEncoding = QueueMessageEncoding.Base64,
|
||||
});
|
||||
|
||||
await queue.CreateIfNotExistsAsync();
|
||||
await queue.SendMessageAsync(subjectAreaId.ToString());
|
||||
}
|
||||
|
||||
|
||||
//todo: figure out where this acctually lives it should be an extension method...
|
||||
string GetConnectionStringOrSetting(IConfiguration configuration, string connectionName) =>
|
||||
configuration.GetConnectionString(connectionName) ?? configuration[connectionName];
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -110,9 +110,9 @@ namespace WebApplication.Services
|
|||
//Next Get Role based on App Roles
|
||||
roles = GetUserRoles(identity);
|
||||
}
|
||||
|
||||
|
||||
if (roles.Any() && !roles.Contains("Reader"))
|
||||
roles.Add("Reader");
|
||||
roles = roles.Append("Reader").ToArray();
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
@model WebApplication.Models.InputSelectionOptionsFor<WebApplication.Forms.PIAWizard.DataBreachImpactManagement>
|
||||
<div class="form-group row col-12">
|
||||
@for (int i = 0; i < Model.Options.Count; i++)
|
||||
{
|
||||
<div class="col-6">
|
||||
<input asp-for="Options[i].IsSelected" />
|
||||
<input type="hidden" asp-for="Options[i].Option"/>
|
||||
<label class="control-label">
|
||||
@Html.DisplayFor(m => m.Options[i].Option)
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
|
@ -0,0 +1,15 @@
|
|||
@model WebApplication.Models.InputSelectionOptionsFor<WebApplication.Forms.PIAWizard.DataBreachPlan>
|
||||
<div class="form-group row col-12">
|
||||
@for (int i = 0; i < Model.Options.Count; i++)
|
||||
{
|
||||
<div class="col-6">
|
||||
<input asp-for="Options[i].IsSelected" />
|
||||
<input type="hidden" asp-for="Options[i].Option"/>
|
||||
<label class="control-label">
|
||||
@Html.DisplayFor(m => m.Options[i].Option)
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
|
@ -0,0 +1,15 @@
|
|||
@model WebApplication.Models.InputSelectionOptionsFor<WebApplication.Forms.PIAWizard.DataModification>
|
||||
<div class="form-group row col-12">
|
||||
@for (int i = 0; i < Model.Options.Count; i++)
|
||||
{
|
||||
<div class="col-6">
|
||||
<input asp-for="Options[i].IsSelected" />
|
||||
<input type="hidden" asp-for="Options[i].Option"/>
|
||||
<label class="control-label">
|
||||
@Html.DisplayFor(m => m.Options[i].Option)
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
|
@ -0,0 +1,15 @@
|
|||
@model WebApplication.Models.InputSelectionOptionsFor<WebApplication.Forms.PIAWizard.EnvironmentReconfigurations>
|
||||
<div class="form-group row col-12">
|
||||
@for (int i = 0; i < Model.Options.Count; i++)
|
||||
{
|
||||
<div class="col-6">
|
||||
<input asp-for="Options[i].IsSelected" />
|
||||
<input type="hidden" asp-for="Options[i].Option"/>
|
||||
<label class="control-label">
|
||||
@Html.DisplayFor(m => m.Options[i].Option)
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
|
@ -0,0 +1,15 @@
|
|||
@model WebApplication.Models.InputSelectionOptionsFor<WebApplication.Forms.PIAWizard.Properties>
|
||||
<div class="form-group row col-12">
|
||||
@for (int i = 0; i < Model.Options.Count; i++)
|
||||
{
|
||||
<div class="col-6">
|
||||
<input asp-for="Options[i].IsSelected" />
|
||||
<input type="hidden" asp-for="Options[i].Option"/>
|
||||
<label class="control-label">
|
||||
@Html.DisplayFor(m => m.Options[i].Option)
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
|
@ -0,0 +1,16 @@
|
|||
@model WebApplication.Models.InputSelectionOptionsFor<WebApplication.Forms.PIAWizard.Specifications>
|
||||
|
||||
<div class="form-group">
|
||||
@for (int i = 0; i < Model.Options.Count; i++)
|
||||
{
|
||||
<div class="topLevelAssessmentOption">
|
||||
<input asp-for="Options[i].IsSelected" />
|
||||
<input type="hidden" asp-for="Options[i].Option"/>
|
||||
<label class="control-label">
|
||||
@Html.DisplayFor(m => m.Options[i].Option)
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
|
@ -0,0 +1,15 @@
|
|||
@model WebApplication.Models.InputSelectionOptionsFor<WebApplication.Forms.PIAWizard.StakeholderAssuranceProtection>
|
||||
<div class="form-group row col-12">
|
||||
@for (int i = 0; i < Model.Options.Count; i++)
|
||||
{
|
||||
<div class="col-6">
|
||||
<input asp-for="Options[i].IsSelected" />
|
||||
<input type="hidden" asp-for="Options[i].Option"/>
|
||||
<label class="control-label">
|
||||
@Html.DisplayFor(m => m.Options[i].Option)
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
|
@ -0,0 +1,6 @@
|
|||
@model IList<UserReference>
|
||||
@for (int i = 0; i < Model.Count(); i++)
|
||||
{
|
||||
@Html.HiddenFor(m => Model[i].UserId)
|
||||
@Html.HiddenFor(m => Model[i].DisplayName)
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
@model UserReference;
|
||||
<div class="form-group">
|
||||
@Html.DropDownListFor(model => model.UserId, ViewBag.PHNUsers as SelectList, "Select User", new { @class = "form-control", @id = "nameDroplist", @onchange = "setDisplayName(this)", @required = "required" })
|
||||
@Html.HiddenFor(model => model.DisplayName)
|
||||
</div>
|
|
@ -0,0 +1,2 @@
|
|||
@model WebApplication.Models.Wizards.PIAWizardViewModel;
|
||||
@Html.EditorFor(model => model.DataStewards, new { @class = "form-control" })
|
|
@ -1,4 +1,5 @@
|
|||
@using Humanizer;
|
||||
@using WebApplication.Controllers
|
||||
@model WebApplication.Models.SubjectArea
|
||||
|
||||
@{
|
||||
|
|
|
@ -164,7 +164,9 @@
|
|||
<div class="form-group">
|
||||
<label> Data Factory Integration Runtime </label>
|
||||
<br />
|
||||
<select asp-for="TaskDatafactoryIr" asp-items="DataFactoryRuntimes.Runtimes" class="form-control"></select>
|
||||
|
||||
@*TODO: Fix this
|
||||
<select asp-for="TaskDatafactoryIr" asp-items="DataFactoryRuntimes.Runtimes" class="form-control"></select>*@
|
||||
<span asp-validation-for="TaskDatafactoryIr" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
@ -105,8 +105,8 @@
|
|||
<label asp-for="PhnId" class="control-label"></label>
|
||||
</div>
|
||||
<div class="formSelect col-6">
|
||||
@Html.DropDownListFor(model => model.PhnZone.Id, ViewBag.PhnZones as SelectList, "Select Your PHN Zone", new { @class = "form-control", @id = "dsSelection" })
|
||||
@Html.HiddenFor(model => model.PhnZone.Name, new { @id = "hiddenPhnName"})
|
||||
@Html.DropDownListFor(model => model.Site.Id, ViewBag.PhnZones as SelectList, "Select Your PHN Zone", new { @class = "form-control", @id = "dsSelection" })
|
||||
@Html.HiddenFor(model => model.Site.Name, new { @id = "hiddenPhnName"})
|
||||
<span asp-validation-for="PhnId" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Graph" Version="4.22.0" />
|
||||
<PackageReference Include="Microsoft.Identity.Web" Version="1.2.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
|
||||
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.113" />
|
||||
|
@ -72,6 +73,18 @@
|
|||
<Folder Include="wwwroot\fonts\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Views\Shared\EditorTemplates\EditorForDataBreachImpactManagement.cshtml" />
|
||||
<None Include="Views\Shared\EditorTemplates\EditorForDataBreachPlan.cshtml" />
|
||||
<None Include="Views\Shared\EditorTemplates\EditorForDataModification.cshtml" />
|
||||
<None Include="Views\Shared\EditorTemplates\EditorForEnvironmentReconfigurations.cshtml" />
|
||||
<None Include="Views\Shared\EditorTemplates\EditorForProperties.cshtml" />
|
||||
<None Include="Views\Shared\EditorTemplates\EditorForSpecifications.cshtml" />
|
||||
<None Include="Views\Shared\EditorTemplates\EditorForStakeholderAssuranceProtection.cshtml" />
|
||||
<None Include="Views\Shared\EditorTemplates\ExternalUsers.cshtml" />
|
||||
<None Include="Views\Shared\EditorTemplates\UserReference.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WebApplication.DataAccess\WebApplication.DataAccess.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче