Private/BrowserAuthPages.ps1
|
function Get-InTUIBrowserAuthPurpose { [CmdletBinding()] param() return @('Authentication', 'PimActivation', 'PimDeactivation') } function Assert-InTUIBrowserAuthPurpose { [CmdletBinding()] param( [Parameter(Mandatory)] [string]$Purpose ) if ($Purpose -notin (Get-InTUIBrowserAuthPurpose)) { throw "Invalid browser auth purpose '$Purpose'." } } function Get-InTUIBrowserAuthPageContent { [CmdletBinding()] param( [Parameter(Mandatory)] [ValidateSet('Success', 'Error')] [string]$Type, [Parameter()] [string]$Purpose = 'Authentication' ) Assert-InTUIBrowserAuthPurpose -Purpose $Purpose $defaultError = @{ Title = 'Authentication Failed - InTUI' Heading = 'Authentication Failed' Message = 'Please close this window and try again.' } $pages = @{ Authentication = @{ Success = @{ Title = 'Authentication Successful - InTUI' Heading = 'Authentication Successful' Message = 'You can close this window and return to PowerShell.' } Error = $defaultError } PimActivation = @{ Success = @{ Title = 'PIM Activation Successful - InTUI' Heading = 'PIM Activation Successful' Message = 'Your elevated session was refreshed. You can close this window and return to InTUI.' } Error = $defaultError } PimDeactivation = @{ Success = @{ Title = 'PIM Deactivation Successful - InTUI' Heading = 'PIM Deactivation Successful' Message = 'Your reduced-privilege session was refreshed. You can close this window and return to InTUI.' } Error = $defaultError } } return [pscustomobject]$pages[$Purpose][$Type] } function Get-InTUIBrowserAuthHtml { [CmdletBinding()] param( [Parameter(Mandatory)] [ValidateSet('Success', 'Error')] [string]$Type, [Parameter()] [string]$Purpose = 'Authentication' ) Assert-InTUIBrowserAuthPurpose -Purpose $Purpose $isSuccess = $Type -eq 'Success' $content = Get-InTUIBrowserAuthPageContent -Type $Type -Purpose $Purpose $background = if ($isSuccess) { 'linear-gradient(135deg, #1e66f5 0%, #209fb5 100%)' } else { 'linear-gradient(135deg, #d20f39 0%, #fe640b 100%)' } $symbol = if ($isSuccess) { '✓' } else { '✕' } $logo = @' ██╗███╗ ██╗████████╗██╗ ██╗██╗ ██║████╗ ██║╚══██╔══╝██║ ██║██║ ██║██╔██╗ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║ ██║ ██║ ██║██║ ██║██║ ╚████║ ██║ ╚██████╔╝██║ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═════╝ ╚═╝ '@ return @" <html> <head> <meta charset='UTF-8'> <title>$($content.Title)</title> <style> body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: $background; } .container { text-align: center; color: white; } .brand { font-size: 14px; letter-spacing: 4px; margin-bottom: 22px; opacity: 0.9; } .version { font-size: 12px; opacity: 0.7; } .logo { display: inline-block; margin: 0 0 18px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; font-size: clamp(10px, 2vw, 18px); line-height: 1.05; letter-spacing: 0; text-align: left; white-space: pre; text-shadow: 0 8px 30px rgba(0, 0, 0, 0.22); } .tagline { margin: 0 0 26px 0; opacity: 0.82; font-size: 15px; } .icon { font-size: 52px; margin-bottom: 18px; } h1 { margin: 0 0 10px 0; font-weight: 300; font-size: 28px; } p { margin: 0; opacity: 0.9; font-size: 16px; } </style> </head> <body> <div class='container'> <div class='brand'>[ I N T U I ] <span class='version'>v$script:InTUIVersion</span></div> <pre class='logo'>$logo</pre> <p class='tagline'>Intune Terminal User Interface</p> <div class='icon'>$symbol</div> <h1>$($content.Heading)</h1> <p>$($content.Message)</p> </div> </body> </html> "@ } |