Dashboard with login

Hi

I am trying to create a dashboard with a page that you can see anonymously (without being prompted for user) and a page that only is visible when logged in. I have not found any documentation on how to achieve this. I have this little sample below, but it prompts for username before i can see anything

I am using a licensed version 2.9.0 UDDashboard

$Page1 = New-UDPage -Name 'Page 1' -Icon home -Content {
    New-UDHtml -Markup "Page 1 - Allow for all"
}

$Page2 = New-UDPage -Name 'Page 2' -Icon home -AuthorizedRole "admin" -Content {
    New-UDHtml -Markup "Page 2 - Only available when logged in"
}

$AuthenticationMethod = New-UDAuthenticationMethod -Endpoint {
    param([PSCredential]$Credentials)
	$Role = ""
	if ($Credentials.UserName -eq "admin") {
		$Role = "admin"
	}
    # testing: always return true
    return New-UDAuthenticationResult -Success -UserName $Credentials.UserName -Role $Role
}
$LoginPage = New-UDLoginPage -AuthenticationMethod $AuthenticationMethod -WelcomeText "Universal Dashboard Authentication Test"


$Dashboard = New-UDDashboard -Title "Hello, World" -Pages @($Page1, $Page2) -LoginPage $LoginPage -Theme $Theme

Get-UDDashboard | Stop-UDDashboard
Start-UDDashboard -Port 80 -Dashboard $Dashboard -AllowHttpForLogin

This currently isn’t possible for 2.9 but is a feature are targeting for 3.0.

1 Like