question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to 'specify permissions' on an Umbraco dashboard?

See original GitHub issue

I found the documentation for managing dashboards. It is not helpful for my task. I need to hide the Redirect URL Management dashboard from users in the Writers group. (It seems like a bug that it shows for them!) In other words, I need to ‘specify permissions’ on an Umbraco (built-in) dashboard. The docs do not cover this important task. They only show how to remove an Umbraco dashboard. I cannot remove the Redirect URL Management dashboard, because Administrators use it.

I tried putting a package.manifest in the App_Plugins folder; however, I do not know the alias of the Redirect URL Management dashboard.

I found the Redirect URL Management view, but I could not easily track down its alias.

{
    "dashboards":  [
        {
            "alias": "redirectUrls",
            "sections": [ "content"],
            "access": [
                { "deny": "writer" },
                { "grant": "admin" }
            ]
        }
    ]
}

In v7, its alias was RedirectUrlManagement. In early v8, it appears it was RedirectUrlDashboard. In the aforementioned documentation, it only references its language key, which is dashboardTabs/contentRedirectManager.

Sadly, once again, something that was dead simple in v7 is complicated and poorly documented. Any help would be greatly appreciated.


This item has been added to our backlog AB#5462

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:29 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
lcichanowiczcommented, Mar 3, 2020

Thanks, @Shazwazza! I express my gratitude with a PR.

https://github.com/umbraco/UmbracoDocs/pull/2335

1reaction
Shazwazzacommented, Mar 2, 2020

This should work:

public class MyComposer : IComposer
{
    public void Compose(Composition composition)
    {
        composition.Dashboards()
            // Remove the default
            .Remove<RedirectUrlDashboard>()
            // Add the overridden one
            .Add<MyRedirectUrlDashboard>();
    }
}

// overridden redirect dashboard with custom rules
public class MyRedirectUrlDashboard : RedirectUrlDashboard, IDashboard
{
    // override explicit implementation
    IAccessRule[] IDashboard.AccessRules { get; } = new IAccessRule[]
    {
        new AccessRule {Type = AccessRuleType.Deny, Value = "writer"},
        new AccessRule {Type = AccessRuleType.Grant, Value = Umbraco.Core.Constants.Security.AdminGroupAlias}
    };
}

Can this be easier? Yes! Ideally the interface for IDashboard could have allowed a mutable collection for access rules but unfortunately thats not the case otherwise it would have been reasonably easy. The IAccessRule themselves is mutable but that doesn’t solve this problem of adding/removing rules from the dashboard definition.

We could allow adding custom filters to override rules which could look something like:

public class MyComposer : IComposer
{
    public void Compose(Composition composition)
    {
        composition.Dashboards()
            .Modify<RedirectUrlDashboard>(new IAccessRule[]
            {
                new AccessRule {Type = AccessRuleType.Deny, Value = "writer"},
                new AccessRule {Type = AccessRuleType.Grant, Value = Umbraco.Core.Constants.Security.AdminGroupAlias}
            });
    }
}

The Modify method could also allow modifying the sections.

Some things in v8 had to be rebuilt, things that relied on the legacy configuration patterns and configuration ‘provider’ models. The config first approach is legacy because it is inflexible, error prone, doesn’t allow for modern coding standards, etc… With these components rebuilt the way they are, it is certainly possible to re-add configuration back in where it makes sense. We didn’t remove file based configuration just to be annoying, it was just re-added for the 8.0 release since we need to gauge the requirement for it and whether/where it makes sense.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grant permissions in dashboard.config
config file are set to grant/deny via the old (version of Umbraco) permissions: administrator; Editor; Writer; Translator. How can I grant ...
Read more >
Dashboards - Umbraco CMS
This is done by setting the 'access' permissions based on the User Group alias, you choose to deny or grant a particular User...
Read more >
restrict which users can see simpleredirect dashboard
In V8 you can specify which user groups can access a 'dashboard' via two ... .com/Documentation/Extending/Dashboards/#specifying-permissions.
Read more >
Permission based Umbraco dashboards
var permissions = _userService.GetPermissions(user, path);. For us, we need the current user, and as we are working with a dashboard ...
Read more >
Extending the umbraco dashboard
The element makes it possible to set permissions on sections, tabs and controls and you can either grant or deny certain usertypes access....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found