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

Initial version to support OWIN, .NET, .NET Core #1661

Merged
merged 58 commits into from
Jul 24, 2022
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7b4298d
Initial version.
jmprieur Mar 16, 2022
51110b1
Updating the tests.
jmprieur Mar 17, 2022
8a0968b
- Adding a plain dotnet token acquisition host.
jmprieur Mar 17, 2022
343d12d
- Adding a plain dotnet token acquisition host.
jmprieur Mar 17, 2022
b1311aa
Simplifying
jmprieur Mar 17, 2022
8bee620
Add a daemon-net6 sample / test
jmprieur Mar 18, 2022
f7e6e23
Moving ITokenAcquirer and TokenAcquisitionOptions to
jmprieur Mar 21, 2022
7af0936
Update
jmprieur Apr 16, 2022
6a72426
Update
jmprieur Apr 16, 2022
2a45071
Merge branch 'jmprieur/Sandbox-FutureDevEx' of https://github.com/Azu…
jmprieur Apr 16, 2022
9fd188e
Merge from master
jmprieur Apr 16, 2022
803cb7a
- Simplifying the experience for the .NET 46x case (remove the need f…
jmprieur Apr 17, 2022
28ac78a
Updarting the OWIN sample
jmprieur Apr 19, 2022
f24e9d4
Merging the OWIN implementation (only for web APIs for the moment)
jmprieur Apr 20, 2022
78532e4
Solving build issues
jmprieur Apr 20, 2022
92998f0
Supporting several authentication schemes in the same controller acti…
jmprieur Apr 21, 2022
fc50e3b
Supporting several authentication schemes in the same controller acti…
jmprieur Apr 21, 2022
293696b
merge
jmprieur Apr 21, 2022
7e4b971
Adding a new assembly Microsoft.Identity.Web.TokenAcquisition
jmprieur Apr 25, 2022
e06cb92
Merge branch 'master' into jmprieur/Sandbox-FutureDevEx
jmprieur Apr 25, 2022
649dab7
Fixing warnings
jmprieur Apr 25, 2022
52cd7e0
Update dotnetcore.yml
jmprieur Apr 25, 2022
caf2561
Update dotnetcore.yml
jmprieur Apr 25, 2022
f9a5024
Update dotnetcore.yml
jmprieur Apr 25, 2022
5f5d66e
Update Microsoft.Identity.Web.sln
jmprieur Apr 26, 2022
4b9b329
Avoid building the OWIN web API in any CPU config
jmprieur Apr 26, 2022
fec6e99
merge conflict
jmprieur Apr 26, 2022
a5ff9e0
Adding a TokenAcquirerFactory and a specialization for OWIN.
jmprieur Apr 30, 2022
b8bc6b4
Adding a factory from the configuration and services
jmprieur May 2, 2022
d7e0d1e
Updating the interfaces based on the discussions
jmprieur May 31, 2022
054ce12
Adding the IDowstreamRestApi
jmprieur Jun 7, 2022
de2940f
Update POC with master (#1752)
jennyf19 Jun 8, 2022
fae9bc7
Update names and provide a class diagram
jmprieur Jun 8, 2022
0ac3859
Addressing Brent's feedback
jmprieur Jun 9, 2022
551cbfb
Taking into account the discussions Brent/Jm from 6/13
jmprieur Jun 14, 2022
cc4902e
Attempt to reconcile ClaimsPrincipal and S2SAuthenticationTicket
jmprieur Jun 14, 2022
94db8aa
Improving the CredentialDescription.
jmprieur Jun 15, 2022
4779f87
Renaming TokenAcquirerOptions to AcquireTokenOptions
jmprieur Jun 15, 2022
eef3d17
Renaming agreed with Brent
jmprieur Jun 17, 2022
9bf72c9
Adressing more feedback
jmprieur Jun 17, 2022
c69ea6a
Update based on decisions made with Brent 6/17
jmprieur Jun 17, 2022
98f648e
Fixing XML comments and adding folders in TokenAcquisition.Abstractions
jmprieur Jun 18, 2022
1b0465c
Renamings + clean-up abstractions
jmprieur Jun 23, 2022
db0f098
Moving the MicrosotAuthenticationTicket
jmprieur Jun 23, 2022
1911b90
Adding Graph extensibility
jmprieur Jun 28, 2022
6b90d6c
Merge from rel/v2.0
jmprieur Jun 28, 2022
3591f0b
Update Microsoft.Identity.Web.Certificate
jmprieur Jun 28, 2022
3e55b5a
Merge from master
jmprieur Jun 29, 2022
7612797
add Owin web app (#1753)
jennyf19 Jul 12, 2022
45b39f0
Merge from rel/v2
jmprieur Jul 12, 2022
3e4f4c3
update new dlls with directory.build.props (#1807)
jennyf19 Jul 18, 2022
a97c4cf
ID.Web.MicrosoftGraph now eferences Id.Web.TokenAcqusition (and not I…
jmprieur Jul 18, 2022
29bb54a
Merge from rel/v2
jmprieur Jul 18, 2022
a036197
address PR comments
jennyf19 Jul 19, 2022
0ed36ad
small edits
jennyf19 Jul 19, 2022
604c5fe
PR feedback and renaming
jennyf19 Jul 23, 2022
b20c211
fix build issues
jennyf19 Jul 23, 2022
0e82262
address governance issues
jennyf19 Jul 23, 2022
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
49 changes: 44 additions & 5 deletions Microsoft.Identity.Web.sln
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,26 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Toke
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Certificate", "src\Microsoft.Identity.Web.Certificate\Microsoft.Identity.Web.Certificate.csproj", "{1E0B96CD-FDBF-482C-996A-775F691D984E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Certificateless", "src\Microsoft.Identity.Web.Certificateless\Microsoft.Identity.Web.Certificateless.csproj", "{01AA87C9-75BB-42DE-A71E-2932229224B2}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Daemon", "Daemon", "{5D970909-98CF-415C-A598-D60B4B4AD8A9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Daemon-app", "tests\daemon-app\Daemon-app\Daemon-app.csproj", "{8C557C25-25C9-45B6-B2D3-77093893EBC5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net462", "net462", "{A4BF732A-BED6-408E-805A-118CE2A692B6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Asp.NET MVC", "Asp.NET MVC", "{7C04159B-BC84-4B8E-B2D8-692AEBA86433}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OwinWebApi", "tests\aspnet-mvc\OwinWebApi\OwinWebApi.csproj", "{E3611BED-B43A-40BD-A0A3-98AD65B5DAA4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.TokenAcquisition.Abstractions", "src\Microsoft.Identity.Web.TokenAcquisition.Abstractions\Microsoft.Identity.Web.TokenAcquisition.Abstractions.csproj", "{98F57CC8-01A0-49F3-B859-DDC4F8F5CD2F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Certificateless", "src\Microsoft.Identity.Web.Certificateless\Microsoft.Identity.Web.Certificateless.csproj", "{01AA87C9-75BB-42DE-A71E-2932229224B2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.OWIN", "src\Microsoft.Identity.Web.OWIN\Microsoft.Identity.Web.OWIN.csproj", "{2467D9A0-045B-4B45-8CCB-1AA229093F9F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.TokenAcquisition", "src\Microsoft.Identity.Web.TokenAcquisition\Microsoft.Identity.Web.TokenAcquisition.csproj", "{74737C0A-25E6-4E2C-B3AA-F7EECB7A07C7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OwinWebApp", "tests\aspnet-mvc\OwinWebApp\OwinWebApp.csproj", "{B288DE73-6B29-4B4D-AF02-6683D4C8D163}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -283,14 +299,31 @@ Global
{1E0B96CD-FDBF-482C-996A-775F691D984E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E0B96CD-FDBF-482C-996A-775F691D984E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E0B96CD-FDBF-482C-996A-775F691D984E}.Release|Any CPU.Build.0 = Release|Any CPU
{01AA87C9-75BB-42DE-A71E-2932229224B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01AA87C9-75BB-42DE-A71E-2932229224B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01AA87C9-75BB-42DE-A71E-2932229224B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01AA87C9-75BB-42DE-A71E-2932229224B2}.Release|Any CPU.Build.0 = Release|Any CPU
{8C557C25-25C9-45B6-B2D3-77093893EBC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C557C25-25C9-45B6-B2D3-77093893EBC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C557C25-25C9-45B6-B2D3-77093893EBC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C557C25-25C9-45B6-B2D3-77093893EBC5}.Release|Any CPU.Build.0 = Release|Any CPU
{E3611BED-B43A-40BD-A0A3-98AD65B5DAA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3611BED-B43A-40BD-A0A3-98AD65B5DAA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98F57CC8-01A0-49F3-B859-DDC4F8F5CD2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98F57CC8-01A0-49F3-B859-DDC4F8F5CD2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98F57CC8-01A0-49F3-B859-DDC4F8F5CD2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98F57CC8-01A0-49F3-B859-DDC4F8F5CD2F}.Release|Any CPU.Build.0 = Release|Any CPU
{01AA87C9-75BB-42DE-A71E-2932229224B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01AA87C9-75BB-42DE-A71E-2932229224B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01AA87C9-75BB-42DE-A71E-2932229224B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01AA87C9-75BB-42DE-A71E-2932229224B2}.Release|Any CPU.Build.0 = Release|Any CPU
{2467D9A0-045B-4B45-8CCB-1AA229093F9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2467D9A0-045B-4B45-8CCB-1AA229093F9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2467D9A0-045B-4B45-8CCB-1AA229093F9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2467D9A0-045B-4B45-8CCB-1AA229093F9F}.Release|Any CPU.Build.0 = Release|Any CPU
{74737C0A-25E6-4E2C-B3AA-F7EECB7A07C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74737C0A-25E6-4E2C-B3AA-F7EECB7A07C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74737C0A-25E6-4E2C-B3AA-F7EECB7A07C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74737C0A-25E6-4E2C-B3AA-F7EECB7A07C7}.Release|Any CPU.Build.0 = Release|Any CPU
{B288DE73-6B29-4B4D-AF02-6683D4C8D163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B288DE73-6B29-4B4D-AF02-6683D4C8D163}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B288DE73-6B29-4B4D-AF02-6683D4C8D163}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -345,6 +378,12 @@ Global
{D3A42D78-8A23-44EB-9A1F-63CF58B56AAC} = {9A51E6E0-A2B0-4D4D-9209-E73B8AD2B9C6}
{15B7F1B3-A438-4A42-BFFA-E3382543C037} = {D3A42D78-8A23-44EB-9A1F-63CF58B56AAC}
{5B9AD363-6A27-4AF2-939E-B20E7C941ADF} = {20CDB9B2-D237-413A-8E76-A973597748B0}
{5D970909-98CF-415C-A598-D60B4B4AD8A9} = {9A51E6E0-A2B0-4D4D-9209-E73B8AD2B9C6}
{8C557C25-25C9-45B6-B2D3-77093893EBC5} = {A4BF732A-BED6-408E-805A-118CE2A692B6}
{A4BF732A-BED6-408E-805A-118CE2A692B6} = {5D970909-98CF-415C-A598-D60B4B4AD8A9}
{7C04159B-BC84-4B8E-B2D8-692AEBA86433} = {9A51E6E0-A2B0-4D4D-9209-E73B8AD2B9C6}
{E3611BED-B43A-40BD-A0A3-98AD65B5DAA4} = {7C04159B-BC84-4B8E-B2D8-692AEBA86433}
{B288DE73-6B29-4B4D-AF02-6683D4C8D163} = {7C04159B-BC84-4B8E-B2D8-692AEBA86433}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F4FA8C4C-3251-41CC-939B-7892F5798549}
Expand Down
4 changes: 3 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</PropertyGroup>

<PropertyGroup Label="Common dependency versions">
<IdentityModelVersion>6.20.0</IdentityModelVersion>
<IdentityModelVersion>6.21.0</IdentityModelVersion>
<MicrosoftIdentityClientVersion>4.42.0</MicrosoftIdentityClientVersion>
<FxCopAnalyzersVersion>3.3.0</FxCopAnalyzersVersion>
<SystemTextEncodingsWebVersion>4.7.2</SystemTextEncodingsWebVersion>
Expand All @@ -78,6 +78,8 @@
<AzureSecurityKeyVaultCertificatesVersion>4.1.0</AzureSecurityKeyVaultCertificatesVersion>
<MicrosoftGraphVersion>4.11.0</MicrosoftGraphVersion>
<MicrosoftGraphBetaVersion>4.22.0-preview</MicrosoftGraphBetaVersion>
<MicrosoftExtensionsConfigurationBinderVersion>5.0.0</MicrosoftExtensionsConfigurationBinderVersion>
<MicrosoftExtensionsHttpVersion>3.1.3</MicrosoftExtensionsHttpVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net472' Or '$(TargetFramework)' == 'net462' Or '$(TargetFramework)' == 'net5.0'">
Expand Down
83 changes: 9 additions & 74 deletions src/Microsoft.Identity.Web.Certificate/Microsoft.Identity.Web.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/Microsoft.Identity.Web.MicrosoftGraph/BaseRequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ public static T WithAuthenticationScheme<T>(this T baseRequest, string authentic
return SetParameter(baseRequest, options => options.AuthenticationScheme = authenticationScheme);
}

/// <summary>
/// Overrides authentication options for a given request.
/// </summary>
/// <typeparam name="T">Request</typeparam>
/// <param name="baseRequest">Request.</param>
/// <param name="overrideAuthenticationOptions">Delegate to override
/// the authentication options</param>
/// <returns>Base request</returns>
public static T WithAuthenticationOptions<T>(this T baseRequest,
Action<DownstreamRestApiOptions> overrideAuthenticationOptions) where T : IBaseRequest
{
// TODO: implement
throw new NotImplementedException();
}

private static T SetParameter<T>(T baseRequest, Action<TokenAcquisitionAuthenticationProviderOption> action) where T : IBaseRequest
{
string authHandlerOptionKey = typeof(AuthenticationHandlerOption).FullName!;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.Graph;

namespace Microsoft.Identity.Web
{
/// <summary>
/// Extensions methods on a MicrosoftIdentityAppCallingWebApiAuthenticationBuilder builder
/// to add support to call Microsoft Graph.
/// </summary>
public static class GraphServiceCollectionExtensions
{
/// <summary>
/// Add support to call Microsoft Graph. From a named option and a configuration section.
/// </summary>
/// <param name="services">Builder.</param>
/// <returns>The service collection to chain.</returns>
public static IServiceCollection AddMicrosoftGraph(this IServiceCollection services)
{
services.AddTokenAcquisition();
services.AddHttpClient();
return services.AddMicrosoftGraph(options => { });
}

/// <summary>
/// Add support to call Microsoft Graph. From a base Graph URL and a default scope.
/// </summary>
/// <param name="services">Builder.</param>
/// <param name="configureMicrosoftGraphOptions">Delegate to configure the graph service options</param>
/// <returns>The service collection to chain.</returns>
public static IServiceCollection AddMicrosoftGraph(this IServiceCollection services, Action<MicrosoftGraphOptions> configureMicrosoftGraphOptions)
{
// https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
services.AddOptions<MicrosoftGraphOptions>().Configure(configureMicrosoftGraphOptions);

services.AddScoped<GraphServiceClient, GraphServiceClient>(serviceProvider =>
{
var tokenAquisitionService = serviceProvider.GetRequiredService<ITokenAcquisition>();
var options = serviceProvider.GetRequiredService<IOptions<MicrosoftGraphOptions>>();

var microsoftGraphOptions = options.Value;
if (microsoftGraphOptions.Scopes == null)
{
throw new ArgumentException(IDWebErrorMessage.CalledApiScopesAreNull);
}

string graphBaseUrl = microsoftGraphOptions.BaseUrl;
string[] initialScopes = microsoftGraphOptions.Scopes.Split(' ');

GraphServiceClient client = string.IsNullOrWhiteSpace(graphBaseUrl) ?
new GraphServiceClient(new TokenAcquisitionAuthenticationProvider(
tokenAquisitionService,
new TokenAcquisitionAuthenticationProviderOption() { Scopes = initialScopes.ToArray() })) :
new GraphServiceClient(graphBaseUrl,
new TokenAcquisitionAuthenticationProvider(
tokenAquisitionService,
new TokenAcquisitionAuthenticationProviderOption() { Scopes = initialScopes.ToArray() }));
return client;
});
return services;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
<ProjectGuid>{E4BC2331-6822-45C3-9702-D76DD0556532}</ProjectGuid>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Graph" Version="$(MicrosoftGraphVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
<ProjectReference Include="..\Microsoft.Identity.Web.TokenAcquisition\Microsoft.Identity.Web.TokenAcquisition.csproj" />
</ItemGroup>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0; net462; net472</TargetFrameworks>
jennyf19 marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

</Project>
Loading