Authorization Policy Help

Trying to use an Authorization policy and its not working.

As soon as I use the -AuthorizationPolicy “Login” switch on the $Page1 definition the dashboard fails to load after logging in.

If I remove the -AuthorizationPolicy “Login” I login via Azure and the Dashboard loads fine.

Debug log shows this.
12:19:31 [Info] Microsoft.AspNetCore.Mvc.Infrastructure.ContentResultExecutor Executing ContentResult with HTTP Response ContentType of text/css
12:19:31 [Info] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker Executed action UniversalDashboard.Controllers.DashboardController.Theme (UniversalDashboard) in 1.8749ms
12:19:31 [Info] Microsoft.AspNetCore.Hosting.Internal.WebHost Request finished in 6.1859ms 200 text/css
12:19:31 [Info] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker Route matched with {action = “Index”, controller = “Dashboard”, area = “”, page = “”}. Executing action UniversalDashboard.Controllers.DashboardController.Index (UniversalDashboard)
12:19:31 [Info] Microsoft.AspNetCore.Authorization.DefaultAuthorizationService Authorization was successful.
12:19:31 [Info] Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker Executing action method UniversalDashboard.Controllers.DashboardController.Index (UniversalDashboard) - Validation state: Valid
12:19:31 [Debug] DashboardController Index
12:19:31 [Debug] AuthorizationService Authorization policies present.
12:19:31 [Debug] AuthorizationService Checking page Page One.
12:19:31 [Debug] AuthorizationService Page authorized.
12:19:31 [Debug] AuthorizationService Checking page Page Two.
12:19:31 [Debug] AuthorizationService Checking policy Login.
12:19:36 [Debug] Quartz.Core.QuartzSchedulerThread Batch acquisition of 0 triggers

then just repeats the last line.

Heres my code. (sensitive bits removed)

Import-Module UniversalDashboard


$Page1 = New-UDPage -Name "Page One" -Icon mail_bulk -Content { 
  New-UDCard -Title "Some Data" -Content {
  } 
}

$Page2 = New-UDPage -Name "Page Two" -Icon home  -AuthorizationPolicy "Login" -Content { 
  New-UDCard -Title "Same Data" -Endpoint {
  } 
}

$Certificate = (Get-ChildItem -Path Cert:\LocalMachine\My\<REDACTED>)

$AzureADParams = @{
  ClientID = '<REDACTED>'
  Instance = '<REDACTED>'
  Domain   = '<REDACTED>'
  TenantID = '<REDACTED>'
}

$AuthenticationMethod = New-UDAuthenticationMethod @AzureADParams

$AuthPolicy = New-UDAuthorizationPolicy -Name "Login" -Endpoint {
  $true
}

$LoginPage = New-UDLoginPage -AuthenticationMethod $AuthenticationMethod -AuthorizationPolicy $AuthPolicy

$ServiceOps = New-UDDashboard -Title "ServiceOps" -Pages @($Page1, $Page2) -LoginPage $LoginPage 

Enable-UDLogging -Level Debug -Console
Start-UDDashboard -Port 443 -Dashboard $ServiceOps -Name "ServiceOps" -Certificate $Certificate -AutoReload

Seems like this should work and should definitely not be a white page. I’ll validate when I have some time today.

Can you do me a favor and switch the order of your pages when you add them to the New-UDDashboard -Pages parameter?

@($Page2, $Page1)

I know it sounds weird but I have a hunch.

Could you also check your browser’s developer tools for errors? You can press F12 in your browser to pop that open.

Switching the order made no difference and nothing in the developer tools is indicating an error. It just shows the page load waiting on a fetch of dashboard.

Any more I can do to debug this?

Can you validate which version of UD you are running? I just tried this on our nightly build and it’s working. That’d said my log messages are a bit different so I wonder which version you are running.

07:36:35 [Debug] DashboardController Index
07:36:35 [Debug] AuthorizationService Authorization policies present.
07:36:35 [Debug] AuthorizationService Checking page Page One.
07:36:35 [Debug] AuthorizationService Checking policy Login.
07:36:35 [Debug] AuthorizationService Policy successful. Breaking.
07:36:35 [Debug] AuthorizationService Page authorized.
07:36:35 [Debug] AuthorizationService Checking page Page Two.
07:36:35 [Debug] AuthorizationService Checking policy Login.
07:36:35 [Debug] AuthorizationService Policy successful. Breaking.
07:36:35 [Debug] AuthorizationService Page authorized.

ok I was on 2.4.1 Once I installed and installed 2.5.3 it started working. I guess ill have to throw an update script into my development environment.

Thanks.

1 Like

Ok. That’s good news. Thanks, Andrew.