Skip to content

Commit

Permalink
Removed the PnP Managent Shell App (`31359c7f-bd7e-475c-86db-fdb8c937…
Browse files Browse the repository at this point in the history
…548e`) as default app to authenticate with
  • Loading branch information
bjansen committed Sep 17, 2024
1 parent d3e8c3e commit fdcbc1a
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 61 deletions.
1 change: 1 addition & 0 deletions src/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Moved the approve permissions for deployed SPFx packages to use Graph instead of CSOM #1479 [mloitzl - Martin Loitzl]
- Added `BaseType` property to `IList` #1532 [jansenbe - Bert Jansen]
- Added support for listing the properties to load when using `IFolder.EnsureFolderAsync` #1504 [jansenbe - Bert Jansen]
- Auth library: Removed the PnP Managent Shell App (`31359c7f-bd7e-475c-86db-fdb8c937548e`) as default app to authenticate with [jansenbe - Bert Jansen]

## [1.14]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,27 @@ public async Task TestCredentialManagerConstructorNoDI()
Assert.IsNotNull(provider.CredentialManagerName);
}

[TestMethod]
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task TestCredentialManagerConstructorNoDI_NullClientId_NullTenantId()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
// Credentialmanager does not work on Linux
if (TestCommon.RunningInGitHubWorkflow()) Assert.Inconclusive("Skipping live test because we're running inside a GitHub action");

var configuration = TestCommon.GetConfigurationSettings();
var credentialManagerName = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{credentialManagerConfigurationPath}:CredentialManager:CredentialManagerName");

var provider = new CredentialManagerAuthenticationProvider(
null,
null,
credentialManagerName);

Assert.IsNotNull(provider);
Assert.IsNotNull(provider.ClientId);
Assert.IsNotNull(provider.TenantId);
Assert.IsNotNull(provider.CredentialManagerName);
}
// [TestMethod]
//#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
// public async Task TestCredentialManagerConstructorNoDI_NullClientId_NullTenantId()
//#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
// {
// // Credentialmanager does not work on Linux
// if (TestCommon.RunningInGitHubWorkflow()) Assert.Inconclusive("Skipping live test because we're running inside a GitHub action");

// var configuration = TestCommon.GetConfigurationSettings();
// var credentialManagerName = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{credentialManagerConfigurationPath}:CredentialManager:CredentialManagerName");

// var provider = new CredentialManagerAuthenticationProvider(
// null,
// null,
// credentialManagerName);

// Assert.IsNotNull(provider);
// Assert.IsNotNull(provider.ClientId);
// Assert.IsNotNull(provider.TenantId);
// Assert.IsNotNull(provider.CredentialManagerName);
// }

[TestMethod]
[ExpectedException(typeof(ConfigurationErrorsException))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ public async Task TestInteractiveConstructorNoDI_NullRedirectUri()
public async Task TestInteractiveConstructorNoDI_DefaultValues()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{

var provider = new InteractiveAuthenticationProvider();
var configuration = TestCommon.GetConfigurationSettings();
var clientId = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{interactiveConfigurationPath}:ClientId");
Uri test = null;
var provider = new InteractiveAuthenticationProvider(clientId, null, test);

Assert.IsNotNull(provider);
Assert.IsNotNull(provider.ClientId);
// ClientId is required now
//Assert.IsNotNull(provider.ClientId);
Assert.IsNotNull(provider.TenantId);
Assert.IsNotNull(provider.RedirectUri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public async Task TestOnBehalfOfConstructorNoDIWithClientSecret()

[TestMethod]
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task TestOnBehalfOfConstructorNoDIWithCertificateFile_NullClientId_NullTenantId()
public async Task TestOnBehalfOfConstructorNoDIWithCertificateFile_NullTenantId()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
if (TestCommon.RunningInGitHubWorkflow()) Assert.Inconclusive("Skipping test because we're running inside a GitHub action and we don't have access to the certificate store");
Expand All @@ -164,12 +164,13 @@ public async Task TestOnBehalfOfConstructorNoDIWithCertificateFile_NullClientId_
var storeName = configuration.GetValue<StoreName>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:OnBehalfOf:StoreName");
var storeLocation = configuration.GetValue<StoreLocation>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:OnBehalfOf:StoreLocation");
var thumbprint = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:OnBehalfOf:Thumbprint");
var clientId = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:ClientId");

var certificateFromFile = X509CertificateUtility.LoadCertificate(storeName, storeLocation, thumbprint);

//string path = $"TestAssets{Path.DirectorySeparatorChar}pnp.pfx";
var provider = new OnBehalfOfAuthenticationProvider(
null,
clientId,
null,
certificate: certificateFromFile,
// We get the consumer access token using an InteractiveAuthenticationProvider
Expand All @@ -182,7 +183,7 @@ public async Task TestOnBehalfOfConstructorNoDIWithCertificateFile_NullClientId_

[TestMethod]
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task TestOnBehalfOfConstructorNoDIWithCertificate_NullClientId_NullTenantId()
public async Task TestOnBehalfOfConstructorNoDIWithCertificate_NullTenantId()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
if (TestCommon.RunningInGitHubWorkflow()) Assert.Inconclusive("Skipping test because we're running inside a GitHub action and we don't have access to the certificate store");
Expand All @@ -191,9 +192,10 @@ public async Task TestOnBehalfOfConstructorNoDIWithCertificate_NullClientId_Null
var storeName = configuration.GetValue<StoreName>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:OnBehalfOf:StoreName");
var storeLocation = configuration.GetValue<StoreLocation>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:OnBehalfOf:StoreLocation");
var thumbprint = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:OnBehalfOf:Thumbprint");
var clientId = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:ClientId");

var provider = new OnBehalfOfAuthenticationProvider(
null,
clientId,
null,
storeName,
storeLocation,
Expand All @@ -209,16 +211,17 @@ public async Task TestOnBehalfOfConstructorNoDIWithCertificate_NullClientId_Null

[TestMethod]
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task TestOnBehalfOfConstructorNoDIWithClientSecret_NullClientId_NullTenantId()
public async Task TestOnBehalfOfConstructorNoDIWithClientSecret_NullTenantId()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
if (TestCommon.RunningInGitHubWorkflow()) Assert.Inconclusive("Skipping test because we're running inside a GitHub action and we don't have access to the certificate store");

var configuration = TestCommon.GetConfigurationSettings();
var clientSecret = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:OnBehalfOf:ClientSecret");
var clientId = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:ClientId");

var provider = new OnBehalfOfAuthenticationProvider(
null,
clientId,
null,
clientSecret.ToSecureString(),
// We get the consumer access token using an InteractiveAuthenticationProvider
Expand All @@ -241,7 +244,7 @@ public async Task TestOnBehalfOfConstructorNoDIWithCertificate_NullThumbprint()
var storeLocation = configuration.GetValue<StoreLocation>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:OnBehalfOf:StoreLocation");

var provider = new OnBehalfOfAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
storeName,
storeLocation,
Expand All @@ -261,7 +264,7 @@ public async Task TestOnBehalfOfConstructorNoDIWithClientSecret_NullClientSecret
var storeLocation = configuration.GetValue<StoreLocation>($"{TestGlobals.CredentialsConfigurationBasePath}:{onBehalfOfConfigurationPath}:OnBehalfOf:StoreLocation");

var provider = new OnBehalfOfAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
clientSecret: null,
// We get the consumer access token using an InteractiveAuthenticationProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task TestUsernamePasswordConstructorNoDI()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
"FakeUsername",
"FakePassword".ToSecureString());
Expand All @@ -64,11 +64,11 @@ public async Task TestUsernamePasswordConstructorNoDI()

[TestMethod]
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task TestUsernamePasswordConstructorNoDI_NullClientId_NullTenantId()
public async Task TestUsernamePasswordConstructorNoDI_NullTenantId()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
var provider = new UsernamePasswordAuthenticationProvider(
null,
TestGlobals.FakeClientId,
null,
"FakeUsername",
"FakePassword".ToSecureString());
Expand All @@ -87,7 +87,7 @@ public async Task TestUsernamePasswordConstructorNoDI_NullUsername()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
null,
"FakePassword".ToSecureString());
Expand All @@ -100,7 +100,7 @@ public async Task TestUsernamePasswordConstructorNoDI_NullPassword()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
"FakeUsername",
null);
Expand All @@ -111,7 +111,7 @@ public async Task TestUsernamePasswordConstructorNoDI_NullPassword()
public async Task TestUsernamePasswordAuthenticateRequestAsyncNoResource()
{
var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
"FakeUsername",
"FakePassword".ToSecureString());
Expand All @@ -124,7 +124,7 @@ public async Task TestUsernamePasswordAuthenticateRequestAsyncNoResource()
public async Task TestUsernamePasswordAuthenticateRequestAsyncNoHttpRequest()
{
var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
"FakeUsername",
"FakePassword".ToSecureString());
Expand All @@ -140,9 +140,10 @@ public async Task TestUsernamePasswordAuthenticateRequestAsyncCorrect()
var configuration = TestCommon.GetConfigurationSettings();
var username = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{usernamePasswordConfigurationPath}:UsernamePassword:Username");
var password = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{usernamePasswordConfigurationPath}:UsernamePassword:Password");
var clientId = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{usernamePasswordConfigurationPath}:ClientId");

var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
clientId,
AuthGlobals.OrganizationsTenantId,
username,
password.ToSecureString());
Expand All @@ -159,7 +160,7 @@ public async Task TestUsernamePasswordAuthenticateRequestAsyncCorrect()
public async Task TestUsernamePasswordGetAccessTokenAsyncNullResource()
{
var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
"FakeUsername",
"FakePassword".ToSecureString());
Expand All @@ -172,7 +173,7 @@ public async Task TestUsernamePasswordGetAccessTokenAsyncNullResource()
public async Task TestUsernamePasswordGetAccessTokenAsyncFullNullResource()
{
var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
"FakeUsername",
"FakePassword".ToSecureString());
Expand All @@ -185,7 +186,7 @@ public async Task TestUsernamePasswordGetAccessTokenAsyncFullNullResource()
public async Task TestUsernamePasswordGetAccessTokenAsyncFullNullScopes()
{
var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
"FakeUsername",
"FakePassword".ToSecureString());
Expand All @@ -201,9 +202,10 @@ public async Task TestUsernamePasswordGetAccessTokenAsyncCorrect()
var configuration = TestCommon.GetConfigurationSettings();
var username = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{usernamePasswordConfigurationPath}:UsernamePassword:Username");
var password = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{usernamePasswordConfigurationPath}:UsernamePassword:Password");
var clientId = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{usernamePasswordConfigurationPath}:ClientId");

var provider = new UsernamePasswordAuthenticationProvider(
AuthGlobals.DefaultClientId,
clientId,
AuthGlobals.OrganizationsTenantId,
username,
password.ToSecureString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task TestX509CertificateConstructorNoDI()

[TestMethod]
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task TestX509CertificateConstructorNoDI_NullClientId_NullTenantId()
public async Task TestX509CertificateConstructorNoDI_NullTenantId()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
//if (TestCommon.RunningInGitHubWorkflow()) Assert.Inconclusive("Skipping test because we're running inside a GitHub action and we don't have access to the certificate store");
Expand All @@ -80,9 +80,10 @@ public async Task TestX509CertificateConstructorNoDI_NullClientId_NullTenantId()
var storeName = configuration.GetValue<StoreName>($"{TestGlobals.CredentialsConfigurationBasePath}:{x509CertificateConfigurationPath}:X509Certificate:StoreName");
var storeLocation = configuration.GetValue<StoreLocation>($"{TestGlobals.CredentialsConfigurationBasePath}:{x509CertificateConfigurationPath}:X509Certificate:StoreLocation");
var thumbprint = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{x509CertificateConfigurationPath}:X509Certificate:Thumbprint");
var clientId = configuration.GetValue<string>($"{TestGlobals.CredentialsConfigurationBasePath}:{x509CertificateConfigurationPath}:ClientId");

var provider = new X509CertificateAuthenticationProvider(
null,
clientId,
null,
storeName,
storeLocation,
Expand All @@ -105,7 +106,7 @@ public async Task TestX509CertificateConstructorNoDI_NullThumbprint()
var storeLocation = configuration.GetValue<StoreLocation>($"{TestGlobals.CredentialsConfigurationBasePath}:{x509CertificateConfigurationPath}:X509Certificate:StoreLocation");

var provider = new X509CertificateAuthenticationProvider(
AuthGlobals.DefaultClientId,
TestGlobals.FakeClientId,
AuthGlobals.OrganizationsTenantId,
storeName,
storeLocation,
Expand Down
2 changes: 2 additions & 0 deletions src/sdk/PnP.Core.Auth.Test/Utilities/TestGlobals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ internal static class TestGlobals

internal static string CredentialsConfigurationBasePath = "PnPCore:Credentials:Configurations";
internal static string SitesConfigurationBasePath = "PnPCore:Sites";

internal static string FakeClientId = "33333333-3333-3333-3333-333333333333";
}
}
7 changes: 0 additions & 7 deletions src/sdk/PnP.Core.Auth/AuthGlobals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ namespace PnP.Core.Auth
{
internal static class AuthGlobals
{
// Microsoft SharePoint Online Management Shell client id = "9bc3ab49-b65d-410a-85ad-de819febfddc";
// PnP Office 365 Management Shell = "31359c7f-bd7e-475c-86db-fdb8c937548e";
/// <summary>
/// Defines the default Client ID for apps that do not rely on their own Client ID
/// </summary>
internal const string DefaultClientId = "31359c7f-bd7e-475c-86db-fdb8c937548e";

/// <summary>
/// Defines the multi-tenant ID for multi-tenant apps
/// </summary>
Expand Down
Loading

0 comments on commit fdcbc1a

Please sign in to comment.