Skip to content

Commit

Permalink
Removed references to the PnP Management Shell app (`31359c7f-bd7e-47…
Browse files Browse the repository at this point in the history
…5c-86db-fdb8c937548e`)
  • Loading branch information
bjansen committed Sep 17, 2024
1 parent 5da023f commit 5a70505
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 43 deletions.
8 changes: 8 additions & 0 deletions src/lib/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added

### Changed

- Removed references to the PnP Management Shell app (`31359c7f-bd7e-475c-86db-fdb8c937548e`) [jansenbe - Bert Jansen]

## [1.17.0]

### Added
Expand Down
9 changes: 5 additions & 4 deletions src/lib/PnP.Framework.Modernization.Test/TestCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,20 @@ private static ClientContext InternalCreateContext(string contextUrl, SourceCont

if (sourceContextMode == SourceContextMode.SPO)
{
if (!string.IsNullOrEmpty(AppSetting("SPOCredentialManagerLabel")))
if (!string.IsNullOrEmpty(AppSetting("SPOCredentialManagerLabel")) && !String.IsNullOrEmpty(AppSetting("AppId")))
{
var tempCred = PnP.Framework.Utilities.CredentialManager.GetCredential(AppSetting("SPOCredentialManagerLabel"));

AuthenticationManager am = new AuthenticationManager(tempCred.UserName, tempCred.SecurePassword);
AuthenticationManager am = new AuthenticationManager(AppSetting("AppId"), tempCred.UserName, tempCred.SecurePassword);
context = am.GetContext(contextUrl);
}
else
{
if (!String.IsNullOrEmpty(AppSetting("SPOUserName")) &&
!String.IsNullOrEmpty(AppSetting("SPOPassword")))
!String.IsNullOrEmpty(AppSetting("SPOPassword")) &&
!String.IsNullOrEmpty(AppSetting("AppId")))
{
AuthenticationManager am = new AuthenticationManager(AppSetting("SPOUserName"), GetSecureString(AppSetting("SPOPassword")));
AuthenticationManager am = new AuthenticationManager(AppSetting("AppId"), AppSetting("SPOUserName"), GetSecureString(AppSetting("SPOPassword")));
context = am.GetContext(contextUrl);
}
else if (!String.IsNullOrEmpty(AppSetting("AppId")) &&
Expand Down
4 changes: 2 additions & 2 deletions src/lib/PnP.Framework.Test/TestCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public static PnPClientContext CreatePnPClientContext(int retryCount = 10, int d
}
else
{
using (var authMgr = new AuthenticationManager(UserName, Password))
using (var authMgr = new AuthenticationManager(AppId, UserName, Password))
{
ClientContext clientContext = authMgr.GetContextAsync(DevSiteUrl).GetAwaiter().GetResult();
context = PnPClientContext.ConvertFrom(clientContext, retryCount, delay);
Expand Down Expand Up @@ -332,7 +332,7 @@ private static ClientContext CreateContext(string contextUrl, AzureEnvironment a
}
else
{
using (AuthenticationManager am = new AuthenticationManager(UserName, Password, azureEnvironment))
using (AuthenticationManager am = new AuthenticationManager(AppId, UserName, Password, null, azureEnvironment))
{

if (azureEnvironment == AzureEnvironment.Custom)
Expand Down
37 changes: 1 addition & 36 deletions src/lib/PnP.Framework/AuthenticationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ public enum AzureEnvironment
public enum KnownClientId
{
/// <summary>
///
/// </summary>
PnPManagementShell,
/// <summary>
///
/// SPO Management Shell app
/// </summary>
SPOManagementShell
}
Expand All @@ -88,10 +84,6 @@ public class AuthenticationManager : IDisposable
/// The client id of the Microsoft SharePoint Online Management Shell application
/// </summary>
public const string CLIENTID_SPOMANAGEMENTSHELL = "9bc3ab49-b65d-410a-85ad-de819febfddc";
/// <summary>
/// The client id of the Microsoft 365 Patters and Practices Management Shell application
/// </summary>
public const string CLIENTID_PNPMANAGEMENTSHELL = "31359c7f-bd7e-475c-86db-fdb8c937548e";

private readonly IPublicClientApplication publicClientApplication;
private readonly IConfidentialClientApplication confidentialClientApplication;
Expand Down Expand Up @@ -212,18 +204,6 @@ public static AuthenticationManager CreateWithInteractiveLogin(string clientId,
return new AuthenticationManager(clientId, redirectUrl ?? Utilities.OAuth.DefaultBrowserUi.FindFreeLocalhostRedirectUri(), tenantId, azureEnvironment, tokenCacheCallback, customWebUi, useWAM);
}

/// <summary>
/// Creates a new instance of the Authentication Manager to acquire authenticated ClientContexts. It uses the PnP Management Shell multi-tenant Azure AD application ID to authenticate. By default tokens will be cached in memory.
/// </summary>
/// <param name="username">The username to use for authentication</param>
/// <param name="password">The password to use for authentication</param>
/// <param name="azureEnvironment">The azure environment to use. Defaults to AzureEnvironment.Production</param>
/// <param name="tokenCacheCallback">If present, after setting up the base flow for authentication this callback will be called register a custom tokencache. See https://aka.ms/msal-net-token-cache-serialization.</param>
public static AuthenticationManager CreateWithCredentials(string username, SecureString password, AzureEnvironment azureEnvironment = AzureEnvironment.Production, Action<ITokenCache> tokenCacheCallback = null)
{
return new AuthenticationManager(username, password, azureEnvironment, tokenCacheCallback);
}

/// <summary>
/// Creates a new instance of the Authentication Manager to acquire authenticated ClientContexts.
/// </summary>
Expand Down Expand Up @@ -385,17 +365,6 @@ public AuthenticationManager(string endpoint, string identityHeader, ManagedIden

}

/// <summary>
/// Creates a new instance of the Authentication Manager to acquire authenticated ClientContexts. It uses the PnP Management Shell multi-tenant Azure AD application ID to authenticate. By default tokens will be cached in memory.
/// </summary>
/// <param name="username">The username to use for authentication</param>
/// <param name="password">The password to use for authentication</param>
/// <param name="azureEnvironment">The azure environment to use. Defaults to AzureEnvironment.Production</param>
/// <param name="tokenCacheCallback">If present, after setting up the base flow for authentication this callback will be called register a custom tokencache. See https://aka.ms/msal-net-token-cache-serialization.</param>
public AuthenticationManager(string username, SecureString password, AzureEnvironment azureEnvironment = AzureEnvironment.Production, Action<ITokenCache> tokenCacheCallback = null) : this(GetKnownClientId(KnownClientId.PnPManagementShell), username, password, $"{GetAzureADLoginEndPointStatic(azureEnvironment)}/common/oauth2/nativeclient", azureEnvironment, tokenCacheCallback)
{
}

/// <summary>
/// Creates a new instance of the Authentication Manager to acquire authenticated ClientContexts.
/// </summary>
Expand Down Expand Up @@ -1339,10 +1308,6 @@ private static string GetKnownClientId(KnownClientId id)
{
switch (id)
{
case KnownClientId.PnPManagementShell:
{
return CLIENTID_PNPMANAGEMENTSHELL;
}
case KnownClientId.SPOManagementShell:
{
return CLIENTID_SPOMANAGEMENTSHELL;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/PnP.Framework/TimerJobs/TimerJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ private AuthenticationManager GetAuthenticationManager(string url)
AuthenticationManager am = null;
if (this.AuthenticationType == AuthenticationType.Office365)
{
am = new AuthenticationManager(this.username, this.password, this.AzureEnvironment);
am = new AuthenticationManager(this.clientId, this.username, this.password, null, this.AzureEnvironment);
}
else if (this.AuthenticationType == AuthenticationType.AzureADAppOnly)
{
Expand Down

0 comments on commit 5a70505

Please sign in to comment.