Skip to content

Commit

Permalink
Remove of UseWebLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinvanhunen committed Nov 21, 2024
1 parent 5c64675 commit bfd247e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 255 deletions.
7 changes: 6 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
"group": {
"kind": "build",
"isDefault": true
}
},
"icon": {
"id": "run",
"color": "terminal.ansiYellow"
},

},
{
"label": "Build with local copy of PnP Framework/PnP Core SDK",
Expand Down
26 changes: 1 addition & 25 deletions documentation/Connect-PnPOnline.md
Original file line number Diff line number Diff line change
Expand Up @@ -666,29 +666,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -UseWebLogin
Windows only: Connects to SharePoint using legacy cookie based authentication.
Notice this type of authentication is limited in its functionality.
We will for instance not be able to acquire an access token for the Graph, and as a result none of the Graph related cmdlets will work.
Also some of the functionality of the provisioning engine (Get-PnPSiteTemplate, Get-PnPTenantTemplate, Invoke-PnPSiteTemplate, Invoke-PnPTenantTemplate) will not work because of this reason.
The cookies will in general expire within a few days and if you use -UseWebLogin within that time popup window will appear that will disappear immediately, this is expected.
Use -ForceAuthentication to reset the authentication cookies and force a new login.

```yaml
Type: SwitchParameter
Parameter Sets: Web Login for Multi Factor Authentication
Aliases:
Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -RelativeUrl
The site-relative URL of the site you're collecting to. Only applies if you're using -UseWebLogin.

```yaml
Type: String
Parameter Sets: Web Login for Multi Factor Authentication
Expand All @@ -703,7 +680,6 @@ Accept wildcard characters: False

### -Interactive
Connects to the Entra ID (Azure AD) using interactive login, allowing you to authenticate using multi-factor authentication.
This parameter has preference over \`-UseWebLogin\`.

```yaml
Type: SwitchParameter
Expand All @@ -718,7 +694,7 @@ Accept wildcard characters: False
```

### -ForceAuthentication
Will clear the stored authentication information when using -UseWebLogin (Windows Only) or -Interactive (all platforms) and allows you to authenticate again towards a site with different credentials.
Will clear the stored authentication information when using Interactive login (all platforms) and allows you to authenticate again towards a site with different credentials.

```yaml
Type: SwitchParameter
Expand Down
39 changes: 0 additions & 39 deletions src/Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class ConnectOnline : BasePSCmdlet
private const string ParameterSet_SPOMANAGEMENT = "SPO Management Shell Credentials";
private const string ParameterSet_DEVICELOGIN = "PnP Management Shell / DeviceLogin";
private const string ParameterSet_ACCESSTOKEN = "Access Token";
private const string ParameterSet_WEBLOGIN = "Web Login for Multi Factor Authentication";
private const string ParameterSet_SYSTEMASSIGNEDMANAGEDIDENTITY = "System Assigned Managed Identity";
private const string ParameterSet_USERASSIGNEDMANAGEDIDENTITYBYCLIENTID = "User Assigned Managed Identity by Client Id";
private const string ParameterSet_USERASSIGNEDMANAGEDIDENTITYBYPRINCIPALID = "User Assigned Managed Identity by Principal Id";
Expand All @@ -49,7 +48,6 @@ public class ConnectOnline : BasePSCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_APPONLYAADTHUMBPRINT, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_SPOMANAGEMENT, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_DEVICELOGIN, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_WEBLOGIN, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_INTERACTIVE, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ACCESSTOKEN, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ENVIRONMENTVARIABLE, ValueFromPipeline = true)]
Expand All @@ -67,7 +65,6 @@ public class ConnectOnline : BasePSCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_APPONLYAADTHUMBPRINT, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_SPOMANAGEMENT, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_DEVICELOGIN, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_WEBLOGIN, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_INTERACTIVE, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ACCESSTOKEN, ValueFromPipeline = true)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ENVIRONMENTVARIABLE, ValueFromPipeline = true)]
Expand All @@ -86,7 +83,6 @@ public class ConnectOnline : BasePSCmdlet
[Parameter(Mandatory = true, Position = 0, ParameterSetName = ParameterSet_SPOMANAGEMENT, ValueFromPipeline = true)]
[Parameter(Mandatory = true, Position = 0, ParameterSetName = ParameterSet_ACCESSTOKEN, ValueFromPipeline = true)]
[Parameter(Mandatory = true, Position = 0, ParameterSetName = ParameterSet_DEVICELOGIN, ValueFromPipeline = true)]
[Parameter(Mandatory = true, Position = 0, ParameterSetName = ParameterSet_WEBLOGIN, ValueFromPipeline = true)]
[Parameter(Mandatory = true, Position = 0, ParameterSetName = ParameterSet_INTERACTIVE, ValueFromPipeline = true)]
[Parameter(Mandatory = false, Position = 0, ParameterSetName = ParameterSet_SYSTEMASSIGNEDMANAGEDIDENTITY, ValueFromPipeline = true)]
[Parameter(Mandatory = false, Position = 0, ParameterSetName = ParameterSet_USERASSIGNEDMANAGEDIDENTITYBYCLIENTID, ValueFromPipeline = true)]
Expand Down Expand Up @@ -130,7 +126,6 @@ public class ConnectOnline : BasePSCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_APPONLYAADTHUMBPRINT)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_SPOMANAGEMENT)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_DEVICELOGIN)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_WEBLOGIN)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_INTERACTIVE)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ENVIRONMENTVARIABLE)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_OSLOGIN)]
Expand All @@ -142,7 +137,6 @@ public class ConnectOnline : BasePSCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_APPONLYAADTHUMBPRINT)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_SPOMANAGEMENT)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_DEVICELOGIN)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_WEBLOGIN)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_INTERACTIVE)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ENVIRONMENTVARIABLE)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_OSLOGIN)]
Expand Down Expand Up @@ -220,7 +214,6 @@ public class ConnectOnline : BasePSCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_APPONLYAADCERTIFICATE)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_APPONLYAADTHUMBPRINT)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_SPOMANAGEMENT)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_WEBLOGIN)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_INTERACTIVE)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ENVIRONMENTVARIABLE)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_OSLOGIN)]
Expand All @@ -246,13 +239,6 @@ public class ConnectOnline : BasePSCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ENVIRONMENTVARIABLE)]
public SwitchParameter TransformationOnPrem;

[Parameter(Mandatory = true, ParameterSetName = ParameterSet_WEBLOGIN)]
public SwitchParameter UseWebLogin;

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_WEBLOGIN)]
public string RelativeUrl;

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_WEBLOGIN)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_INTERACTIVE)]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_OSLOGIN)]
public SwitchParameter ForceAuthentication;
Expand Down Expand Up @@ -396,9 +382,6 @@ protected void Connect(ref CancellationToken cancellationToken)
case ParameterSet_USERASSIGNEDMANAGEDIDENTITYBYAZURERESOURCEID:
newConnection = ConnectManagedIdentity();
break;
case ParameterSet_WEBLOGIN:
newConnection = ConnectWebLogin();
break;
case ParameterSet_INTERACTIVE:
newConnection = ConnectInteractive();
break;
Expand Down Expand Up @@ -788,28 +771,6 @@ private PnPConnection ConnectManagedIdentity()
return PnPConnection.CreateWithManagedIdentity(this, Url, TenantAdminUrl, UserAssignedManagedIdentityObjectId, UserAssignedManagedIdentityClientId, UserAssignedManagedIdentityAzureResourceId);
}

private PnPConnection ConnectWebLogin()
{
WriteVerbose("Connecting using WebLogin");
WriteWarning("Consider using -Interactive or -OSLogin instead, which provides better functionality. This will be removed in a future release. See the documentation at https://pnp.github.io/powershell/cmdlets/Connect-PnPOnline.html#interactive-for-multi-factor-authentication");

if (Utilities.OperatingSystem.IsWindows())
{
if (!string.IsNullOrWhiteSpace(RelativeUrl))
{
return PnPConnection.CreateWithWeblogin(new Uri(Url.ToLower()), TenantAdminUrl, ForceAuthentication, siteRelativeUrl: RelativeUrl);
}
else
{
return PnPConnection.CreateWithWeblogin(new Uri(Url.ToLower()), TenantAdminUrl, ForceAuthentication);
}
}
else
{
throw new PSArgumentException("-UseWebLogin only works when running on Microsoft Windows due to the requirement to show a login window.");
}
}

private PnPConnection ConnectInteractive()
{
WriteVerbose("Connecting using Interactive login");
Expand Down
Loading

0 comments on commit bfd247e

Please sign in to comment.