forked from OrchardCMS/OrchardCore
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Media Permissions to Media.Core (OrchardCMS#16493)
- Loading branch information
1 parent
9df8f05
commit 8366a89
Showing
5 changed files
with
82 additions
and
69 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/OrchardCore.Modules/OrchardCore.Media/PermissionProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using OrchardCore.Security.Permissions; | ||
|
||
namespace OrchardCore.Media; | ||
|
||
public sealed class PermissionProvider : IPermissionProvider | ||
{ | ||
private readonly IEnumerable<Permission> _allPermissions = | ||
[ | ||
Permissions.ManageMedia, | ||
Permissions.ManageMediaFolder, | ||
Permissions.ManageOthersMedia, | ||
Permissions.ManageOwnMedia, | ||
Permissions.ManageAttachedMediaFieldsFolder, | ||
Permissions.ManageMediaProfiles, | ||
Permissions.ViewMediaOptions, | ||
]; | ||
|
||
private readonly IEnumerable<Permission> _generalPermissions = | ||
[ | ||
Permissions.ManageOwnMedia, | ||
]; | ||
|
||
public Task<IEnumerable<Permission>> GetPermissionsAsync() | ||
=> Task.FromResult(_allPermissions); | ||
|
||
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() => | ||
[ | ||
new PermissionStereotype | ||
{ | ||
Name = OrchardCoreConstants.Roles.Administrator, | ||
Permissions = | ||
[ | ||
Permissions.ManageMediaFolder, | ||
Permissions.ManageMediaProfiles, | ||
Permissions.ViewMediaOptions, | ||
], | ||
}, | ||
new PermissionStereotype | ||
{ | ||
Name = OrchardCoreConstants.Roles.Editor, | ||
Permissions = | ||
[ | ||
Permissions.ManageMedia, | ||
Permissions.ManageOwnMedia, | ||
], | ||
}, | ||
new PermissionStereotype | ||
{ | ||
Name = OrchardCoreConstants.Roles.Author, | ||
Permissions = _generalPermissions, | ||
}, | ||
new PermissionStereotype | ||
{ | ||
Name = OrchardCoreConstants.Roles.Contributor, | ||
Permissions = _generalPermissions, | ||
}, | ||
]; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using OrchardCore.Security.Permissions; | ||
|
||
namespace OrchardCore.Media; | ||
|
||
public static class Permissions | ||
{ | ||
public static readonly Permission ManageMediaFolder = new("ManageMediaFolder", "Manage All Media Folders"); | ||
|
||
public static readonly Permission ManageOthersMedia = new("ManageOthersMediaContent", "Manage Media For Others", [ManageMediaFolder]); | ||
|
||
public static readonly Permission ManageOwnMedia = new("ManageOwnMediaContent", "Manage Own Media", [ManageOthersMedia]); | ||
|
||
public static readonly Permission ManageMedia = new("ManageMediaContent", "Manage Media", [ManageOwnMedia]); | ||
|
||
public static readonly Permission ManageAttachedMediaFieldsFolder = new("ManageAttachedMediaFieldsFolder", "Manage Attached Media Fields Folder", [ManageMediaFolder]); | ||
|
||
public static readonly Permission ManageMediaProfiles = new("ManageMediaProfiles", "Manage Media Profiles"); | ||
|
||
public static readonly Permission ViewMediaOptions = new("ViewMediaOptions", "View Media Options"); | ||
} |