Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Get-PnPAzureADAppSitePermission, Grant-PnPAzureADAppSitePermission and Revoke-PnPAzureADAppSitePermission cmdlets throwing an error when the site URL is not specified #4421

Merged
Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fix `Add-PnPDataRowsToSiteTemplate` setting keyColumn to null when not passed. [#4325](https://github.com/pnp/powershell/pull/4325)
- Fix `Connect-PnPOnline` not working correctly when `-DeviceLogin` and `-LaunchBrowser` both are specified. It used to open it in a popup. Now it correctly launches the browser. [#4325](https://github.com/pnp/powershell/pull/4345)
- `Export-PnPUserInfo`, `Export-PnPUserProfile` and `Remove-PnPUserProfile` cmdlets now work properly with proper `-Connection` parameter if specified. [#4389](https://github.com/pnp/powershell/pull/4389)

- Fixed `Get-PnPAzureADAppSitePermission`, `Grant-PnPAzureADAppSitePermission` and `Revoke-PnPAzureADAppSitePermission` cmdlets throwing an error when the site URL is not specified and the app registration used only having Graph permissions [#4421](https://github.com/pnp/powershell/pull/4421)

### Removed

- Removed `Publish-PnPCompanyApp` cmdlet as it was not supported anymore. [#4387](https://github.com/pnp/powershell/pull/4387)
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/Apps/GetAzureADAppSitePermission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace PnP.PowerShell.Commands.Apps
{
[Cmdlet(VerbsCommon.Get, "PnPAzureADAppSitePermission", DefaultParameterSetName = ParameterSet_ALL)]
[RequiredApiApplicationPermissions("graph/Sites.FullControl.All")]
[RequiredApiDelegatedOrApplicationPermissions("graph/Sites.FullControl.All")]
[Alias("Get-PnPEntraIDAppSitePermission")]
public class GetPnPAzureADAppSitePermission : PnPGraphCmdlet
{
Expand Down Expand Up @@ -41,7 +41,7 @@ protected override void ExecuteCmdlet()
}
else
{
siteId = PnPContext.Site.Id;
siteId = new SitePipeBind(Connection.Url).GetSiteIdThroughGraph(Connection, AccessToken);
}

if (siteId != Guid.Empty)
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/Apps/GrantAzureADAppSitePermission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace PnP.PowerShell.Commands.Apps
{
[Cmdlet(VerbsSecurity.Grant, "PnPAzureADAppSitePermission")]
[RequiredApiApplicationPermissions("graph/Sites.FullControl.All")]
[RequiredApiDelegatedOrApplicationPermissions("graph/Sites.FullControl.All")]
[Alias("Grant-PnPEntraIDAppSitePermission")]
[OutputType(typeof(AzureADAppPermissionInternal))]
public class GrantPnPAzureADAppSitePermission : PnPGraphCmdlet
Expand Down Expand Up @@ -44,7 +44,7 @@ protected override void ExecuteCmdlet()
else
{
WriteVerbose($"No specific site passed in through -{nameof(Site)}, taking the currently connected to site");
siteId = PnPContext.Site.Id;
siteId = new SitePipeBind(Connection.Url).GetSiteIdThroughGraph(Connection, AccessToken);
WriteVerbose($"Currently connected to site has Id {siteId}");
}

Expand Down
6 changes: 3 additions & 3 deletions src/Commands/Apps/RevokeAzureADAppSitePermission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace PnP.PowerShell.Commands.Apps
{
[Cmdlet(VerbsSecurity.Revoke, "PnPAzureADAppSitePermission")]
[RequiredApiApplicationPermissions("graph/Sites.FullControl.All")]
[RequiredApiDelegatedOrApplicationPermissions("graph/Sites.FullControl.All")]
[Alias("Revoke-PnPEntraIDAppSitePermission")]
public class RevokePnPAzureADAppSitePermission : PnPGraphCmdlet
{
Expand All @@ -31,14 +31,14 @@ protected override void ExecuteCmdlet()
}
else
{
siteId = PnPContext.Site.Id;
siteId = new SitePipeBind(Connection.Url).GetSiteIdThroughGraph(Connection, AccessToken);
}

if (siteId != Guid.Empty)
{
if (Force || ShouldContinue("Are you sure you want to revoke the permissions?", string.Empty))
{
var results = PnP.PowerShell.Commands.Utilities.REST.RestHelper.Delete(Connection.HttpClient, $"https://{Connection.GraphEndPoint}/v1.0/sites/{siteId}/permissions/{PermissionId}", AccessToken);
var results = Utilities.REST.RestHelper.Delete(Connection.HttpClient, $"https://{Connection.GraphEndPoint}/v1.0/sites/{siteId}/permissions/{PermissionId}", AccessToken);
}
}
}
Expand Down
Loading