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
6 changes: 3 additions & 3 deletions src/Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ private PnPConnection ConnectDeviceLogin()
Tenant = TenantExtensions.GetTenantIdByUrl(Url, AzureEnvironment);
}

var returnedConnection = PnPConnection.CreateWithDeviceLogin(clientId, Url, Tenant, messageWriter, AzureEnvironment, cancellationTokenSource, PersistLogin, Host);
var returnedConnection = PnPConnection.CreateWithDeviceLogin(clientId, Url, Tenant, messageWriter, AzureEnvironment, cancellationTokenSource, PersistLogin, Host, ErrorActionSetting);
connection = returnedConnection;
messageWriter.Finished = true;
}
Expand Down Expand Up @@ -790,7 +790,7 @@ private PnPConnection ConnectInteractive()
}
}
LogDebug($"Using ClientID {ClientId}");
return PnPConnection.CreateWithInteractiveLogin(new Uri(Url.ToLower()), ClientId, TenantAdminUrl, AzureEnvironment, cancellationTokenSource, ForceAuthentication, Tenant, false, PersistLogin, Host);
return PnPConnection.CreateWithInteractiveLogin(new Uri(Url.ToLower()), ClientId, TenantAdminUrl, AzureEnvironment, cancellationTokenSource, ForceAuthentication, Tenant, false, PersistLogin, Host, ErrorActionSetting);
}

private PnPConnection ConnectEnvironmentVariable(InitializationType initializationType = InitializationType.EnvironmentVariable)
Expand Down Expand Up @@ -932,7 +932,7 @@ private PnPConnection ConnectWithOSLogin()
{
WriteObject("Cache used. Clear the cache entry with Disconnect-PnPOnline");
}
return PnPConnection.CreateWithInteractiveLogin(new Uri(Url.ToLower()), ClientId, TenantAdminUrl, AzureEnvironment, cancellationTokenSource, ForceAuthentication, Tenant, true, PersistLogin, Host);
return PnPConnection.CreateWithInteractiveLogin(new Uri(Url.ToLower()), ClientId, TenantAdminUrl, AzureEnvironment, cancellationTokenSource, ForceAuthentication, Tenant, true, PersistLogin, Host, ErrorActionSetting);
}

private PnPConnection ConnectFederatedIdentity()
Expand Down
24 changes: 17 additions & 7 deletions src/Commands/Base/PnPConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ internal PnPContext PnPContext
internal PnP.Framework.AuthenticationManager AuthenticationManager { get; set; }

private string _graphEndPoint;

/// <summary>
private static readonly string[] sourceArray = ["stop", "ignore", "silentlycontinue"];
#endregion

#region Creators
Expand Down Expand Up @@ -258,15 +259,18 @@ internal static PnPConnection CreateWithACSAppOnly(Uri url, string realm, string
return spoConnection;
}

internal static PnPConnection CreateWithDeviceLogin(string clientId, string url, string tenantId, CmdletMessageWriter messageWriter, AzureEnvironment azureEnvironment, CancellationTokenSource cancellationTokenSource, bool persistLogin, System.Management.Automation.Host.PSHost host)
internal static PnPConnection CreateWithDeviceLogin(string clientId, string url, string tenantId, CmdletMessageWriter messageWriter, AzureEnvironment azureEnvironment, CancellationTokenSource cancellationTokenSource, bool persistLogin, System.Management.Automation.Host.PSHost host, string ErrorActionSetting = null)
{
if (persistLogin)
{
EnableCaching(url, clientId);
}
if (CacheEnabled(url, clientId))
{
WriteCacheEnabledMessage(host);
if (!sourceArray.Contains(ErrorActionSetting.ToLowerInvariant()))
{
WriteCacheEnabledMessage(host);
}
}
var connectionUri = new Uri(url);
var scopes = new[] { $"{connectionUri.Scheme}://{connectionUri.Authority}//.default" }; // the second double slash is not a typo.
Expand Down Expand Up @@ -468,15 +472,18 @@ internal static PnPConnection CreateWithManagedIdentity(string url, string tenan
}
}

internal static PnPConnection CreateWithCredentials(Cmdlet cmdlet, Uri url, PSCredential credentials, bool currentCredentials, string tenantAdminUrl, bool persistLogin, System.Management.Automation.Host.PSHost host, AzureEnvironment azureEnvironment = AzureEnvironment.Production, string clientId = null, string redirectUrl = null, bool onPrem = false, InitializationType initializationType = InitializationType.Credentials)
internal static PnPConnection CreateWithCredentials(Cmdlet cmdlet, Uri url, PSCredential credentials, bool currentCredentials, string tenantAdminUrl, bool persistLogin, System.Management.Automation.Host.PSHost host, AzureEnvironment azureEnvironment = AzureEnvironment.Production, string clientId = null, string redirectUrl = null, bool onPrem = false, InitializationType initializationType = InitializationType.Credentials, string ErrorActionSetting = null)
{
if (persistLogin)
{
EnableCaching(url.ToString(), clientId);
}
if (CacheEnabled(url.ToString(), clientId))
{
WriteCacheEnabledMessage(host);
if (!sourceArray.Contains(ErrorActionSetting.ToLowerInvariant()))
{
WriteCacheEnabledMessage(host);
}
}
var context = new PnPClientContext(url.AbsoluteUri)
{
Expand Down Expand Up @@ -588,15 +595,18 @@ internal static PnPConnection CreateWithCredentials(Cmdlet cmdlet, Uri url, PSCr
return spoConnection;
}

internal static PnPConnection CreateWithInteractiveLogin(Uri uri, string clientId, string tenantAdminUrl, AzureEnvironment azureEnvironment, CancellationTokenSource cancellationTokenSource, bool forceAuthentication, string tenant, bool enableLoginWithWAM, bool persistLogin, System.Management.Automation.Host.PSHost host)
internal static PnPConnection CreateWithInteractiveLogin(Uri uri, string clientId, string tenantAdminUrl, AzureEnvironment azureEnvironment, CancellationTokenSource cancellationTokenSource, bool forceAuthentication, string tenant, bool enableLoginWithWAM, bool persistLogin, System.Management.Automation.Host.PSHost host, string ErrorActionSetting)
{
if (persistLogin)
{
EnableCaching(uri.ToString(), clientId);
}
if (CacheEnabled(uri.ToString(), clientId))
{
WriteCacheEnabledMessage(host);
if (!sourceArray.Contains(ErrorActionSetting.ToLowerInvariant()))
{
WriteCacheEnabledMessage(host);
}
}

var htmlMessageSuccess = "<html lang=en><meta charset=utf-8><title>PnP PowerShell - Sign In</title><meta content=\"width=device-width,initial-scale=1\"name=viewport><style>html{height:100%}.message-container{flex-grow:1;display:flex;align-items:center;justify-content:center;margin:0 30px}body{box-sizing:border-box;min-height:100%;display:flex;flex-direction:column;color:#fff;font-family:\"Segoe UI\",\"Helvetica Neue\",Helvetica,Arial,sans-serif;background-color:#2c2c32;margin:0;padding:15px 30px}.message{font-weight:300;font-size:1.4rem}.branding{background-image:url(data:image/png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-repeat;padding-left:26px;font-size:20px;letter-spacing:-.04rem;font-weight:400;height:26px;color:#fff;background-position:left center;text-decoration:none}</style><a class=branding href=https://pnp.github.io/powershell>PnP PowerShell</a><div class=message-container><div class=message>You are signed in now and can close this page.</div></div>";
Expand Down
Loading