Only allow administrator users to see the Skybrud Redirect Dashboard and Content App

Hello folks

Currently I’m having a task on a v13.9 site where I need to hide the built in Redirect Dashboard (Umbraco’s own to handle internal 301 redirects) and also the Skybrud Redirects Dashboard.

Following the documentation I managed to hide the built in dashboard using this code

public class DashboardDefaultSettings : IComposer 
{ 	
	public void Compose(IUmbracoBuilder builder) 	
	{ 		
		// Unregister Umbraco's Redirect Url Dashboard 		
		builder.Dashboards().Remove<RedirectUrlDashboard>();  		
		// Re-register Umbraco's Redirect Url Dashboard using an override 		
		builder.Dashboards().Add<RedirectUrlDashboardOverride>(); 	
	} 
}
public class RedirectUrlDashboardOverride : RedirectUrlDashboard, IDashboard 
{ 	
	IAccessRule[] IDashboard.AccessRules { get; } = new IAccessRule[] 	
	{ 		
		new AccessRule {Type = AccessRuleType.Grant, Value = Constants.Security.AdminGroupAlias} 	
	}; 
}

This is all good and works like a charm I only see the Dashboard whenever I’m logged in as an administrator.

However I can’t seem to figure out how to do the same with the Skybrud Redirects Dashboard - I have been reading this thread on Discord Hide Skybrud Redirects dashboard from custom user group Umbraco #help-with-umbraco

But I can’t seem to add the Skybrud namespace in my Composer, like it’s showcased in the examples and the Skybrud Redirects documentation. According to ChatGPT a recent change in Skybrud v13 means that the Class is now internal and therefore can’t be reached as usual.

So I’m wondering if there is another way around this? I have not been able to figure it out - Also I’m usually a frontend developer so I’m a bit out of my comfort zone here and I might have gotten things in the wrong order… Who knows :slight_smile:

/Jan

Hey Jan,

This should work tested on Umbraco 13.10 and Skybrud 13.0.8

Are you in a “Core” project or in the website project? You might need to add the nuget dependency to the Core project if thats the case.


using Skybrud.Umbraco.Redirects.Dashboards;
using Skybrud.Umbraco.Redirects.Helpers;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Dashboards;
using Umbraco.Cms.Core.DependencyInjection;

namespace Project;

public class Composer :  IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        //Replace SkyBrud Dashboard
        builder.Dashboards().Remove<RedirectsDashboard>();
        builder.Dashboards().Add<RedirectsDashboardOverride>();

        //Replace Umbraco Dashboard
        builder.Dashboards().Remove<RedirectUrlDashboard>();
        builder.Dashboards().Add<RedirectUrlDashboardOverride>();
    }
}


public class RedirectUrlDashboardOverride : RedirectUrlDashboard, IDashboard
{
    IAccessRule[] IDashboard.AccessRules { get; } = new IAccessRule[]
    {
        new AccessRule {Type = AccessRuleType.Grant, Value = Constants.Security.AdminGroupAlias}
    };
}


public class RedirectsDashboardOverride : RedirectsDashboard, IDashboard
{
    public RedirectsDashboardOverride(RedirectsBackOfficeHelper backoffice) : base(backoffice)
    {
    }

    IAccessRule[] IDashboard.AccessRules { get; } = new IAccessRule[]
    {
        new AccessRule {Type = AccessRuleType.Grant, Value = Constants.Security.AdminGroupAlias}
    };
}

Hope this helps
Matt

1 Like

Hi Matt

Thanks for chiming in - Yes, you’re right I totally forgot about adding the project to my Core project - Works like a charm. Thanks!

/Jan