Skip to content

Commit d112b93

Browse files
adding "-AT PoP" option to "Set-MgGraphOptions"
1 parent 31f1a58 commit d112b93

File tree

9 files changed

+65
-5
lines changed

9 files changed

+65
-5
lines changed

docs/authentication.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ When using `-AccessToken`, we won't have access to the refresh token and the cli
112112

113113
Before using the provided `-AccessToken` to get Microsoft Graph resources, customers should ensure that the access token has the necessary scopes/ permissions needed to access/modify a resource.
114114

115+
### Access Token Proof of Possession (AT PoP)
116+
117+
AT PoP is a security mechanism that binds an access token to a cryptographic key that only the intended recipient has. This prevents unauthorized use of the token by malicious actors. AT PoP enhances data protection, reduces token replay attacks, and enables fine-grained authorization policies.
118+
119+
Microsoft Graph PowerShell module supports AT PoP in the following scenario:
120+
121+
- To enable AT PoP on supported devices
122+
123+
```PowerShell
124+
Set-MgGraphOption -EnableATPoP $true
125+
```
126+
127+
- To disable AT PoP on supported devices
128+
129+
```PowerShell
130+
Set-MgGraphOption -EnableATPoP $false
131+
```
132+
115133
## Web Account Manager (WAM)
116134

117135
WAM is a Windows 10+ component that acts as an authentication broker allowing the users of an app benefit from integration with accounts known to Windows, such as the account already signed into an active Windows session.

src/Authentication/Authentication.Core/Interfaces/IGraphOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ namespace Microsoft.Graph.PowerShell.Authentication
1111
public interface IGraphOption
1212
{
1313
bool EnableWAMForMSGraph { get; set; }
14+
bool EnableATPoPForMSGraph { get; set; }
1415
}
1516
}

src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
<ItemGroup>
1414
<PackageReference Include="Azure.Identity" Version="1.10.3" />
1515
<PackageReference Include="Azure.Identity.Broker" Version="1.0.0-beta.5" />
16+
<PackageReference Include="Azure.Identity.BrokeredAuthentication" Version="1.0.0-beta.3" />
1617
<PackageReference Include="Microsoft.Graph.Core" Version="3.0.9" />
18+
<PackageReference Include="Microsoft.Identity.Client" Version="4.56.0" />
19+
<PackageReference Include="Microsoft.Identity.Client.Broker" Version="4.56.0" />
1720
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1821
</ItemGroup>
1922
<Target Name="CopyFiles" AfterTargets="Build">

src/Authentication/Authentication/Cmdlets/SetMgGraphOption.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public class SetMgGraphOption : PSCmdlet
1313
{
1414
[Parameter]
1515
public bool EnableLoginByWAM { get; set; }
16+
17+
[Parameter]
18+
public bool EnableATPoP { get; set; }
1619

1720
protected override void BeginProcessing()
1821
{
@@ -27,6 +30,11 @@ protected override void ProcessRecord()
2730
GraphSession.Instance.GraphOption.EnableWAMForMSGraph = EnableLoginByWAM;
2831
WriteDebug($"Signin by Web Account Manager (WAM) is {(EnableLoginByWAM ? "enabled" : "disabled")}.");
2932
}
33+
if (this.IsParameterBound(nameof(EnableATPoP)))
34+
{
35+
GraphSession.Instance.GraphOption.EnableATPoPForMSGraph = EnableATPoP;
36+
WriteDebug($"Access Token Proof of Posession (AT-PoP) is {(EnableATPoP ? "enabled" : "disabled")}.");
37+
}
3038
File.WriteAllText(Constants.GraphOptionsFilePath, JsonConvert.SerializeObject(GraphSession.Instance.GraphOption, Formatting.Indented));
3139
}
3240

src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft
55
#
6-
# Generated on: 21/09/2023
6+
# Generated on: 12/28/2023
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = './Microsoft.Graph.Authentication.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.6.1'
15+
ModuleVersion = '2.11.1'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core', 'Desktop'

src/Authentication/Authentication/Models/GraphOption.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Microsoft.Graph.PowerShell.Authentication
99
internal class GraphOption : IGraphOption
1010
{
1111
public bool EnableWAMForMSGraph { get; set; }
12+
public bool EnableATPoPForMSGraph { get; set; }
1213
}
1314

1415
}

src/Authentication/Authentication/test/Set-MgGraphOption.Tests.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Describe "Set-MgGraphOption" {
99
Import-Module $ModulePath -Force -ErrorAction SilentlyContinue
1010
}
1111
Context "When executing the command" {
12-
it 'Should have one ParameterSets' {
12+
it 'Should have two ParameterSets' {
1313
$SetMgGraphOptionCommand = Get-Command Set-MgGraphOption
1414
$SetMgGraphOptionCommand | Should -Not -BeNullOrEmpty
1515
$SetMgGraphOptionCommand.ParameterSets | Should -HaveCount 1
1616
$SetMgGraphOptionCommand.ParameterSets.Parameters | Should -HaveCount 13 # PS common parameters.
1717
}
1818

19-
It 'Executes successfully whren toggling WAM on' {
19+
It 'Executes successfully when toggling WAM on' {
2020
{ Set-MgGraphOption -EnableLoginByWAM $true -Debug | Out-Null } | Should -Not -Be $null
2121
{ Set-MgGraphOption -EnableLoginByWAM $true -ErrorAction SilentlyContinue } | Should -Not -Throw
2222
}
@@ -25,5 +25,15 @@ Describe "Set-MgGraphOption" {
2525
{ Set-MgGraphOption -EnableLoginByWAM $false -Debug | Out-Null } | Should -Not -Be $null
2626
{ Set-MgGraphOption -EnableLoginByWAM $false -ErrorAction SilentlyContinue } | Should -Not -Throw
2727
}
28+
29+
It 'Executes successfully when toggling AT PoP on' {
30+
{ Set-MgGraphOption -EnableATPoP $true -Debug | Out-Null } | Should -Not -Be $null
31+
{ Set-MgGraphOption -EnableATPoP $true -ErrorAction SilentlyContinue } | Should -Not -Throw
32+
}
33+
34+
It 'Executes successfully when toggling AT PoP off' {
35+
{ Set-MgGraphOption -EnableATPoP $false -Debug | Out-Null } | Should -Not -Be $null
36+
{ Set-MgGraphOption -EnableATPoP $false -ErrorAction SilentlyContinue } | Should -Not -Throw
37+
}
2838
}
2939
}

src/Authentication/docs/Set-MgGraphOption.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Sets global configurations that apply to the SDK. For example, toggle Web Accoun
1515
```
1616
Set-MgGraphOption [-EnableLoginByWAM <Boolean>] [<CommonParameters>]
1717
```
18+
```
19+
Set-MgGraphOption [-EnableATPoP <Boolean>] [<CommonParameters>]
20+
```
1821

1922
## DESCRIPTION
2023
Sets global configurations that apply to the SDK. For example, toggle Web Account Manager (WAM) support.
@@ -28,11 +31,21 @@ PS C:\> Set-MgGraphOption -EnableLoginByWAM $True
2831

2932
Sets web account manager support
3033

34+
### Example 2: Set access token proof of possession support
35+
```powershell
36+
PS C:\> Set-MgGraphOption -EnableATPoP $True
37+
```
38+
39+
Sets access token proof of possession support
40+
3141
## PARAMETERS
3242

3343
### -EnableLoginByWAM
3444
{{ Fill EnableLoginByWAM Description }}
3545

46+
### -EnableATPoP
47+
{{ Fill EnableATPoP Description }}
48+
3649
```yaml
3750
Type: Boolean
3851
Parameter Sets: (All)

src/Authentication/examples/Set-MgGraphOption.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22
```powershell
33
PS C:\> Set-MgGraphOption -EnableLoginByWAM $True
44
```
5-
Sets web account manager support
5+
Sets web account manager support
6+
7+
### Example 2: Set access token proof of possession support
8+
```powershell
9+
PS C:\> Set-MgGraphOption -EnableATPoP $True
10+
```
11+
Sets access token proof of possession support

0 commit comments

Comments
 (0)