Skip to content

Commit

Permalink
Publish v20 (#149)
Browse files Browse the repository at this point in the history
* Fix: In claims configuration page, the values in the list of "PickerEntity metadata" was not populated correctly, which caused an issue with the "Title" (and a few others)
* Fix: Ensure augmentation can continue even if a tenant has a problem
* Reorganize AzureCP.csproj file
* Add a link to the privacy policy
* Explicitly set build property DependsOnNETStandard to false to try to get rid of occasional FileNotFoundException error "Could not load file or assembly 'netstandard, Version=2.0.0.0"
* Update NuGet package Microsoft.Graph to 3.35
* Update NuGet package Microsoft.Identity.Client to 4.42.1
* Update NuGet package Nito.AsyncEx to 5.1.2
* Update NuGet package NUnit to 3.13.3
* Update NuGet package NUnit3TestAdapter to 4.2.1
  • Loading branch information
Yvand authored Apr 21, 2022
1 parent 9c24abe commit 26bda0a
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 60 deletions.
6 changes: 3 additions & 3 deletions AzureCP.Tests/AzureCP.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@
<Version>1.0.12</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
<Version>13.0.1</Version>
</PackageReference>
<PackageReference Include="NUnit">
<Version>3.13.1</Version>
<Version>3.13.3</Version>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter">
<Version>3.17.0</Version>
<Version>4.2.1</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
9 changes: 9 additions & 0 deletions AzureCP/AzureCP.AdminLinks/Elements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@
Sequence="20">
<UrlAction Url="/_admin/azurecp/ClaimTypesConfig.aspx" />
</CustomAction>

<CustomAction
Id="AzureCPPrivacyPolicy"
GroupId="AzureCP"
Location="Microsoft.SharePoint.Administration.Security"
Title="Privacy policy"
Sequence="30">
<UrlAction Url="https://azurecp.yvand.net/privacy-policy/" />
</CustomAction>
</Elements>
24 changes: 17 additions & 7 deletions AzureCP/AzureCP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -757,13 +757,23 @@ protected async Task<List<SPClaim>> GetGroupMembershipFromAzureADAsync(Operation
// URL encode the filter to prevent that it gets truncated like this: "UserPrincipalName eq 'guest_contoso.com" instead of "UserPrincipalName eq 'guest_contoso.com#EXT#@TENANT.onmicrosoft.com'"
string filter = HttpUtility.UrlEncode($"{currentContext.IncomingEntityClaimTypeConfig.DirectoryObjectProperty} eq '{currentContext.IncomingEntity.Value}'");

// https://github.com/Yvand/AzureCP/issues/78
// In this method, awaiting on the async task hangs in some scenario (reproduced only in multi-server 2019 farm in the w3wp of a site while using "check permissions" feature)
// Workaround: Instead of awaiting on the async task directly, run it in a parent task, and await on the parent task.
//IGraphServiceUsersCollectionPage userResult = await tenant.GraphService.Users.Request().Filter(filter).GetAsync().ConfigureAwait(false);
IGraphServiceUsersCollectionPage userResult = await Task.Run(() => tenant.GraphService.Users.Request().Filter(filter).GetAsync()).ConfigureAwait(false);
User user = userResult.FirstOrDefault();
// Do this operation in a try/catch, so if current tenant throws an exception (e.g. secret is expired), execution can still continue for other tenants
IGraphServiceUsersCollectionPage userResult = null;
try
{
// https://github.com/Yvand/AzureCP/issues/78
// In this method, awaiting on the async task hangs in some scenario (reproduced only in multi-server 2019 farm in the w3wp of a site while using "check permissions" feature)
// Workaround: Instead of awaiting on the async task directly, run it in a parent task, and await on the parent task.
// userResult = await tenant.GraphService.Users.Request().Filter(filter).GetAsync().ConfigureAwait(false);
userResult = await Task.Run(() => tenant.GraphService.Users.Request().Filter(filter).GetAsync()).ConfigureAwait(false);
}
catch (Exception ex)
{
ClaimsProviderLogging.LogException(ProviderInternalName, $"on tenant '{tenant.Name}' while running query '{filter}'", TraceCategory.Lookup, ex);
return claims;
}

User user = userResult.FirstOrDefault();
if (user == null)
{
// If user was not found, he might be a Guest user. Query to check this: /users?$filter=userType eq 'Guest' and mail eq '[email protected]'&$select=userPrincipalName, Id
Expand Down Expand Up @@ -1464,7 +1474,7 @@ protected virtual async Task<AzureADResult> QueryAzureADTenantAsync(OperationCon
// Use await Task.WhenAll() as it does not block other threads, so all AAD tenants are actually queried in parallel.
// More info: https://stackoverflow.com/questions/12337671/using-async-await-for-multiple-tasks
await Task.WhenAll(new Task[1] { batchQueryTask }).ConfigureAwait(false);
ClaimsProviderLogging.LogDebug($"Waiting on Task.WaitAll for {tenant.Name} finished");
ClaimsProviderLogging.LogDebug($"Waiting on Task.WaitAll for {tenant.Name} finished");
}
}
catch (OperationCanceledException)
Expand Down
45 changes: 21 additions & 24 deletions AzureCP/AzureCP.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<!-- Common -->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EEC47949-34B5-4805-A04D-A372BE75D3CB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
Expand All @@ -25,7 +24,11 @@
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>AzureCP.snk</AssemblyOriginatorKeyFile>
<DependsOnNETStandard>false</DependsOnNETStandard>
</PropertyGroup>
<!-- Debug configuration -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
Expand All @@ -36,6 +39,7 @@
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<!-- Release configuration -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand All @@ -45,12 +49,7 @@
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>AzureCP.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<!-- Project references -->
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
Expand All @@ -65,20 +64,16 @@
<Compile Include="AzureCP.cs" />
<Compile Include="AzureCPConfig.cs" />
<Compile Include="AzureCPLogging.cs" />
<Compile Include="AzureCPUserControl.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="AzureCPUserControl.cs" />
<Compile Include="ClaimTypeConfig.cs" />
<Compile Include="TEMPLATE\ADMIN\AzureCP\ClaimTypesConfig.ascx.cs">
<DependentUpon>ClaimTypesConfig.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="TEMPLATE\ADMIN\AzureCP\ClaimTypesConfig.ascx.designer.cs">
<DependentUpon>ClaimTypesConfig.ascx.cs</DependentUpon>
</Compile>
<Compile Include="TEMPLATE\ADMIN\AzureCP\AzureCPGlobalSettings.ascx.cs">
<DependentUpon>AzureCPGlobalSettings.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="TEMPLATE\ADMIN\AzureCP\AzureCPGlobalSettings.ascx.designer.cs">
<DependentUpon>AzureCPGlobalSettings.ascx.cs</DependentUpon>
Expand Down Expand Up @@ -109,15 +104,16 @@
<SharePointProjectItemId>{aa00a720-1ea7-47a5-8993-73b778baef87}</SharePointProjectItemId>
</None>
</ItemGroup>
<!-- NuGet packages -->
<ItemGroup>
<PackageReference Include="Microsoft.Graph">
<Version>3.23.0</Version>
<Version>3.35.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Identity.Client">
<Version>4.25.0</Version>
<Version>4.42.1</Version>
</PackageReference>
<PackageReference Include="Nito.AsyncEx">
<Version>5.1.0</Version>
<Version>5.1.2</Version>
</PackageReference>
<PackageReference Include="StrongNamer">
<Version>0.2.5</Version>
Expand All @@ -144,25 +140,26 @@
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\SharePointTools\Microsoft.VisualStudio.SharePoint.targets" Condition="'$(VSToolsPath)' != ''" />
<!-- Copy the assemblies that will be added to the WSP package -->
<PropertyGroup>
<PostBuildEvent>"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\gacutil.exe" /f /i "$(TargetPath)"
copy /Y "$(TargetDir)Microsoft.Identity.Client.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Microsoft.Graph.Core.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Microsoft.Graph.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Microsoft.Identity.Client.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Newtonsoft.Json.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Buffers.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Collections.Immutable.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Diagnostics.DiagnosticSource.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Memory.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Numerics.Vectors.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Runtime.CompilerServices.Unsafe.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Nito.AsyncEx.Context.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Nito.AsyncEx.Coordination.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Nito.AsyncEx.Interop.WaitHandles.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Nito.AsyncEx.Oop.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Nito.AsyncEx.Tasks.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Nito.Cancellation.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Nito.Collections.Deque.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)Nito.Disposables.dll" $(ProjectDir)\bin</PostBuildEvent>
copy /Y "$(TargetDir)Nito.Disposables.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Buffers.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Collections.Immutable.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Diagnostics.DiagnosticSource.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Memory.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Numerics.Vectors.dll" $(ProjectDir)\bin
copy /Y "$(TargetDir)System.Runtime.CompilerServices.Unsafe.dll" $(ProjectDir)\bin</PostBuildEvent>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion AzureCP/AzureCPConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static class ClaimsProviderConstants
public static string GroupClaimEntityType { get; set; } = SPClaimEntityTypes.FormsRole;
public static bool EnforceOnly1ClaimTypeForGroup => true; // In AzureCP, only 1 claim type can be used to create group permissions
public static string DefaultMainGroupClaimType => WIF4_5.ClaimTypes.Role;
public static string PUBLICSITEURL => "https://yvand.github.io/AzureCP/";
public static string PUBLICSITEURL => "https://azurecp.yvand.net/";
public static string GUEST_USERTYPE => "Guest";
public static string MEMBER_USERTYPE => "Member";
private static object Sync_SetClaimsProviderVersion = new object();
Expand Down
26 changes: 13 additions & 13 deletions AzureCP/Package/Package.package
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.0.0.0" Id="1db45b9b-2fff-4f07-992b-344dde907316" solutionId="1db45b9b-2fff-4f07-992b-344dde907316" resetWebServer="false" title="Azure AD Claims Provider" sharePointProductVersion="15.0" name="AzureCP" xmlns="http://schemas.microsoft.com/VisualStudio/2008/SharePointTools/PackageModel">
<assemblies>
<customAssembly location="Microsoft.Identity.Client.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Microsoft.Identity.Client.dll" />
<customAssembly location="Microsoft.Graph.Core.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Microsoft.Graph.Core.dll" />
<customAssembly location="Microsoft.Graph.Core.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Microsoft.Graph.Core.dll" />
<customAssembly location="Microsoft.Graph.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Microsoft.Graph.dll" />
<customAssembly location="Newtonsoft.Json.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Newtonsoft.Json.dll" />
<customAssembly location="Microsoft.Identity.Client.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Microsoft.Identity.Client.dll" />
<customAssembly location="Newtonsoft.Json.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Newtonsoft.Json.dll" />
<customAssembly location="Nito.AsyncEx.Context.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Context.dll" />
<customAssembly location="Nito.AsyncEx.Coordination.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Coordination.dll" />
<customAssembly location="Nito.AsyncEx.Interop.WaitHandles.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Interop.WaitHandles.dll" />
<customAssembly location="Nito.AsyncEx.Oop.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Oop.dll" />
<customAssembly location="Nito.AsyncEx.Tasks.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Tasks.dll" />
<customAssembly location="Nito.Cancellation.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.Cancellation.dll" />
<customAssembly location="Nito.Collections.Deque.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.Collections.Deque.dll" />
<customAssembly location="Nito.Disposables.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.Disposables.dll" />
<customAssembly location="System.Buffers.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\System.Buffers.dll" />
<customAssembly location="System.Collections.Immutable.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\System.Collections.Immutable.dll" />
<customAssembly location="System.Diagnostics.DiagnosticSource.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\System.Diagnostics.DiagnosticSource.dll" />
<customAssembly location="System.Memory.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\System.Memory.dll" />
<customAssembly location="System.Numerics.Vectors.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\System.Numerics.Vectors.dll" />
<customAssembly location="System.Memory.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\System.Memory.dll" />
<customAssembly location="System.Numerics.Vectors.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\System.Numerics.Vectors.dll" />
<customAssembly location="System.Runtime.CompilerServices.Unsafe.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\System.Runtime.CompilerServices.Unsafe.dll" />
<customAssembly location="Nito.AsyncEx.Context.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Context.dll" />
<customAssembly location="Nito.AsyncEx.Coordination.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Coordination.dll" />
<customAssembly location="Nito.AsyncEx.Interop.WaitHandles.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Interop.WaitHandles.dll" />
<customAssembly location="Nito.AsyncEx.Oop.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Oop.dll" />
<customAssembly location="Nito.AsyncEx.Tasks.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.AsyncEx.Tasks.dll" />
<customAssembly location="Nito.Cancellation.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.Cancellation.dll" />
<customAssembly location="Nito.Collections.Deque.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.Collections.Deque.dll" />
<customAssembly location="Nito.Disposables.dll" deploymentTarget="GlobalAssemblyCache" sourcePath="bin\Nito.Disposables.dll" />
</assemblies>
<features>
<featureReference itemId="70b104e2-19df-4cb1-9802-c98eaf14d84e" />
Expand Down
2 changes: 1 addition & 1 deletion AzureCP/TEMPLATE/ADMIN/AzureCP/AzureCPGlobalSettings.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
</wssuc:inputformsection>
<wssuc:inputformsection title="Register a new Azure Active Directory tenant" runat="server">
<template_description>
<wssawc:EncodedLiteral runat="server" text="<p>AzureCP needs its own app registration to connect to your Azure AD tenant, with permissions 'Group.Read.All' and 'User.Read.All'.<br />Check <a href='https://yvand.github.io/AzureCP/Register-App-In-AAD.html' target='_blank'>this page</a> to see how to register it properly.<br /><br />AzureCP can authenticate using <a href='https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#get-a-token' target='_blank'>either a secret or a certificate</a>.</p>" EncodeMethod='NoEncode' />
<wssawc:EncodedLiteral runat="server" text="<p>AzureCP needs its own app registration to connect to your Azure AD tenant, with permissions 'Group.Read.All' and 'User.Read.All'.<br />Check <a href='https://azurecp.yvand.net/docs/usage/register-application/' target='_blank'>this page</a> to see how to register it properly.<br /><br />AzureCP can authenticate using <a href='https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#get-a-token' target='_blank'>either a secret or a certificate</a>.</p>" EncodeMethod='NoEncode' />
</template_description>
<template_inputformcontrols>
<tr><td>
Expand Down
4 changes: 3 additions & 1 deletion AzureCP/TEMPLATE/ADMIN/AzureCP/ClaimTypesConfig.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ protected void Initialize()
DdlNewEntityMetadata.Items.Add(String.Empty);
foreach (object field in typeof(PeopleEditorEntityDataKeys).GetFields())
{
DdlNewEntityMetadata.Items.Add(((System.Reflection.FieldInfo)field).Name);
FieldInfo fi = (FieldInfo)field;
object fieldValue = fi.GetValue(null);
DdlNewEntityMetadata.Items.Add(fieldValue.ToString());
}

DdlNewGraphProperty.Items.Add(String.Empty);
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change log for AzureCP

## Unreleased

* Fix: In claims configurfation page, the values in the list of "PickerEntity metadata" was not populated correctly, which caused an issue with the "Title" (and a few others)
* Fix: Ensure augmentation can continue even if a tenant has a problem
* Reorganize AzureCP.csproj file
* Add a link to the privacy policy
* Explicitely set build property DependsOnNETStandard to false to try to get rid of occasional FileNotFoundException error "Could not load file or assembly 'netstandard, Version=2.0.0.0"
* Update NuGet package Microsoft.Graph to 3.35
* Update NuGet package Microsoft.Identity.Client to 4.42.1
* Update NuGet package Nito.AsyncEx to 5.1.2
* Update NuGet package NUnit to 3.13.3
* Update NuGet package NUnit3TestAdapter to 4.2.1

## AzureCP 19.0.20210211.1285 enhancements & bug-fixes - Published in February 11, 2021

* Fix bug: No Azure AD group was returned when FilterSecurityEnabledGroupsOnly is set to true - https://github.com/Yvand/AzureCP/issues/109
Expand Down
Loading

0 comments on commit 26bda0a

Please sign in to comment.