Last active
February 7, 2020 15:53
-
-
Save adamdriscoll/09ec6fdf54e87a3140bbdc0230899747 to your computer and use it in GitHub Desktop.
Creating a login page for Universal Automation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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