Permissions & Authorization for Users #24

Initial Release; Includes Database and MVC refactoring
This commit is contained in:
Gary Sharp
2013-10-10 19:13:16 +11:00
parent 172ce5524a
commit a099d68915
458 changed files with 40221 additions and 12130 deletions
@@ -0,0 +1,105 @@
using Disco.Models.Authorization;
using Disco.Models.UI.Config.AuthorizationRole;
using Disco.Services.Authorization;
using Disco.Services.Authorization.Roles;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Users;
using Disco.Services.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
[DiscoAuthorize(Claims.DiscoAdminAccount)]
public partial class AuthorizationRoleController : AuthorizedDatabaseController
{
public virtual ActionResult Index(int? id)
{
if (id.HasValue)
{
// Show
var ar = Database.AuthorizationRoles.Find(id.Value);
if (ar == null)
throw new ArgumentException("Invalid Authorization Role Id");
var token = RoleToken.FromAuthorizationRole(ar);
var subjects = token.SubjectIds == null ? new List<Models.AuthorizationRole.ShowModel.SubjectDescriptor>() :
token.SubjectIds.Select(subjectId => Disco.BI.Interop.ActiveDirectory.ActiveDirectory.GetObject(subjectId))
.Where(item => item != null)
.Select(item => Models.AuthorizationRole.ShowModel.SubjectDescriptor.FromActiveDirectoryObject(item))
.OrderBy(item => item.Name).ToList();
var m = new Models.AuthorizationRole.ShowModel()
{
Token = token,
Subjects = subjects,
ClaimNavigator = Claims.RoleClaimNavigator.BuildClaimTree(token.Claims)
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleShowModel>(this.ControllerContext, m);
return View(MVC.Config.AuthorizationRole.Views.Show, m);
}
else
{
// List Index
var ars = Database.AuthorizationRoles.ToList()
.Select(ar => RoleToken.FromAuthorizationRole(ar)).Cast<IRoleToken>().ToList();
var m = new Models.AuthorizationRole.IndexModel()
{
Tokens = ars
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleIndexModel>(this.ControllerContext, m);
return View(m);
}
}
public virtual ActionResult Create()
{
// Default Role
var m = new Models.AuthorizationRole.CreateModel()
{
AuthorizationRole = new Disco.Models.Repository.AuthorizationRole()
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleCreateModel>(this.ControllerContext, m);
return View(m);
}
[HttpPost]
public virtual ActionResult Create(Models.AuthorizationRole.CreateModel model)
{
if (ModelState.IsValid)
{
// Check for Existing
var existing = Database.AuthorizationRoles.Where(m => m.Name == model.AuthorizationRole.Name).FirstOrDefault();
if (existing == null)
{
var roleId = UserService.CreateAuthorizationRole(Database, model.AuthorizationRole);
return RedirectToAction(MVC.Config.AuthorizationRole.Index(roleId));
}
else
{
ModelState.AddModelError("Name", "Am Authorization Role with this name already exists.");
}
}
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleCreateModel>(this.ControllerContext, model);
return View(model);
}
}
}
@@ -1,22 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Disco.Services.Authorization;
using Disco.Services.Web;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class ConfigController : dbAdminController
public partial class ConfigController : AuthorizedDatabaseController
{
//
// GET: /Config/Config/
[DiscoAuthorize(Claims.Config.Show)]
public virtual ActionResult Index()
{
var m = new Models.Config.IndexModel()
{
UpdateResponse = dbContext.DiscoConfiguration.UpdateLastCheck
UpdateResponse = Database.DiscoConfiguration.UpdateLastCheck
};
return View(m);
@@ -1,26 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Disco.BI;
using Disco.BI.Extensions;
using Disco.Web.Extensions;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.BI.Extensions;
using Disco.Models.UI.Config.DeviceBatch;
using Disco.Services.Authorization;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Web;
using System;
using System.Linq;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class DeviceBatchController : dbAdminController
public partial class DeviceBatchController : AuthorizedDatabaseController
{
[DiscoAuthorize(Claims.Config.DeviceBatch.Show)]
public virtual ActionResult Index(int? id)
{
dbContext.Configuration.LazyLoadingEnabled = true;
Database.Configuration.LazyLoadingEnabled = true;
if (id.HasValue)
{
var m = dbContext.DeviceBatches.Where(db => db.Id == id.Value)
var m = Database.DeviceBatches.Where(db => db.Id == id.Value)
.Select(db => new Models.DeviceBatch.ShowModel()
{
DeviceBatch = db,
@@ -38,9 +36,18 @@ namespace Disco.Web.Areas.Config.Controllers
DeviceDecommissionedCount = dG.Count(d => d.DecommissionedDate.HasValue)
}).ToArray().Cast<ConfigDeviceBatchShowModelMembership>().ToList();
m.CanDelete = m.DeviceBatch.CanDelete(dbContext);
if (Authorization.Has(Claims.Config.DeviceBatch.Delete))
m.CanDelete = m.DeviceBatch.CanDelete(Database);
m.DeviceModels = dbContext.DeviceModels.ToList();
if (Authorization.Has(Claims.Config.DeviceBatch.Configure))
{
m.DeviceModels = Database.DeviceModels.ToList();
m.DefaultDeviceModel = m.DeviceBatch.DefaultDeviceModelId.HasValue ? m.DeviceModels.FirstOrDefault(dm => dm.Id == m.DeviceBatch.DefaultDeviceModelId.Value) : null;
}
else
{
m.DefaultDeviceModel = m.DeviceBatch.DefaultDeviceModelId.HasValue ? Database.DeviceModels.Find(m.DeviceBatch.DefaultDeviceModelId.Value) : null;
}
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceBatchShowModel>(this.ControllerContext, m);
@@ -49,7 +56,7 @@ namespace Disco.Web.Areas.Config.Controllers
}
else
{
var m = Models.DeviceBatch.IndexModel.Build(dbContext);
var m = Models.DeviceBatch.IndexModel.Build(Database);
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceBatchIndexModel>(this.ControllerContext, m);
@@ -58,12 +65,13 @@ namespace Disco.Web.Areas.Config.Controllers
}
}
[DiscoAuthorizeAll(Claims.Config.DeviceBatch.Create, Claims.Config.DeviceBatch.Configure)]
public virtual ActionResult Create()
{
// Default Batch
var m = new Models.DeviceBatch.CreateModel()
{
DeviceBatch = BI.DeviceBI.BatchUtilities.DefaultNewDeviceBatch(dbContext)
DeviceBatch = BI.DeviceBI.BatchUtilities.DefaultNewDeviceBatch(Database)
};
// UI Extensions
@@ -72,17 +80,17 @@ namespace Disco.Web.Areas.Config.Controllers
return View(m);
}
[HttpPost]
[DiscoAuthorizeAll(Claims.Config.DeviceBatch.Create, Claims.Config.DeviceBatch.Configure), HttpPost]
public virtual ActionResult Create(Models.DeviceBatch.CreateModel model)
{
if (ModelState.IsValid)
{
// Check for Existing
var existing = dbContext.DeviceBatches.Where(m => m.Name == model.DeviceBatch.Name).FirstOrDefault();
var existing = Database.DeviceBatches.Where(m => m.Name == model.DeviceBatch.Name).FirstOrDefault();
if (existing == null)
{
dbContext.DeviceBatches.Add(model.DeviceBatch);
dbContext.SaveChanges();
Database.DeviceBatches.Add(model.DeviceBatch);
Database.SaveChanges();
return RedirectToAction(MVC.Config.DeviceBatch.Index(model.DeviceBatch.Id));
}
else
@@ -97,6 +105,7 @@ namespace Disco.Web.Areas.Config.Controllers
return View(model);
}
[DiscoAuthorize(Claims.Config.DeviceBatch.ShowTimeline)]
public virtual ActionResult Timeline()
{
var m = new Models.DeviceBatch.TimelineModel();
@@ -1,23 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Disco.Services.Plugins.Features.WarrantyProvider;
using Disco.Services.Plugins;
using Disco.BI.Extensions;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.BI.Extensions;
using Disco.Models.UI.Config.DeviceModel;
using Disco.Services.Authorization;
using Disco.Services.Plugins;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Plugins.Features.WarrantyProvider;
using Disco.Services.Web;
using System;
using System.Linq;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class DeviceModelController : dbAdminController
public partial class DeviceModelController : AuthorizedDatabaseController
{
[DiscoAuthorize(Claims.Config.DeviceModel.Show)]
public virtual ActionResult Index(int? id)
{
if (id.HasValue)
{
var m = dbContext.DeviceModels.Include("DeviceComponents").Where(dm => dm.Id == id.Value).Select(dm => new Models.DeviceModel.ShowModel()
var m = Database.DeviceModels.Include("DeviceComponents").Where(dm => dm.Id == id.Value).Select(dm => new Models.DeviceModel.ShowModel()
{
DeviceModel = dm,
DeviceCount = dm.Devices.Count(),
@@ -32,16 +33,11 @@ namespace Disco.Web.Areas.Config.Controllers
m.DeviceComponentsModel = new Models.DeviceModel.ComponentsModel()
{
DeviceModelId = m.DeviceModel.Id,
DeviceComponents = dbContext.DeviceComponents.Include("JobSubTypes").Where(dc => dc.DeviceModelId == m.DeviceModel.Id).ToList(),
JobSubTypes = dbContext.JobSubTypes.Where(jst => jst.JobTypeId == Disco.Models.Repository.JobType.JobTypeIds.HNWar).ToList()
DeviceComponents = Database.DeviceComponents.Include("JobSubTypes").Where(dc => dc.DeviceModelId == m.DeviceModel.Id).ToList(),
JobSubTypes = Database.JobSubTypes.Where(jst => jst.JobTypeId == Disco.Models.Repository.JobType.JobTypeIds.HNWar).ToList()
};
m.CanDelete = m.DeviceModel.CanDelete(dbContext);
//m.Devices = BI.DeviceBI.SelectDeviceSearchResultItem(dbContext.Devices.Where(d => d.DeviceModelId == m.DeviceModel.Id));
//m.Devices = dbContext.Devices.Include("DeviceModel").Include("DeviceProfile").Include("AssignedUser")
// .Where(d => d.DeviceModelId == m.DeviceModel.Id).ToList();
m.CanDelete = m.DeviceModel.CanDelete(Database);
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceModelShowModel>(this.ControllerContext, m);
@@ -50,7 +46,7 @@ namespace Disco.Web.Areas.Config.Controllers
}
else
{
var m = Models.DeviceModel.IndexModel.Build(dbContext);
var m = Models.DeviceModel.IndexModel.Build(Database);
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceModelIndexModel>(this.ControllerContext, m);
@@ -59,12 +55,13 @@ namespace Disco.Web.Areas.Config.Controllers
}
}
[DiscoAuthorize(Claims.Config.DeviceModel.Show)]
public virtual ActionResult GenericComponents()
{
var m = new Models.DeviceModel.ComponentsModel()
{
DeviceComponents = dbContext.DeviceComponents.Include("JobSubTypes").Where(dc => !dc.DeviceModelId.HasValue).ToList(),
JobSubTypes = dbContext.JobSubTypes.Where(jst => jst.JobTypeId == Disco.Models.Repository.JobType.JobTypeIds.HNWar).ToList()
DeviceComponents = Database.DeviceComponents.Include("JobSubTypes").Where(dc => !dc.DeviceModelId.HasValue).ToList(),
JobSubTypes = Database.JobSubTypes.Where(jst => jst.JobTypeId == Disco.Models.Repository.JobType.JobTypeIds.HNWar).ToList()
};
// UI Extensions
@@ -1,26 +1,26 @@
using System;
using Disco.BI.Extensions;
using Disco.Models.Repository;
using Disco.Models.UI.Config.DeviceProfile;
using Disco.Services.Authorization;
using Disco.Services.Plugins;
using Disco.Services.Plugins.Features.CertificateProvider;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Disco.Data.Configuration;
using Disco.BI;
using Disco.BI.Extensions;
using Disco.Services.Plugins.Features.CertificateProvider;
using Disco.Services.Plugins;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Models.UI.Config.DeviceProfile;
using Disco.Models.Repository;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class DeviceProfileController : dbAdminController
public partial class DeviceProfileController : AuthorizedDatabaseController
{
[DiscoAuthorize(Claims.Config.DeviceProfile.Show)]
public virtual ActionResult Index(int? id)
{
if (id.HasValue)
{
var m = dbContext.DeviceProfiles.Where(dp => dp.Id == id.Value).Select(dp => new Models.DeviceProfile.ShowModel()
var m = Database.DeviceProfiles.Where(dp => dp.Id == id.Value).Select(dp => new Models.DeviceProfile.ShowModel()
{
DeviceProfile = dp,
DeviceCount = dp.Devices.Count(),
@@ -30,7 +30,11 @@ namespace Disco.Web.Areas.Config.Controllers
if (m == null || m.DeviceProfile == null)
throw new ArgumentException("Invalid Device Profile Id", "id");
m.OrganisationAddresses = dbContext.DiscoConfiguration.OrganisationAddresses.Addresses;
m.OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses;
if (m.DeviceProfile.DefaultOrganisationAddress.HasValue)
m.DefaultOrganisationAddress = Database.DiscoConfiguration.OrganisationAddresses.GetAddress(m.DeviceProfile.DefaultOrganisationAddress.Value);
m.CertificateProviders = Plugins.GetPluginFeatures(typeof(CertificateProviderFeature));
var DistributionValues = Enum.GetValues(typeof(Disco.Models.Repository.DeviceProfile.DistributionTypes));
@@ -44,13 +48,7 @@ namespace Disco.Web.Areas.Config.Controllers
Selected = ((int)m.DeviceProfile.DistributionType == value)
});
}
m.CanDelete = m.DeviceProfile.CanDelete(dbContext);
// Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
//var config = m.DeviceProfile.Configuration(dbContext);
//m.AllocateWirelessCertificate = m.DeviceProfile.AllocateWirelessCertificate;
//m.OrganisationalUnit = m.DeviceProfile.OrganisationalUnit;
//m.ComputerNameTemplate = m.DeviceProfile.ComputerNameTemplate;
m.CanDelete = m.DeviceProfile.CanDelete(Database);
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceProfileShowModel>(this.ControllerContext, m);
@@ -59,7 +57,7 @@ namespace Disco.Web.Areas.Config.Controllers
}
else
{
var m = Models.DeviceProfile.IndexModel.Build(dbContext);
var m = Models.DeviceProfile.IndexModel.Build(Database);
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceProfileIndexModel>(this.ControllerContext, m);
@@ -68,6 +66,7 @@ namespace Disco.Web.Areas.Config.Controllers
}
}
[DiscoAuthorizeAll(Claims.Config.DeviceProfile.Create, Claims.Config.DeviceProfile.Configure)]
public virtual ActionResult Create()
{
var m = new Models.DeviceProfile.CreateModel()
@@ -86,19 +85,19 @@ namespace Disco.Web.Areas.Config.Controllers
return View(m);
}
[HttpPost]
[DiscoAuthorizeAll(Claims.Config.DeviceProfile.Create, Claims.Config.DeviceProfile.Configure), HttpPost]
public virtual ActionResult Create(Models.DeviceProfile.CreateModel model)
{
if (ModelState.IsValid)
{
// Check for Existing
var existing = dbContext.DeviceProfiles.Where(m => m.Name == model.DeviceProfile.Name).FirstOrDefault();
var existing = Database.DeviceProfiles.Where(m => m.Name == model.DeviceProfile.Name).FirstOrDefault();
if (existing == null)
{
model.DeviceProfile.ProvisionADAccount = true;
dbContext.DeviceProfiles.Add(model.DeviceProfile);
dbContext.SaveChanges();
Database.DeviceProfiles.Add(model.DeviceProfile);
Database.SaveChanges();
return RedirectToAction(MVC.Config.DeviceProfile.Index(model.DeviceProfile.Id));
}
else
@@ -113,13 +112,14 @@ namespace Disco.Web.Areas.Config.Controllers
return View(model);
}
[DiscoAuthorize(Claims.Config.DeviceProfile.ConfigureDefaults)]
public virtual ActionResult Defaults()
{
var m = new Models.DeviceProfile.DefaultsModel()
{
DeviceProfiles = dbContext.DeviceProfiles.ToList(),
Default = dbContext.DiscoConfiguration.DeviceProfiles.DefaultDeviceProfileId,
DefaultAddDeviceOffline = dbContext.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId
DeviceProfiles = Database.DeviceProfiles.ToList(),
Default = Database.DiscoConfiguration.DeviceProfiles.DefaultDeviceProfileId,
DefaultAddDeviceOffline = Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId
};
m.DeviceProfilesAndNone = m.DeviceProfiles.ToList();
m.DeviceProfilesAndNone.Insert(0, new Disco.Models.Repository.DeviceProfile() { Id = 0, Name = "<No Default>" });
@@ -1,23 +1,23 @@
using System;
using Disco.BI.Extensions;
using Disco.Models.UI.Config.DocumentTemplate;
using Disco.Services.Authorization;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Disco.BI;
using Disco.BI.Extensions;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Models.UI.Config.DocumentTemplate;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class DocumentTemplateController : dbAdminController
public partial class DocumentTemplateController : AuthorizedDatabaseController
{
[DiscoAuthorize(Claims.Config.DocumentTemplate.Show)]
public virtual ActionResult Index(string id)
{
if (string.IsNullOrEmpty(id))
{
var m = new Models.DocumentTemplate.IndexModel() { DocumentTemplates = dbContext.DocumentTemplates.ToList() };
var m = new Models.DocumentTemplate.IndexModel() { DocumentTemplates = Database.DocumentTemplates.ToList() };
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateIndexModel>(this.ControllerContext, m);
@@ -28,10 +28,10 @@ namespace Disco.Web.Areas.Config.Controllers
{
var m = new Models.DocumentTemplate.ShowModel()
{
DocumentTemplate = dbContext.DocumentTemplates.Include("JobSubTypes").Where(at => at.Id == id).FirstOrDefault()
DocumentTemplate = Database.DocumentTemplates.Include("JobSubTypes").Where(at => at.Id == id).FirstOrDefault()
};
m.TemplateExpressions = m.DocumentTemplate.ExtractPdfExpressions(dbContext);
m.UpdateModel(dbContext);
m.TemplateExpressions = m.DocumentTemplate.ExtractPdfExpressions(Database);
m.UpdateModel(Database);
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateShowModel>(this.ControllerContext, m);
@@ -40,6 +40,7 @@ namespace Disco.Web.Areas.Config.Controllers
}
}
[DiscoAuthorize(Claims.Config.DocumentTemplate.ShowStatus)]
public virtual ActionResult ImportStatus()
{
var m = new Models.DocumentTemplate.ImportStatusModel();
@@ -49,11 +50,13 @@ namespace Disco.Web.Areas.Config.Controllers
return View();
}
[DiscoAuthorize(Claims.Config.DocumentTemplate.UndetectedPages)]
public virtual ActionResult UndetectedPages()
{
var m = new Models.DocumentTemplate.UndetectedPagesModel()
{
DocumentTemplates = dbContext.DocumentTemplates.ToList()
DocumentTemplates = Database.DocumentTemplates.ToList()
};
// UI Extensions
@@ -62,10 +65,11 @@ namespace Disco.Web.Areas.Config.Controllers
return View(m);
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Create, Claims.Config.DocumentTemplate.Configure)]
public virtual ActionResult Create()
{
var m = new Models.DocumentTemplate.CreateModel();
m.UpdateModel(dbContext);
m.UpdateModel(Database);
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreateModel>(this.ControllerContext, m);
@@ -73,19 +77,19 @@ namespace Disco.Web.Areas.Config.Controllers
return View(m);
}
[HttpPost]
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Create, Claims.Config.DocumentTemplate.Configure), HttpPost]
public virtual ActionResult Create(Models.DocumentTemplate.CreateModel model)
{
model.UpdateModel(dbContext);
model.UpdateModel(Database);
if (ModelState.IsValid)
{
// Check for Existing
var existing = dbContext.DocumentTemplates.Where(m => m.Id == model.DocumentTemplate.Id).FirstOrDefault();
var existing = Database.DocumentTemplates.Where(m => m.Id == model.DocumentTemplate.Id).FirstOrDefault();
if (existing == null)
{
dbContext.DocumentTemplates.Add(model.DocumentTemplate);
Database.DocumentTemplates.Add(model.DocumentTemplate);
if (model.DocumentTemplate.Scope == Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Job)
{
@@ -96,10 +100,10 @@ namespace Disco.Web.Areas.Config.Controllers
// model.AttachmentType.JobSubTypes.Add(jobSubType);
}
dbContext.SaveChanges();
Database.SaveChanges();
// Save Template
model.DocumentTemplate.SavePdfTemplate(dbContext, model.Template.InputStream);
model.DocumentTemplate.SavePdfTemplate(Database, model.Template.InputStream);
return RedirectToAction(MVC.Config.DocumentTemplate.Index(model.DocumentTemplate.Id));
}
@@ -115,6 +119,7 @@ namespace Disco.Web.Areas.Config.Controllers
return View(model);
}
[DiscoAuthorize(Claims.Config.Show)]
public virtual ActionResult ExpressionBrowser(string type, bool StaticDeclaredMembersOnly = false)
{
if (string.IsNullOrWhiteSpace(type))
@@ -1,23 +1,19 @@
using Disco.Models.UI.Config.Enrolment;
using Disco.Services.Authorization;
using Disco.Services.Plugins.Features.UIExtension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Disco.Services.Web;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class EnrolmentController : dbAdminController
public partial class EnrolmentController : AuthorizedDatabaseController
{
//
// GET: /Config/Bootstrapper/
[DiscoAuthorize(Claims.Config.Enrolment.Show)]
public virtual ActionResult Index()
{
var m = new Models.Enrolment.IndexModel()
{
MacSshUsername = dbContext.DiscoConfiguration.Bootstrapper.MacSshUsername
MacSshUsername = Database.DiscoConfiguration.Bootstrapper.MacSshUsername
};
// UI Extensions
@@ -25,6 +21,8 @@ namespace Disco.Web.Areas.Config.Controllers
return View(m);
}
[DiscoAuthorize(Claims.Config.Enrolment.ShowStatus)]
public virtual ActionResult Status()
{
var m = new Models.Enrolment.StatusModel();
@@ -1,22 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Disco.Services.Authorization;
using Disco.Services.Web;
using System;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class ExpressionsController : Controller
[DiscoAuthorize(Claims.DiscoAdminAccount)]
public partial class ExpressionsController : AuthorizedDatabaseController
{
//
// GET: /Config/Expressions/
// Under Construction - Not In Production
public virtual ActionResult Index()
{
return View(Views.Editor, new Models.Expressions.EditorModel()
{
Expression = @"JobComponentsTotalCost() < 100 ? JobComponentsTotalCost().ToString('c') : '$100.00'"
});
throw new NotImplementedException();
//return View(Views.Editor, new Models.Expressions.EditorModel()
//{
// Expression = @"JobComponentsTotalCost() < 100 ? JobComponentsTotalCost().ToString('c') : '$100.00'"
//});
}
}
@@ -1,20 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Disco.Models.UI.Config.Logging;
using Disco.Services.Authorization;
using Disco.Services.Logging;
using Disco.Services.Logging.Models;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Models.UI.Config.Logging;
using Disco.Services.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class LoggingController : dbAdminController
public partial class LoggingController : AuthorizedDatabaseController
{
//
// GET: /Config/Logs/
[DiscoAuthorize(Claims.Config.Logging.Show)]
public virtual ActionResult Index()
{
var m = new Models.Logging.IndexModel()
@@ -1,25 +1,24 @@
using Disco.Models.UI.Config.Organisation;
using Disco.Services.Authorization;
using Disco.Services.Plugins.Features.UIExtension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Disco.Services.Web;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class OrganisationController : dbAdminController
public partial class OrganisationController : AuthorizedDatabaseController
{
//
// GET: /Config/Organisation/
[DiscoAuthorize(Claims.Config.Organisation.Show)]
public virtual ActionResult Index()
{
var viewModel = new Models.Organisation.IndexModel();
viewModel.OrganisationName = dbContext.DiscoConfiguration.OrganisationName;
viewModel.MultiSiteMode = dbContext.DiscoConfiguration.MultiSiteMode;
viewModel.OrganisationAddresses = dbContext.DiscoConfiguration.OrganisationAddresses.Addresses;
viewModel.OrganisationName = Database.DiscoConfiguration.OrganisationName;
viewModel.MultiSiteMode = Database.DiscoConfiguration.MultiSiteMode;
viewModel.OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses;
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigOrganisationIndexModel>(this.ControllerContext, viewModel);
@@ -1,30 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Disco.Models.BI.Interop.Community;
using Disco.Services.Authorization;
using Disco.Services.Plugins;
using Disco.Services.Tasks;
using Disco.Services.Users;
using Disco.Services.Web;
using Disco.Web.Areas.Config.Models.Plugins;
using System;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class PluginsController : dbAdminController
public partial class PluginsController : AuthorizedDatabaseController
{
[HttpGet]
[DiscoAuthorize(Claims.Config.Plugin.Show), HttpGet]
public virtual ActionResult Index()
{
Models.Plugins.IndexViewModel vm = new Models.Plugins.IndexViewModel()
{
PluginManifests = Plugins.GetPlugins(),
Catalogue = Plugins.LoadCatalogue(dbContext)
Catalogue = Plugins.LoadCatalogue(Database)
};
return View(vm);
}
#region Plugin Configuration
[HttpPost]
[DiscoAuthorize(Claims.Config.Plugin.Configure), HttpPost]
public virtual ActionResult Configure(string PluginId, FormCollection form)
{
if (string.IsNullOrEmpty(PluginId))
@@ -34,24 +32,24 @@ namespace Disco.Web.Areas.Config.Controllers
using (PluginConfigurationHandler configHandler = manifest.CreateConfigurationHandler())
{
if (configHandler.Post(dbContext, form, this))
if (configHandler.Post(Database, form, this))
{
dbContext.SaveChanges();
Database.SaveChanges();
PluginsLog.LogPluginConfigurationSaved(manifest.Id, DiscoApplication.CurrentUser.Id);
PluginsLog.LogPluginConfigurationSaved(manifest.Id, UserService.CurrentUserId);
return RedirectToAction(MVC.Config.Plugins.Index());
}
else
{
// Config Errors
PluginConfigurationViewModel vm = new PluginConfigurationViewModel(configHandler.Get(dbContext, this));
PluginConfigurationViewModel vm = new PluginConfigurationViewModel(configHandler.Get(Database, this));
return View(Views.Configure, vm);
}
}
}
[HttpGet]
[DiscoAuthorize(Claims.Config.Plugin.Configure), HttpGet]
public virtual ActionResult Configure(string PluginId)
{
if (string.IsNullOrEmpty(PluginId))
@@ -61,18 +59,18 @@ namespace Disco.Web.Areas.Config.Controllers
using (PluginConfigurationHandler configHandler = manifest.CreateConfigurationHandler())
{
PluginConfigurationViewModel vm = new PluginConfigurationViewModel(configHandler.Get(dbContext, this));
PluginsLog.LogPluginConfigurationLoaded(manifest.Id, DiscoApplication.CurrentUser.Id);
PluginConfigurationViewModel vm = new PluginConfigurationViewModel(configHandler.Get(Database, this));
PluginsLog.LogPluginConfigurationLoaded(manifest.Id, UserService.CurrentUserId);
return View(Views.Configure, vm);
}
}
#endregion
[DiscoAuthorize(Claims.Config.Plugin.Install)]
public virtual ActionResult Install()
{
// Check for recent catalogue
var catalogue = Plugins.LoadCatalogue(dbContext);
var catalogue = Plugins.LoadCatalogue(Database);
if (catalogue == null || catalogue.ResponseTimestamp < DateTime.Now.AddHours(-1))
{
@@ -1,25 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Disco.Services.Authorization;
using Disco.Services.Web;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class SystemConfigController : dbAdminController
public partial class SystemConfigController : AuthorizedDatabaseController
{
[HttpGet]
[DiscoAuthorize(Claims.Config.System.Show), HttpGet]
public virtual ActionResult Index()
{
var m = Models.SystemConfig.IndexModel.FromConfiguration(dbContext.DiscoConfiguration);
var m = Models.SystemConfig.IndexModel.FromConfiguration(Database.DiscoConfiguration);
return View(m);
}
[HttpPost]
[DiscoAuthorizeAll(Claims.Config.System.Show, Claims.Config.System.ConfigureProxy), HttpPost]
public virtual ActionResult Index(Models.SystemConfig.IndexModel config)
{
if (ModelState.IsValid)
{
config.ToConfiguration(dbContext);
config.ToConfiguration(Database);
return RedirectToAction(MVC.Config.Config.Index());
}
else