Skip to content

Commit

Permalink
Merge pull request #744 from psah434/pallavisah/passwordbox
Browse files Browse the repository at this point in the history
Pallavisah/passwordbox
  • Loading branch information
psah434 authored Jun 5, 2023
2 parents 6b75cb7 + 695bfa5 commit fdf592b
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@ $passwordBoxes = $CreateUIDefinitionObject |
foreach ($pwb in $passwordBoxes) { # Loop over each password box
$controlName = $pwb.Name # and find the output it maps to.
$theOutput = foreach ($out in $CreateUIDefinitionObject.parameters.outputs.psobject.properties) {
if (($out.Value -like "*steps(*$controlName*") -or ($out.Value -like "*basics(*$controlName*")) {
$out; break
$outputValueType = $out.Value.GetType().Name
if ($outputValueType -eq "PSCustomObject") {
$outputJson = $out.Value | ConvertTo-Json -Compress
if (($outputJson -like "*steps(*$controlName*") -or ($outputJson -like "*basics(*$controlName*")) {
$out; break
}
}
else {
if (($out.Value -like "*steps(*$controlName*") -or ($out.Value -like "*basics(*$controlName*")) {
$out; break
}
}
}

Expand All @@ -39,13 +48,13 @@ foreach ($pwb in $passwordBoxes) { # Loop over each password box

# If we couldn't find it, write an error.
if (-not $MainTemplateParam) {
Write-Error "Password box $($pwb.Name) is missing from main template parameters "-TargetObject $pwb
Write-Error "Password box $($pwb.Name) linked to output $($theOutput.Name) is missing from main template parameters "-TargetObject $pwb
continue
}

# If the main template parameter type is neither a Secure String nor a Secure Object
if (($MainTemplateParam.type -ne 'SecureString') -and ($MainTemplateParam.type -ne 'SecureObject')) {
# write an error.
Write-Error "PasswordBox controls must use secureString or secureObject parameter types. The Main template parameter '$($pwb.Name)' is a '$($MainTemplateParam.type)'" -TargetObject @($pwb, $MainTemplateParam)
Write-Error "PasswordBox controls must use secureString or secureObject parameter types. The Main template parameter '$($theOutput.Name)' linked to '$($pwb.Name)' is a '$($MainTemplateParam.type)'" -TargetObject @($pwb, $MainTemplateParam)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location."
}
},
"certificates": {
"type": "object",
"defaultValue": [
{
"password": "password"
}
],
"metadata": {
"description": "Backend data."
}
}
},
"variables": {
},
"resources": [
],
"outputs": {
"location": {
"type": "string",
"value": "[parameters('location')]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{
"name": "settings",
"label": "Settings",
"bladeTitle": "Settings",
"elements": [
{
"type": "Microsoft.Common.Section",
"name": "section",
"label": "Section Settings",
"visible": "true",
"elements": [
{
"type": "Microsoft.Common.PasswordBox",
"name": "passwordBox",
"label": {
"password": "Password",
"confirmPassword": "Confirm password"
},
"toolTip": "Password for password box",
"visible": true,
"constraints": {
"required": true,
"regex": "^[\\S]{10,25}$",
"validationMessage": "Password must be between 10 and 25 characters."
},
"options": {
"hideConfirmation": false
}
}
]
}
]
}
],
"outputs": {
"Location": "[location()]",
"certificates": {
"0": {
"password": "[coalesce(steps('settings').section.passwordBox, 'NA')]"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location."
}
},
"certificates": {
"type": "secureObject",
"defaultValue": [
{
"password": "password"
}
],
"metadata": {
"description": "Backend data."
}
}
},
"variables": {
},
"resources": [
],
"outputs": {
"location": {
"type": "string",
"value": "[parameters('location')]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{
"name": "settings",
"label": "Settings",
"bladeTitle": "Settings",
"elements": [
{
"type": "Microsoft.Common.Section",
"name": "section",
"label": "Section Settings",
"visible": "true",
"elements": [
{
"type": "Microsoft.Common.PasswordBox",
"name": "passwordBox",
"label": {
"password": "Password",
"confirmPassword": "Confirm password"
},
"toolTip": "Password for password box",
"visible": true,
"constraints": {
"required": true,
"regex": "^[\\S]{10,25}$",
"validationMessage": "Password must be between 10 and 25 characters."
},
"options": {
"hideConfirmation": false
}
}
]
}
]
}
],
"outputs": {
"Location": "[location()]",
"certificates": {
"0": {
"password": "[coalesce(steps('settings').section.passwordBox, 'NA')]"
}
}
}
}
}

0 comments on commit fdf592b

Please sign in to comment.