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

Moving to Active Directory SDK 4.5 and adding Xamarin.iOS10 support #365

Merged
merged 2 commits into from
Feb 11, 2019
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
4 changes: 3 additions & 1 deletion src/Microsoft.Azure.EventHubs/EventHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public static EventHubClient Create(
return eventHubClient;
}

#if !UAP10_0 && !IOS
/// <summary>
/// Creates a new instance of the Event Hubs client using the specified endpoint, entity path, AAD authentication context.
/// </summary>
Expand All @@ -109,6 +110,7 @@ public static EventHubClient Create(
operationTimeout,
transportType);
}
#endif

/// <summary>
/// Creates a new instance of the Event Hubs client using the specified endpoint, entity path, AAD authentication context.
Expand Down Expand Up @@ -142,7 +144,7 @@ public static EventHubClient Create(
transportType);
}

#if !UAP10_0
#if !UAP10_0 && !IOS
/// <summary>
/// Creates a new instance of the Event Hubs client using the specified endpoint, entity path, AAD authentication context.
/// </summary>
Expand Down
20 changes: 15 additions & 5 deletions src/Microsoft.Azure.EventHubs/Microsoft.Azure.EventHubs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyTitle>Microsoft.Azure.EventHubs</AssemblyTitle>
<VersionPrefix>2.2.0</VersionPrefix>
<Authors>Microsoft</Authors>
<TargetFrameworks>net461;netstandard2.0;uap10.0</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;uap10.0;Xamarin.iOS10</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
<AssemblyOriginatorKeyFile>../../build/keyfile.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -49,11 +49,15 @@
<DefineConstants>$(DefineConstants);NETSTANDARD2_0</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'Xamarin.iOS10'">
<DefineConstants>$(DefineConstants);IOS</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.IdentityModel" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="4.0.4.403061554" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="4.0.4.403061554" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
Expand All @@ -67,17 +71,21 @@
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.4" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'Xamarin.iOS10' ">
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.6.40" PrivateAssets="All" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.4" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Amqp" Version="2.3.7" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.0.3" />
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.19.8" />
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="4.5.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
<PackageReference Include="System.Net.Http" Version="4.3.3" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.0" />
</ItemGroup>


<ItemGroup>
<ItemGroup>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand All @@ -92,4 +100,6 @@
</EmbeddedResource>
</ItemGroup>

<Import Project="$(MSBuildSdkExtrasTargets)" Condition="Exists('$(MSBuildSdkExtrasTargets)')" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ namespace Microsoft.Azure.EventHubs
public class AzureActiveDirectoryTokenProvider : TokenProvider
{
readonly AuthenticationContext authContext;

#if !UAP10_0 && !IOS
readonly ClientCredential clientCredential;
#if !UAP10_0
readonly ClientAssertionCertificate clientAssertionCertificate;
#endif
readonly string clientId;
Expand All @@ -32,6 +33,7 @@ enum AuthType

readonly AuthType authType;

#if !UAP10_0 && !IOS
internal AzureActiveDirectoryTokenProvider(AuthenticationContext authContext, ClientCredential credential)
{
this.clientCredential = credential;
Expand All @@ -40,7 +42,6 @@ internal AzureActiveDirectoryTokenProvider(AuthenticationContext authContext, Cl
this.clientId = clientCredential.ClientId;
}

#if !UAP10_0
internal AzureActiveDirectoryTokenProvider(AuthenticationContext authContext, ClientAssertionCertificate clientAssertionCertificate)
{
this.clientAssertionCertificate = clientAssertionCertificate;
Expand Down Expand Up @@ -72,16 +73,15 @@ public override async Task<SecurityToken> GetTokenAsync(string appliesTo, TimeSp

switch (this.authType)
{
#if !UAP10_0 && !IOS
case AuthType.ClientCredential:
authResult = await this.authContext.AcquireTokenAsync(ClientConstants.AadEventHubsAudience, this.clientCredential);
break;

#if !UAP10_0
case AuthType.ClientAssertionCertificate:
authResult = await this.authContext.AcquireTokenAsync(ClientConstants.AadEventHubsAudience, this.clientAssertionCertificate);
break;
#endif

case AuthType.InteractiveUserLogin:
authResult = await this.authContext.AcquireTokenAsync(ClientConstants.AadEventHubsAudience, this.clientId, this.redirectUri, this.platformParameters, this.userIdentifier);
break;
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Azure.EventHubs/Primitives/ClientInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ static ClientInfo()
platform = "UAP";
#elif NET461
platform = Environment.OSVersion.VersionString;
#elif IOS
platform = "IOS";
#endif
}
catch { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Microsoft.Azure.EventHubs
{
using System;
using System.Collections.ObjectModel;
using System.IdentityModel.Tokens;
#if !NET461
using System.IdentityModel.Tokens.Jwt;
Expand Down
5 changes: 4 additions & 1 deletion src/Microsoft.Azure.EventHubs/Primitives/TokenProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public static TokenProvider CreateSharedAccessSignatureTokenProvider(string keyN
return new SharedAccessSignatureTokenProvider(keyName, sharedAccessKey, tokenTimeToLive, tokenScope);
}


#if !UAP10_0 && !IOS
/// <summary>Creates an Azure Active Directory token provider.</summary>
/// <param name="authContext">AuthenticationContext for AAD.</param>
/// <param name="clientCredential">The app credential.</param>
Expand All @@ -87,6 +89,7 @@ public static TokenProvider CreateAadTokenProvider(AuthenticationContext authCon

return new AzureActiveDirectoryTokenProvider(authContext, clientCredential);
}
#endif

/// <summary>Creates an Azure Active Directory token provider.</summary>
/// <param name="authContext">AuthenticationContext for AAD.</param>
Expand All @@ -110,7 +113,7 @@ public static TokenProvider CreateAadTokenProvider(
return new AzureActiveDirectoryTokenProvider(authContext, clientId, redirectUri, platformParameters, userIdentifier);
}

#if !UAP10_0
#if !UAP10_0 && !IOS
/// <summary>Creates an Azure Active Directory token provider.</summary>
/// <param name="authContext">AuthenticationContext for AAD.</param>
/// <param name="clientAssertionCertificate">The client assertion certificate credential.</param>
Expand Down