Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Last active February 7, 2020 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamdriscoll/09ec6fdf54e87a3140bbdc0230899747 to your computer and use it in GitHub Desktop.
Save adamdriscoll/09ec6fdf54e87a3140bbdc0230899747 to your computer and use it in GitHub Desktop.
Creating a login page for Universal Automation
$AuthMethod = New-UDAuthenticationMethod -Endpoint {
param([pscredential]$Credential)
New-UDAuthenticationResult -Success -UserName $Credential.UserName
}
$AuthPolicy = New-UDAuthorizationPolicy -Name "Policy" -Endpoint {
param($ClaimsPrincipal)
$UserName = $ClaimsPrincipal.Identity.Name
$Session:UserRole = ""
$Identity = Get-UAIdentity -Name $UserName
if ($Identity -eq $null)
{
if ($UserName -eq 'OperatorFred')
{
$Role = Get-UARole -Name "Operator"
$Identity = New-UAIdentity -Name $UserName -Role $Role
$Session:UserRole = "Operator"
}
elseif ($UserName -eq 'ReaderJane')
{
$Role = Get-UARole -Name "Reader"
$Identity = New-UAIdentity -Name $UserName -Role $Role
$Session:UserRole = "Reader"
}
else
{
$Role = Get-UARole -Name "Administrator"
$Identity = New-UAIdentity -Name $UserName -Role $Role
$Session:UserRole = "Administrator"
}
}
$Session:AppToken = (Grant-UAAppToken -Identity $Identity).Token
$true
}
$LoginPage = New-UDLoginPage -AuthenticationMethod $AuthMethod -AuthorizationPolicy $AuthPolicy
$Dashboard = New-UADashboard
$Dashboard.LoginPage = $LoginPage
Start-UDDashboard -Dashboard $Dashboard -Port 10001 -AdminMode -AllowHttpForLogin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment