Hi
I need some help and inspiration on how the Authentication and Authorization is supposed to be implemented in Universal Automation & Dashboard hosted in IIS. Especially with the app tokens.
Our goal is to have a forms-based login on Universal Dashboard backed by a Windows Active Directory.
I’ve studyed the examples on the docs page, but they have different concepts:
- [sample-script](https:/ /docs.universalautomation.io/sample-script)
- [authentication](https:/ /docs.universalautomation.io/dashboard/authentication)
Automation part hosted in IIS, reachable as powershell-api.company.com:
$uaServerSplat = @{
ConnectionString = 'C:\PathToDatabase\database.db'
RepositoryPath = 'C:\PathToRepository'
GitRemote = 'https://remote/repo.git'
GitRemoteCredential = $cred
JwtSigningKey = 'some-very-long-key'
JwtAudience = 'Universal Automation'
JwtIssuer = 'Company'
InProcess = $true
}
Start-UAServer @uaServerSplat
Dashboard part hosted in IIS, reachable as powershell.company.com:
Connect-UAServer -ComputerName 'https:/ /powershell-api.company.com'
$dashboard = New-UADashboard -ComputerName 'https:/ /powershell-api.company.com'
$authMethod = New-UDAuthenticationMethod -Endpoint {
param ([PSCredential] $Credential)
if (Test-Credential -Credential $Credential -Method 'ActiveDirectory' -Quiet)
{
# If the test credentail cmdlet against active directory was
# successful, get direct group members of the user and check if he
# has the necessary role group.
$groups = Get-ADUser -Identity $Credential.Username -Credential $Credential -Properties 'MemberOf' |
Select-Object -ExpandProperty 'MemberOf' |
ForEach-Object { $_.Split('=,')[1] }
if ($groups -contains 'Automation Administrators')
{
$role = 'Administrator'
}
elseif ($groups -contains 'Automation Operators')
{
$role = 'Operator'
}
elseif ($groups -contains 'Automation Readers')
{
$role = 'Reader'
}
else
{
New-UDAuthenticationResult -ErrorMessage 'Missing user group assignment.'
return
}
# Will not work ???
$appToken = Grant-UAAppToken -IdentityName $Credential.Username -Role $role
}
else
{
New-UDAuthenticationResult -ErrorMessage 'Wrong username or password.'
return
}
}
$dashboard.LoginPage = New-UDLoginPage -AuthenticationMethod $authMethod
Start-UDDashboard -Dashboard $dashboard -AllowHttpForLogin -Wait
My problem starts with this:
As I’ve created the first app token, the API will switch to authenticated. After that, the dashboard itself doesn’t have the option to get and grand new token -> access denied. So how should I authenticate the Dashboard against the Automation? Must I first initially create a System AppToken and speify it in the dashboard all the time we use the api?
Kind Regards
Claudio Spizzi