mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Update default roles to work with Features
The code used to deal with Modules as the basic unit and needed to be updated to work with "Features" instead, since features are the basic units than can be enabled/disabled. --HG-- branch : dev
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Core.Common {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ChangeOwner = new Permission { Name = "ChangeOwner", Description = "Change the owner of content items" };
|
||||
|
||||
public string ModuleName {
|
||||
get { return "Common"; }
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Core.Contents {
|
||||
@@ -12,11 +13,7 @@ namespace Orchard.Core.Contents {
|
||||
|
||||
public static readonly Permission MetaListContent = new Permission { ImpliedBy = new[] { EditContent, PublishContent, DeleteContent } };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "Content";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new [] {
|
||||
|
@@ -1,13 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Core.Navigation {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageMainMenu = new Permission { Name = "ManageMainMenu", Description = "Manage main menu" };
|
||||
|
||||
public string ModuleName {
|
||||
get { return "Navigation"; }
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new[] {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Core.Settings {
|
||||
@@ -6,9 +7,7 @@ namespace Orchard.Core.Settings {
|
||||
public static readonly Permission ManageSettings = new Permission { Name = "ManageSettings", Description = "Manage site settings" };
|
||||
public static readonly Permission ChangeSuperuser = new Permission { Name = "ChangeSuperuser", Description = "Change the superuser for the site" };
|
||||
|
||||
public string ModuleName {
|
||||
get { return "Settings"; }
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Blogs {
|
||||
@@ -16,11 +17,7 @@ namespace Orchard.Blogs {
|
||||
public static readonly Permission MetaListOthersBlogs = new Permission { ImpliedBy = new[] { EditOthersBlogPost, PublishOthersBlogPost, DeleteOthersBlogPost } };
|
||||
public static readonly Permission MetaListBlogs = new Permission { ImpliedBy = new[] { EditBlogPost, PublishBlogPost, DeleteBlogPost } };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "Blogs";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Comments {
|
||||
@@ -11,11 +12,7 @@ namespace Orchard.Comments {
|
||||
public static readonly Permission ManageComments = new Permission { Description = "Manage comments", Name = "ManageComments" };
|
||||
public static readonly Permission ManageOthersComments = new Permission { Description = "Manage comments for others", Name = "ManageOthersComments" };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "Comments";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.ContentTypes {
|
||||
@@ -6,9 +7,7 @@ namespace Orchard.ContentTypes {
|
||||
public static readonly Permission CreateContentTypes = new Permission { Name = "CreateContentTypes", Description = "Create custom content types." };
|
||||
public static readonly Permission EditContentTypes = new Permission { Name = "EditContentTypes", Description = "Edit content types." };
|
||||
|
||||
public string ModuleName {
|
||||
get { return "Contents"; }
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new [] {
|
||||
|
@@ -2,17 +2,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.DevTools {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission DebugShowAllMenuItems = new Permission { Description = "DevTools: Show all menu items", Name = "DebugShowAllMenuItems" };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "DevTools";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -1,15 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Indexing {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageSearchIndex = new Permission { Description = "Manage Search Index", Name = "ManageSearchIndex" };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "Indexing";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new[] { ManageSearchIndex };
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Media {
|
||||
@@ -6,11 +7,7 @@ namespace Orchard.Media {
|
||||
public static readonly Permission ManageMediaFiles = new Permission { Description = "Modifying Media Files", Name = "ManageMediaFiles" };
|
||||
public static readonly Permission UploadMediaFiles = new Permission { Description = "Uploading Media Files", Name = "UploadMediaFiles", ImpliedBy = new[] { ManageMediaFiles } };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "Media";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Modules {
|
||||
@@ -6,9 +7,7 @@ namespace Orchard.Modules {
|
||||
public static readonly Permission ManageModules = new Permission { Description = "Manage Modules", Name = "ManageModules" };
|
||||
public static readonly Permission ManageFeatures = new Permission { Description = "Manage Features", Name = "ManageFeatures", ImpliedBy = new[] {ManageModules}};
|
||||
|
||||
public string ModuleName {
|
||||
get { return "Modules"; }
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new[] {ManageModules, ManageFeatures};
|
||||
|
@@ -1,15 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.MultiTenancy {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageTenants = new Permission { Description = "Modifying Tenants of a Site", Name = "ManageTenants" };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "MultiTenancy";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new[] {
|
||||
|
@@ -8,7 +8,6 @@ using Orchard.Roles.Models;
|
||||
using Orchard.Roles.Services;
|
||||
using Orchard.Roles.ViewModels;
|
||||
using Orchard.Security;
|
||||
using Orchard.Security.Permissions;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Roles.Controllers {
|
||||
@@ -36,7 +35,7 @@ namespace Orchard.Roles.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var model = new RolesIndexViewModel { Rows = _roleService.GetRoles() as IList<RoleRecord> };
|
||||
var model = new RolesIndexViewModel { Rows = _roleService.GetRoles().ToList() };
|
||||
|
||||
return View(model);
|
||||
}
|
||||
@@ -65,7 +64,7 @@ namespace Orchard.Roles.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var model = new RoleCreateViewModel { ModulePermissions = _roleService.GetInstalledPermissions() };
|
||||
var model = new RoleCreateViewModel { FeaturePermissions = _roleService.GetInstalledPermissions() };
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -103,11 +102,11 @@ namespace Orchard.Roles.Controllers {
|
||||
throw new HttpException(404, "page with id " + id + " was not found");
|
||||
}
|
||||
var model = new RoleEditViewModel { Name = role.Name, Id = role.Id,
|
||||
ModulePermissions = _roleService.GetInstalledPermissions(),
|
||||
FeaturePermissions = _roleService.GetInstalledPermissions(),
|
||||
CurrentPermissions = _roleService.GetPermissionsForRole(id)};
|
||||
|
||||
var simulation = UserSimulation.Create(role.Name);
|
||||
model.EffectivePermissions = model.ModulePermissions
|
||||
model.EffectivePermissions = model.FeaturePermissions
|
||||
.SelectMany(group => group.Value)
|
||||
.Where(permission => _authorizationService.TryCheckAccess(permission, simulation, null))
|
||||
.Select(permission=>permission.Name)
|
||||
|
@@ -4,11 +4,11 @@ namespace Orchard.Roles.DataMigrations {
|
||||
public class RolesDataMigration : DataMigrationImpl {
|
||||
|
||||
public int Create() {
|
||||
//CREATE TABLE Orchard_Roles_PermissionRecord (Id integer, Name TEXT, ModuleName TEXT, Description TEXT, primary key (Id));
|
||||
//CREATE TABLE Orchard_Roles_PermissionRecord (Id integer, Name TEXT, FeatureName TEXT, Description TEXT, primary key (Id));
|
||||
SchemaBuilder.CreateTable("PermissionRecord", table => table
|
||||
.Column<int>("Id", column => column.PrimaryKey().Identity())
|
||||
.Column<string>("Name")
|
||||
.Column<string>("ModuleName")
|
||||
.Column<string>("FeatureName")
|
||||
.Column<string>("Description")
|
||||
);
|
||||
|
||||
|
@@ -38,7 +38,7 @@ namespace Orchard.Roles {
|
||||
var featureName = feature.Descriptor.Name;
|
||||
|
||||
// when another module is being enabled, locate matching permission providers
|
||||
var providersForEnabledModule = _permissionProviders.Where(x => x.ModuleName == featureName);
|
||||
var providersForEnabledModule = _permissionProviders.Where(x => x.Feature.Descriptor.Name == featureName);
|
||||
|
||||
if (providersForEnabledModule.Any()) {
|
||||
Logger.Debug("Configuring default roles for module {0}", featureName);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
public class PermissionRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string ModuleName { get; set; }
|
||||
public virtual string FeatureName { get; set; }
|
||||
public virtual string Description { get; set; }
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Roles {
|
||||
@@ -9,11 +10,7 @@ namespace Orchard.Roles {
|
||||
public static readonly Permission ManageRoles = new Permission { Description = "Create and manage roles", Name = "ManageRoles" };
|
||||
public static readonly Permission ApplyRoles = new Permission { Description = "Assign users to roles", Name = "AssignUsersToRoles", ImpliedBy = new[] { ManageRoles } };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "Roles";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Roles.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
@@ -47,7 +48,7 @@ namespace Orchard.Roles.Services {
|
||||
_permissionRepository.Create(new PermissionRecord {
|
||||
Description = GetPermissionDescription(permissionName),
|
||||
Name = permissionName,
|
||||
ModuleName = GetModuleName(permissionName)
|
||||
FeatureName = GetFeatureName(permissionName)
|
||||
});
|
||||
}
|
||||
RoleRecord roleRecord = GetRoleByName(roleName);
|
||||
@@ -65,7 +66,7 @@ namespace Orchard.Roles.Services {
|
||||
_permissionRepository.Create(new PermissionRecord {
|
||||
Description = GetPermissionDescription(permission),
|
||||
Name = permission,
|
||||
ModuleName = GetModuleName(permission)
|
||||
FeatureName = GetFeatureName(permission)
|
||||
});
|
||||
}
|
||||
PermissionRecord permissionRecord = _permissionRepository.Get(x => x.Name == permission);
|
||||
@@ -73,11 +74,11 @@ namespace Orchard.Roles.Services {
|
||||
}
|
||||
}
|
||||
|
||||
private string GetModuleName(string permissionName) {
|
||||
private string GetFeatureName(string permissionName) {
|
||||
foreach (var permissionProvider in _permissionProviders) {
|
||||
foreach (var permission in permissionProvider.GetPermissions()) {
|
||||
if (String.Equals(permissionName, permission.Name, StringComparison.OrdinalIgnoreCase)) {
|
||||
return permissionProvider.ModuleName;
|
||||
return permissionProvider.Feature.Descriptor.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,20 +101,22 @@ namespace Orchard.Roles.Services {
|
||||
}
|
||||
|
||||
public IDictionary<string, IEnumerable<Permission>> GetInstalledPermissions() {
|
||||
Dictionary<string, IEnumerable<Permission>> installedPermissions = new Dictionary<string, IEnumerable<Permission>>();
|
||||
var installedPermissions = new Dictionary<string, IEnumerable<Permission>>();
|
||||
foreach (var permissionProvider in _permissionProviders) {
|
||||
IEnumerable<Permission> permissions = permissionProvider.GetPermissions();
|
||||
if (installedPermissions.ContainsKey(permissionProvider.ModuleName))
|
||||
installedPermissions[permissionProvider.ModuleName] = installedPermissions[permissionProvider.ModuleName].Concat(permissions);
|
||||
var featureName = permissionProvider.Feature.Descriptor.Name;
|
||||
var permissions = permissionProvider.GetPermissions();
|
||||
|
||||
if (installedPermissions.ContainsKey(featureName))
|
||||
installedPermissions[featureName] = installedPermissions[featureName].Concat(permissions);
|
||||
else
|
||||
installedPermissions.Add(permissionProvider.ModuleName, permissions);
|
||||
installedPermissions.Add(featureName, permissions);
|
||||
}
|
||||
|
||||
return installedPermissions;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetPermissionsForRole(int id) {
|
||||
List<string> permissions = new List<string>();
|
||||
var permissions = new List<string>();
|
||||
RoleRecord roleRecord = GetRole(id);
|
||||
foreach (RolesPermissionsRecord rolesPermission in roleRecord.RolesPermissions) {
|
||||
permissions.Add(rolesPermission.Permission.Name);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Security.Permissions;
|
||||
@@ -7,6 +7,6 @@ namespace Orchard.Roles.ViewModels {
|
||||
public class RoleCreateViewModel : BaseViewModel {
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public IDictionary<string, IEnumerable<Permission>> ModulePermissions { get; set; }
|
||||
public IDictionary<string, IEnumerable<Permission>> FeaturePermissions { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ namespace Orchard.Roles.ViewModels {
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public IDictionary<string, IEnumerable<Permission>> ModulePermissions { get; set; }
|
||||
public IDictionary<string, IEnumerable<Permission>> FeaturePermissions { get; set; }
|
||||
public IEnumerable<string> CurrentPermissions { get; set; }
|
||||
public IEnumerable<string> EffectivePermissions { get; set; }
|
||||
}
|
||||
|
@@ -10,9 +10,9 @@
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><%: T("Permissions") %></legend>
|
||||
<% foreach (var moduleName in Model.ModulePermissions.Keys) { %>
|
||||
<% foreach (var featureName in Model.FeaturePermissions.Keys) { %>
|
||||
<fieldset>
|
||||
<legend><%: T("{0} Module", moduleName) %></legend>
|
||||
<legend><%: T("{0} Module", featureName) %></legend>
|
||||
<table class="items">
|
||||
<colgroup>
|
||||
<col id="Permission" />
|
||||
@@ -24,7 +24,7 @@
|
||||
<th scope="col"><%: T("Allow") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% foreach (var permission in Model.ModulePermissions[moduleName]) { %>
|
||||
<% foreach (var permission in Model.FeaturePermissions[featureName]) { %>
|
||||
<tr>
|
||||
<td><%: permission.Description %></td>
|
||||
<td style="width:60px;/* todo: (heskew) make not inline :( */"><input type="checkbox" value="true" name="<%: T("Checkbox.{0}", permission.Name) %>"/></td>
|
||||
|
@@ -11,9 +11,9 @@
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><%: T("Permissions") %></legend>
|
||||
<% foreach (var moduleName in Model.ModulePermissions.Keys) { %>
|
||||
<% foreach (var featureName in Model.FeaturePermissions.Keys) { %>
|
||||
<fieldset>
|
||||
<legend><%: T("{0} Module", moduleName) %></legend>
|
||||
<legend><%: T("{0} Feature", featureName) %></legend>
|
||||
<table class="items">
|
||||
<colgroup>
|
||||
<col id="Col1" />
|
||||
@@ -26,7 +26,7 @@
|
||||
<th scope="col"><%: T("Effective") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% foreach (var permission in Model.ModulePermissions[moduleName]) { %>
|
||||
<% foreach (var permission in Model.FeaturePermissions[featureName]) { %>
|
||||
<tr>
|
||||
<td><%: permission.Description %></td>
|
||||
<td style="width:60px;/* todo: (heskew) make not inline :(">
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Tags {
|
||||
@@ -8,11 +9,7 @@ namespace Orchard.Tags {
|
||||
public static readonly Permission CreateTag = new Permission { Description = "Create tag", Name = "CreateTag", ImpliedBy = new[] { ManageTags } };
|
||||
public static readonly Permission ApplyTag = new Permission { Description = "Applying a Tag", Name = "ApplyTag", ImpliedBy = new[] { ManageTags, CreateTag } };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "Tags";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Themes {
|
||||
@@ -6,11 +7,7 @@ namespace Orchard.Themes {
|
||||
public static readonly Permission ManageThemes = new Permission { Description = "Manage Themes", Name = "ManageThemes" };
|
||||
public static readonly Permission ApplyTheme = new Permission { Description = "Apply a Theme", Name = "ApplyTheme" };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "Themes";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Users {
|
||||
@@ -7,11 +8,7 @@ namespace Orchard.Users {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageUsers = new Permission { Description = "Manage users", Name = "ManageUsers" };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
return "Users";
|
||||
}
|
||||
}
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.Security.Permissions {
|
||||
/// <summary>
|
||||
@@ -6,7 +7,7 @@ namespace Orchard.Security.Permissions {
|
||||
/// the which may be granted
|
||||
/// </summary>
|
||||
public interface IPermissionProvider : IDependency {
|
||||
string ModuleName { get; }
|
||||
Feature Feature { get; }
|
||||
IEnumerable<Permission> GetPermissions();
|
||||
IEnumerable<PermissionStereotype> GetDefaultStereotypes();
|
||||
}
|
||||
|
@@ -1,4 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Security {
|
||||
@@ -6,10 +9,21 @@ namespace Orchard.Security {
|
||||
public static readonly Permission AccessAdminPanel = new Permission { Name = "AccessAdminPanel", Description = "Access admin panel" };
|
||||
public static readonly Permission AccessFrontEnd = new Permission { Name = "AccessFrontEnd", Description = "Access site front-end" };
|
||||
|
||||
public string ModuleName {
|
||||
public Feature Feature {
|
||||
get {
|
||||
// This is a lie, but it enables the permissions and stereotypes to be created
|
||||
return "Common";
|
||||
return new Feature {
|
||||
Descriptor = new FeatureDescriptor {
|
||||
Name = "Orchard.Framework",
|
||||
Category = "Core",
|
||||
Dependencies = Enumerable.Empty<string>(),
|
||||
Description = "",
|
||||
Extension = new ExtensionDescriptor {
|
||||
Name = "Orchard.Framework"
|
||||
}
|
||||
},
|
||||
ExportedTypes = Enumerable.Empty<Type>()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user