Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public interface IAuthContext
string Environment { get; set; }
string AppName { get; set; }
string Account { get; set; }
string UserPrincipalName { get; set; }
string CertificateThumbprint { get; set; }
string CertificateSubjectName { get; set; }
bool SendCertificateChain { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private static async Task<InteractiveBrowserCredential> GetInteractiveBrowserCre
interactiveOptions.TenantId = authContext.TenantId ?? "common";
interactiveOptions.AuthorityHost = new Uri(GetAuthorityUrl(authContext));
interactiveOptions.TokenCachePersistenceOptions = GetTokenCachePersistenceOptions(authContext);
interactiveOptions.LoginHint = authContext.UserPrincipalName;

if (!File.Exists(Constants.AuthRecordPath))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net8.0;net472</TargetFrameworks>
<IsPackable>false</IsPackable>
<Version>2.25.0</Version>
<Version>2.30.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
Expand Down
5 changes: 5 additions & 0 deletions src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public class ConnectMgGraph : PSCmdlet, IModuleAssemblyInitializer, IModuleAssem
[Alias("ManagedIdentity", "ManagedServiceIdentity", "MSI")]
public SwitchParameter Identity { get; set; }

[Parameter(ParameterSetName = Constants.UserParameterSet, Mandatory = false, HelpMessage = HelpMessages.UserPrincipalName)]
[Alias("UPN")]
public string UserPrincipalName { get; set; }

[Parameter(ParameterSetName = Constants.EnvironmentVariableParameterSet, Mandatory = false, HelpMessage = HelpMessages.EnvironmentVariable)]
public SwitchParameter EnvironmentVariable { get; set; }

Expand Down Expand Up @@ -182,6 +186,7 @@ private async Task ProcessRecordAsync()
if (MyInvocation.BoundParameters.ContainsKey(nameof(ClientId)))
authContext.ClientId = ClientId;
authContext.AuthType = AuthenticationType.Delegated;
authContext.UserPrincipalName = UserPrincipalName;
string[] processedScopes = ProcessScopes(Scopes);
authContext.Scopes = !processedScopes.Any() ? new[] { "User.Read" } : processedScopes;
if (RuntimeInformation.OSDescription.ContainsValue("WSL", StringComparison.InvariantCulture))
Expand Down
1 change: 1 addition & 0 deletions src/Authentication/Authentication/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static class HelpMessages
public const string ClientTimeout = "Sets the HTTP client timeout in seconds.";
public const string NoWelcome = "Hides the welcome message.";
public const string Identity = "Login using a Managed Identity.";
public const string UserPrincipalName = "Specifies the account that you want to use to connect in order to skip the connection prompt.";
public const string EnvironmentVariable = "Allows for authentication using environment variables configured on the host machine. See https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/identity/Azure.Identity#environment-variables.";
public const string ManagedIdentityClientId = "The client id to authenticate for a user assigned managed identity. For more information on user assigned managed identities see: https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview#how-a-user-assigned-managed-identity-works-with-an-azure-vmId. To use the SystemAssigned identity, leave this field blank.";
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<WarningsAsErrors />
<NuspecFile>Microsoft.Graph.Authentication.nuspec</NuspecFile>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<Version>2.6.1</Version>
<Version>2.30.0</Version>
</PropertyGroup>
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package>
<metadata>
<version>2.6.1</version>
<version>2.30.0</version>
<id>Microsoft.Graph.Authentication</id>
<description>Microsoft Graph PowerShell authentication module</description>
<authors>Microsoft</authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft
#
# Generated on: 21/09/2023
# Generated on: 2025-09-24
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = './Microsoft.Graph.Authentication.psm1'

# Version number of this module.
ModuleVersion = '2.6.1'
ModuleVersion = '2.30.0'

# Supported PSEditions
CompatiblePSEditions = 'Core', 'Desktop'
Expand Down
1 change: 1 addition & 0 deletions src/Authentication/Authentication/Models/AuthContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class AuthContext : IAuthContext
public string CertificateSubjectName { get; set; }
public bool SendCertificateChain { get; set; }
public string Account { get; set; }
public string UserPrincipalName { get; set; }
public string AppName { get; set; }
public ContextScope ContextScope { get; set; }
public X509Certificate2 Certificate { get; set; }
Expand Down
21 changes: 17 additions & 4 deletions src/Authentication/docs/Add-MgEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ schema: 2.0.0
## SYNTAX

```
Add-MgEnvironment [-Name] <String> [-AzureADEndpoint] <String> [-GraphEndpoint] <String> [-WhatIf] [-Confirm]
[<CommonParameters>]
Add-MgEnvironment [-Name] <String> [-AzureADEndpoint] <String> [-GraphEndpoint] <String>
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -79,6 +79,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -ProgressAction
{{ Fill ProgressAction Description }}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm
Prompts you for confirmation before running the cmdlet.

Expand Down Expand Up @@ -116,11 +131,9 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## INPUTS

### System.String

## OUTPUTS

### Microsoft.Graph.PowerShell.Authentication.Models.GraphEnvironment

## NOTES

## RELATED LINKS
Expand Down
63 changes: 55 additions & 8 deletions src/Authentication/docs/Connect-MgGraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,41 @@ Microsoft Graph PowerShell supports two types of authentication: delegated and a
### UserParameterSet (Default)
```
Connect-MgGraph [[-Scopes] <String[]>] [[-ClientId] <String>] [-TenantId <String>]
[-ContextScope <ContextScope>] [-Environment <String>] [-UseDeviceCode] [-ClientTimeout <Double>] [-NoWelcome]
[<CommonParameters>]
[-ContextScope <ContextScope>] [-Environment <String>] [-UseDeviceCode] [-ClientTimeout <Double>]
[-UserPrincipalName <String>] [-NoWelcome] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

### AppCertificateParameterSet
```
Connect-MgGraph [-ClientId] <String> [[-CertificateSubjectName] <String>] [[-CertificateThumbprint] <String>]
[-Certificate <X509Certificate2>] [-TenantId <String>] [-ContextScope <ContextScope>] [-Environment <String>]
[-ClientTimeout <Double>] [-NoWelcome] [<CommonParameters>]
[-SendCertificateChain <Boolean>] [-Certificate <X509Certificate2>] [-TenantId <String>]
[-ContextScope <ContextScope>] [-Environment <String>] [-ClientTimeout <Double>] [-NoWelcome]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
```

### IdentityParameterSet
```
Connect-MgGraph [[-ClientId] <String>] [-ContextScope <ContextScope>] [-Environment <String>]
[-ClientTimeout <Double>] [-Identity] [-NoWelcome] [<CommonParameters>]
[-ClientTimeout <Double>] [-Identity] [-NoWelcome] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

### AppSecretCredentialParameterSet
```
Connect-MgGraph [-ClientSecretCredential <PSCredential>] [-TenantId <String>] [-ContextScope <ContextScope>]
[-Environment <String>] [-ClientTimeout <Double>] [-NoWelcome] [<CommonParameters>]
[-Environment <String>] [-ClientTimeout <Double>] [-NoWelcome] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
```

### AccessTokenParameterSet
```
Connect-MgGraph [-AccessToken] <SecureString> [-Environment <String>] [-ClientTimeout <Double>] [-NoWelcome]
[<CommonParameters>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
```

### EnvironmentVariableParameterSet
```
Connect-MgGraph [-ContextScope <ContextScope>] [-Environment <String>] [-ClientTimeout <Double>]
[-EnvironmentVariable] [-NoWelcome] [<CommonParameters>]
[-EnvironmentVariable] [-NoWelcome] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -351,6 +353,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction
{{ Fill ProgressAction Description }}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Scopes
An array of delegated permissions to consent to.

Expand All @@ -366,6 +383,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -SendCertificateChain
Include x5c header in client claims when acquiring a token to enable subject name / issuer based authentication using given certificate.

```yaml
Type: Boolean
Parameter Sets: AppCertificateParameterSet
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -TenantId
The id of the tenant to connect to.
You can also use this parameter to specify your sign-in audience.
Expand Down Expand Up @@ -399,6 +431,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -UserPrincipalName
Specifies the account that you want to use to connect in order to skip the connection prompt.

```yaml
Type: String
Parameter Sets: UserParameterSet
Aliases: UPN

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

Expand Down
17 changes: 16 additions & 1 deletion src/Authentication/docs/Disconnect-MgGraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Once you're signed in, you'll remain signed in until you invoke Disconnect-MgGra
## SYNTAX

```
Disconnect-MgGraph [<CommonParameters>]
Disconnect-MgGraph [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -30,6 +30,21 @@ Use Disconnect-MgGraph to sign out.

## PARAMETERS

### -ProgressAction
{{ Fill ProgressAction Description }}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

Expand Down
17 changes: 16 additions & 1 deletion src/Authentication/docs/Get-MgContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Get-MgContext is used to retrieve the details about your current session, which
## SYNTAX

```
Get-MgContext [<CommonParameters>]
Get-MgContext [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -61,6 +61,21 @@ Retrieves all scopes.

## PARAMETERS

### -ProgressAction
{{ Fill ProgressAction Description }}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

Expand Down
17 changes: 16 additions & 1 deletion src/Authentication/docs/Get-MgEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ When you use Connect-MgGraph, you can choose to target other environments. By de
## SYNTAX

```
Get-MgEnvironment [[-Name] <String>] [<CommonParameters>]
Get-MgEnvironment [[-Name] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -51,6 +51,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -ProgressAction
{{ Fill ProgressAction Description }}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

Expand Down
19 changes: 16 additions & 3 deletions src/Authentication/docs/Get-MgGraphOption.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gets global configurations that apply to the SDK. For example, check if Web Acco
## SYNTAX

```
Get-MgGraphOption [<CommonParameters>]
Get-MgGraphOption [-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -33,17 +33,30 @@ Confirms if WAM support has been enabled.

## PARAMETERS

### -ProgressAction
{{ Fill ProgressAction Description }}

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### None

## OUTPUTS

### Microsoft.Graph.PowerShell.Authentication.IGraphOption

## NOTES

## RELATED LINKS
Loading