Skip to content

Commit 0fccbdb

Browse files
Add isolated MSAL WAM authentication (#42)
* Update curated website materials * Add isolated MSAL WAM authentication * Address WAM review feedback * Address WAM login hint review * Skip signing when build certificate is unavailable * Prompt when WAM account is ambiguous * Clarify settings example wording * Address WAM cache reuse feedback * Fix WAM tenant-scoped broker cache * Refactor nested helpers into private functions * Simplify signing certificate build config * Use direct signing configuration * Use refresh-only PSD1 build mode
1 parent b5b6736 commit 0fccbdb

93 files changed

Lines changed: 2411 additions & 1866 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Build/BuildModule.ps1

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,26 @@
7676
New-ConfigurationFormat -ApplyTo 'DefaultPSD1', 'OnMergePSD1' -PSD1Style 'Minimal'
7777

7878
# configuration for documentation, at the same time it enables documentation processing
79-
New-ConfigurationDocumentation -Enable:$false -StartClean -UpdateWhenNew -PathReadme 'Docs\Readme.md' -Path 'Docs'
79+
New-ConfigurationDocumentation -Enable:$false -PathReadme 'Docs\Readme.md' -Path 'Docs'
8080

81-
New-ConfigurationImportModule -ImportSelf -ImportRequiredModules
81+
New-ConfigurationImportModule -ImportSelf -ImportRequiredModules -SkipBinaryConflictAnalysis
8282

8383
$newConfigurationBuildSplat = @{
8484
Enable = $true
8585
SignModule = $true
86+
CertificateThumbprint = '483292C9E317AA13B07BB7A96AE9D1A5ED9E7703'
8687
DeleteTargetModuleBeforeBuild = $true
8788
MergeModuleOnBuild = $true
88-
CertificateThumbprint = '483292C9E317AA13B07BB7A96AE9D1A5ED9E7703'
8989
DoNotAttemptToFixRelativePaths = $true
9090
MergeFunctionsFromApprovedModules = $true
9191
RefreshPSD1Only = $true
92+
NETProjectPath = "$PSScriptRoot\..\Sources\O365Essentials.Auth\O365Essentials.Auth.csproj"
93+
NETProjectName = 'O365Essentials.Auth'
94+
NETFramework = @('net8.0')
95+
NETBinaryModule = @('O365Essentials.Auth.dll')
96+
NETBinaryModuleCmdletScanDisabled = $true
97+
NETAssemblyLoadContext = $true
98+
NETHandleRuntimes = $true
9299
}
93100
New-ConfigurationBuild @newConfigurationBuildSplat
94101

@@ -98,4 +105,4 @@
98105
# global options for publishing to github/psgallery
99106
#New-ConfigurationPublish -Type PowerShellGallery -FilePath 'C:\Support\Important\PowerShellGalleryAPI.txt' -Enabled:$true
100107
#New-ConfigurationPublish -Type GitHub -FilePath 'C:\Support\Important\GitHubAPI.txt' -UserName 'EvotecIT' -Enabled:$true
101-
} -ExitCode
108+
} -ExitCode

O365Essentials.psd1

Lines changed: 28 additions & 28 deletions
Large diffs are not rendered by default.

Private/Add-CookieMapToSession.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function Add-CookieMapToSession {
2+
[cmdletbinding()]
3+
param(
4+
[Parameter(Mandatory)][Microsoft.PowerShell.Commands.WebRequestSession] $Session,
5+
[Parameter(Mandatory)][System.Collections.IDictionary] $CookieMap,
6+
[Parameter(Mandatory)][string] $Domain
7+
)
8+
9+
foreach ($Entry in @($CookieMap.GetEnumerator())) {
10+
$CookieName = [string] $Entry.Key
11+
$CookieValue = [string] $Entry.Value
12+
if ([string]::IsNullOrWhiteSpace($CookieName) -or [string]::IsNullOrWhiteSpace($CookieValue)) {
13+
continue
14+
}
15+
Add-CookieToSession -Session $Session -Name $CookieName -Value $CookieValue -Domain $Domain
16+
}
17+
}

Private/Add-CookieToSession.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function Add-CookieToSession {
2+
[cmdletbinding()]
3+
param(
4+
[Parameter(Mandatory)][Microsoft.PowerShell.Commands.WebRequestSession] $Session,
5+
[Parameter(Mandatory)][string] $Name,
6+
[Parameter(Mandatory)][string] $Value,
7+
[Parameter(Mandatory)][string] $Domain
8+
)
9+
10+
$Cookie = [System.Net.Cookie]::new($Name, $Value, '/', $Domain)
11+
$Session.Cookies.Add($Cookie)
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function Convert-CookieHeaderToMap {
2+
[cmdletbinding()]
3+
param(
4+
[Parameter(Mandatory)][string] $Header
5+
)
6+
7+
$Parsed = [ordered] @{}
8+
foreach ($Pair in ($Header -split ';')) {
9+
$TrimmedPair = $Pair.Trim()
10+
if ([string]::IsNullOrWhiteSpace($TrimmedPair)) {
11+
continue
12+
}
13+
$KeyValue = $TrimmedPair -split '=', 2
14+
if ($KeyValue.Count -lt 2) {
15+
continue
16+
}
17+
$Parsed[$KeyValue[0].Trim()] = $KeyValue[1].Trim()
18+
}
19+
$Parsed
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function Convert-CookieListToMap {
2+
[cmdletbinding()]
3+
param(
4+
[Parameter(Mandatory)][System.Collections.IEnumerable] $Cookies
5+
)
6+
7+
$Parsed = [ordered] @{}
8+
foreach ($Cookie in $Cookies) {
9+
if ($null -eq $Cookie) {
10+
continue
11+
}
12+
13+
$CookieName = Get-MappedPortalValue -Source $Cookie -Names @('Name', 'name')
14+
if ([string]::IsNullOrWhiteSpace($CookieName)) {
15+
continue
16+
}
17+
18+
$CookieValue = Get-MappedPortalValue -Source $Cookie -Names @('Value', 'value')
19+
$Parsed[$CookieName] = $CookieValue
20+
}
21+
$Parsed
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function Convert-PortalSourceToMap {
2+
[cmdletbinding()]
3+
param(
4+
[Parameter(Mandatory)] $Source
5+
)
6+
7+
$Parsed = [ordered] @{}
8+
if ($Source -is [System.Collections.IDictionary]) {
9+
foreach ($Key in $Source.Keys) {
10+
$Parsed[[string] $Key] = $Source[$Key]
11+
}
12+
return $Parsed
13+
}
14+
15+
if ($Source.PSObject -and $Source.PSObject.Properties) {
16+
foreach ($Property in $Source.PSObject.Properties) {
17+
if ($Property.MemberType -notin 'NoteProperty', 'Property') {
18+
continue
19+
}
20+
$Parsed[$Property.Name] = $Property.Value
21+
}
22+
}
23+
$Parsed
24+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function ConvertTo-BoolOrDefault {
2+
[cmdletbinding()]
3+
param(
4+
[string] $Value,
5+
[bool] $Default = $false
6+
)
7+
8+
if ([string]::IsNullOrWhiteSpace($Value)) {
9+
return $Default
10+
}
11+
12+
switch -Regex ($Value.Trim()) {
13+
'^(1|true|yes|y|on)$' { return $true }
14+
'^(0|false|no|n|off)$' { return $false }
15+
default { return $Default }
16+
}
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function ConvertTo-MicrosoftEdgeDeviceSummary {
2+
[cmdletbinding()]
3+
param(
4+
[Parameter(Mandatory)] $DeviceResult
5+
)
6+
7+
[PSCustomObject] @{
8+
Count = $DeviceResult.'@odata.count'
9+
Sample = @($DeviceResult.value)
10+
RawSettings = $DeviceResult
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function Copy-AuthorizationState {
2+
[cmdletbinding()]
3+
param(
4+
[System.Collections.IDictionary] $Source
5+
)
6+
7+
$Clone = [ordered] @{}
8+
if ($Source) {
9+
foreach ($Entry in @($Source.GetEnumerator())) {
10+
$Clone[$Entry.Key] = $Entry.Value
11+
}
12+
}
13+
$Clone
14+
}

0 commit comments

Comments
 (0)