From d84abf1fe6c39729df4cd485a7ccd4b72c98e10f Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 4 May 2017 19:26:44 -0700 Subject: [PATCH 001/248] Migrate to netcoreapp2.0 (#1202) * Migrate to netcoreapp2.0, remove Microsoft.Owin.Security.Interop & tests. * Remove net45 baselines --- Security.sln | 74 +- build/dependencies.props | 2 +- build/repo.props | 1 - samples/CookieSample/CookieSample.csproj | 4 +- .../CookieSessionSample.csproj | 4 +- .../JwtBearerSample/JwtBearerSample.csproj | 4 +- .../OpenIdConnect.AzureAdSample.csproj | 2 +- .../OpenIdConnectSample.csproj | 2 +- samples/SocialSample/SocialSample.csproj | 2 +- ...t.AspNetCore.Authentication.Cookies.csproj | 2 +- .../baseline.net45.json | 1661 ---------- ....AspNetCore.Authentication.Facebook.csproj | 2 +- .../baseline.net45.json | 453 --- ...ft.AspNetCore.Authentication.Google.csproj | 2 +- .../baseline.net45.json | 291 -- ...AspNetCore.Authentication.JwtBearer.csproj | 2 +- .../baseline.net45.json | 976 ------ ...ore.Authentication.MicrosoftAccount.csproj | 2 +- .../baseline.net45.json | 256 -- ...oft.AspNetCore.Authentication.OAuth.csproj | 2 +- .../baseline.net45.json | 955 ------ ...etCore.Authentication.OpenIdConnect.csproj | 2 +- .../baseline.net45.json | 2005 ------------ ...t.AspNetCore.Authentication.Twitter.csproj | 2 +- .../baseline.net45.json | 848 ----- ...Microsoft.AspNetCore.Authentication.csproj | 2 +- .../baseline.net45.json | 2897 ----------------- .../Microsoft.AspNetCore.Authorization.csproj | 2 +- .../baseline.net45.json | 1593 --------- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 +- .../baseline.net45.json | 392 --- .../AspNetTicketDataFormat.cs | 17 - .../AspNetTicketSerializer.cs | 220 -- .../ChunkingCookieManager.cs | 281 -- .../Constants.cs | 13 - .../DataProtectorShim.cs | 31 - .../Microsoft.Owin.Security.Interop.csproj | 18 - .../Properties/AssemblyInfo.cs | 8 - .../baseline.netframework.json | 373 --- ...soft.AspNetCore.Authentication.Test.csproj | 3 +- ...osoft.AspNetCore.Authorization.Test.csproj | 3 +- ....ChunkingCookieManager.Sources.Test.csproj | 3 +- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 3 +- .../CookieInteropTests.cs | 332 -- ...icrosoft.Owin.Security.Interop.Test.csproj | 28 - .../TicketInteropTests.cs | 91 - 46 files changed, 43 insertions(+), 13825 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authentication/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.Authorization/baseline.net45.json delete mode 100644 src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json delete mode 100644 src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/Constants.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj delete mode 100644 src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.Owin.Security.Interop/baseline.netframework.json delete mode 100644 test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs delete mode 100644 test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj delete mode 100644 test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs diff --git a/Security.sln b/Security.sln index 81d0cc4b9..157849c91 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.0 +VisualStudioVersion = 15.0.26403.7 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -46,10 +46,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtBearerSample", "samples\JwtBearerSample\JwtBearerSample.csproj", "{D399B84F-591B-4E98-92BA-B0F63E7B6957}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop", "src\Microsoft.Owin.Security.Interop\Microsoft.Owin.Security.Interop.csproj", "{A7922DD8-09F1-43E4-938B-CC523EA08898}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop.Test", "test\Microsoft.Owin.Security.Interop.Test\Microsoft.Owin.Security.Interop.Test.csproj", "{A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenIdConnect.AzureAdSample", "samples\OpenIdConnect.AzureAdSample\OpenIdConnect.AzureAdSample.csproj", "{3A7AD414-EBDE-4F92-B307-4E8F19B6117E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test", "test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj", "{51563775-C659-4907-9BAF-9995BAB87D01}" @@ -140,6 +136,22 @@ Global {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x64.Build.0 = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x86.ActiveCfg = Release|Any CPU {FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|x86.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.ActiveCfg = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.Build.0 = Debug|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.Build.0 = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.ActiveCfg = Release|Any CPU + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.Build.0 = Release|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Any CPU.Build.0 = Debug|Any CPU {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -348,38 +360,6 @@ Global {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x64.Build.0 = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.ActiveCfg = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.Build.0 = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.ActiveCfg = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.Build.0 = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.ActiveCfg = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.Build.0 = Debug|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.Build.0 = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.ActiveCfg = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.Build.0 = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.ActiveCfg = Release|Any CPU - {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.Build.0 = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.ActiveCfg = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.Build.0 = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.ActiveCfg = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.Build.0 = Debug|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.Build.0 = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.ActiveCfg = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.Build.0 = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.ActiveCfg = Release|Any CPU - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.Build.0 = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -412,22 +392,6 @@ Global {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x64.Build.0 = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.ActiveCfg = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.Build.0 = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.ActiveCfg = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x64.Build.0 = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.ActiveCfg = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Debug|x86.Build.0 = Debug|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Any CPU.Build.0 = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.ActiveCfg = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x64.Build.0 = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.ActiveCfg = Release|Any CPU - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -438,6 +402,7 @@ Global {19711880-46DA-4A26-9E0F-9B2E41D27651} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {BEF0F5C3-EF4E-4649-9C49-D5E279A3CA2B} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {FC152CC4-054B-457E-8D91-389C5DE3C561} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {EEAAEE68-607B-4E33-AF3E-45C66B4DBA5A} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {76579C39-B829-490D-B8BE-1BD35FE8412E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {35115D55-B69E-46D4-BB33-C9E9E6EC5E7A} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} @@ -451,10 +416,7 @@ Global {1790E052-646F-4529-B90E-6FEA95520D69} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {2755BFE5-7421-4A31-A644-F817DF5CAA98} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {D399B84F-591B-4E98-92BA-B0F63E7B6957} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} - {A7922DD8-09F1-43E4-938B-CC523EA08898} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} - {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} - {BC0D4B56-1A5B-4D88-AFBF-68C0F2D545FB} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} EndGlobalSection EndGlobal diff --git a/build/dependencies.props b/build/dependencies.props index 77c4b3d71..5203ebced 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 4.3.0 3.13.8 2.1.3 - 2.0.0-* + 2.1.0-* 10.0.1 $(BundledNETStandardPackageVersion) 3.0.1 diff --git a/build/repo.props b/build/repo.props index d4bab3eeb..396aed1f5 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,5 +1,4 @@ - diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 9fd7e9412..27fa4ca17 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,9 +1,9 @@ - + - net46;netcoreapp2.0 + netcoreapp2.0 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index e4a42b8c4..2a838df7e 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,9 +1,9 @@ - + - net46;netcoreapp2.0 + netcoreapp2.0 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 1f9310329..86b04d587 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,9 +1,9 @@ - + - net46;netcoreapp2.0 + netcoreapp2.0 aspnet5-JwtBearerSample-20151210102827 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 65d0ef740..274fe9afa 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -3,7 +3,7 @@ - net46;netcoreapp2.0 + netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 41bf8c0ef..152072898 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -3,7 +3,7 @@ - net46;netcoreapp2.0 + netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index fe63ab5ca..e0336cc0e 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -3,7 +3,7 @@ - net46;netcoreapp2.0 + netcoreapp2.0 aspnet5-SocialSample-20151210111056 diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index a7da8e72c..a5728fbab 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to use cookie based authentication. - netstandard1.3 + netcoreapp2.0 $(DefineConstants);SECURITY $(NoWarn);CS1591 true diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json deleted file mode 100644 index 56e48d3fe..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.net45.json +++ /dev/null @@ -1,1661 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseCookieAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseCookieAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "ImplementedInterfaces": [ - "Microsoft.Extensions.Options.IOptions" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_CookieName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieDomain", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieDomain", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookiePath", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookiePath", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieHttpOnly", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieHttpOnly", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieSecure", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieSecure", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_DataProtectionProvider", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_DataProtectionProvider", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ExpireTimeSpan", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ExpireTimeSpan", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SlidingExpiration", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SlidingExpiration", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_LoginPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_LoginPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_LogoutPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_LogoutPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessDeniedPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AccessDeniedPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ReturnUrlParameter", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ReturnUrlParameter", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TicketDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TicketDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieManager", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieManager", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SessionStore", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SessionStore", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_ChunkSize", - "Parameters": [], - "ReturnType": "System.Nullable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ChunkSize", - "Parameters": [ - { - "Name": "value", - "Type": "System.Nullable" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ThrowForPartialCookies", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ThrowForPartialCookies", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetRequestCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AppendResponseCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "value", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "DeleteCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "CookiePrefix", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "LoginPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "LogoutPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessDeniedPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "ReturnUrlParameter", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Cookies\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "urlEncoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetRequestCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AppendResponseCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "value", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "DeleteCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "StoreAsync", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RenewAsync", - "Parameters": [ - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RetrieveAsync", - "Parameters": [ - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RemoveAsync", - "Parameters": [ - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnValidatePrincipal", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnValidatePrincipal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnSigningIn", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnSigningIn", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnSignedIn", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnSignedIn", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnSigningOut", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnSigningOut", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToLogin", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToLogin", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToAccessDenied", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToAccessDenied", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToLogout", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToLogout", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToReturnUrl", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToReturnUrl", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ValidatePrincipal", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignedIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogout", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogin", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToReturnUrl", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAccessDenied", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RedirectUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "redirectUri", - "Type": "System.String" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" - }, - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieOptions", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieOptions", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" - }, - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "cookieOptions", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_CookieOptions", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieOptions", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "cookieOptions", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ShouldRenew", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ShouldRenew", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReplacePrincipal", - "Parameters": [ - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RejectPrincipal", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "ValidatePrincipal", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignedIn", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogout", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToLogin", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToReturnUrl", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAccessDenied", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SigningOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 8f46ff169..19ec83413 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json deleted file mode 100644 index 1e070fc7f..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.net45.json +++ /dev/null @@ -1,453 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Facebook\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetAgeRangeMin", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetAgeRangeMax", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetBirthday", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetFirstName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetGender", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLastName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLink", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLocation", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLocale", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetMiddleName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTimeZone", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseFacebookAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseFacebookAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.FacebookOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.FacebookOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AppId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AppId", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AppSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AppSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SendAppSecretProof", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SendAppSecretProof", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Fields", - "Parameters": [], - "ReturnType": "System.Collections.Generic.ICollection", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index 7b6c9ee5d..e403fe4a9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -4,7 +4,7 @@ ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json deleted file mode 100644 index 647633afa..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.net45.json +++ /dev/null @@ -1,291 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Google\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetFamilyName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetProfile", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.GoogleAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseGoogleAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseGoogleAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.GoogleOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.GoogleOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AccessType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AccessType", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 9d6c49442..05bdd4131 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. - net46;netstandard1.4 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json deleted file mode 100644 index 37e18e53e..000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.net45.json +++ /dev/null @@ -1,976 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Bearer\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Exception", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Exception", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.JwtBearerOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Challenge", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthenticateFailure", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticateFailure", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Error", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Error", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ErrorDescription", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ErrorDescription", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ErrorUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ErrorUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnAuthenticationFailed", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnAuthenticationFailed", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnMessageReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnMessageReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnTokenValidated", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTokenValidated", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnChallenge", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnChallenge", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Challenge", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Token", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Token", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_SecurityToken", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Tokens.SecurityToken", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SecurityToken", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Tokens.SecurityToken" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseJwtBearerAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseJwtBearerAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.JwtBearerOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RequireHttpsMetadata", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RequireHttpsMetadata", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_MetadataAddress", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_MetadataAddress", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Authority", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Authority", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Audience", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Audience", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Challenge", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Challenge", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_BackchannelHttpHandler", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpMessageHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelHttpHandler", - "Parameters": [ - { - "Name": "value", - "Type": "System.Net.Http.HttpMessageHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_BackchannelTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelTimeout", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Configuration", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Configuration", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ConfigurationManager", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ConfigurationManager", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RefreshOnIssuerKeyNotFound", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RefreshOnIssuerKeyNotFound", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SecurityTokenValidators", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenValidationParameters", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenValidationParameters", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SaveToken", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SaveToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_IncludeErrorDetails", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_IncludeErrorDetails", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 5b8263c9c..4d91e0da1 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json deleted file mode 100644 index 06b3cd0d5..000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.net45.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Microsoft\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDisplayName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetSurname", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseMicrosoftAccountAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseMicrosoftAccountAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 73b5140ed..5fb75ead9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json deleted file mode 100644 index d485aedb1..000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.net45.json +++ /dev/null @@ -1,955 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ExchangeCodeAsync", - "Parameters": [ - { - "Name": "code", - "Type": "System.String" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateTicketAsync", - "Parameters": [ - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleUnauthorizedAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "BuildChallengeUrl", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "FormatScope", - "Parameters": [], - "ReturnType": "System.String", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.OAuthOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "New": true, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.OAuthOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "Success", - "Parameters": [ - { - "Name": "response", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Failed", - "Parameters": [ - { - "Name": "error", - "Type": "System.Exception" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Response", - "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Response", - "Parameters": [ - { - "Name": "value", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AccessToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenType", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RefreshToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RefreshToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ExpiresIn", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ExpiresIn", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Error", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Error", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_User", - "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenResponse", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RefreshToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ExpiresIn", - "Parameters": [], - "ReturnType": "System.Nullable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Ticket", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Identity", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsIdentity", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" - } - ], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" - }, - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnCreatingTicket", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnCreatingTicket", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToAuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseOAuthAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseOAuthAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OAuthOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_ClientId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientId", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClientSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthorizationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UserInformationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Scope", - "Parameters": [], - "ReturnType": "System.Collections.Generic.ICollection", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_StateDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_StateDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 773bc41d6..aab8833d2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. - net46;netstandard1.4 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json deleted file mode 100644 index 64cb79487..000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.net45.json +++ /dev/null @@ -1,2005 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthenticationPropertiesKey", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "Caption", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "CookieNoncePrefix", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "RedirectUriForCodePropertiesKey", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserstatePropertiesKey", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"OpenIdConnect\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HtmlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteSignOutAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "signout", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleUnauthorizedAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedeemAuthorizationCodeAsync", - "Parameters": [ - { - "Name": "tokenEndpointRequest", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetUserInformationAsync", - "Parameters": [ - { - "Name": "message", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - }, - { - "Name": "jwt", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HtmlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "services", - "Type": "System.IServiceProvider" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", - "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "RedirectGet", - "Parameters": [], - "GenericParameter": [], - "Literal": "0" - }, - { - "Kind": "Field", - "Name": "FormPost", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Exception", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Exception", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_JwtSecurityToken", - "Parameters": [], - "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_JwtSecurityToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpointRequest", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpointRequest", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpointResponse", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpointResponse", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HandledCodeRedemption", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleCodeRedemption", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleCodeRedemption", - "Parameters": [ - { - "Name": "accessToken", - "Type": "System.String" - }, - { - "Name": "idToken", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleCodeRedemption", - "Parameters": [ - { - "Name": "tokenEndpointResponse", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ProtocolMessage", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ProtocolMessage", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizationCodeReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProvider", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProviderForSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RemoteSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenResponseReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UserInformationReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Token", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Token", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnAuthenticationFailed", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnAuthenticationFailed", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnAuthorizationCodeReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnAuthorizationCodeReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnMessageReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnMessageReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToIdentityProvider", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToIdentityProvider", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToIdentityProviderForSignOut", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToIdentityProviderForSignOut", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRemoteSignOut", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRemoteSignOut", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnTokenResponseReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTokenResponseReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnTokenValidated", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTokenValidated", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnUserInformationReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnUserInformationReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizationCodeReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProvider", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToIdentityProviderForSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RemoteSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenResponseReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UserInformationReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - }, - { - "Name": "message", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpointResponse", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpointResponse", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SecurityToken", - "Parameters": [], - "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SecurityToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenEndpointResponse", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenEndpointResponse", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Nonce", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Nonce", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_User", - "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_User", - "Parameters": [ - { - "Name": "value", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseOpenIdConnectAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseOpenIdConnectAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Authority", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Authority", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClientId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientId", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClientSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Configuration", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Configuration", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ConfigurationManager", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ConfigurationManager", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_GetClaimsFromUserInfoEndpoint", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_GetClaimsFromUserInfoEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RequireHttpsMetadata", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RequireHttpsMetadata", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_MetadataAddress", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_MetadataAddress", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ProtocolValidator", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ProtocolValidator", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolValidator" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_PostLogoutRedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PostLogoutRedirectUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RefreshOnIssuerKeyNotFound", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RefreshOnIssuerKeyNotFound", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthenticationMethod", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticationMethod", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Resource", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Resource", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ResponseMode", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ResponseMode", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ResponseType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ResponseType", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Scope", - "Parameters": [], - "ReturnType": "System.Collections.Generic.ICollection", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RemoteSignOutPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RemoteSignOutPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignOutScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignOutScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_StateDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_StateDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_StringDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_StringDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SecurityTokenValidator", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Tokens.ISecurityTokenValidator", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SecurityTokenValidator", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Tokens.ISecurityTokenValidator" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenValidationParameters", - "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenValidationParameters", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UseTokenLifetime", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UseTokenLifetime", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SkipUnrecognizedRequests", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SkipUnrecognizedRequests", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "authenticationScheme", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 3d13a3d07..5dd58d680 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json deleted file mode 100644 index c35232a31..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.net45.json +++ /dev/null @@ -1,848 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Twitter\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.TwitterOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_UserId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ScreenName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessToken", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AccessTokenSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_User", - "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - }, - { - "Name": "userId", - "Type": "System.String" - }, - { - "Name": "screenName", - "Type": "System.String" - }, - { - "Name": "accessToken", - "Type": "System.String" - }, - { - "Name": "accessTokenSecret", - "Type": "System.String" - }, - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnCreatingTicket", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnCreatingTicket", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnRedirectToAuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.AccessToken", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_UserId", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UserId", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ScreenName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ScreenName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Token", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Token", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_TokenSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_TokenSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CallbackConfirmed", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CallbackConfirmed", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.RequestTokenSerializer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "model", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "token", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken" - } - ], - "ReturnType": "System.Void", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Read", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseTwitterAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseTwitterAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.TwitterOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_ConsumerKey", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ConsumerKey", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ConsumerSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ConsumerSecret", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RetrieveUserDetails", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RetrieveUserDetails", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_StateDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_StateDataFormat", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 07936ed25..54b560702 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -4,7 +4,7 @@ ASP.NET Core common types used by the various authentication middleware components. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.net45.json b/src/Microsoft.AspNetCore.Authentication/baseline.net45.json deleted file mode 100644 index 1f69da5a8..000000000 --- a/src/Microsoft.AspNetCore.Authentication/baseline.net45.json +++ /dev/null @@ -1,2897 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticationScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AutomaticAuthenticate", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AutomaticAuthenticate", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AutomaticChallenge", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AutomaticChallenge", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClaimsIssuer", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClaimsIssuer", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Description", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Description", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "transform", - "Type": "System.Func>" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Transformer", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Transformer", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_BackchannelTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelTimeout", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_BackchannelHttpHandler", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpMessageHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelHttpHandler", - "Parameters": [ - { - "Name": "value", - "Type": "System.Net.Http.HttpMessageHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CallbackPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CallbackPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignInScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignInScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_DisplayName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_DisplayName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RemoteAuthenticationTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RemoteAuthenticationTimeout", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SaveTokens", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SaveTokens", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Succeeded", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Failure", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Success", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Skip", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Fail", - "Parameters": [ - { - "Name": "failure", - "Type": "System.Exception" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Fail", - "Parameters": [ - { - "Name": "failureMessage", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_SignInAccepted", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignInAccepted", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignOutAccepted", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignOutAccepted", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ChallengeCalled", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ChallengeCalled", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Request", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Response", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OriginalPathBase", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OriginalPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Logger", - "Parameters": [], - "ReturnType": "Microsoft.Extensions.Logging.ILogger", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UrlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.UrlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_PriorHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PriorHandler", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CurrentUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "T0", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "InitializeAsync", - "Parameters": [ - { - "Name": "options", - "Type": "T0" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "logger", - "Type": "Microsoft.Extensions.Logging.ILogger" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "BuildRedirectUri", - "Parameters": [ - { - "Name": "targetPath", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "FinishResponseAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDescriptions", - "Parameters": [ - { - "Name": "describeContext", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ShouldHandleScheme", - "Parameters": [ - { - "Name": "authenticationScheme", - "Type": "System.String" - }, - { - "Name": "handleAutomatic", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthenticateAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAuthenticateOnceAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleForbiddenAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleUnauthorizedAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ChallengeAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticationScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "T0", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "T0" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Logger", - "Parameters": [], - "ReturnType": "Microsoft.Extensions.Logging.ILogger", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Logger", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.Extensions.Logging.ILogger" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_UrlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.UrlEncoder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_UrlEncoder", - "Parameters": [ - { - "Name": "value", - "Type": "System.Text.Encodings.Web.UrlEncoder" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - } - ], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "New": true, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationToken", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Name", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Name", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Value", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Value", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_PriorHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PriorHandler", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthenticateAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ChallengeAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDescriptions", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RegisterAuthenticationHandler", - "Parameters": [ - { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UnregisterAuthenticationHandler", - "Parameters": [ - { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "transform", - "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - }, - { - "Name": "httpContext", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnTransform", - "Parameters": [], - "ReturnType": "System.Func>", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTransform", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func>" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TransformAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "TransformAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_UtcNow", - "Parameters": [], - "ReturnType": "System.DateTimeOffset", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteCallbackAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignInAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleForbiddenAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GenerateCorrelationId", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ValidateCorrelationId", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Boolean", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_SignInScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignInScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SystemClock", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.ISystemClock" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_UtcNow", - "Parameters": [], - "ReturnType": "System.DateTimeOffset", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "StoreTokens", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokens", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "System.Void", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTokenValue", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTokens", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTokenAsync", - "Parameters": [ - { - "Name": "manager", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetTokenAsync", - "Parameters": [ - { - "Name": "manager", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" - }, - { - "Name": "signInScheme", - "Type": "System.String" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "model", - "Type": "T0" - } - ], - "ReturnType": "System.Byte[]", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "T0", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TModel", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "data", - "Type": "T0" - } - ], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "data", - "Type": "T0" - }, - { - "Name": "purpose", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedText", - "Type": "System.String" - } - ], - "ReturnType": "T0", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedText", - "Type": "System.String" - }, - { - "Name": "purpose", - "Type": "System.String" - } - ], - "ReturnType": "T0", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TData", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.PropertiesDataFormat", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Default", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "model", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Read", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SecureDataFormat", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - ], - "Members": [ - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "data", - "Type": "T0" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "data", - "Type": "T0" - }, - { - "Name": "purpose", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedText", - "Type": "System.String" - } - ], - "ReturnType": "T0", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedText", - "Type": "System.String" - }, - { - "Name": "purpose", - "Type": "System.String" - } - ], - "ReturnType": "T0", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "serializer", - "Type": "Microsoft.AspNetCore.Authentication.IDataSerializer" - }, - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TData", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "Encode", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Decode", - "Parameters": [ - { - "Name": "text", - "Type": "System.String" - } - ], - "ReturnType": "System.Byte[]", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.TicketDataFormat", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.TicketSerializer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Default", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.TicketSerializer", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WriteIdentity", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WriteClaim", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "claim", - "Type": "System.Security.Claims.Claim" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Read", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReadIdentity", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "System.Security.Claims.ClaimsIdentity", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReadClaim", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Security.Claims.Claim", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.BaseContext", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_HttpContext", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Request", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Response", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_State", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.EventResultState", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_State", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.EventResultState" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HandledResponse", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleResponse", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SkipToNextMiddleware", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Ticket", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CheckEventResult", - "Parameters": [ - { - "Name": "result", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Direction": "Out" - } - ], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.EventResultState", - "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "Continue", - "Parameters": [], - "GenericParameter": [], - "Literal": "0" - }, - { - "Kind": "Field", - "Name": "Skipped", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" - }, - { - "Kind": "Field", - "Name": "HandledResponse", - "Parameters": [], - "GenericParameter": [], - "Literal": "2" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.FailureContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Failure", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Failure", - "Parameters": [ - { - "Name": "value", - "Type": "System.Exception" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "failure", - "Type": "System.Exception" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "RemoteFailure", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TicketReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnRemoteFailure", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRemoteFailure", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnTicketReceived", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnTicketReceived", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RemoteFailure", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "TicketReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ReturnUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ReturnUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AddAuthentication", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddAuthentication", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - }, - { - "Name": "configureOptions", - "Type": "System.Action" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 0382fd2b5..bc5b7be91 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -7,7 +7,7 @@ Commonly used types: Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute Microsoft.AspNetCore.Authorization.AuthorizeAttribute - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;authorization diff --git a/src/Microsoft.AspNetCore.Authorization/baseline.net45.json b/src/Microsoft.AspNetCore.Authorization/baseline.net45.json deleted file mode 100644 index 8ae585270..000000000 --- a/src/Microsoft.AspNetCore.Authorization/baseline.net45.json +++ /dev/null @@ -1,1593 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.Extensions.DependencyInjection.AuthorizationServiceCollectionExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AddAuthorization", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddAuthorization", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - }, - { - "Name": "configure", - "Type": "System.Action" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "System.Attribute", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAllowAnonymous" - ], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "T0" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TRequirement", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "T0" - }, - { - "Name": "resource", - "Type": "T1" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TRequirement", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ] - }, - { - "ParameterName": "TResource", - "ParameterPosition": 1, - "BaseTypeOrInterfaces": [] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Requirements", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_User", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Resource", - "Parameters": [], - "ReturnType": "System.Object", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_PendingRequirements", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HasFailed", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HasSucceeded", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Fail", - "Parameters": [], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Succeed", - "Parameters": [ - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "requirements", - "Type": "System.Collections.Generic.IEnumerable" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_DefaultPolicy", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_DefaultPolicy", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddPolicy", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddPolicy", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - }, - { - "Name": "configurePolicy", - "Type": "System.Action" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetPolicy", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Requirements", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IReadOnlyList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthenticationSchemes", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IReadOnlyList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Combine", - "Parameters": [ - { - "Name": "policies", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Combine", - "Parameters": [ - { - "Name": "policies", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CombineAsync", - "Parameters": [ - { - "Name": "policyProvider", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" - }, - { - "Name": "authorizeData", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "requirements", - "Type": "System.Collections.Generic.IEnumerable" - }, - { - "Name": "authenticationSchemes", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Requirements", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Requirements", - "Parameters": [ - { - "Name": "value", - "Type": "System.Collections.Generic.IList" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AuthenticationSchemes", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticationSchemes", - "Parameters": [ - { - "Name": "value", - "Type": "System.Collections.Generic.IList" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddAuthenticationSchemes", - "Parameters": [ - { - "Name": "schemes", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddRequirements", - "Parameters": [ - { - "Name": "requirements", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Combine", - "Parameters": [ - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireClaim", - "Parameters": [ - { - "Name": "claimType", - "Type": "System.String" - }, - { - "Name": "requiredValues", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireClaim", - "Parameters": [ - { - "Name": "claimType", - "Type": "System.String" - }, - { - "Name": "requiredValues", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireClaim", - "Parameters": [ - { - "Name": "claimType", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireRole", - "Parameters": [ - { - "Name": "roles", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireRole", - "Parameters": [ - { - "Name": "roles", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireUserName", - "Parameters": [ - { - "Name": "userName", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireAuthenticatedUser", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireAssertion", - "Parameters": [ - { - "Name": "handler", - "Type": "System.Func" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RequireAssertion", - "Parameters": [ - { - "Name": "handler", - "Type": "System.Func>" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Build", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "authenticationSchemes", - "Type": "System.String[]", - "IsParams": true - } - ], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizationServiceExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "service", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "service", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "service", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "service", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" - }, - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.AuthorizeAttribute", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "System.Attribute", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizeData" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Policy", - "Parameters": [], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Policy", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Roles", - "Parameters": [], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Roles", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ActiveAuthenticationSchemes", - "Parameters": [], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ActiveAuthenticationSchemes", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "policy", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationPolicyProvider", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" - ], - "Members": [ - { - "Kind": "Method", - "Name": "GetDefaultPolicyAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetPolicyAsync", - "Parameters": [ - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationService", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationService" - ], - "Members": [ - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "requirements", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "policyProvider", - "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider" - }, - { - "Name": "handlers", - "Type": "System.Collections.Generic.IEnumerable" - }, - { - "Name": "logger", - "Type": "Microsoft.Extensions.Logging.ILogger" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAllowAnonymous", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetPolicyAsync", - "Parameters": [ - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetDefaultPolicyAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationService", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "requirements", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AuthorizeAsync", - "Parameters": [ - { - "Name": "user", - "Type": "System.Security.Claims.ClaimsPrincipal" - }, - { - "Name": "resource", - "Type": "System.Object" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.IAuthorizeData", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Policy", - "Parameters": [], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Policy", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Roles", - "Parameters": [], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Roles", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ActiveAuthenticationSchemes", - "Parameters": [], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ActiveAuthenticationSchemes", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.AssertionRequirement", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Handler", - "Parameters": [], - "ReturnType": "System.Func>", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "handler", - "Type": "System.Func" - } - ], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "handler", - "Type": "System.Func>" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.ClaimsAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_ClaimType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AllowedValues", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.ClaimsAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "claimType", - "Type": "System.String" - }, - { - "Name": "allowedValues", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.DenyAnonymousAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.DenyAnonymousAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.NameAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_RequiredName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.NameAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "requiredName", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.OperationAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Name", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Name", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.PassThroughAuthorizationHandler", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationHandler" - ], - "Members": [ - { - "Kind": "Method", - "Name": "HandleAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authorization.Infrastructure.RolesAuthorizationRequirement", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_AllowedRoles", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequirementAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" - }, - { - "Name": "requirement", - "Type": "Microsoft.AspNetCore.Authorization.Infrastructure.RolesAuthorizationRequirement" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "allowedRoles", - "Type": "System.Collections.Generic.IEnumerable" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 146917cab..31ce5b761 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -4,7 +4,7 @@ ASP.NET Core cookie policy classes to control the behavior of cookies. - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json deleted file mode 100644 index 8eef347eb..000000000 --- a/src/Microsoft.AspNetCore.CookiePolicy/baseline.net45.json +++ /dev/null @@ -1,392 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseCookiePolicy", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseCookiePolicy", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookiePolicyOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.CookiePolicyOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_HttpOnly", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_HttpOnly", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Secure", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Secure", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnAppendCookie", - "Parameters": [], - "ReturnType": "System.Action", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnAppendCookie", - "Parameters": [ - { - "Name": "value", - "Type": "System.Action" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnDeleteCookie", - "Parameters": [], - "ReturnType": "System.Action", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnDeleteCookie", - "Parameters": [ - { - "Name": "value", - "Type": "System.Action" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.CookiePolicy.AppendCookieContext", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieOptions", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieValue", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieValue", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - }, - { - "Name": "name", - "Type": "System.String" - }, - { - "Name": "value", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.CookiePolicyOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.CookiePolicyOptions" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.CookiePolicy.DeleteCookieContext", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieOptions", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CookieName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CookieName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - }, - { - "Name": "name", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy", - "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "None", - "Parameters": [], - "GenericParameter": [], - "Literal": "0" - }, - { - "Kind": "Field", - "Name": "Always", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs deleted file mode 100644 index f1a07c5bf..000000000 --- a/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Owin.Security.DataHandler; -using Microsoft.Owin.Security.DataHandler.Encoder; -using Microsoft.Owin.Security.DataProtection; - -namespace Microsoft.Owin.Security.Interop -{ - public class AspNetTicketDataFormat : SecureDataFormat - { - public AspNetTicketDataFormat(IDataProtector protector) - : base(AspNetTicketSerializer.Default, protector, TextEncodings.Base64Url) - { - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs deleted file mode 100644 index 6a1019fbc..000000000 --- a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; -using System.Linq; -using System.Security.Claims; -using Microsoft.Owin.Security.DataHandler.Serializer; - -namespace Microsoft.Owin.Security.Interop -{ - // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.DataHandler.TicketSerializer - public class AspNetTicketSerializer : IDataSerializer - { - private const string DefaultStringPlaceholder = "\0"; - private const int FormatVersion = 5; - - public static AspNetTicketSerializer Default { get; } = new AspNetTicketSerializer(); - - public virtual byte[] Serialize(AuthenticationTicket ticket) - { - using (var memory = new MemoryStream()) - { - using (var writer = new BinaryWriter(memory)) - { - Write(writer, ticket); - } - return memory.ToArray(); - } - } - - public virtual AuthenticationTicket Deserialize(byte[] data) - { - using (var memory = new MemoryStream(data)) - { - using (var reader = new BinaryReader(memory)) - { - return Read(reader); - } - } - } - - public virtual void Write(BinaryWriter writer, AuthenticationTicket ticket) - { - writer.Write(FormatVersion); - writer.Write(ticket.Identity.AuthenticationType); - - var identity = ticket.Identity; - if (identity == null) - { - throw new ArgumentNullException("ticket.Identity"); - } - - // There is always a single identity - writer.Write(1); - WriteIdentity(writer, identity); - PropertiesSerializer.Write(writer, ticket.Properties); - } - - protected virtual void WriteIdentity(BinaryWriter writer, ClaimsIdentity identity) - { - var authenticationType = identity.AuthenticationType ?? string.Empty; - - writer.Write(authenticationType); - WriteWithDefault(writer, identity.NameClaimType, ClaimsIdentity.DefaultNameClaimType); - WriteWithDefault(writer, identity.RoleClaimType, ClaimsIdentity.DefaultRoleClaimType); - - // Write the number of claims contained in the identity. - writer.Write(identity.Claims.Count()); - - foreach (var claim in identity.Claims) - { - WriteClaim(writer, claim); - } - - var bootstrap = identity.BootstrapContext as string; - if (!string.IsNullOrEmpty(bootstrap)) - { - writer.Write(true); - writer.Write(bootstrap); - } - else - { - writer.Write(false); - } - - if (identity.Actor != null) - { - writer.Write(true); - WriteIdentity(writer, identity.Actor); - } - else - { - writer.Write(false); - } - } - - protected virtual void WriteClaim(BinaryWriter writer, Claim claim) - { - WriteWithDefault(writer, claim.Type, claim.Subject?.NameClaimType ?? ClaimsIdentity.DefaultNameClaimType); - writer.Write(claim.Value); - WriteWithDefault(writer, claim.ValueType, ClaimValueTypes.String); - WriteWithDefault(writer, claim.Issuer, ClaimsIdentity.DefaultIssuer); - WriteWithDefault(writer, claim.OriginalIssuer, claim.Issuer); - - // Write the number of properties contained in the claim. - writer.Write(claim.Properties.Count); - - foreach (var property in claim.Properties) - { - writer.Write(property.Key ?? string.Empty); - writer.Write(property.Value ?? string.Empty); - } - } - - public virtual AuthenticationTicket Read(BinaryReader reader) - { - if (reader.ReadInt32() != FormatVersion) - { - return null; - } - - var scheme = reader.ReadString(); - - // Any identities after the first will be ignored. - var count = reader.ReadInt32(); - if (count < 0) - { - return null; - } - - var identity = ReadIdentity(reader); - var properties = PropertiesSerializer.Read(reader); - - return new AuthenticationTicket(identity, properties); - } - - protected virtual ClaimsIdentity ReadIdentity(BinaryReader reader) - { - var authenticationType = reader.ReadString(); - var nameClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultNameClaimType); - var roleClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultRoleClaimType); - - // Read the number of claims contained - // in the serialized identity. - var count = reader.ReadInt32(); - - var identity = new ClaimsIdentity(authenticationType, nameClaimType, roleClaimType); - - for (int index = 0; index != count; ++index) - { - var claim = ReadClaim(reader, identity); - - identity.AddClaim(claim); - } - - // Determine whether the identity - // has a bootstrap context attached. - if (reader.ReadBoolean()) - { - identity.BootstrapContext = reader.ReadString(); - } - - // Determine whether the identity - // has an actor identity attached. - if (reader.ReadBoolean()) - { - identity.Actor = ReadIdentity(reader); - } - - return identity; - } - - protected virtual Claim ReadClaim(BinaryReader reader, ClaimsIdentity identity) - { - var type = ReadWithDefault(reader, identity.NameClaimType); - var value = reader.ReadString(); - var valueType = ReadWithDefault(reader, ClaimValueTypes.String); - var issuer = ReadWithDefault(reader, ClaimsIdentity.DefaultIssuer); - var originalIssuer = ReadWithDefault(reader, issuer); - - var claim = new Claim(type, value, valueType, issuer, originalIssuer, identity); - - // Read the number of properties stored in the claim. - var count = reader.ReadInt32(); - - for (var index = 0; index != count; ++index) - { - var key = reader.ReadString(); - var propertyValue = reader.ReadString(); - - claim.Properties.Add(key, propertyValue); - } - - return claim; - } - - private static void WriteWithDefault(BinaryWriter writer, string value, string defaultValue) - { - if (string.Equals(value, defaultValue, StringComparison.Ordinal)) - { - writer.Write(DefaultStringPlaceholder); - } - else - { - writer.Write(value); - } - } - - private static string ReadWithDefault(BinaryReader reader, string defaultValue) - { - var value = reader.ReadString(); - if (string.Equals(value, DefaultStringPlaceholder, StringComparison.Ordinal)) - { - return defaultValue; - } - return value; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs deleted file mode 100644 index b323258d9..000000000 --- a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using Microsoft.Owin.Infrastructure; - -namespace Microsoft.Owin.Security.Interop -{ - // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager - /// - /// This handles cookies that are limited by per cookie length. It breaks down long cookies for responses, and reassembles them - /// from requests. - /// - public class ChunkingCookieManager : ICookieManager - { - private const string ChunkKeySuffix = "C"; - private const string ChunkCountPrefix = "chunks-"; - - public ChunkingCookieManager() - { - // Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case. - // See http://browsercookielimits.x64.me/. - // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. - ChunkSize = 4070; - ThrowForPartialCookies = true; - } - - /// - /// The maximum size of cookie to send back to the client. If a cookie exceeds this size it will be broken down into multiple - /// cookies. Set this value to null to disable this behavior. The default is 4090 characters, which is supported by all - /// common browsers. - /// - /// Note that browsers may also have limits on the total size of all cookies per domain, and on the number of cookies per domain. - /// - public int? ChunkSize { get; set; } - - /// - /// Throw if not all chunks of a cookie are available on a request for re-assembly. - /// - public bool ThrowForPartialCookies { get; set; } - - // Parse the "chunks-XX" to determine how many chunks there should be. - private static int ParseChunksCount(string value) - { - if (value != null && value.StartsWith(ChunkCountPrefix, StringComparison.Ordinal)) - { - var chunksCountString = value.Substring(ChunkCountPrefix.Length); - int chunksCount; - if (int.TryParse(chunksCountString, NumberStyles.None, CultureInfo.InvariantCulture, out chunksCount)) - { - return chunksCount; - } - } - return 0; - } - - /// - /// Get the reassembled cookie. Non chunked cookies are returned normally. - /// Cookies with missing chunks just have their "chunks-XX" header returned. - /// - /// - /// - /// The reassembled cookie, if any, or null. - public string GetRequestCookie(IOwinContext context, string key) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - - var requestCookies = context.Request.Cookies; - var value = requestCookies[key]; - var chunksCount = ParseChunksCount(value); - if (chunksCount > 0) - { - var chunks = new string[chunksCount]; - for (var chunkId = 1; chunkId <= chunksCount; chunkId++) - { - var chunk = requestCookies[key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture)]; - if (string.IsNullOrEmpty(chunk)) - { - if (ThrowForPartialCookies) - { - var totalSize = 0; - for (int i = 0; i < chunkId - 1; i++) - { - totalSize += chunks[i].Length; - } - throw new FormatException( - string.Format(CultureInfo.CurrentCulture, - "The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded.", - chunkId - 1, chunksCount, totalSize)); - } - // Missing chunk, abort by returning the original cookie value. It may have been a false positive? - return value; - } - - chunks[chunkId - 1] = chunk; - } - - return string.Join(string.Empty, chunks); - } - return value; - } - - /// - /// Appends a new response cookie to the Set-Cookie header. If the cookie is larger than the given size limit - /// then it will be broken down into multiple cookies as follows: - /// Set-Cookie: CookieName=chunks-3; path=/ - /// Set-Cookie: CookieNameC1=Segment1; path=/ - /// Set-Cookie: CookieNameC2=Segment2; path=/ - /// Set-Cookie: CookieNameC3=Segment3; path=/ - /// - /// - /// - /// - /// - public void AppendResponseCookie(IOwinContext context, string key, string value, CookieOptions options) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - var domainHasValue = !string.IsNullOrEmpty(options.Domain); - var pathHasValue = !string.IsNullOrEmpty(options.Path); - var expiresHasValue = options.Expires.HasValue; - - var templateLength = key.Length + "=".Length - + (domainHasValue ? "; domain=".Length + options.Domain.Length : 0) - + (pathHasValue ? "; path=".Length + options.Path.Length : 0) - + (expiresHasValue ? "; expires=ddd, dd-MMM-yyyy HH:mm:ss GMT".Length : 0) - + (options.Secure ? "; secure".Length : 0) - + (options.HttpOnly ? "; HttpOnly".Length : 0); - - // Normal cookie - var responseCookies = context.Response.Cookies; - if (!ChunkSize.HasValue || ChunkSize.Value > templateLength + value.Length) - { - responseCookies.Append(key, value, options); - } - else if (ChunkSize.Value < templateLength + 10) - { - // 10 is the minimum data we want to put in an individual cookie, including the cookie chunk identifier "CXX". - // No room for data, we can't chunk the options and name - throw new InvalidOperationException("The cookie key and options are larger than ChunksSize, leaving no room for data."); - } - else - { - // Break the cookie down into multiple cookies. - // Key = CookieName, value = "Segment1Segment2Segment2" - // Set-Cookie: CookieName=chunks-3; path=/ - // Set-Cookie: CookieNameC1="Segment1"; path=/ - // Set-Cookie: CookieNameC2="Segment2"; path=/ - // Set-Cookie: CookieNameC3="Segment3"; path=/ - var dataSizePerCookie = ChunkSize.Value - templateLength - 3; // Budget 3 chars for the chunkid. - var cookieChunkCount = (int)Math.Ceiling(value.Length * 1.0 / dataSizePerCookie); - - responseCookies.Append(key, ChunkCountPrefix + cookieChunkCount.ToString(CultureInfo.InvariantCulture), options); - - var offset = 0; - for (var chunkId = 1; chunkId <= cookieChunkCount; chunkId++) - { - var remainingLength = value.Length - offset; - var length = Math.Min(dataSizePerCookie, remainingLength); - var segment = value.Substring(offset, length); - offset += length; - - responseCookies.Append(key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture), segment, options); - } - } - } - - /// - /// Deletes the cookie with the given key by setting an expired state. If a matching chunked cookie exists on - /// the request, delete each chunk. - /// - /// - /// - /// - public void DeleteCookie(IOwinContext context, string key, CookieOptions options) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - var keys = new List(); - keys.Add(key + "="); - - var requestCookie = context.Request.Cookies[key]; - var chunks = ParseChunksCount(requestCookie); - if (chunks > 0) - { - for (int i = 1; i <= chunks + 1; i++) - { - var subkey = key + ChunkKeySuffix + i.ToString(CultureInfo.InvariantCulture); - keys.Add(subkey + "="); - } - } - - var domainHasValue = !string.IsNullOrEmpty(options.Domain); - var pathHasValue = !string.IsNullOrEmpty(options.Path); - - Func rejectPredicate; - Func predicate = value => keys.Any(k => value.StartsWith(k, StringComparison.OrdinalIgnoreCase)); - if (domainHasValue) - { - rejectPredicate = value => predicate(value) && value.IndexOf("domain=" + options.Domain, StringComparison.OrdinalIgnoreCase) != -1; - } - else if (pathHasValue) - { - rejectPredicate = value => predicate(value) && value.IndexOf("path=" + options.Path, StringComparison.OrdinalIgnoreCase) != -1; - } - else - { - rejectPredicate = value => predicate(value); - } - - var responseHeaders = context.Response.Headers; - string[] existingValues; - if (responseHeaders.TryGetValue(Constants.Headers.SetCookie, out existingValues) && existingValues != null) - { - responseHeaders.SetValues(Constants.Headers.SetCookie, existingValues.Where(value => !rejectPredicate(value)).ToArray()); - } - - AppendResponseCookie( - context, - key, - string.Empty, - new CookieOptions() - { - Path = options.Path, - Domain = options.Domain, - Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), - }); - - for (int i = 1; i <= chunks; i++) - { - AppendResponseCookie( - context, - key + "C" + i.ToString(CultureInfo.InvariantCulture), - string.Empty, - new CookieOptions() - { - Path = options.Path, - Domain = options.Domain, - Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), - }); - } - } - } -} diff --git a/src/Microsoft.Owin.Security.Interop/Constants.cs b/src/Microsoft.Owin.Security.Interop/Constants.cs deleted file mode 100644 index 1e75761b7..000000000 --- a/src/Microsoft.Owin.Security.Interop/Constants.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Microsoft.Owin.Security.Interop -{ - internal static class Constants - { - internal static class Headers - { - internal const string SetCookie = "Set-Cookie"; - } - } -} diff --git a/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs deleted file mode 100644 index 731358894..000000000 --- a/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.DataProtection; - -namespace Microsoft.Owin.Security.Interop -{ - /// - /// Converts an to an - /// . - /// - public sealed class DataProtectorShim : Microsoft.Owin.Security.DataProtection.IDataProtector - { - private readonly IDataProtector _protector; - - public DataProtectorShim(IDataProtector protector) - { - _protector = protector; - } - - public byte[] Protect(byte[] userData) - { - return _protector.Protect(userData); - } - - public byte[] Unprotect(byte[] protectedData) - { - return _protector.Unprotect(protectedData); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj deleted file mode 100644 index 1a6679119..000000000 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication. - net46 - $(NoWarn);CS1591 - true - aspnetcore;katana;owin;security - - - - - - - - diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs deleted file mode 100644 index 490fa7cb2..000000000 --- a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Runtime.InteropServices; - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a7922dd8-09f1-43e4-938b-cc523ea08898")] - diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json deleted file mode 100644 index 1fc242ec5..000000000 --- a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json +++ /dev/null @@ -1,373 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.Owin.Security.DataHandler.SecureDataFormat", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.Owin.Security.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_Default", - "Parameters": [], - "ReturnType": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Serialize", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.Owin.Security.AuthenticationTicket" - } - ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "ticket", - "Type": "Microsoft.Owin.Security.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WriteIdentity", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WriteClaim", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "claim", - "Type": "System.Security.Claims.Claim" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Read", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReadIdentity", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - } - ], - "ReturnType": "System.Security.Claims.ClaimsIdentity", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ReadClaim", - "Parameters": [ - { - "Name": "reader", - "Type": "System.IO.BinaryReader" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Security.Claims.Claim", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Owin.Security.Interop.ChunkingCookieManager", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.Owin.Infrastructure.ICookieManager" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_ChunkSize", - "Parameters": [], - "ReturnType": "System.Nullable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ChunkSize", - "Parameters": [ - { - "Name": "value", - "Type": "System.Nullable" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ThrowForPartialCookies", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ThrowForPartialCookies", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetRequestCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.Owin.IOwinContext" - }, - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AppendResponseCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.Owin.IOwinContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "value", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.Owin.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "DeleteCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.Owin.IOwinContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.Owin.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Owin.Security.Interop.DataProtectorShim", - "Visibility": "Public", - "Kind": "Class", - "Sealed": true, - "ImplementedInterfaces": [ - "Microsoft.Owin.Security.DataProtection.IDataProtector" - ], - "Members": [ - { - "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "userData", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.Byte[]", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Unprotect", - "Parameters": [ - { - "Name": "protectedData", - "Type": "System.Byte[]" - } - ], - "ReturnType": "System.Byte[]", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ], - "SourceFilters": [] -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 801567d7e..df51faf88 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -2,8 +2,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 true true diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index c964221fb..a2d4a61de 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -2,8 +2,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index d2736ca0d..6ca53f519 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -2,8 +2,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index a972731ea..ca850d754 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -2,8 +2,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 true true diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs deleted file mode 100644 index ae5e6f018..000000000 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Security.Claims; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.Linq; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Net.Http.Headers; -using Microsoft.Owin.Security.Cookies; -using Microsoft.Owin.Testing; -using Owin; -using Xunit; - -namespace Microsoft.Owin.Security.Interop -{ - public class CookiesInteropTests - { - [Fact] - public async Task AspNetCoreWithInteropCookieContainsIdentity() - { - var identity = new ClaimsIdentity("Cookies"); - identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); - - var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); - var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); - - var interopServer = TestServer.Create(app => - { - app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - - app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions - { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), - CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix - + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, - }); - - app.Run(context => - { - context.Authentication.SignIn(identity); - return Task.FromResult(0); - }); - }); - - var transaction = await SendAsync(interopServer, "http://example.com"); - - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseAuthentication(); - app.Run(async context => - { - var result = await context.AuthenticateAsync("Cookies"); - await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); - }); - }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); - var newServer = new AspNetCore.TestHost.TestServer(builder); - - var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); - foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) - { - request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); - } - var response = await newServer.CreateClient().SendAsync(request); - - Assert.Equal("Alice", await response.Content.ReadAsStringAsync()); - } - - [Fact] - public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() - { - var identity = new ClaimsIdentity("Cookies"); - identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); - - var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); - var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); - - var interopServer = TestServer.Create(app => - { - app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - - app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions - { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), - CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix - + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, - CookieManager = new ChunkingCookieManager(), - }); - - app.Run(context => - { - context.Authentication.SignIn(identity); - return Task.FromResult(0); - }); - }); - - var transaction = await SendAsync(interopServer, "http://example.com"); - - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseAuthentication(); - app.Run(async context => - { - var result = await context.AuthenticateAsync("Cookies"); - await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); - }); - }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); - var newServer = new AspNetCore.TestHost.TestServer(builder); - - var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); - foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) - { - request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); - } - var response = await newServer.CreateClient().SendAsync(request); - - Assert.Equal(1024 * 5, (await response.Content.ReadAsStringAsync()).Length); - } - - [Fact] - public async Task InteropWithNewCookieContainsIdentity() - { - var user = new ClaimsPrincipal(); - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); - user.AddIdentity(identity); - - var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); - var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); - - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseAuthentication(); - app.Run(context => context.SignInAsync("Cookies", user)); - }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); - var newServer = new AspNetCore.TestHost.TestServer(builder); - - var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); - - var server = TestServer.Create(app => - { - app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - - app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions - { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), - CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix - + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, - }); - - app.Run(async context => - { - var result = await context.Authentication.AuthenticateAsync("Cookies"); - Describe(context.Response, result); - }); - }); - - var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); - - Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); - } - - [Fact] - public async Task InteropWithLargeNewCookieContainsIdentity() - { - var user = new ClaimsPrincipal(); - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); - user.AddIdentity(identity); - - var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); - var dataProtector = dataProtection.CreateProtector( - "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type - Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); - - var builder = new WebHostBuilder() - .Configure(app => - { - app.UseAuthentication(); - app.Run(context => context.SignInAsync("Cookies", user)); - }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); - var newServer = new AspNetCore.TestHost.TestServer(builder); - - var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); - - var server = TestServer.Create(app => - { - app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; - - app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions - { - TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), - CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix - + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, - CookieManager = new ChunkingCookieManager(), - }); - - app.Run(async context => - { - var result = await context.Authentication.AuthenticateAsync("Cookies"); - Describe(context.Response, result); - }); - }); - - var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); - - Assert.Equal(1024 * 5, FindClaimValue(transaction2, ClaimTypes.Name).Length); - } - - private static async Task> SendAndGetCookies(AspNetCore.TestHost.TestServer server, string uri) - { - var request = new HttpRequestMessage(HttpMethod.Get, uri); - var response = await server.CreateClient().SendAsync(request); - if (response.Headers.Contains("Set-Cookie")) - { - IList cookieHeaders = new List(); - foreach (var cookie in SetCookieHeaderValue.ParseList(response.Headers.GetValues("Set-Cookie").ToList())) - { - cookieHeaders.Add(cookie.Name + "=" + cookie.Value); - } - return cookieHeaders; - } - return null; - } - - private static string FindClaimValue(Transaction transaction, string claimType) - { - XElement claim = transaction.ResponseElement.Elements("claim").SingleOrDefault(elt => elt.Attribute("type").Value == claimType); - if (claim == null) - { - return null; - } - return claim.Attribute("value").Value; - } - - private static void Describe(IOwinResponse res, AuthenticateResult result) - { - res.StatusCode = 200; - res.ContentType = "text/xml"; - var xml = new XElement("xml"); - if (result != null && result.Identity != null) - { - xml.Add(result.Identity.Claims.Select(claim => new XElement("claim", new XAttribute("type", claim.Type), new XAttribute("value", claim.Value)))); - } - if (result != null && result.Properties != null) - { - xml.Add(result.Properties.Dictionary.Select(extra => new XElement("extra", new XAttribute("type", extra.Key), new XAttribute("value", extra.Value)))); - } - using (var memory = new MemoryStream()) - { - using (var writer = new XmlTextWriter(memory, Encoding.UTF8)) - { - xml.WriteTo(writer); - } - res.Body.Write(memory.ToArray(), 0, memory.ToArray().Length); - } - } - - private static async Task SendAsync(TestServer server, string uri, IList cookieHeaders = null, bool ajaxRequest = false) - { - var request = new HttpRequestMessage(HttpMethod.Get, uri); - if (cookieHeaders != null) - { - request.Headers.Add("Cookie", cookieHeaders); - } - if (ajaxRequest) - { - request.Headers.Add("X-Requested-With", "XMLHttpRequest"); - } - var transaction = new Transaction - { - Request = request, - Response = await server.HttpClient.SendAsync(request), - }; - if (transaction.Response.Headers.Contains("Set-Cookie")) - { - transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList(); - } - if (transaction.SetCookie != null && transaction.SetCookie.Any()) - { - transaction.CookieNameValue = transaction.SetCookie.First().Split(new[] { ';' }, 2).First(); - } - transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync(); - - if (transaction.Response.Content != null && - transaction.Response.Content.Headers.ContentType != null && - transaction.Response.Content.Headers.ContentType.MediaType == "text/xml") - { - transaction.ResponseElement = XElement.Parse(transaction.ResponseText); - } - return transaction; - } - - private class Transaction - { - public HttpRequestMessage Request { get; set; } - public HttpResponseMessage Response { get; set; } - - public IList SetCookie { get; set; } - public string CookieNameValue { get; set; } - - public string ResponseText { get; set; } - public XElement ResponseElement { get; set; } - } - - } -} - diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj deleted file mode 100644 index 02763b93f..000000000 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - net46 - true - true - - - - - - - - - - - - - - - - - - - - diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs deleted file mode 100644 index b14ea0d74..000000000 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Linq; -using System.Security.Claims; -using Microsoft.AspNetCore.Authentication; -using Xunit; - -namespace Microsoft.Owin.Security.Interop.Test -{ - public class TicketInteropTests - { - [Fact] - public void NewSerializerCanReadInteropTicket() - { - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim("Test", "Value")); - - var expires = DateTime.Today; - var issued = new DateTime(1979, 11, 11); - var properties = new Owin.Security.AuthenticationProperties(); - properties.IsPersistent = true; - properties.RedirectUri = "/redirect"; - properties.Dictionary["key"] = "value"; - properties.ExpiresUtc = expires; - properties.IssuedUtc = issued; - - var interopTicket = new Owin.Security.AuthenticationTicket(identity, properties); - var interopSerializer = new AspNetTicketSerializer(); - - var bytes = interopSerializer.Serialize(interopTicket); - - var newSerializer = new TicketSerializer(); - var newTicket = newSerializer.Deserialize(bytes); - - Assert.NotNull(newTicket); - Assert.Equal(1, newTicket.Principal.Identities.Count()); - var newIdentity = newTicket.Principal.Identity as ClaimsIdentity; - Assert.NotNull(newIdentity); - Assert.Equal("scheme", newIdentity.AuthenticationType); - Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); - Assert.NotNull(newTicket.Properties); - Assert.True(newTicket.Properties.IsPersistent); - Assert.Equal("/redirect", newTicket.Properties.RedirectUri); - Assert.Equal("value", newTicket.Properties.Items["key"]); - Assert.Equal(expires, newTicket.Properties.ExpiresUtc); - Assert.Equal(issued, newTicket.Properties.IssuedUtc); - } - - [Fact] - public void InteropSerializerCanReadNewTicket() - { - var user = new ClaimsPrincipal(); - var identity = new ClaimsIdentity("scheme"); - identity.AddClaim(new Claim("Test", "Value")); - user.AddIdentity(identity); - - var expires = DateTime.Today; - var issued = new DateTime(1979, 11, 11); - var properties = new AspNetCore.Authentication.AuthenticationProperties(); - properties.IsPersistent = true; - properties.RedirectUri = "/redirect"; - properties.Items["key"] = "value"; - properties.ExpiresUtc = expires; - properties.IssuedUtc = issued; - - var newTicket = new AspNetCore.Authentication.AuthenticationTicket(user, properties, "scheme"); - var newSerializer = new TicketSerializer(); - - var bytes = newSerializer.Serialize(newTicket); - - var interopSerializer = new AspNetTicketSerializer(); - var interopTicket = interopSerializer.Deserialize(bytes); - - Assert.NotNull(interopTicket); - var newIdentity = interopTicket.Identity; - Assert.NotNull(newIdentity); - Assert.Equal("scheme", newIdentity.AuthenticationType); - Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); - Assert.NotNull(interopTicket.Properties); - Assert.True(interopTicket.Properties.IsPersistent); - Assert.Equal("/redirect", interopTicket.Properties.RedirectUri); - Assert.Equal("value", interopTicket.Properties.Dictionary["key"]); - Assert.Equal(expires, interopTicket.Properties.ExpiresUtc); - Assert.Equal(issued, interopTicket.Properties.IssuedUtc); - } - } -} - - From b7a5a6044d61ee2fa0625446b52ef4f181c08505 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Tue, 9 May 2017 08:57:39 -0700 Subject: [PATCH 002/248] Fix samples logging (#1205) --- samples/CookieSample/Program.cs | 6 ++++++ samples/CookieSample/Startup.cs | 5 +---- samples/CookieSessionSample/Program.cs | 7 ++++++- samples/CookieSessionSample/Startup.cs | 5 +---- samples/OpenIdConnect.AzureAdSample/Program.cs | 6 ++++++ samples/OpenIdConnect.AzureAdSample/Startup.cs | 5 +---- samples/OpenIdConnectSample/Program.cs | 8 ++++++++ samples/OpenIdConnectSample/Startup.cs | 6 +----- samples/SocialSample/Program.cs | 7 ++++++- samples/SocialSample/Startup.cs | 5 +---- 10 files changed, 37 insertions(+), 23 deletions(-) diff --git a/samples/CookieSample/Program.cs b/samples/CookieSample/Program.cs index 7deed359e..3f40d3194 100644 --- a/samples/CookieSample/Program.cs +++ b/samples/CookieSample/Program.cs @@ -1,5 +1,6 @@ using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace CookieSample { @@ -8,6 +9,11 @@ public static class Program public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 0480556f6..3aebb419f 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace CookieSample { @@ -17,10 +16,8 @@ public void ConfigureServices(IServiceCollection services) services.AddCookieAuthentication(); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Information); - app.UseAuthentication(); app.Run(async context => diff --git a/samples/CookieSessionSample/Program.cs b/samples/CookieSessionSample/Program.cs index adf8f1f1a..1a19850e6 100644 --- a/samples/CookieSessionSample/Program.cs +++ b/samples/CookieSessionSample/Program.cs @@ -1,6 +1,6 @@ using System.IO; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace CookieSessionSample { @@ -9,6 +9,11 @@ public static class Program public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index ca21070dc..9ad9e6841 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace CookieSessionSample { @@ -18,10 +17,8 @@ public void ConfigureServices(IServiceCollection services) services.AddCookieAuthentication(o => o.SessionStore = new MemoryCacheTicketStore()); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Information); - app.UseAuthentication(); app.Run(async context => diff --git a/samples/OpenIdConnect.AzureAdSample/Program.cs b/samples/OpenIdConnect.AzureAdSample/Program.cs index 11d1fbeaf..9de0185a4 100644 --- a/samples/OpenIdConnect.AzureAdSample/Program.cs +++ b/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -1,5 +1,6 @@ using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace OpenIdConnect.AzureAdSample { @@ -8,6 +9,11 @@ public static class Program public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 19bb0ac6a..ebb59c060 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -12,7 +12,6 @@ using Microsoft.AspNetCore.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -79,10 +78,8 @@ public void ConfigureServices(IServiceCollection services) }); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(Microsoft.Extensions.Logging.LogLevel.Information); - app.UseDeveloperExceptionPage(); app.UseAuthentication(); diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index 741dd6ebf..b4d24505d 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -5,6 +5,7 @@ using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Logging; namespace OpenIdConnectSample { @@ -13,6 +14,13 @@ public static class Program public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddDebug(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + factory.AddFilter("Debug", level => level >= LogLevel.Information); + }) .UseKestrel(options => { if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 5faa48b52..af1406289 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace OpenIdConnectSample @@ -76,11 +75,8 @@ public void ConfigureServices(IServiceCollection services) }); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Information); - loggerfactory.AddDebug(LogLevel.Information); - app.UseDeveloperExceptionPage(); app.UseAuthentication(); diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs index 76fb5e59a..96bce512d 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -4,8 +4,8 @@ using System.Reflection; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Logging; namespace SocialSample { @@ -14,6 +14,11 @@ public static class Program public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseKestrel(options => { if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 7c1dd9d8d..22c44b3ea 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -16,7 +16,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; namespace SocialSample @@ -209,10 +208,8 @@ public void ConfigureServices(IServiceCollection services) }); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Information); - app.UseDeveloperExceptionPage(); app.UseAuthentication(); From 36605636dfbb84fbcbe96058c75154e08254767f Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 10 May 2017 11:47:56 -0700 Subject: [PATCH 003/248] Remove unnecessary package references (#1210) --- build/dependencies.props | 2 -- .../Microsoft.AspNetCore.Authentication.JwtBearer.csproj | 3 +-- .../Microsoft.AspNetCore.Authentication.OAuth.csproj | 6 +----- ...Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj | 3 +-- .../Microsoft.AspNetCore.Authorization.csproj | 6 +----- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 3 +-- 6 files changed, 5 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8dbb18b6c..955457fe8 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,13 +1,11 @@ 2.0.0-* - 4.3.0 3.13.8 2.1.3 2.1.0-* 10.0.1 $(BundledNETStandardPackageVersion) - 3.0.1 15.0.0 2.2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 05bdd4131..c2b99e47d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -1,4 +1,4 @@ - + ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. @@ -11,7 +11,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 5fb75ead9..8e33372c1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -1,4 +1,4 @@ - + @@ -17,8 +17,4 @@ - - - - diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index aab8833d2..b3829b59d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -1,4 +1,4 @@ - + ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. @@ -13,6 +13,5 @@ - diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index bc5b7be91..b39a7bf3d 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -1,4 +1,4 @@ - + @@ -19,8 +19,4 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - - - - diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index ca850d754..34224e21f 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,4 +1,4 @@ - + @@ -13,7 +13,6 @@ - From 785c1251dd511dfa4dd0218a65a31bb806494190 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Thu, 11 May 2017 16:32:19 -0700 Subject: [PATCH 004/248] Add auth link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ab822bd68..e8e64c293 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Travis: [![Travis](https://travis-ci.org/aspnet/Security.svg?branch=dev)](http Contains the security and authorization middlewares for ASP.NET Core. +A list of community projects related to authentication and security for ASP.NET Core are listed in the [documentation](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/community). + ### Notes ASP.NET Security will not include Basic Authentication middleware due to its potential insecurity and performance problems. If you host under IIS you can enable it via IIS configuration. From bdd4d219962201907393734d9fab2903921fec9d Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 12 May 2017 14:25:44 -0700 Subject: [PATCH 005/248] Update test framework versions and fix issues with tests --- build/dependencies.props | 4 ++-- .../GoogleTests.cs | 22 +++++++++---------- ...soft.AspNetCore.Authentication.Test.csproj | 12 +++++----- .../OAuthTests.cs | 2 ++ .../TicketSerializerTests.cs | 16 +++++++------- .../TokenExtensionTests.cs | 6 ++--- .../DefaultAuthorizationServiceTests.cs | 3 ++- ...osoft.AspNetCore.Authorization.Test.csproj | 13 ++++++----- ....ChunkingCookieManager.Sources.Test.csproj | 8 +++---- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 12 +++++----- 10 files changed, 54 insertions(+), 44 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 955457fe8..74d501f7c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -6,7 +6,7 @@ 2.1.0-* 10.0.1 $(BundledNETStandardPackageVersion) - 15.0.0 - 2.2.0 + 15.3.0-* + 2.3.0-beta2-* diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 0ab3e4493..68ea33462 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -405,7 +405,7 @@ public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string cla Assert.Equal("Test Family Name", transaction.FindClaimValue(ClaimTypes.Surname, expectedIssuer)); Assert.Equal("Test email", transaction.FindClaimValue(ClaimTypes.Email, expectedIssuer)); - // Ensure claims transformation + // Ensure claims transformation Assert.Equal("yup", transaction.FindClaimValue("xform")); transaction = await server.SendAsync("https://example.com/tokens", authCookie); @@ -688,14 +688,14 @@ public async Task ValidateAuthenticatedContext() OnCreatingTicket = context => { Assert.NotNull(context.User); - Assert.Equal(context.AccessToken, "Test Access Token"); - Assert.Equal(context.RefreshToken, "Test Refresh Token"); - Assert.Equal(context.ExpiresIn, TimeSpan.FromSeconds(3600)); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.Email)?.Value, "Test email"); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.NameIdentifier)?.Value, "Test User ID"); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.Name)?.Value, "Test Name"); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.Surname)?.Value, "Test Family Name"); - Assert.Equal(context.Identity.FindFirst(ClaimTypes.GivenName)?.Value, "Test Given Name"); + Assert.Equal("Test Access Token", context.AccessToken); + Assert.Equal("Test Refresh Token", context.RefreshToken); + Assert.Equal(TimeSpan.FromSeconds(3600), context.ExpiresIn); + Assert.Equal("Test email", context.Identity.FindFirst(ClaimTypes.Email)?.Value); + Assert.Equal("Test User ID", context.Identity.FindFirst(ClaimTypes.NameIdentifier)?.Value); + Assert.Equal("Test Name", context.Identity.FindFirst(ClaimTypes.Name)?.Value); + Assert.Equal("Test Family Name", context.Identity.FindFirst(ClaimTypes.Surname)?.Value); + Assert.Equal("Test Given Name", context.Identity.FindFirst(ClaimTypes.GivenName)?.Value); return Task.FromResult(0); } }; @@ -954,7 +954,7 @@ public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() var authCookie = transaction.AuthenticationCookieValue; transaction = await server.SendAsync("https://example.com/authenticateFacebook", authCookie); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.Equal(null, transaction.FindClaimValue(ClaimTypes.Name)); + Assert.Null(transaction.FindClaimValue(ClaimTypes.Name)); } [Fact] @@ -1103,7 +1103,7 @@ private static TestServer CreateServer(Action configureOptions, F } else if (req.Path == new PathString("/unauthorized")) { - // Simulate Authorization failure + // Simulate Authorization failure var result = await context.AuthenticateAsync("Google"); await context.ChallengeAsync("Google"); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index df51faf88..98d727fde 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -1,11 +1,13 @@  + netcoreapp2.0 true true + @@ -16,14 +18,14 @@ - - + + + + + - - - diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index dd48f7c95..2381fd6cd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -73,6 +73,7 @@ public async Task ThrowsIfClientSecretMissing() Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] public async Task ThrowsIfCallbackPathMissing() { var server = CreateServer( @@ -118,6 +119,7 @@ public async Task ThrowsIfTokenEndpointMissing() Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] public async Task ThrowsIfAuthorizationEndpointMissing() { var server = CreateServer( diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs index 8eeedde0d..41429cd37 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs @@ -78,7 +78,7 @@ public void CanRoundTripActorIdentity() var identity = (ClaimsIdentity) readTicket.Principal.Identity; Assert.NotNull(identity.Actor); - Assert.Equal(identity.Actor.AuthenticationType, "actor"); + Assert.Equal("actor", identity.Actor.AuthenticationType); } } @@ -113,17 +113,17 @@ public void CanRoundTripClaimProperties() var readClaim = readTicket.Principal.FindFirst("type"); Assert.NotNull(claim); - Assert.Equal(claim.Type, "type"); - Assert.Equal(claim.Value, "value"); - Assert.Equal(claim.ValueType, "valueType"); - Assert.Equal(claim.Issuer, "issuer"); - Assert.Equal(claim.OriginalIssuer, "original-issuer"); + Assert.Equal("type", claim.Type); + Assert.Equal("value", claim.Value); + Assert.Equal("valueType", claim.ValueType); + Assert.Equal("issuer", claim.Issuer); + Assert.Equal("original-issuer", claim.OriginalIssuer); var property1 = readClaim.Properties["property-1"]; - Assert.Equal(property1, "property-value"); + Assert.Equal("property-value", property1); var property2 = readClaim.Properties["property-2"]; - Assert.Equal(property2, string.Empty); + Assert.Equal(string.Empty, property2); } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs index fb7ea3443..afdef0a40 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -45,9 +45,9 @@ public void SubsequentStoreTokenDeletesPreviousTokens() props.StoreTokens(new[] { new AuthenticationToken { Name = "Zero", Value = "0" } }); Assert.Equal("0", props.GetTokenValue("Zero")); - Assert.Equal(null, props.GetTokenValue("One")); - Assert.Equal(null, props.GetTokenValue("Two")); - Assert.Equal(null, props.GetTokenValue("Three")); + Assert.Null(props.GetTokenValue("One")); + Assert.Null(props.GetTokenValue("Two")); + Assert.Null(props.GetTokenValue("Three")); Assert.Equal(1, props.GetTokens().Count()); } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 7b0fc8c8b..246eed9a5 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -106,6 +106,7 @@ public async Task Authorize_ShouldAllowIfClaimIsAmongValues() Assert.True(allowed); } + [Fact] public async Task Authorize_ShouldInvokeAllHandlersByDefault() { // Arrange @@ -1152,4 +1153,4 @@ public async Task CanUseCustomContextThatAlwaysFails() } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index a2d4a61de..a9ba71a79 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -1,19 +1,22 @@  + netcoreapp2.0 + - - + + + + + - - - + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 6ca53f519..7908e98fc 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -1,20 +1,20 @@  + netcoreapp2.0 + + + - - - - diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index 34224e21f..b7b2c6afe 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -6,16 +6,18 @@ true true + - - + + + + + - - - + From 1f5a27e20adf5438adcd9caf8587230307b685ce Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 17 May 2017 14:05:27 -0700 Subject: [PATCH 006/248] Switch to Options Initializer --- samples/SocialSample/Startup.cs | 4 - .../CookieAuthenticationHandler.cs | 33 ----- .../CookieAuthenticationInitializer.cs | 60 +++++++++ .../CookieAuthenticationOptions.cs | 7 +- .../CookieExtensions.cs | 11 +- .../FacebookExtensions.cs | 2 +- .../FacebookHandler.cs | 5 +- .../GoogleExtensions.cs | 2 +- .../GoogleHandler.cs | 5 +- .../JwtBearerExtensions.cs | 2 + .../JwtBearerHandler.cs | 43 ------- .../JwtBearerInitializer.cs | 63 ++++++++++ .../MicrosoftAccountExtensions.cs | 2 +- .../MicrosoftAccountHandler.cs | 5 +- .../Events/OAuthCreatingTicketContext.cs | 2 +- .../OAuthExtensions.cs | 19 ++- .../OAuthHandler.cs | 27 +---- .../OAuthInitializer.cs | 45 +++++++ .../OpenIdConnectExtensions.cs | 4 +- .../OpenIdConnectHandler.cs | 93 +------------- .../OpenIdConnectInitializer.cs | 114 ++++++++++++++++++ .../OpenIdConnectOptions.cs | 1 - .../TwitterExtensions.cs | 4 +- .../TwitterHandler.cs | 40 ++---- .../TwitterInitializer.cs | 51 ++++++++ .../AuthenticationHandler.cs | 24 +--- .../AuthenticationSchemeOptions.cs | 24 ++-- ...thenticationServiceCollectionExtensions.cs | 25 ++++ .../RemoteAuthenticationHandler.cs | 26 +--- .../FacebookTests.cs | 2 - .../GoogleTests.cs | 2 - .../JwtBearerTests.cs | 6 +- .../MicrosoftAccountTests.cs | 2 - .../OpenIdConnect/OpenIdConnectTests.cs | 2 + .../TwitterTests.cs | 2 - 35 files changed, 434 insertions(+), 325 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 22c44b3ea..ffffa4646 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -75,7 +75,6 @@ public void ConfigureServices(IServiceCollection services) // https://console.developers.google.com/project services.AddOAuthAuthentication("Google-AccessToken", o => { - o.DisplayName = "Google-AccessToken"; o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; o.CallbackPath = new PathString("/signin-google-token"); @@ -137,7 +136,6 @@ public void ConfigureServices(IServiceCollection services) // https://apps.dev.microsoft.com/ services.AddOAuthAuthentication("Microsoft-AccessToken", o => { - o.DisplayName = "MicrosoftAccount-AccessToken"; o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; o.CallbackPath = new PathString("/signin-microsoft-token"); @@ -160,7 +158,6 @@ public void ConfigureServices(IServiceCollection services) // https://github.com/settings/applications/ services.AddOAuthAuthentication("GitHub-AccessToken", o => { - o.DisplayName = "Github-AccessToken"; o.ClientId = Configuration["github-token:clientid"]; o.ClientSecret = Configuration["github-token:clientsecret"]; o.CallbackPath = new PathString("/signin-github-token"); @@ -178,7 +175,6 @@ public void ConfigureServices(IServiceCollection services) // https://github.com/settings/applications/ services.AddOAuthAuthentication("GitHub", o => { - o.DisplayName = "Github"; o.ClientId = Configuration["github:clientid"]; o.ClientSecret = Configuration["github:clientsecret"]; o.CallbackPath = new PathString("/signin-github"); diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 017e7911c..5a4ffc547 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -59,39 +59,6 @@ protected override Task InitializeHandlerAsync() /// A new instance of the events instance. protected override Task CreateEventsAsync() => Task.FromResult(new CookieAuthenticationEvents()); - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (String.IsNullOrEmpty(Options.CookieName)) - { - Options.CookieName = CookieAuthenticationDefaults.CookiePrefix + Scheme.Name; - } - if (Options.TicketDataFormat == null) - { - var provider = Options.DataProtectionProvider ?? Context.RequestServices.GetRequiredService(); - // Note: the purpose for the data protector must remain fixed for interop to work. - var dataProtector = provider.CreateProtector("Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", Scheme.Name, "v2"); - Options.TicketDataFormat = new TicketDataFormat(dataProtector); - } - if (Options.CookieManager == null) - { - Options.CookieManager = new ChunkingCookieManager(); - } - if (!Options.LoginPath.HasValue) - { - Options.LoginPath = CookieAuthenticationDefaults.LoginPath; - } - if (!Options.LogoutPath.HasValue) - { - Options.LogoutPath = CookieAuthenticationDefaults.LogoutPath; - } - if (!Options.AccessDeniedPath.HasValue) - { - Options.AccessDeniedPath = CookieAuthenticationDefaults.AccessDeniedPath; - } - } - private Task EnsureCookieTicket() { // We only need to read the ticket once diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs new file mode 100644 index 000000000..af4a85b19 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs @@ -0,0 +1,60 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.Cookies +{ + /// + /// Used to setup defaults for all . + /// + public class CookieAuthenticationInitializer : IInitializeOptions + { + private readonly IDataProtectionProvider _dp; + + public CookieAuthenticationInitializer(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + /// + /// Invoked to initialize a TOptions instance. + /// + /// The name of the options instance being initialized. + /// The options instance to initialize. + public void Initialize(string name, CookieAuthenticationOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + + if (String.IsNullOrEmpty(options.CookieName)) + { + options.CookieName = CookieAuthenticationDefaults.CookiePrefix + name; + } + if (options.TicketDataFormat == null) + { + // Note: the purpose for the data protector must remain fixed for interop to work. + var dataProtector = options.DataProtectionProvider.CreateProtector("Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", name, "v2"); + options.TicketDataFormat = new TicketDataFormat(dataProtector); + } + if (options.CookieManager == null) + { + options.CookieManager = new ChunkingCookieManager(); + } + if (!options.LoginPath.HasValue) + { + options.LoginPath = CookieAuthenticationDefaults.LoginPath; + } + if (!options.LogoutPath.HasValue) + { + options.LogoutPath = CookieAuthenticationDefaults.LogoutPath; + } + if (!options.AccessDeniedPath.HasValue) + { + options.AccessDeniedPath = CookieAuthenticationDefaults.AccessDeniedPath; + } + } + + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 56d6ca238..9b6b51d8e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -4,6 +4,7 @@ using System; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -71,7 +72,7 @@ public string CookieName public CookieSecurePolicy CookieSecure { get; set; } /// - /// If set this will be used by the CookieAuthenticationMiddleware for data protection. + /// If set this will be used by the CookieAuthenticationHandler for data protection. /// public IDataProtectionProvider DataProtectionProvider { get; set; } @@ -129,9 +130,7 @@ public string CookieName /// /// The TicketDataFormat is used to protect and unprotect the identity and other properties which are stored in the - /// cookie value. If it is not provided a default data handler is created using the data protection service contained - /// in the IApplicationBuilder.Properties. The default data protection service is based on machine key when running on ASP.NET, - /// and on DPAPI when running in a different process. + /// cookie value. If not provided one will be created using . /// public ISecureDataFormat TicketDataFormat { get; set; } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index e8a21d01b..b528dec9c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -3,6 +3,10 @@ using System; using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.AspNetCore.Authentication; namespace Microsoft.Extensions.DependencyInjection { @@ -15,7 +19,10 @@ public static class CookieExtensions public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, Action configureOptions) => services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions); - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) => - services.AddScheme(authenticationScheme, configureOptions); + public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + services.TryAddEnumerable(ServiceDescriptor.Singleton, CookieAuthenticationInitializer>()); + return services.AddScheme(authenticationScheme, configureOptions); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 79d9ac66c..032be8235 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddFacebookAuthentication(this IServiceCollecti public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 521684d14..c94048f9b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -9,7 +9,6 @@ using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -19,8 +18,8 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { internal class FacebookHandler : OAuthHandler { - public FacebookHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, logger, encoder, dataProtection, clock) + public FacebookHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } protected override async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index 420d14030..d71e8b461 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddGoogleAuthentication(this IServiceCollection public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index c699f5cc9..3a93c5cbf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -9,7 +9,6 @@ using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -19,8 +18,8 @@ namespace Microsoft.AspNetCore.Authentication.Google { internal class GoogleHandler : OAuthHandler { - public GoogleHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, logger, encoder, dataProtection, clock) + public GoogleHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } protected override async Task CreateTicketAsync( diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 77ffd76ff..4f6453bd9 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection @@ -26,6 +27,7 @@ public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollect public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { + services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerInitializer>()); return services.AddScheme(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 2ea03a51f..ec48e3e20 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -40,49 +40,6 @@ public JwtBearerHandler(IOptionsSnapshot options, ILoggerFacto protected override Task CreateEventsAsync() => Task.FromResult(new JwtBearerEvents()); - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.Audience)) - { - Options.TokenValidationParameters.ValidAudience = Options.Audience; - } - - if (Options.ConfigurationManager == null) - { - if (Options.Configuration != null) - { - Options.ConfigurationManager = new StaticConfigurationManager(Options.Configuration); - } - else if (!(string.IsNullOrEmpty(Options.MetadataAddress) && string.IsNullOrEmpty(Options.Authority))) - { - if (string.IsNullOrEmpty(Options.MetadataAddress) && !string.IsNullOrEmpty(Options.Authority)) - { - Options.MetadataAddress = Options.Authority; - if (!Options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) - { - Options.MetadataAddress += "/"; - } - - Options.MetadataAddress += ".well-known/openid-configuration"; - } - - if (Options.RequireHttpsMetadata && !Options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); - } - - var httpClient = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - httpClient.Timeout = Options.BackchannelTimeout; - httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - - Options.ConfigurationManager = new ConfigurationManager(Options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), - new HttpDocumentRetriever(httpClient) { RequireHttps = Options.RequireHttpsMetadata }); - } - } - } - /// /// Searches the 'Authorization' header for a 'Bearer' token. If the 'Bearer' token is found, it is validated using set in the options. /// diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs new file mode 100644 index 000000000..0aeed1183 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs @@ -0,0 +1,63 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Net.Http; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; + +namespace Microsoft.AspNetCore.Authentication.JwtBearer +{ + /// + /// Used to setup defaults for all . + /// + public class JwtBearerInitializer : IInitializeOptions + { + /// + /// Invoked to initialize a JwtBearerOptions instance. + /// + /// The name of the options instance being initialized. + /// The options instance to initialize. + public void Initialize(string name, JwtBearerOptions options) + { + if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(options.Audience)) + { + options.TokenValidationParameters.ValidAudience = options.Audience; + } + + if (options.ConfigurationManager == null) + { + if (options.Configuration != null) + { + options.ConfigurationManager = new StaticConfigurationManager(options.Configuration); + } + else if (!(string.IsNullOrEmpty(options.MetadataAddress) && string.IsNullOrEmpty(options.Authority))) + { + if (string.IsNullOrEmpty(options.MetadataAddress) && !string.IsNullOrEmpty(options.Authority)) + { + options.MetadataAddress = options.Authority; + if (!options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) + { + options.MetadataAddress += "/"; + } + + options.MetadataAddress += ".well-known/openid-configuration"; + } + + if (options.RequireHttpsMetadata && !options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); + } + + var httpClient = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + httpClient.Timeout = options.BackchannelTimeout; + httpClient.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + + options.ConfigurationManager = new ConfigurationManager(options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), + new HttpDocumentRetriever(httpClient) { RequireHttps = options.RequireHttpsMetadata }); + } + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 509016ff2..6ccb39234 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -26,7 +26,7 @@ public static IServiceCollection AddMicrosoftAccountAuthentication(this IService public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index b2b787b97..815b94bf4 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -7,7 +7,6 @@ using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; @@ -16,8 +15,8 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { internal class MicrosoftAccountHandler : OAuthHandler { - public MicrosoftAccountHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, logger, encoder, dataProtection, clock) + public MicrosoftAccountHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } protected override async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index f50dff3f5..6e3105639 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -170,7 +170,7 @@ public void RunClaimActions(JObject userData) foreach (var action in Options.ClaimActions) { - action.Run(userData, Identity, Options.ClaimsIssuer); + action.Run(userData, Identity, Options.ClaimsIssuer ?? Scheme.Name); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 6fd0f57f4..408789b03 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -3,13 +3,24 @@ using System; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.Extensions.DependencyInjection { public static class OAuthExtensions { - public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) => - services.AddScheme>(authenticationScheme, authenticationScheme, configureOptions); + public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + { + return services.AddScheme>(authenticationScheme, authenticationScheme, configureOptions); + } + + public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) + where TOptions : OAuthOptions, new() + where THandler : OAuthHandler + { + services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthInitializer>()); + return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index cafc4f0bc..63bcdbdf2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -10,7 +10,6 @@ using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -33,30 +32,10 @@ namespace Microsoft.AspNetCore.Authentication.OAuth set { base.Events = value; } } - public OAuthHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, dataProtection, logger, encoder, clock) + public OAuthHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (Options.Backchannel == null) - { - Options.Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OAuth handler"); - Options.Backchannel.Timeout = Options.BackchannelTimeout; - Options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - } - - if (Options.StateDataFormat == null) - { - var dataProtector = DataProtection.CreateProtector( - GetType().FullName, Scheme.Name, "v1"); - Options.StateDataFormat = new PropertiesDataFormat(dataProtector); - } - } - /// /// Creates a new instance of the events instance. /// @@ -119,7 +98,7 @@ protected override async Task HandleRemoteAuthenticateAsync( return AuthenticateResult.Fail("Failed to retrieve access token."); } - var identity = new ClaimsIdentity(Options.ClaimsIssuer); + var identity = new ClaimsIdentity(ClaimsIssuer); if (Options.SaveTokens) { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs new file mode 100644 index 000000000..99f65253a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs @@ -0,0 +1,45 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Net.Http; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + /// + /// Used to setup defaults for the OAuthOptions. + /// + public class OAuthInitializer : IInitializeOptions + where TOptions : OAuthOptions, new() + where THandler : OAuthHandler + { + private readonly IDataProtectionProvider _dp; + + public OAuthInitializer(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + public void Initialize(string name, TOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + if (options.Backchannel == null) + { + options.Backchannel = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OAuth handler"); + options.Backchannel.Timeout = options.BackchannelTimeout; + options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + } + + if (options.StateDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(THandler).FullName, name, "v1"); + options.StateDataFormat = new PropertiesDataFormat(dataProtector); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index 64737a9ad..c79dc7212 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection @@ -26,7 +27,8 @@ public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCol public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectInitializer>()); + return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 69acbf9a0..d51c324dc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -13,12 +13,10 @@ using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; -using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -57,8 +55,8 @@ public class OpenIdConnectHandler : RemoteAuthenticationHandler sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, HtmlEncoder htmlEncoder, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, dataProtection, logger, encoder, clock) + public OpenIdConnectHandler(IOptionsSnapshot options, ILoggerFactory logger, HtmlEncoder htmlEncoder, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { HtmlEncoder = htmlEncoder; } @@ -75,76 +73,6 @@ public OpenIdConnectHandler(IOptions sharedOptions, IOpti protected override Task CreateEventsAsync() => Task.FromResult(new OpenIdConnectEvents()); - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (string.IsNullOrEmpty(Options.SignOutScheme)) - { - Options.SignOutScheme = SignInScheme; - } - - if (Options.StateDataFormat == null) - { - var dataProtector = DataProtection.CreateProtector( - GetType().FullName, Scheme.Name, "v1"); - Options.StateDataFormat = new PropertiesDataFormat(dataProtector); - } - - if (Options.StringDataFormat == null) - { - var dataProtector = DataProtection.CreateProtector( - GetType().FullName, - typeof(string).FullName, - Scheme.Name, - "v1"); - - Options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector); - } - - if (string.IsNullOrEmpty(Options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(Options.ClientId)) - { - Options.TokenValidationParameters.ValidAudience = Options.ClientId; - } - - if (Options.Backchannel == null) - { - Options.Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OpenIdConnect handler"); - Options.Backchannel.Timeout = Options.BackchannelTimeout; - Options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - } - - if (Options.ConfigurationManager == null) - { - if (Options.Configuration != null) - { - Options.ConfigurationManager = new StaticConfigurationManager(Options.Configuration); - } - else if (!(string.IsNullOrEmpty(Options.MetadataAddress) && string.IsNullOrEmpty(Options.Authority))) - { - if (string.IsNullOrEmpty(Options.MetadataAddress) && !string.IsNullOrEmpty(Options.Authority)) - { - Options.MetadataAddress = Options.Authority; - if (!Options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) - { - Options.MetadataAddress += "/"; - } - - Options.MetadataAddress += ".well-known/openid-configuration"; - } - - if (Options.RequireHttpsMetadata && !Options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); - } - - Options.ConfigurationManager = new ConfigurationManager(Options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), - new HttpDocumentRetriever(Backchannel) { RequireHttps = Options.RequireHttpsMetadata }); - } - } - } - public override Task HandleRequestAsync() { if (Options.RemoteSignOutPath.HasValue && Options.RemoteSignOutPath == Request.Path) @@ -749,7 +677,7 @@ protected override async Task HandleRemoteAuthenticateAsync( var identity = (ClaimsIdentity)ticket.Principal.Identity; foreach (var action in Options.ClaimActions) { - action.Run(null, identity, Options.ClaimsIssuer); + action.Run(null, identity, ClaimsIssuer); } } @@ -902,7 +830,7 @@ protected virtual async Task GetUserInformationAsync(OpenIdC foreach (var action in Options.ClaimActions) { - action.Run(user, identity, Options.ClaimsIssuer); + action.Run(user, identity, ClaimsIssuer); } return AuthenticateResult.Success(ticket); @@ -1301,18 +1229,5 @@ private OpenIdConnectProtocolException CreateOpenIdConnectProtocolException(Open description, errorUri)); } - - private class StringSerializer : IDataSerializer - { - public string Deserialize(byte[] data) - { - return Encoding.UTF8.GetString(data); - } - - public byte[] Serialize(string model) - { - return Encoding.UTF8.GetBytes(model); - } - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs new file mode 100644 index 000000000..7421af9c0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs @@ -0,0 +1,114 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Net.Http; +using System.Text; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; + +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +{ + /// + /// Used to setup defaults for all . + /// + public class OpenIdConnectInitializer : IInitializeOptions + { + private readonly IDataProtectionProvider _dp; + + public OpenIdConnectInitializer(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + /// + /// Invoked to initialize a TOptions instance. + /// + /// The name of the options instance being initialized. + /// The options instance to initialize. + public void Initialize(string name, OpenIdConnectOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + + if (string.IsNullOrEmpty(options.SignOutScheme)) + { + options.SignOutScheme = options.SignInScheme; + } + + if (options.StateDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(OpenIdConnectHandler).FullName, name, "v1"); + options.StateDataFormat = new PropertiesDataFormat(dataProtector); + } + + if (options.StringDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(OpenIdConnectHandler).FullName, + typeof(string).FullName, + name, + "v1"); + + options.StringDataFormat = new SecureDataFormat(new StringSerializer(), dataProtector); + } + + if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(options.ClientId)) + { + options.TokenValidationParameters.ValidAudience = options.ClientId; + } + + if (options.Backchannel == null) + { + options.Backchannel = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OpenIdConnect handler"); + options.Backchannel.Timeout = options.BackchannelTimeout; + options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + } + + if (options.ConfigurationManager == null) + { + if (options.Configuration != null) + { + options.ConfigurationManager = new StaticConfigurationManager(options.Configuration); + } + else if (!(string.IsNullOrEmpty(options.MetadataAddress) && string.IsNullOrEmpty(options.Authority))) + { + if (string.IsNullOrEmpty(options.MetadataAddress) && !string.IsNullOrEmpty(options.Authority)) + { + options.MetadataAddress = options.Authority; + if (!options.MetadataAddress.EndsWith("/", StringComparison.Ordinal)) + { + options.MetadataAddress += "/"; + } + + options.MetadataAddress += ".well-known/openid-configuration"; + } + + if (options.RequireHttpsMetadata && !options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); + } + + options.ConfigurationManager = new ConfigurationManager(options.MetadataAddress, new OpenIdConnectConfigurationRetriever(), + new HttpDocumentRetriever(options.Backchannel) { RequireHttps = options.RequireHttpsMetadata }); + } + } + } + + private class StringSerializer : IDataSerializer + { + public string Deserialize(byte[] data) + { + return Encoding.UTF8.GetString(data); + } + + public byte[] Serialize(string model) + { + return Encoding.UTF8.GetBytes(model); + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 5ca270dde..b2d69d524 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -39,7 +39,6 @@ public class OpenIdConnectOptions : RemoteAuthenticationOptions /// public OpenIdConnectOptions() { - DisplayName = OpenIdConnectDefaults.Caption; CallbackPath = new PathString("/signin-oidc"); SignedOutCallbackPath = new PathString("/signout-callback-oidc"); RemoteSignOutPath = new PathString("/signout-oidc"); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index 1e126d4c4..3bcc80c3d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Twitter; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection @@ -26,7 +27,8 @@ public static IServiceCollection AddTwitterAuthentication(this IServiceCollectio public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme(authenticationScheme, authenticationScheme, configureOptions); + services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterInitializer>()); + return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index c166b175a..7ae9f973c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -40,36 +40,12 @@ internal class TwitterHandler : RemoteAuthenticationHandler set { base.Events = value; } } - public TwitterHandler(IOptions sharedOptions, IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) - : base(sharedOptions, options, dataProtection, logger, encoder, clock) + public TwitterHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) { } protected override Task CreateEventsAsync() => Task.FromResult(new TwitterEvents()); - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (Options.StateDataFormat == null) - { - var dataProtector = DataProtection.CreateProtector( - GetType().FullName, Scheme.Name, "v1"); - Options.StateDataFormat = new SecureDataFormat( - new RequestTokenSerializer(), - dataProtector); - } - - if (Options.Backchannel == null) - { - Options.Backchannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()); - Options.Backchannel.Timeout = Options.BackchannelTimeout; - Options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB - Options.Backchannel.DefaultRequestHeaders.Accept.ParseAdd("*/*"); - Options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core Twitter handler"); - Options.Backchannel.DefaultRequestHeaders.ExpectContinue = false; - } - } - protected override async Task HandleRemoteAuthenticateAsync() { AuthenticationProperties properties = null; @@ -116,12 +92,12 @@ protected override async Task HandleRemoteAuthenticateAsync( var identity = new ClaimsIdentity(new[] { - new Claim(ClaimTypes.NameIdentifier, accessToken.UserId, ClaimValueTypes.String, Options.ClaimsIssuer), - new Claim(ClaimTypes.Name, accessToken.ScreenName, ClaimValueTypes.String, Options.ClaimsIssuer), - new Claim("urn:twitter:userid", accessToken.UserId, ClaimValueTypes.String, Options.ClaimsIssuer), - new Claim("urn:twitter:screenname", accessToken.ScreenName, ClaimValueTypes.String, Options.ClaimsIssuer) + new Claim(ClaimTypes.NameIdentifier, accessToken.UserId, ClaimValueTypes.String, ClaimsIssuer), + new Claim(ClaimTypes.Name, accessToken.ScreenName, ClaimValueTypes.String, ClaimsIssuer), + new Claim("urn:twitter:userid", accessToken.UserId, ClaimValueTypes.String, ClaimsIssuer), + new Claim("urn:twitter:screenname", accessToken.ScreenName, ClaimValueTypes.String, ClaimsIssuer) }, - Options.ClaimsIssuer); + ClaimsIssuer); JObject user = null; if (Options.RetrieveUserDetails) @@ -145,7 +121,7 @@ protected virtual async Task CreateTicketAsync( { foreach (var action in Options.ClaimActions) { - action.Run(user, identity, Options.ClaimsIssuer); + action.Run(user, identity, ClaimsIssuer); } var context = new TwitterCreatingTicketContext(Context, Scheme, Options, properties, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs new file mode 100644 index 000000000..08e9c5b83 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs @@ -0,0 +1,51 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Net.Http; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.Twitter +{ + /// + /// Used to setup defaults for all . + /// + public class TwitterInitializer : IInitializeOptions + { + private readonly IDataProtectionProvider _dp; + + public TwitterInitializer(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + /// + /// Invoked to initialize a TOptions instance. + /// + /// The name of the options instance being initialized. + /// The options instance to initialize. + public void Initialize(string name, TwitterOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + + if (options.StateDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(TwitterHandler).FullName, name, "v1"); + options.StateDataFormat = new SecureDataFormat( + new RequestTokenSerializer(), + dataProtector); + } + + if (options.Backchannel == null) + { + options.Backchannel = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + options.Backchannel.Timeout = options.BackchannelTimeout; + options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + options.Backchannel.DefaultRequestHeaders.Accept.ParseAdd("*/*"); + options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core Twitter handler"); + options.Backchannel.DefaultRequestHeaders.ExpectContinue = false; + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 083884a02..ba1c919fe 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -48,6 +48,8 @@ protected HttpResponse Response /// protected virtual object Events { get; set; } + protected virtual string ClaimsIssuer => Options.ClaimsIssuer ?? Scheme.Name; + protected string CurrentUri { get @@ -85,18 +87,6 @@ public async Task InitializeAsync(AuthenticationScheme scheme, HttpContext conte Context = context; Options = OptionsSnapshot.Get(Scheme.Name) ?? new TOptions(); - if (!Options.Initialized) - { - lock (Options.InitializeLock) - { - if (!Options.Initialized) - { - InitializeOptions(); - Options.Initialized = true; - } - } - } - Options.Validate(); await InitializeEventsAsync(); @@ -122,16 +112,6 @@ protected virtual async Task InitializeEventsAsync() /// A new instance of the events instance. protected virtual Task CreateEventsAsync() => Task.FromResult(new object()); - /// - /// Initializes the options, will be called only once by . - /// - protected virtual void InitializeOptions() - { - // REVIEW: is there a better place for this default? - Options.DisplayName = Options.DisplayName ?? Scheme.Name; - Options.ClaimsIssuer = Options.ClaimsIssuer ?? Scheme.Name; - } - /// /// Called after options/events have been initialized for the handler to finish initializing itself. /// diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs index 09e7abbd4..55bc09d8a 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -2,9 +2,18 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication { + public class InitializeAuthenticationSchemeOptions : InitializeOptions + where TOptions : AuthenticationSchemeOptions + { + public InitializeAuthenticationSchemeOptions(string name) + : base(name, options => options.ClaimsIssuer = options.ClaimsIssuer ?? name) + { } + } + /// /// Contains the options used by the . /// @@ -17,11 +26,6 @@ public virtual void Validate() { } - /// - /// Gets or sets the display name for the authentication provider. - /// - public string DisplayName { get; set; } - /// /// Gets or sets the issuer that should be used for any claims that are created /// @@ -36,15 +40,5 @@ public virtual void Validate() /// If set, will be used as the service type to get the Events instance instead of the property. /// public Type EventsType { get; set; } - - /// - /// Used to ensure that the options are only initialized once. - /// - public bool Initialized { get; set; } - - /// - /// Used to prevent concurrent access during intialization. - /// - public object InitializeLock { get; } = new object(); } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 0315562ff..ff367f555 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -74,5 +74,30 @@ public static IServiceCollection AddScheme(this IServiceColl where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler => services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); + + public static IServiceCollection AddRemoteScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureOptions) + where TOptions : RemoteAuthenticationOptions, new() + where THandler : RemoteAuthenticationHandler + { + services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); + return services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); + } + + // Used to ensure that there's always a default data protection provider + private class EnsureSignInScheme : IInitializeOptions where TOptions : RemoteAuthenticationOptions + { + private readonly AuthenticationOptions _authOptions; + + public EnsureSignInScheme(IOptions authOptions) + { + _authOptions = authOptions.Value; + } + + public void Initialize(string name, TOptions options) + { + options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme; + } + } + } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index fc663317e..bf875a7a0 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -5,9 +5,7 @@ using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -25,10 +23,6 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand protected string SignInScheme => Options.SignInScheme; - protected IDataProtectionProvider DataProtection { get; set; } - - private readonly AuthenticationOptions _authOptions; - /// /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. @@ -39,17 +33,9 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand set { base.Events = value; } } - protected RemoteAuthenticationHandler(IOptions sharedOptions, IOptionsSnapshot options, IDataProtectionProvider dataProtection, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + protected RemoteAuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { - _authOptions = sharedOptions.Value; - DataProtection = dataProtection; - } - - protected override Task InitializeHandlerAsync() - { - DataProtection = Options.DataProtectionProvider ?? DataProtection; - return TaskCache.CompletedTask; } protected override Task CreateEventsAsync() @@ -57,16 +43,6 @@ protected override Task CreateEventsAsync() return Task.FromResult(new RemoteAuthenticationEvents()); } - protected override void InitializeOptions() - { - base.InitializeOptions(); - - if (Options.SignInScheme == null) - { - Options.SignInScheme = _authOptions.DefaultSignInScheme; - } - } - public virtual Task ShouldHandleRequestAsync() { return Task.FromResult(Options.CallbackPath == Request.Path); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index edd9eb578..060eb649f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -50,7 +50,6 @@ public void AddCanBindAgainstDefaultConfig() {"Facebook:BackchannelTimeout", "0.0:0:30"}, //{"Facebook:CallbackPath", "/callbackpath"}, // PathString doesn't convert {"Facebook:ClaimsIssuer", ""}, - {"Facebook:DisplayName", ""}, {"Facebook:RemoteAuthenticationTimeout", "0.0:0:30"}, {"Facebook:SaveTokens", "true"}, {"Facebook:SendAppSecretProof", "true"}, @@ -73,7 +72,6 @@ public void AddCanBindAgainstDefaultConfig() Assert.Equal("", options.ClaimsIssuer); Assert.Equal("", options.ClientId); Assert.Equal("", options.ClientSecret); - Assert.Equal("", options.DisplayName); Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); Assert.True(options.SaveTokens); Assert.True(options.SendAppSecretProof); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 68ea33462..2c86bc778 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -49,7 +49,6 @@ public void AddCanBindAgainstDefaultConfig() {"Google:BackchannelTimeout", "0.0:0:30"}, //{"Google:CallbackPath", "/callbackpath"}, // PathString doesn't convert {"Google:ClaimsIssuer", ""}, - {"Google:DisplayName", ""}, {"Google:RemoteAuthenticationTimeout", "0.0:0:30"}, {"Google:SaveTokens", "true"}, {"Google:SendAppSecretProof", "true"}, @@ -70,7 +69,6 @@ public void AddCanBindAgainstDefaultConfig() Assert.Equal("", options.ClaimsIssuer); Assert.Equal("", options.ClientId); Assert.Equal("", options.ClientSecret); - Assert.Equal("", options.DisplayName); Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); Assert.True(options.SaveTokens); Assert.Equal("", options.SignInScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 42efe00dd..59f1e880c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -48,11 +48,10 @@ public void AddCanBindAgainstDefaultConfig() {"Bearer:BackchannelTimeout", "0.0:0:30"}, {"Bearer:Challenge", ""}, {"Bearer:ClaimsIssuer", ""}, - {"Bearer:DisplayName", ""}, {"Bearer:IncludeErrorDetails", "true"}, {"Bearer:MetadataAddress", ""}, {"Bearer:RefreshOnIssuerKeyNotFound", "true"}, - {"Bearer:RequireHttpsMetadata", "true"}, + {"Bearer:RequireHttpsMetadata", "false"}, {"Bearer:SaveToken", "true"}, }; var configurationBuilder = new ConfigurationBuilder(); @@ -67,11 +66,10 @@ public void AddCanBindAgainstDefaultConfig() Assert.Equal("", options.Authority); Assert.Equal("", options.Challenge); Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.DisplayName); Assert.True(options.IncludeErrorDetails); Assert.Equal("", options.MetadataAddress); Assert.True(options.RefreshOnIssuerKeyNotFound); - Assert.True(options.RequireHttpsMetadata); + Assert.False(options.RequireHttpsMetadata); Assert.True(options.SaveToken); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 1f0f394f3..062215ff4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -50,7 +50,6 @@ public void AddCanBindAgainstDefaultConfig() {"Microsoft:BackchannelTimeout", "0.0:0:30"}, //{"Microsoft:CallbackPath", "/callbackpath"}, // PathString doesn't convert {"Microsoft:ClaimsIssuer", ""}, - {"Microsoft:DisplayName", ""}, {"Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"}, {"Microsoft:SaveTokens", "true"}, {"Microsoft:SendAppSecretProof", "true"}, @@ -71,7 +70,6 @@ public void AddCanBindAgainstDefaultConfig() Assert.Equal("", options.ClaimsIssuer); Assert.Equal("", options.ClientId); Assert.Equal("", options.ClientSecret); - Assert.Equal("", options.DisplayName); Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); Assert.True(options.SaveTokens); Assert.Equal("", options.SignInScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index a3d7f5130..b2459cf81 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -36,6 +36,7 @@ public void AddCanBindAgainstDefaultConfig() { {"OpenIdConnect:ClientId", ""}, {"OpenIdConnect:ClientSecret", ""}, + {"OpenIdConnect:RequireHttpsMetadata", "false"}, {"OpenIdConnect:Authority", ""} }; var configurationBuilder = new ConfigurationBuilder(); @@ -48,6 +49,7 @@ public void AddCanBindAgainstDefaultConfig() Assert.Equal("", options.ClientId); Assert.Equal("", options.ClientSecret); Assert.Equal("", options.Authority); + Assert.False(options.RequireHttpsMetadata); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 9993559f6..1acddc5af 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -42,7 +42,6 @@ public void AddCanBindAgainstDefaultConfig() {"Twitter:BackchannelTimeout", "0.0:0:30"}, //{"Twitter:CallbackPath", "/callbackpath"}, // PathString doesn't convert {"Twitter:ClaimsIssuer", ""}, - {"Twitter:DisplayName", ""}, {"Twitter:RemoteAuthenticationTimeout", "0.0:0:30"}, {"Twitter:SaveTokens", "true"}, {"Twitter:SendAppSecretProof", "true"}, @@ -60,7 +59,6 @@ public void AddCanBindAgainstDefaultConfig() Assert.Equal("", options.ClaimsIssuer); Assert.Equal("", options.ConsumerKey); Assert.Equal("", options.ConsumerSecret); - Assert.Equal("", options.DisplayName); Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); Assert.True(options.SaveTokens); Assert.Equal("", options.SignInScheme); From 2a4a7dd26af2f55a3d8be67fd5d12840d229b0b6 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 22 May 2017 10:01:44 -0700 Subject: [PATCH 007/248] Make samples work. Fix AddOAuthAuthentication extension. (#1226) --- samples/CookieSample/Startup.cs | 7 +++++++ samples/CookieSessionSample/Startup.cs | 7 +++++++ samples/JwtBearerSample/Startup.cs | 7 +++++++ .../OpenIdConnectSample/OpenIdConnectSample.csproj | 10 +++++++++- samples/OpenIdConnectSample/Program.cs | 14 +++++--------- samples/SocialSample/Program.cs | 14 +++++--------- samples/SocialSample/SocialSample.csproj | 10 +++++++++- samples/SocialSample/Startup.cs | 10 +++++----- .../OAuthExtensions.cs | 2 +- 9 files changed, 55 insertions(+), 26 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 3aebb419f..79d1b3c3f 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -13,6 +13,13 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { + // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + services.AddCookieAuthentication(); } diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index 9ad9e6841..c35dfd999 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -14,6 +14,13 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { + // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; + }); + services.AddCookieAuthentication(o => o.SessionStore = new MemoryCacheTicketStore()); } diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 9df41a9ab..030e640c9 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -43,6 +43,13 @@ public Startup(IHostingEnvironment env) // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { + // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + }); + services.AddJwtBearerAuthentication(o => { // You also need to update /wwwroot/app/scripts/app.js diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index e69563ced..875762d12 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,4 +1,4 @@ - + @@ -7,6 +7,10 @@ aspnet5-OpenIdConnectSample-20151210110318 + + + + @@ -25,4 +29,8 @@ + + + + diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index b4d24505d..87e775508 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -23,16 +23,12 @@ public static void Main(string[] args) }) .UseKestrel(options => { - if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + options.Listen(IPAddress.Loopback, 44318, listenOptions => { - // ANCM is not hosting the process - options.Listen(IPAddress.Loopback, 44318, listenOptions => - { - // Configure SSL - var serverCertificate = LoadCertificate(); - listenOptions.UseHttps(serverCertificate); - }); - } + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs index 96bce512d..a712b6c03 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -21,16 +21,12 @@ public static void Main(string[] args) }) .UseKestrel(options => { - if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + options.Listen(IPAddress.Loopback, 44318, listenOptions => { - // ANCM is not hosting the process - options.Listen(IPAddress.Loopback, 44318, listenOptions => - { - // Configure SSL - var serverCertificate = LoadCertificate(); - listenOptions.UseHttps(serverCertificate); - }); - } + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index e0336cc0e..723d74de3 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,4 +1,4 @@ - + @@ -7,6 +7,14 @@ aspnet5-SocialSample-20151210111056 + + + + + + + + diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index ffffa4646..003972009 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -164,11 +164,6 @@ public void ConfigureServices(IServiceCollection services) o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; o.TokenEndpoint = "https://github.com/login/oauth/access_token"; o.SaveTokens = true; - o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); - o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); - o.ClaimActions.MapJsonKey("urn:github:name", "name"); - o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); - o.ClaimActions.MapJsonKey("urn:github:url", "url"); }); // You must first create an app with GitHub and add its ID and Secret to your user-secrets. @@ -184,6 +179,11 @@ public void ConfigureServices(IServiceCollection services) o.ClaimsIssuer = "OAuth2-Github"; o.SaveTokens = true; // Retrieving user information is unique to each provider. + o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); + o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login"); + o.ClaimActions.MapJsonKey("urn:github:name", "name"); + o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); + o.ClaimActions.MapJsonKey("urn:github:url", "url"); o.Events = new OAuthEvents { OnCreatingTicket = async context => diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 408789b03..257aed9cb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -12,7 +12,7 @@ public static class OAuthExtensions { public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - return services.AddScheme>(authenticationScheme, authenticationScheme, configureOptions); + return services.AddOAuthAuthentication>(authenticationScheme, configureOptions); } public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) From 769da5fd8768ae1ceab0c77b5af2ca394aa1d812 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 18 May 2017 20:12:41 -0700 Subject: [PATCH 008/248] Add SameSitePolicy to CookiePolicyMiddleware --- .../ChunkingCookieManager.cs | 7 +- .../CookieAuthenticationHandler.cs | 1 + .../CookieAuthenticationOptions.cs | 8 +- .../OpenIdConnectHandler.cs | 2 + .../TwitterHandler.cs | 2 + .../RemoteAuthenticationHandler.cs | 2 + .../CookiePolicyMiddleware.cs | 20 ++- .../CookiePolicyOptions.cs | 5 + .../CookieTests.cs | 5 + .../CookieChunkingTests.cs | 38 +++--- .../CookiePolicyTests.cs | 126 ++++++++++++++---- 11 files changed, 165 insertions(+), 51 deletions(-) diff --git a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs index 16426507c..9b602383c 100644 --- a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -33,7 +33,7 @@ internal class ChunkingCookieManager /// /// The default maximum size of characters in a cookie to send back to the client. /// - public const int DefaultChunkSize = 4070; + public const int DefaultChunkSize = 4050; private const string ChunkKeySuffix = "C"; private const string ChunkCountPrefix = "chunks-"; @@ -42,7 +42,7 @@ public ChunkingCookieManager() { // Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case. // See http://browsercookielimits.x64.me/. - // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. + // Leave at least 40 in case CookiePolicy tries to add 'secure', 'samesite=strict' and/or 'httponly'. ChunkSize = DefaultChunkSize; ThrowForPartialCookies = true; } @@ -166,6 +166,7 @@ public void AppendResponseCookie(HttpContext context, string key, string value, { Domain = options.Domain, Expires = options.Expires, + SameSite = (Net.Http.Headers.SameSiteMode)options.SameSite, HttpOnly = options.HttpOnly, Path = options.Path, Secure = options.Secure, @@ -284,6 +285,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) { Path = options.Path, Domain = options.Domain, + SameSite = options.SameSite, Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), }); @@ -297,6 +299,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) { Path = options.Path, Domain = options.Domain, + SameSite = options.SameSite, Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), }); } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 5a4ffc547..13a20e55b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -179,6 +179,7 @@ private CookieOptions BuildCookieOptions() var cookieOptions = new CookieOptions { Domain = Options.CookieDomain, + SameSite = Options.CookieSameSite, HttpOnly = Options.CookieHttpOnly, Path = Options.CookiePath ?? (OriginalPathBase.HasValue ? OriginalPathBase.ToString() : "/"), }; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 9b6b51d8e..02d0361b7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -4,7 +4,6 @@ using System; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -23,6 +22,7 @@ public CookieAuthenticationOptions() ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; + CookieSameSite = SameSiteMode.Strict; CookieHttpOnly = true; CookieSecure = CookieSecurePolicy.SameAsRequest; Events = new CookieAuthenticationEvents(); @@ -57,6 +57,12 @@ public string CookieName /// public string CookiePath { get; set; } + /// + /// Determines if the browser should allow the cookie to be attached to same-site or cross-site requests. The + /// default is Strict, which means the cookie is only allowed to be attached to same-site requests. + /// + public SameSiteMode CookieSameSite { get; set; } + /// /// Determines if the browser should allow the cookie to be accessed by client-side javascript. The /// default is true, which means the cookie will only be passed to http requests and is not made available diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index d51c324dc..04359142a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -899,6 +899,7 @@ private void WriteNonceCookie(string nonce) new CookieOptions { HttpOnly = true, + SameSite = Http.SameSiteMode.Lax, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) }); @@ -930,6 +931,7 @@ private string ReadNonceCookie(string nonce) var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = Http.SameSiteMode.Lax, Secure = Request.IsHttps }; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 7ae9f973c..ff054d3c6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -83,6 +83,7 @@ protected override async Task HandleRemoteAuthenticateAsync( var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps }; @@ -160,6 +161,7 @@ protected override async Task HandleUnauthorizedAsync(ChallengeContext context) var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index bf875a7a0..a7de95dfe 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -203,6 +203,7 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; @@ -242,6 +243,7 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties var cookieOptions = new CookieOptions { HttpOnly = true, + SameSite = SameSiteMode.Lax, Secure = Request.IsHttps }; Response.Cookies.Delete(cookieName, cookieOptions); diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index 46daaad81..92adac967 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -74,7 +74,7 @@ public IResponseCookies Cookies private bool PolicyRequiresCookieOptions() { - return Policy.HttpOnly != HttpOnlyPolicy.None || Policy.Secure != CookieSecurePolicy.None; + return Policy.MinimumSameSitePolicy != SameSiteMode.None || Policy.HttpOnly != HttpOnlyPolicy.None || Policy.Secure != CookieSecurePolicy.None; } public void Append(string key, string value) @@ -151,6 +151,22 @@ private void ApplyPolicy(CookieOptions options) default: throw new InvalidOperationException(); } + switch (Policy.MinimumSameSitePolicy) + { + case SameSiteMode.None: + break; + case SameSiteMode.Lax: + if (options.SameSite == SameSiteMode.None) + { + options.SameSite = SameSiteMode.Lax; + } + break; + case SameSiteMode.Strict: + options.SameSite = SameSiteMode.Strict; + break; + default: + throw new InvalidOperationException($"Unrecognized {nameof(SameSiteMode)} value {Policy.MinimumSameSitePolicy.ToString()}"); + } switch (Policy.HttpOnly) { case HttpOnlyPolicy.Always: @@ -159,7 +175,7 @@ private void ApplyPolicy(CookieOptions options) case HttpOnlyPolicy.None: break; default: - throw new InvalidOperationException(); + throw new InvalidOperationException($"Unrecognized {nameof(HttpOnlyPolicy)} value {Policy.HttpOnly.ToString()}"); } } } diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index 6aed18bfb..7203e73e6 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -12,6 +12,11 @@ namespace Microsoft.AspNetCore.Builder /// public class CookiePolicyOptions { + /// + /// Affects the cookie's same site attribute. + /// + public SameSiteMode MinimumSameSitePolicy { get; set; } = SameSiteMode.Strict; + /// /// Affects whether cookies must be HttpOnly. /// diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 419d82493..e38dc1587 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -136,6 +136,7 @@ public async Task SignInCausesDefaultCookieToBeCreated() Assert.StartsWith("TestCookie=", setCookie); Assert.Contains("; path=/", setCookie); Assert.Contains("; httponly", setCookie); + Assert.Contains("; samesite=", setCookie); Assert.DoesNotContain("; expires=", setCookie); Assert.DoesNotContain("; domain=", setCookie); Assert.DoesNotContain("; secure", setCookie); @@ -206,6 +207,7 @@ public async Task CookieOptionsAlterSetCookieHeader() o.CookiePath = "/foo"; o.CookieDomain = "another.com"; o.CookieSecure = CookieSecurePolicy.Always; + o.CookieSameSite = SameSiteMode.None; o.CookieHttpOnly = true; }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); @@ -217,12 +219,14 @@ public async Task CookieOptionsAlterSetCookieHeader() Assert.Contains(" path=/foo", setCookie1); Assert.Contains(" domain=another.com", setCookie1); Assert.Contains(" secure", setCookie1); + Assert.DoesNotContain(" samesite", setCookie1); Assert.Contains(" httponly", setCookie1); var server2 = CreateServer(o => { o.CookieName = "SecondCookie"; o.CookieSecure = CookieSecurePolicy.None; + o.CookieSameSite = SameSiteMode.Strict; o.CookieHttpOnly = false; }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); @@ -232,6 +236,7 @@ public async Task CookieOptionsAlterSetCookieHeader() Assert.Contains("SecondCookie=", setCookie2); Assert.Contains(" path=/base", setCookie2); + Assert.Contains(" samesite=strict", setCookie2); Assert.DoesNotContain(" domain=", setCookie2); Assert.DoesNotContain(" secure", setCookie2); Assert.DoesNotContain(" httponly", setCookie2); diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs index c978d169e..143e1d254 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -18,7 +18,7 @@ public void AppendLargeCookie_Appended() new ChunkingCookieManager() { ChunkSize = null }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); var values = context.Response.Headers["Set-Cookie"]; Assert.Equal(1, values.Count); - Assert.Equal("TestCookie=" + testString + "; path=/", values[0]); + Assert.Equal("TestCookie=" + testString + "; path=/; samesite=lax", values[0]); } [Fact] @@ -27,20 +27,20 @@ public void AppendLargeCookieWithLimit_Chunked() HttpContext context = new DefaultHttpContext(); string testString = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - new ChunkingCookieManager() { ChunkSize = 30 }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); + new ChunkingCookieManager() { ChunkSize = 44 }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); var values = context.Response.Headers["Set-Cookie"]; Assert.Equal(9, values.Count); Assert.Equal(new[] { - "TestCookie=chunks-8; path=/", - "TestCookieC1=abcdefgh; path=/", - "TestCookieC2=ijklmnop; path=/", - "TestCookieC3=qrstuvwx; path=/", - "TestCookieC4=yz012345; path=/", - "TestCookieC5=6789ABCD; path=/", - "TestCookieC6=EFGHIJKL; path=/", - "TestCookieC7=MNOPQRST; path=/", - "TestCookieC8=UVWXYZ; path=/", + "TestCookie=chunks-8; path=/; samesite=lax", + "TestCookieC1=abcdefgh; path=/; samesite=lax", + "TestCookieC2=ijklmnop; path=/; samesite=lax", + "TestCookieC3=qrstuvwx; path=/; samesite=lax", + "TestCookieC4=yz012345; path=/; samesite=lax", + "TestCookieC5=6789ABCD; path=/; samesite=lax", + "TestCookieC6=EFGHIJKL; path=/; samesite=lax", + "TestCookieC7=MNOPQRST; path=/; samesite=lax", + "TestCookieC8=UVWXYZ; path=/; samesite=lax", }, values); } @@ -116,14 +116,14 @@ public void DeleteChunkedCookieWithOptions_AllDeleted() Assert.Equal(8, cookies.Count); Assert.Equal(new[] { - "TestCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC1=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC2=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC3=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC4=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC5=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC6=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", - "TestCookieC7=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/", + "TestCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC1=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC2=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC3=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC4=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC5=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC6=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", + "TestCookieC7=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=foo.com; path=/; samesite=lax", }, cookies); } } diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index e45c7f690..737c12dc3 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -36,6 +36,15 @@ public class CookiePolicyTests context.Response.Cookies.Append("D", "D", new CookieOptions { HttpOnly = true }); return Task.FromResult(0); }; + private RequestDelegate SameSiteCookieAppends = context => + { + context.Response.Cookies.Append("A", "A"); + context.Response.Cookies.Append("B", "B", new CookieOptions { SameSite = Http.SameSiteMode.None }); + context.Response.Cookies.Append("C", "C", new CookieOptions()); + context.Response.Cookies.Append("D", "D", new CookieOptions { SameSite = Http.SameSiteMode.Lax }); + context.Response.Cookies.Append("E", "E", new CookieOptions { SameSite = Http.SameSiteMode.Strict }); + return Task.FromResult(0); + }; [Fact] public async Task SecureAlwaysSetsSecure() @@ -50,10 +59,10 @@ await RunTest("/secureAlways", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; secure; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); })); } @@ -70,10 +79,10 @@ await RunTest("/secureNone", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); })); } @@ -90,19 +99,19 @@ await RunTest("/secureSame", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=strict", transaction.SetCookie[3]); }), new RequestTest("https://example.com/secureSame", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; secure; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); })); } @@ -119,10 +128,10 @@ await RunTest("/httpOnlyAlways", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; httponly", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; httponly", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; httponly", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; httponly", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=strict; httponly", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict; httponly", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict; httponly", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=strict; httponly", transaction.SetCookie[3]); })); } @@ -137,12 +146,75 @@ await RunTest("/httpOnlyNone", HttpCookieAppends, new RequestTest("http://example.com/httpOnlyNone", transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=strict; httponly", transaction.SetCookie[3]); + })); + } + + [Fact] + public async Task SameSiteStrictSetsItAlways() + { + await RunTest("/sameSiteStrict", + new CookiePolicyOptions + { + MinimumSameSitePolicy = Http.SameSiteMode.Strict + }, + SameSiteCookieAppends, + new RequestTest("http://example.com/sameSiteStrict", + transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("E=E; path=/; samesite=strict", transaction.SetCookie[4]); + })); + } + + [Fact] + public async Task SameSiteLaxSetsItAlways() + { + await RunTest("/sameSiteLax", + new CookiePolicyOptions + { + MinimumSameSitePolicy = Http.SameSiteMode.Lax + }, + SameSiteCookieAppends, + new RequestTest("http://example.com/sameSiteLax", + transaction => + { + Assert.NotNull(transaction.SetCookie); + Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax", transaction.SetCookie[3]); + Assert.Equal("E=E; path=/; samesite=strict", transaction.SetCookie[4]); + })); + } + + [Fact] + public async Task SameSiteNoneLeavesItAlone() + { + await RunTest("/sameSiteNone", + new CookiePolicyOptions + { + MinimumSameSitePolicy = Http.SameSiteMode.None + }, + SameSiteCookieAppends, + new RequestTest("http://example.com/sameSiteNone", + transaction => { Assert.NotNull(transaction.SetCookie); Assert.Equal("A=A; path=/", transaction.SetCookie[0]); Assert.Equal("B=B; path=/", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; httponly", transaction.SetCookie[3]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax", transaction.SetCookie[3]); + Assert.Equal("E=E; path=/; samesite=strict", transaction.SetCookie[4]); })); } @@ -170,10 +242,10 @@ public async Task CookiePolicyCanHijackAppend() var transaction = await server.SendAsync("http://example.com/login"); Assert.NotNull(transaction.SetCookie); - Assert.Equal("Hao=Hao; path=/", transaction.SetCookie[0]); - Assert.Equal("Hao=Hao; path=/", transaction.SetCookie[1]); - Assert.Equal("Hao=Hao; path=/", transaction.SetCookie[2]); - Assert.Equal("Hao=Hao; path=/; secure", transaction.SetCookie[3]); + Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[0]); + Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[1]); + Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[2]); + Assert.Equal("Hao=Hao; path=/; secure; samesite=strict", transaction.SetCookie[3]); } [Fact] @@ -201,7 +273,7 @@ public async Task CookiePolicyCanHijackDelete() Assert.NotNull(transaction.SetCookie); Assert.Equal(1, transaction.SetCookie.Count); - Assert.Equal("A=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/", transaction.SetCookie[0]); + Assert.Equal("A=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax", transaction.SetCookie[0]); } [Fact] From 30392a1811d45b41ffb12c0c57e4df6cac51e1fb Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 24 May 2017 09:24:08 -0700 Subject: [PATCH 009/248] Retarget to netstandard2.0 and net461 --- Security.sln | 48 ++- build/common.props | 4 +- build/dependencies.props | 4 +- build/repo.props | 1 + samples/CookieSample/CookieSample.csproj | 8 +- .../CookieSessionSample.csproj | 8 +- .../JwtBearerSample/JwtBearerSample.csproj | 8 +- .../OpenIdConnect.AzureAdSample.csproj | 6 +- .../OpenIdConnectSample.csproj | 6 +- samples/SocialSample/SocialSample.csproj | 6 +- ...t.AspNetCore.Authentication.Cookies.csproj | 2 +- ....AspNetCore.Authentication.Facebook.csproj | 2 +- ...ft.AspNetCore.Authentication.Google.csproj | 2 +- ...AspNetCore.Authentication.JwtBearer.csproj | 2 +- ...ore.Authentication.MicrosoftAccount.csproj | 2 +- ...oft.AspNetCore.Authentication.OAuth.csproj | 2 +- ...etCore.Authentication.OpenIdConnect.csproj | 2 +- ...t.AspNetCore.Authentication.Twitter.csproj | 2 +- ...Microsoft.AspNetCore.Authentication.csproj | 4 +- .../Microsoft.AspNetCore.Authorization.csproj | 2 +- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 +- .../AspNetTicketDataFormat.cs | 17 + .../AspNetTicketSerializer.cs | 220 +++++++++++ .../ChunkingCookieManager.cs | 281 +++++++++++++ .../Constants.cs | 13 + .../DataProtectorShim.cs | 31 ++ .../Microsoft.Owin.Security.Interop.csproj | 18 + .../Properties/AssemblyInfo.cs | 8 + .../baseline.netframework.json | 373 ++++++++++++++++++ ...soft.AspNetCore.Authentication.Test.csproj | 6 +- ...osoft.AspNetCore.Authorization.Test.csproj | 3 +- ....ChunkingCookieManager.Sources.Test.csproj | 3 +- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 5 +- .../CookieInteropTests.cs | 332 ++++++++++++++++ ...icrosoft.Owin.Security.Interop.Test.csproj | 26 ++ .../TicketInteropTests.cs | 91 +++++ 36 files changed, 1517 insertions(+), 33 deletions(-) create mode 100644 src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs create mode 100644 src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs create mode 100644 src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs create mode 100644 src/Microsoft.Owin.Security.Interop/Constants.cs create mode 100644 src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs create mode 100644 src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj create mode 100644 src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.Owin.Security.Interop/baseline.netframework.json create mode 100644 test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs create mode 100644 test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj create mode 100644 test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs diff --git a/Security.sln b/Security.sln index 157849c91..b9e6ac567 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26403.7 +VisualStudioVersion = 15.0.26510.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -46,10 +46,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtBearerSample", "samples\JwtBearerSample\JwtBearerSample.csproj", "{D399B84F-591B-4E98-92BA-B0F63E7B6957}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop", "src\Microsoft.Owin.Security.Interop\Microsoft.Owin.Security.Interop.csproj", "{A7922DD8-09F1-43E4-938B-CC523EA08898}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Owin.Security.Interop.Test", "test\Microsoft.Owin.Security.Interop.Test\Microsoft.Owin.Security.Interop.Test.csproj", "{A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenIdConnect.AzureAdSample", "samples\OpenIdConnect.AzureAdSample\OpenIdConnect.AzureAdSample.csproj", "{3A7AD414-EBDE-4F92-B307-4E8F19B6117E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test", "test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test\Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj", "{51563775-C659-4907-9BAF-9995BAB87D01}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86BD08B1-F978-4F58-9982-2A017807F01C}" + ProjectSection(SolutionItems) = preProject + build\common.props = build\common.props + build\dependencies.props = build\dependencies.props + build\Key.snk = build\Key.snk + build\repo.props = build\repo.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -360,6 +372,38 @@ Global {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x64.Build.0 = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.ActiveCfg = Release|Any CPU {D399B84F-591B-4E98-92BA-B0F63E7B6957}.Release|x86.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x64.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.ActiveCfg = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Debug|x86.Build.0 = Debug|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Any CPU.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x64.Build.0 = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.ActiveCfg = Release|Any CPU + {A7922DD8-09F1-43E4-938B-CC523EA08898}.Release|x86.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x64.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.ActiveCfg = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Debug|x86.Build.0 = Debug|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Any CPU.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x64.Build.0 = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.ActiveCfg = Release|Any CPU + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24}.Release|x86.Build.0 = Release|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A7AD414-EBDE-4F92-B307-4E8F19B6117E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -416,6 +460,8 @@ Global {1790E052-646F-4529-B90E-6FEA95520D69} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {2755BFE5-7421-4A31-A644-F817DF5CAA98} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {D399B84F-591B-4E98-92BA-B0F63E7B6957} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} + {A7922DD8-09F1-43E4-938B-CC523EA08898} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} EndGlobalSection diff --git a/build/common.props b/build/common.props index 3f55ba5b3..dc4ad9a78 100644 --- a/build/common.props +++ b/build/common.props @@ -16,8 +16,8 @@ - - + + diff --git a/build/dependencies.props b/build/dependencies.props index 74d501f7c..f7e538a50 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,11 +1,13 @@ 2.0.0-* + 4.4.0-* 3.13.8 2.1.3 2.1.0-* 10.0.1 - $(BundledNETStandardPackageVersion) + 2.0.0-* + 3.0.1 15.3.0-* 2.3.0-beta2-* diff --git a/build/repo.props b/build/repo.props index 396aed1f5..d4bab3eeb 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,5 @@ + diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 27fa4ca17..d251b844e 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,9 +1,9 @@ - + - netcoreapp2.0 + net461;netcoreapp2.0 @@ -19,4 +19,8 @@ + + + + diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 2a838df7e..a2d0490f1 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,9 +1,9 @@ - + - netcoreapp2.0 + net461;netcoreapp2.0 @@ -19,4 +19,8 @@ + + + + diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 86b04d587..c2f73fd96 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,9 +1,9 @@ - + - netcoreapp2.0 + net461;netcoreapp2.0 aspnet5-JwtBearerSample-20151210102827 @@ -20,4 +20,8 @@ + + + + diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 78ba03c2a..785724908 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + net461;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 @@ -23,4 +23,8 @@ + + + + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 875762d12..03384f567 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + net461;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 @@ -33,4 +33,8 @@ + + + + diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 723d74de3..999dc91a6 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + net461;netcoreapp2.0 aspnet5-SocialSample-20151210111056 @@ -35,4 +35,8 @@ + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index a5728fbab..41c4ff790 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to use cookie based authentication. - netcoreapp2.0 + netstandard2.0 $(DefineConstants);SECURITY $(NoWarn);CS1591 true diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 19ec83413..e39b31e90 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index e403fe4a9..c4f1e7ad8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -4,7 +4,7 @@ ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index c2b99e47d..5b25e00e8 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 4d91e0da1..1a954c850 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 8e33372c1..508c815fe 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index b3829b59d..0ce2fe34e 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 5dd58d680..b78de6597 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -4,7 +4,7 @@ ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 54b560702..cbdb05b58 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -4,7 +4,7 @@ ASP.NET Core common types used by the various authentication middleware components. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authentication;security @@ -18,7 +18,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index b39a7bf3d..93673ef00 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -7,7 +7,7 @@ Commonly used types: Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute Microsoft.AspNetCore.Authorization.AuthorizeAttribute - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;authorization diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 31ce5b761..5dc2cd928 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -4,7 +4,7 @@ ASP.NET Core cookie policy classes to control the behavior of cookies. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs new file mode 100644 index 000000000..f1a07c5bf --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/AspNetTicketDataFormat.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Owin.Security.DataHandler; +using Microsoft.Owin.Security.DataHandler.Encoder; +using Microsoft.Owin.Security.DataProtection; + +namespace Microsoft.Owin.Security.Interop +{ + public class AspNetTicketDataFormat : SecureDataFormat + { + public AspNetTicketDataFormat(IDataProtector protector) + : base(AspNetTicketSerializer.Default, protector, TextEncodings.Base64Url) + { + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs new file mode 100644 index 000000000..6a1019fbc --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/AspNetTicketSerializer.cs @@ -0,0 +1,220 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Linq; +using System.Security.Claims; +using Microsoft.Owin.Security.DataHandler.Serializer; + +namespace Microsoft.Owin.Security.Interop +{ + // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.DataHandler.TicketSerializer + public class AspNetTicketSerializer : IDataSerializer + { + private const string DefaultStringPlaceholder = "\0"; + private const int FormatVersion = 5; + + public static AspNetTicketSerializer Default { get; } = new AspNetTicketSerializer(); + + public virtual byte[] Serialize(AuthenticationTicket ticket) + { + using (var memory = new MemoryStream()) + { + using (var writer = new BinaryWriter(memory)) + { + Write(writer, ticket); + } + return memory.ToArray(); + } + } + + public virtual AuthenticationTicket Deserialize(byte[] data) + { + using (var memory = new MemoryStream(data)) + { + using (var reader = new BinaryReader(memory)) + { + return Read(reader); + } + } + } + + public virtual void Write(BinaryWriter writer, AuthenticationTicket ticket) + { + writer.Write(FormatVersion); + writer.Write(ticket.Identity.AuthenticationType); + + var identity = ticket.Identity; + if (identity == null) + { + throw new ArgumentNullException("ticket.Identity"); + } + + // There is always a single identity + writer.Write(1); + WriteIdentity(writer, identity); + PropertiesSerializer.Write(writer, ticket.Properties); + } + + protected virtual void WriteIdentity(BinaryWriter writer, ClaimsIdentity identity) + { + var authenticationType = identity.AuthenticationType ?? string.Empty; + + writer.Write(authenticationType); + WriteWithDefault(writer, identity.NameClaimType, ClaimsIdentity.DefaultNameClaimType); + WriteWithDefault(writer, identity.RoleClaimType, ClaimsIdentity.DefaultRoleClaimType); + + // Write the number of claims contained in the identity. + writer.Write(identity.Claims.Count()); + + foreach (var claim in identity.Claims) + { + WriteClaim(writer, claim); + } + + var bootstrap = identity.BootstrapContext as string; + if (!string.IsNullOrEmpty(bootstrap)) + { + writer.Write(true); + writer.Write(bootstrap); + } + else + { + writer.Write(false); + } + + if (identity.Actor != null) + { + writer.Write(true); + WriteIdentity(writer, identity.Actor); + } + else + { + writer.Write(false); + } + } + + protected virtual void WriteClaim(BinaryWriter writer, Claim claim) + { + WriteWithDefault(writer, claim.Type, claim.Subject?.NameClaimType ?? ClaimsIdentity.DefaultNameClaimType); + writer.Write(claim.Value); + WriteWithDefault(writer, claim.ValueType, ClaimValueTypes.String); + WriteWithDefault(writer, claim.Issuer, ClaimsIdentity.DefaultIssuer); + WriteWithDefault(writer, claim.OriginalIssuer, claim.Issuer); + + // Write the number of properties contained in the claim. + writer.Write(claim.Properties.Count); + + foreach (var property in claim.Properties) + { + writer.Write(property.Key ?? string.Empty); + writer.Write(property.Value ?? string.Empty); + } + } + + public virtual AuthenticationTicket Read(BinaryReader reader) + { + if (reader.ReadInt32() != FormatVersion) + { + return null; + } + + var scheme = reader.ReadString(); + + // Any identities after the first will be ignored. + var count = reader.ReadInt32(); + if (count < 0) + { + return null; + } + + var identity = ReadIdentity(reader); + var properties = PropertiesSerializer.Read(reader); + + return new AuthenticationTicket(identity, properties); + } + + protected virtual ClaimsIdentity ReadIdentity(BinaryReader reader) + { + var authenticationType = reader.ReadString(); + var nameClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultNameClaimType); + var roleClaimType = ReadWithDefault(reader, ClaimsIdentity.DefaultRoleClaimType); + + // Read the number of claims contained + // in the serialized identity. + var count = reader.ReadInt32(); + + var identity = new ClaimsIdentity(authenticationType, nameClaimType, roleClaimType); + + for (int index = 0; index != count; ++index) + { + var claim = ReadClaim(reader, identity); + + identity.AddClaim(claim); + } + + // Determine whether the identity + // has a bootstrap context attached. + if (reader.ReadBoolean()) + { + identity.BootstrapContext = reader.ReadString(); + } + + // Determine whether the identity + // has an actor identity attached. + if (reader.ReadBoolean()) + { + identity.Actor = ReadIdentity(reader); + } + + return identity; + } + + protected virtual Claim ReadClaim(BinaryReader reader, ClaimsIdentity identity) + { + var type = ReadWithDefault(reader, identity.NameClaimType); + var value = reader.ReadString(); + var valueType = ReadWithDefault(reader, ClaimValueTypes.String); + var issuer = ReadWithDefault(reader, ClaimsIdentity.DefaultIssuer); + var originalIssuer = ReadWithDefault(reader, issuer); + + var claim = new Claim(type, value, valueType, issuer, originalIssuer, identity); + + // Read the number of properties stored in the claim. + var count = reader.ReadInt32(); + + for (var index = 0; index != count; ++index) + { + var key = reader.ReadString(); + var propertyValue = reader.ReadString(); + + claim.Properties.Add(key, propertyValue); + } + + return claim; + } + + private static void WriteWithDefault(BinaryWriter writer, string value, string defaultValue) + { + if (string.Equals(value, defaultValue, StringComparison.Ordinal)) + { + writer.Write(DefaultStringPlaceholder); + } + else + { + writer.Write(value); + } + } + + private static string ReadWithDefault(BinaryReader reader, string defaultValue) + { + var value = reader.ReadString(); + if (string.Equals(value, DefaultStringPlaceholder, StringComparison.Ordinal)) + { + return defaultValue; + } + return value; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs new file mode 100644 index 000000000..b323258d9 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs @@ -0,0 +1,281 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using Microsoft.Owin.Infrastructure; + +namespace Microsoft.Owin.Security.Interop +{ + // This MUST be kept in sync with Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager + /// + /// This handles cookies that are limited by per cookie length. It breaks down long cookies for responses, and reassembles them + /// from requests. + /// + public class ChunkingCookieManager : ICookieManager + { + private const string ChunkKeySuffix = "C"; + private const string ChunkCountPrefix = "chunks-"; + + public ChunkingCookieManager() + { + // Lowest common denominator. Safari has the lowest known limit (4093), and we leave little extra just in case. + // See http://browsercookielimits.x64.me/. + // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. + ChunkSize = 4070; + ThrowForPartialCookies = true; + } + + /// + /// The maximum size of cookie to send back to the client. If a cookie exceeds this size it will be broken down into multiple + /// cookies. Set this value to null to disable this behavior. The default is 4090 characters, which is supported by all + /// common browsers. + /// + /// Note that browsers may also have limits on the total size of all cookies per domain, and on the number of cookies per domain. + /// + public int? ChunkSize { get; set; } + + /// + /// Throw if not all chunks of a cookie are available on a request for re-assembly. + /// + public bool ThrowForPartialCookies { get; set; } + + // Parse the "chunks-XX" to determine how many chunks there should be. + private static int ParseChunksCount(string value) + { + if (value != null && value.StartsWith(ChunkCountPrefix, StringComparison.Ordinal)) + { + var chunksCountString = value.Substring(ChunkCountPrefix.Length); + int chunksCount; + if (int.TryParse(chunksCountString, NumberStyles.None, CultureInfo.InvariantCulture, out chunksCount)) + { + return chunksCount; + } + } + return 0; + } + + /// + /// Get the reassembled cookie. Non chunked cookies are returned normally. + /// Cookies with missing chunks just have their "chunks-XX" header returned. + /// + /// + /// + /// The reassembled cookie, if any, or null. + public string GetRequestCookie(IOwinContext context, string key) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + var requestCookies = context.Request.Cookies; + var value = requestCookies[key]; + var chunksCount = ParseChunksCount(value); + if (chunksCount > 0) + { + var chunks = new string[chunksCount]; + for (var chunkId = 1; chunkId <= chunksCount; chunkId++) + { + var chunk = requestCookies[key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture)]; + if (string.IsNullOrEmpty(chunk)) + { + if (ThrowForPartialCookies) + { + var totalSize = 0; + for (int i = 0; i < chunkId - 1; i++) + { + totalSize += chunks[i].Length; + } + throw new FormatException( + string.Format(CultureInfo.CurrentCulture, + "The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded.", + chunkId - 1, chunksCount, totalSize)); + } + // Missing chunk, abort by returning the original cookie value. It may have been a false positive? + return value; + } + + chunks[chunkId - 1] = chunk; + } + + return string.Join(string.Empty, chunks); + } + return value; + } + + /// + /// Appends a new response cookie to the Set-Cookie header. If the cookie is larger than the given size limit + /// then it will be broken down into multiple cookies as follows: + /// Set-Cookie: CookieName=chunks-3; path=/ + /// Set-Cookie: CookieNameC1=Segment1; path=/ + /// Set-Cookie: CookieNameC2=Segment2; path=/ + /// Set-Cookie: CookieNameC3=Segment3; path=/ + /// + /// + /// + /// + /// + public void AppendResponseCookie(IOwinContext context, string key, string value, CookieOptions options) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var domainHasValue = !string.IsNullOrEmpty(options.Domain); + var pathHasValue = !string.IsNullOrEmpty(options.Path); + var expiresHasValue = options.Expires.HasValue; + + var templateLength = key.Length + "=".Length + + (domainHasValue ? "; domain=".Length + options.Domain.Length : 0) + + (pathHasValue ? "; path=".Length + options.Path.Length : 0) + + (expiresHasValue ? "; expires=ddd, dd-MMM-yyyy HH:mm:ss GMT".Length : 0) + + (options.Secure ? "; secure".Length : 0) + + (options.HttpOnly ? "; HttpOnly".Length : 0); + + // Normal cookie + var responseCookies = context.Response.Cookies; + if (!ChunkSize.HasValue || ChunkSize.Value > templateLength + value.Length) + { + responseCookies.Append(key, value, options); + } + else if (ChunkSize.Value < templateLength + 10) + { + // 10 is the minimum data we want to put in an individual cookie, including the cookie chunk identifier "CXX". + // No room for data, we can't chunk the options and name + throw new InvalidOperationException("The cookie key and options are larger than ChunksSize, leaving no room for data."); + } + else + { + // Break the cookie down into multiple cookies. + // Key = CookieName, value = "Segment1Segment2Segment2" + // Set-Cookie: CookieName=chunks-3; path=/ + // Set-Cookie: CookieNameC1="Segment1"; path=/ + // Set-Cookie: CookieNameC2="Segment2"; path=/ + // Set-Cookie: CookieNameC3="Segment3"; path=/ + var dataSizePerCookie = ChunkSize.Value - templateLength - 3; // Budget 3 chars for the chunkid. + var cookieChunkCount = (int)Math.Ceiling(value.Length * 1.0 / dataSizePerCookie); + + responseCookies.Append(key, ChunkCountPrefix + cookieChunkCount.ToString(CultureInfo.InvariantCulture), options); + + var offset = 0; + for (var chunkId = 1; chunkId <= cookieChunkCount; chunkId++) + { + var remainingLength = value.Length - offset; + var length = Math.Min(dataSizePerCookie, remainingLength); + var segment = value.Substring(offset, length); + offset += length; + + responseCookies.Append(key + ChunkKeySuffix + chunkId.ToString(CultureInfo.InvariantCulture), segment, options); + } + } + } + + /// + /// Deletes the cookie with the given key by setting an expired state. If a matching chunked cookie exists on + /// the request, delete each chunk. + /// + /// + /// + /// + public void DeleteCookie(IOwinContext context, string key, CookieOptions options) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var keys = new List(); + keys.Add(key + "="); + + var requestCookie = context.Request.Cookies[key]; + var chunks = ParseChunksCount(requestCookie); + if (chunks > 0) + { + for (int i = 1; i <= chunks + 1; i++) + { + var subkey = key + ChunkKeySuffix + i.ToString(CultureInfo.InvariantCulture); + keys.Add(subkey + "="); + } + } + + var domainHasValue = !string.IsNullOrEmpty(options.Domain); + var pathHasValue = !string.IsNullOrEmpty(options.Path); + + Func rejectPredicate; + Func predicate = value => keys.Any(k => value.StartsWith(k, StringComparison.OrdinalIgnoreCase)); + if (domainHasValue) + { + rejectPredicate = value => predicate(value) && value.IndexOf("domain=" + options.Domain, StringComparison.OrdinalIgnoreCase) != -1; + } + else if (pathHasValue) + { + rejectPredicate = value => predicate(value) && value.IndexOf("path=" + options.Path, StringComparison.OrdinalIgnoreCase) != -1; + } + else + { + rejectPredicate = value => predicate(value); + } + + var responseHeaders = context.Response.Headers; + string[] existingValues; + if (responseHeaders.TryGetValue(Constants.Headers.SetCookie, out existingValues) && existingValues != null) + { + responseHeaders.SetValues(Constants.Headers.SetCookie, existingValues.Where(value => !rejectPredicate(value)).ToArray()); + } + + AppendResponseCookie( + context, + key, + string.Empty, + new CookieOptions() + { + Path = options.Path, + Domain = options.Domain, + Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }); + + for (int i = 1; i <= chunks; i++) + { + AppendResponseCookie( + context, + key + "C" + i.ToString(CultureInfo.InvariantCulture), + string.Empty, + new CookieOptions() + { + Path = options.Path, + Domain = options.Domain, + Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), + }); + } + } + } +} diff --git a/src/Microsoft.Owin.Security.Interop/Constants.cs b/src/Microsoft.Owin.Security.Interop/Constants.cs new file mode 100644 index 000000000..1e75761b7 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/Constants.cs @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.Owin.Security.Interop +{ + internal static class Constants + { + internal static class Headers + { + internal const string SetCookie = "Set-Cookie"; + } + } +} diff --git a/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs new file mode 100644 index 000000000..731358894 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/DataProtectorShim.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.DataProtection; + +namespace Microsoft.Owin.Security.Interop +{ + /// + /// Converts an to an + /// . + /// + public sealed class DataProtectorShim : Microsoft.Owin.Security.DataProtection.IDataProtector + { + private readonly IDataProtector _protector; + + public DataProtectorShim(IDataProtector protector) + { + _protector = protector; + } + + public byte[] Protect(byte[] userData) + { + return _protector.Protect(userData); + } + + public byte[] Unprotect(byte[] protectedData) + { + return _protector.Unprotect(protectedData); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj new file mode 100644 index 000000000..10a8be30f --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -0,0 +1,18 @@ + + + + + + A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication. + net461 + $(NoWarn);CS1591 + true + aspnetcore;katana;owin;security + + + + + + + + diff --git a/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..490fa7cb2 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/Properties/AssemblyInfo.cs @@ -0,0 +1,8 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Runtime.InteropServices; + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a7922dd8-09f1-43e4-938b-cc523ea08898")] + diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json new file mode 100644 index 000000000..1fc242ec5 --- /dev/null +++ b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json @@ -0,0 +1,373 @@ +{ + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.Owin.Security.DataHandler.SecureDataFormat", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.Owin.Security.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Default", + "Parameters": [], + "ReturnType": "Microsoft.Owin.Security.Interop.AspNetTicketSerializer", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Serialize", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.Owin.Security.AuthenticationTicket" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataHandler.Serializer.IDataSerializer", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Write", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "ticket", + "Type": "Microsoft.Owin.Security.AuthenticationTicket" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteIdentity", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WriteClaim", + "Parameters": [ + { + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "claim", + "Type": "System.Security.Claims.Claim" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "Microsoft.Owin.Security.AuthenticationTicket", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadIdentity", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + } + ], + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ReadClaim", + "Parameters": [ + { + "Name": "reader", + "Type": "System.IO.BinaryReader" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + } + ], + "ReturnType": "System.Security.Claims.Claim", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Owin.Security.Interop.ChunkingCookieManager", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Owin.Infrastructure.ICookieManager" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_ChunkSize", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ChunkSize", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ThrowForPartialCookies", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ThrowForPartialCookies", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetRequestCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.Owin.IOwinContext" + }, + { + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AppendResponseCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.Owin.IOwinContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.Owin.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteCookie", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.Owin.IOwinContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.Owin.CookieOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Infrastructure.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Owin.Security.Interop.DataProtectorShim", + "Visibility": "Public", + "Kind": "Class", + "Sealed": true, + "ImplementedInterfaces": [ + "Microsoft.Owin.Security.DataProtection.IDataProtector" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Protect", + "Parameters": [ + { + "Name": "userData", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.Byte[]", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedData", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.Byte[]", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Owin.Security.DataProtection.IDataProtector", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ], + "SourceFilters": [] +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 98d727fde..c44069f43 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -3,9 +3,8 @@ - netcoreapp2.0 - true - true + netcoreapp2.0;net461 + netcoreapp2.0 @@ -24,6 +23,7 @@ + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index a9ba71a79..48b134740 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 7908e98fc..b578f5dcf 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index b7b2c6afe..f513de4b3 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -2,9 +2,8 @@ - netcoreapp2.0 - true - true + netcoreapp2.0;net461 + netcoreapp2.0 diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs new file mode 100644 index 000000000..ae5e6f018 --- /dev/null +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -0,0 +1,332 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Security.Claims; +using System.Text; +using System.Threading.Tasks; +using System.Xml; +using System.Xml.Linq; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; +using Microsoft.Owin.Security.Cookies; +using Microsoft.Owin.Testing; +using Owin; +using Xunit; + +namespace Microsoft.Owin.Security.Interop +{ + public class CookiesInteropTests + { + [Fact] + public async Task AspNetCoreWithInteropCookieContainsIdentity() + { + var identity = new ClaimsIdentity("Cookies"); + identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var interopServer = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + }); + + app.Run(context => + { + context.Authentication.SignIn(identity); + return Task.FromResult(0); + }); + }); + + var transaction = await SendAsync(interopServer, "http://example.com"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Run(async context => + { + var result = await context.AuthenticateAsync("Cookies"); + await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); + }); + }) + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); + foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) + { + request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); + } + var response = await newServer.CreateClient().SendAsync(request); + + Assert.Equal("Alice", await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() + { + var identity = new ClaimsIdentity("Cookies"); + identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var interopServer = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + CookieManager = new ChunkingCookieManager(), + }); + + app.Run(context => + { + context.Authentication.SignIn(identity); + return Task.FromResult(0); + }); + }); + + var transaction = await SendAsync(interopServer, "http://example.com"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Run(async context => + { + var result = await context.AuthenticateAsync("Cookies"); + await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); + }); + }) + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); + foreach (var cookie in SetCookieHeaderValue.ParseList(transaction.SetCookie)) + { + request.Headers.Add("Cookie", cookie.Name + "=" + cookie.Value); + } + var response = await newServer.CreateClient().SendAsync(request); + + Assert.Equal(1024 * 5, (await response.Content.ReadAsStringAsync()).Length); + } + + [Fact] + public async Task InteropWithNewCookieContainsIdentity() + { + var user = new ClaimsPrincipal(); + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim(ClaimTypes.Name, "Alice")); + user.AddIdentity(identity); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Run(context => context.SignInAsync("Cookies", user)); + }) + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); + + var server = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + }); + + app.Run(async context => + { + var result = await context.Authentication.AuthenticateAsync("Cookies"); + Describe(context.Response, result); + }); + }); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); + + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + } + + [Fact] + public async Task InteropWithLargeNewCookieContainsIdentity() + { + var user = new ClaimsPrincipal(); + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim(ClaimTypes.Name, new string('a', 1024 * 5))); + user.AddIdentity(identity); + + var dataProtection = DataProtectionProvider.Create(new DirectoryInfo("..\\..\\artifacts")); + var dataProtector = dataProtection.CreateProtector( + "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", // full name of the ASP.NET Core type + Cookies.CookieAuthenticationDefaults.AuthenticationType, "v2"); + + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Run(context => context.SignInAsync("Cookies", user)); + }) + .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + var newServer = new AspNetCore.TestHost.TestServer(builder); + + var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); + + var server = TestServer.Create(app => + { + app.Properties["host.AppName"] = "Microsoft.Owin.Security.Tests"; + + app.UseCookieAuthentication(new Cookies.CookieAuthenticationOptions + { + TicketDataFormat = new AspNetTicketDataFormat(new DataProtectorShim(dataProtector)), + CookieName = AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.CookiePrefix + + AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme, + CookieManager = new ChunkingCookieManager(), + }); + + app.Run(async context => + { + var result = await context.Authentication.AuthenticateAsync("Cookies"); + Describe(context.Response, result); + }); + }); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", cookies); + + Assert.Equal(1024 * 5, FindClaimValue(transaction2, ClaimTypes.Name).Length); + } + + private static async Task> SendAndGetCookies(AspNetCore.TestHost.TestServer server, string uri) + { + var request = new HttpRequestMessage(HttpMethod.Get, uri); + var response = await server.CreateClient().SendAsync(request); + if (response.Headers.Contains("Set-Cookie")) + { + IList cookieHeaders = new List(); + foreach (var cookie in SetCookieHeaderValue.ParseList(response.Headers.GetValues("Set-Cookie").ToList())) + { + cookieHeaders.Add(cookie.Name + "=" + cookie.Value); + } + return cookieHeaders; + } + return null; + } + + private static string FindClaimValue(Transaction transaction, string claimType) + { + XElement claim = transaction.ResponseElement.Elements("claim").SingleOrDefault(elt => elt.Attribute("type").Value == claimType); + if (claim == null) + { + return null; + } + return claim.Attribute("value").Value; + } + + private static void Describe(IOwinResponse res, AuthenticateResult result) + { + res.StatusCode = 200; + res.ContentType = "text/xml"; + var xml = new XElement("xml"); + if (result != null && result.Identity != null) + { + xml.Add(result.Identity.Claims.Select(claim => new XElement("claim", new XAttribute("type", claim.Type), new XAttribute("value", claim.Value)))); + } + if (result != null && result.Properties != null) + { + xml.Add(result.Properties.Dictionary.Select(extra => new XElement("extra", new XAttribute("type", extra.Key), new XAttribute("value", extra.Value)))); + } + using (var memory = new MemoryStream()) + { + using (var writer = new XmlTextWriter(memory, Encoding.UTF8)) + { + xml.WriteTo(writer); + } + res.Body.Write(memory.ToArray(), 0, memory.ToArray().Length); + } + } + + private static async Task SendAsync(TestServer server, string uri, IList cookieHeaders = null, bool ajaxRequest = false) + { + var request = new HttpRequestMessage(HttpMethod.Get, uri); + if (cookieHeaders != null) + { + request.Headers.Add("Cookie", cookieHeaders); + } + if (ajaxRequest) + { + request.Headers.Add("X-Requested-With", "XMLHttpRequest"); + } + var transaction = new Transaction + { + Request = request, + Response = await server.HttpClient.SendAsync(request), + }; + if (transaction.Response.Headers.Contains("Set-Cookie")) + { + transaction.SetCookie = transaction.Response.Headers.GetValues("Set-Cookie").ToList(); + } + if (transaction.SetCookie != null && transaction.SetCookie.Any()) + { + transaction.CookieNameValue = transaction.SetCookie.First().Split(new[] { ';' }, 2).First(); + } + transaction.ResponseText = await transaction.Response.Content.ReadAsStringAsync(); + + if (transaction.Response.Content != null && + transaction.Response.Content.Headers.ContentType != null && + transaction.Response.Content.Headers.ContentType.MediaType == "text/xml") + { + transaction.ResponseElement = XElement.Parse(transaction.ResponseText); + } + return transaction; + } + + private class Transaction + { + public HttpRequestMessage Request { get; set; } + public HttpResponseMessage Response { get; set; } + + public IList SetCookie { get; set; } + public string CookieNameValue { get; set; } + + public string ResponseText { get; set; } + public XElement ResponseElement { get; set; } + } + + } +} + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj new file mode 100644 index 000000000..d6e9d16e5 --- /dev/null +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -0,0 +1,26 @@ + + + + + + net461 + + + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs new file mode 100644 index 000000000..b14ea0d74 --- /dev/null +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -0,0 +1,91 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Security.Claims; +using Microsoft.AspNetCore.Authentication; +using Xunit; + +namespace Microsoft.Owin.Security.Interop.Test +{ + public class TicketInteropTests + { + [Fact] + public void NewSerializerCanReadInteropTicket() + { + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim("Test", "Value")); + + var expires = DateTime.Today; + var issued = new DateTime(1979, 11, 11); + var properties = new Owin.Security.AuthenticationProperties(); + properties.IsPersistent = true; + properties.RedirectUri = "/redirect"; + properties.Dictionary["key"] = "value"; + properties.ExpiresUtc = expires; + properties.IssuedUtc = issued; + + var interopTicket = new Owin.Security.AuthenticationTicket(identity, properties); + var interopSerializer = new AspNetTicketSerializer(); + + var bytes = interopSerializer.Serialize(interopTicket); + + var newSerializer = new TicketSerializer(); + var newTicket = newSerializer.Deserialize(bytes); + + Assert.NotNull(newTicket); + Assert.Equal(1, newTicket.Principal.Identities.Count()); + var newIdentity = newTicket.Principal.Identity as ClaimsIdentity; + Assert.NotNull(newIdentity); + Assert.Equal("scheme", newIdentity.AuthenticationType); + Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); + Assert.NotNull(newTicket.Properties); + Assert.True(newTicket.Properties.IsPersistent); + Assert.Equal("/redirect", newTicket.Properties.RedirectUri); + Assert.Equal("value", newTicket.Properties.Items["key"]); + Assert.Equal(expires, newTicket.Properties.ExpiresUtc); + Assert.Equal(issued, newTicket.Properties.IssuedUtc); + } + + [Fact] + public void InteropSerializerCanReadNewTicket() + { + var user = new ClaimsPrincipal(); + var identity = new ClaimsIdentity("scheme"); + identity.AddClaim(new Claim("Test", "Value")); + user.AddIdentity(identity); + + var expires = DateTime.Today; + var issued = new DateTime(1979, 11, 11); + var properties = new AspNetCore.Authentication.AuthenticationProperties(); + properties.IsPersistent = true; + properties.RedirectUri = "/redirect"; + properties.Items["key"] = "value"; + properties.ExpiresUtc = expires; + properties.IssuedUtc = issued; + + var newTicket = new AspNetCore.Authentication.AuthenticationTicket(user, properties, "scheme"); + var newSerializer = new TicketSerializer(); + + var bytes = newSerializer.Serialize(newTicket); + + var interopSerializer = new AspNetTicketSerializer(); + var interopTicket = interopSerializer.Deserialize(bytes); + + Assert.NotNull(interopTicket); + var newIdentity = interopTicket.Identity; + Assert.NotNull(newIdentity); + Assert.Equal("scheme", newIdentity.AuthenticationType); + Assert.True(newIdentity.HasClaim(c => c.Type == "Test" && c.Value == "Value")); + Assert.NotNull(interopTicket.Properties); + Assert.True(interopTicket.Properties.IsPersistent); + Assert.Equal("/redirect", interopTicket.Properties.RedirectUri); + Assert.Equal("value", interopTicket.Properties.Dictionary["key"]); + Assert.Equal(expires, interopTicket.Properties.ExpiresUtc); + Assert.Equal(issued, interopTicket.Properties.IssuedUtc); + } + } +} + + From e940cdb36bc7617af3d762ff9cc853a8fef55b0a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 25 May 2017 18:29:19 -0700 Subject: [PATCH 010/248] AuthZ 2.0 changes + react to Http --- Security.sln | 57 ++++++ .../CookieAuthenticationHandler.cs | 21 +- .../FacebookConfigureOptions.cs | 6 +- .../FacebookExtensions.cs | 16 +- .../GoogleConfigureOptions.cs | 6 +- .../GoogleExtensions.cs | 16 +- .../JwtBearerConfigureOptions.cs | 6 +- .../JwtBearerExtensions.cs | 15 +- .../JwtBearerHandler.cs | 8 +- .../MicrosoftAccountConfigureOptions.cs | 6 +- .../MicrosoftAccountExtensions.cs | 20 +- .../OAuthHandler.cs | 8 +- .../OpenIdConnectConfigureOptions.cs | 6 +- .../OpenIdConnectExtensions.cs | 13 +- .../OpenIdConnectHandler.cs | 11 +- .../TwitterConfigureOptions.cs | 6 +- .../TwitterExtensions.cs | 13 +- .../TwitterHandler.cs | 9 +- .../AuthenticationHandler.cs | 65 +++---- .../Events/BaseAuthenticationContext.cs | 41 ++++ .../Events/BaseContext.cs | 49 +++++ .../RemoteAuthenticationHandler.cs | 8 +- .../IPolicyEvaluator.cs | 36 ++++ ...oft.AspNetCore.Authorization.Policy.csproj | 27 +++ .../PolicyAuthorizationResult.cs | 35 ++++ .../PolicyEvaluator.cs | 92 +++++++++ .../PolicyServiceCollectionExtensions.cs | 31 +++ .../AuthorizationFailure.cs | 46 +++++ .../AuthorizationPolicy.cs | 2 +- .../AuthorizationResult.cs | 37 ++++ ...uthorizationServiceCollectionExtensions.cs | 1 + .../AuthorizationServiceExtensions.cs | 8 +- .../AuthorizeAttribute.cs | 24 ++- .../DefaultAuthorizationEvaluator.cs | 24 +-- .../DefaultAuthorizationHandlerProvider.cs | 35 ++++ .../DefaultAuthorizationService.cs | 28 +-- .../IAuthorizationEvaluator.cs | 13 +- .../IAuthorizationHandlerProvider.cs | 21 ++ .../IAuthorizationService.cs | 4 +- .../IAuthorizeData.cs | 2 +- .../AuthenticationMiddlewareTests.cs | 35 +++- .../CookieTests.cs | 40 +--- .../FacebookTests.cs | 28 +-- .../GoogleTests.cs | 64 ++----- .../JwtBearerTests.cs | 62 +++--- .../MicrosoftAccountTests.cs | 28 +-- .../OpenIdConnect/OpenIdConnectTests.cs | 14 +- .../TicketSerializerTests.cs | 2 +- .../TwitterTests.cs | 22 ++- .../AuthorizationPolicyFacts.cs | 12 +- .../DefaultAuthorizationServiceTests.cs | 134 +++++++------ ...osoft.AspNetCore.Authorization.Test.csproj | 2 + .../PolicyEvaluatorTests.cs | 179 ++++++++++++++++++ 53 files changed, 1029 insertions(+), 465 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs create mode 100644 src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs diff --git a/Security.sln b/Security.sln index b9e6ac567..61ea7b0c3 100644 --- a/Security.sln +++ b/Security.sln @@ -62,6 +62,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build\repo.props = build\repo.props EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization.Policy", "src\Microsoft.AspNetCore.Authorization.Policy\Microsoft.AspNetCore.Authorization.Policy.csproj", "{58194599-F07D-47A3-9DF2-E21A22C5EF9E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Abstractions", "..\HttpAbstractions\src\Microsoft.AspNetCore.Authentication.Abstractions\Microsoft.AspNetCore.Authentication.Abstractions.csproj", "{97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Core", "..\HttpAbstractions\src\Microsoft.AspNetCore.Authentication.Core\Microsoft.AspNetCore.Authentication.Core.csproj", "{85545633-7E70-47EA-8CD2-30654C80112C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -436,6 +442,54 @@ Global {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x64.Build.0 = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.ActiveCfg = Release|Any CPU {51563775-C659-4907-9BAF-9995BAB87D01}.Release|x86.Build.0 = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|x64.ActiveCfg = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|x64.Build.0 = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|x86.ActiveCfg = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Debug|x86.Build.0 = Debug|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|Any CPU.Build.0 = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x64.ActiveCfg = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x64.Build.0 = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.ActiveCfg = Release|Any CPU + {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.Build.0 = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x64.ActiveCfg = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x64.Build.0 = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x86.ActiveCfg = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x86.Build.0 = Debug|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Any CPU.Build.0 = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x64.ActiveCfg = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x64.Build.0 = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x86.ActiveCfg = Release|Any CPU + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x86.Build.0 = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x64.ActiveCfg = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x64.Build.0 = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x86.ActiveCfg = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x86.Build.0 = Debug|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Any CPU.Build.0 = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x64.ActiveCfg = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x64.Build.0 = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x86.ActiveCfg = Release|Any CPU + {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -464,5 +518,8 @@ Global {A2B5DC39-68D5-4145-A8CC-6AEAB7D33A24} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} + {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {85545633-7E70-47EA-8CD2-30654C80112C} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 13a20e55b..bb2c10fee 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -247,7 +247,7 @@ protected virtual async Task FinishResponseAsync() } } - protected override async Task HandleSignInAsync(SignInContext signin) + protected override async Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { _signInCalled = true; @@ -259,8 +259,8 @@ protected override async Task HandleSignInAsync(SignInContext signin) Context, Scheme, Options, - signin.Principal, - signin.Properties, + user, + properties, cookieOptions); DateTimeOffset issuedUtc; @@ -325,7 +325,7 @@ protected override async Task HandleSignInAsync(SignInContext signin) await ApplyHeaders(shouldRedirect, signedInContext.Properties); } - protected override async Task HandleSignOutAsync(SignOutContext signOutContext) + protected override async Task HandleSignOutAsync(AuthenticationProperties properties) { _signOutCalled = true; @@ -341,7 +341,7 @@ protected override async Task HandleSignOutAsync(SignOutContext signOutContext) Context, Scheme, Options, - signOutContext.Properties, + properties, cookieOptions); await Events.SigningOut(context); @@ -401,9 +401,8 @@ private static bool IsHostRelative(string path) return path[0] == '/' && path[1] != '/' && path[1] != '\\'; } - protected override async Task HandleForbiddenAsync(ChallengeContext context) + protected override async Task HandleForbiddenAsync(AuthenticationProperties properties) { - var properties = context.Properties; var returnUrl = properties.RedirectUri; if (string.IsNullOrEmpty(returnUrl)) { @@ -414,14 +413,8 @@ protected override async Task HandleForbiddenAsync(ChallengeContext context) await Events.RedirectToAccessDenied(redirectContext); } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var properties = context.Properties; var redirectUri = properties.RedirectUri; if (string.IsNullOrEmpty(redirectUri)) { diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs index 9305623da..887789ebf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.Facebook { - internal class FacebookConfigureOptions : ConfigureNamedOptions + internal class FacebookConfigureOptions : ConfigureDefaultOptions { public FacebookConfigureOptions(IConfiguration config) : base(FacebookDefaults.AuthenticationScheme, - options => config.GetSection(FacebookDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+FacebookDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 032be8235..1bb065414 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -3,29 +3,21 @@ using System; using Microsoft.AspNetCore.Authentication.Facebook; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class FacebookAuthenticationOptionsExtensions { - /// - /// Adds facebook authentication with options bound against the "Facebook" section - /// from the IConfiguration in the service container. - /// - /// - /// - public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services) - { - services.AddSingleton, FacebookConfigureOptions>(); - return services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { }); - } + public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services) + => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, Action configureOptions) => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { + services.AddSingleton, FacebookConfigureOptions>(); return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs index e19c1fdb1..1041f1eec 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs @@ -2,15 +2,15 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.Google { - internal class GoogleConfigureOptions : ConfigureNamedOptions + internal class GoogleConfigureOptions : ConfigureDefaultOptions { public GoogleConfigureOptions(IConfiguration config) : base(GoogleDefaults.AuthenticationScheme, - options => config.GetSection(GoogleDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+GoogleDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index d71e8b461..c11b155d9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -3,29 +3,21 @@ using System; using Microsoft.AspNetCore.Authentication.Google; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class GoogleExtensions { - /// - /// Adds google authentication with options bound against the "Google" section - /// from the IConfiguration in the service container. - /// - /// - /// - public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services) - { - services.AddSingleton, GoogleConfigureOptions>(); - return services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { }); - } + public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services) + => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, Action configureOptions) => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { + services.AddSingleton, GoogleConfigureOptions>(); return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs index f3571a49c..d26bf6671 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs @@ -2,16 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - internal class JwtBearerConfigureOptions : ConfigureNamedOptions + internal class JwtBearerConfigureOptions : ConfigureDefaultOptions { // Bind to "Bearer" section by default public JwtBearerConfigureOptions(IConfiguration config) : base(JwtBearerDefaults.AuthenticationScheme, - options => config.GetSection(JwtBearerDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+JwtBearerDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 4f6453bd9..0bd3a9400 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -5,22 +5,14 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class JwtBearerExtensions { - /// - /// Adds JwtBearer authentication with options bound against the "Bearer" section - /// from the IConfiguration in the service container. - /// - /// - /// - public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services) - { - services.AddSingleton, JwtBearerConfigureOptions>(); - return services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { }); - } + public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services) + => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, Action configureOptions) => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, configureOptions); @@ -28,6 +20,7 @@ public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollect public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerInitializer>()); + services.AddSingleton, JwtBearerConfigureOptions>(); return services.AddScheme(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index ec48e3e20..0087d38d0 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -201,10 +201,10 @@ protected override async Task HandleAuthenticateAsync() } } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { var authResult = await HandleAuthenticateOnceSafeAsync(); - var eventContext = new JwtBearerChallengeContext(Context, Scheme, Options, context.Properties) + var eventContext = new JwtBearerChallengeContext(Context, Scheme, Options, properties) { AuthenticateFailure = authResult?.Failure }; @@ -330,12 +330,12 @@ private static string CreateErrorDescription(Exception authFailure) return string.Join("; ", messages); } - protected override Task HandleSignOutAsync(SignOutContext context) + protected override Task HandleSignOutAsync(AuthenticationProperties properties) { throw new NotSupportedException(); } - protected override Task HandleSignInAsync(SignInContext context) + protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotSupportedException(); } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs index 520c3758d..b0be3de97 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs @@ -2,16 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { - internal class MicrosoftAccountConfigureOptions : ConfigureNamedOptions + internal class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions { // Bind to "Microsoft" section by default public MicrosoftAccountConfigureOptions(IConfiguration config) : base(MicrosoftAccountDefaults.AuthenticationScheme, - options => config.GetSection(MicrosoftAccountDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+MicrosoftAccountDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 6ccb39234..1a7fee370 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -3,29 +3,21 @@ using System; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class MicrosoftAccountExtensions { - /// - /// Adds MicrosoftAccount authentication with options bound against the "Microsoft" section - /// from the IConfiguration in the service container. - /// - /// - /// - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services) - { - services.AddSingleton, MicrosoftAccountConfigureOptions>(); - return services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, o => { }); - } + public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services) + => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, _ => { }); - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, Action configureOptions) => - services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); + public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, Action configureOptions) + => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { + services.AddSingleton, MicrosoftAccountConfigureOptions>(); return services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 63bcdbdf2..bbe4f4038 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -191,14 +191,8 @@ protected virtual async Task CreateTicketAsync(ClaimsIdent return context.Ticket; } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var properties = context.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs index 9afae436d..1a6450b7b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs @@ -2,16 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - internal class OpenIdConnectConfigureOptions : ConfigureNamedOptions + internal class OpenIdConnectConfigureOptions : ConfigureDefaultOptions { // Bind to "OpenIdConnect" section by default public OpenIdConnectConfigureOptions(IConfiguration config) : base(OpenIdConnectDefaults.AuthenticationScheme, - options => config.GetSection(OpenIdConnectDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+OpenIdConnectDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index c79dc7212..b4ac4b9fb 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -5,22 +5,14 @@ using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class OpenIdConnectExtensions { - /// - /// Adds OpenIdConnect authentication with options bound against the "OpenIdConnect" section - /// from the IConfiguration in the service container. - /// - /// - /// public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services) - { - services.AddSingleton, OpenIdConnectConfigureOptions>(); - return services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); - } + => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, Action configureOptions) => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); @@ -28,6 +20,7 @@ public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCol public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectInitializer>()); + services.AddSingleton, OpenIdConnectConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 04359142a..9c8f4ecc6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -161,7 +161,7 @@ protected virtual async Task HandleRemoteSignOutAsync() /// Redirect user to the identity provider for sign out /// /// A task executing the sign out procedure - protected override async Task HandleSignOutAsync(SignOutContext signout) + protected override async Task HandleSignOutAsync(AuthenticationProperties properties) { Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); @@ -180,7 +180,6 @@ protected override async Task HandleSignOutAsync(SignOutContext signout) }; // Get the post redirect URI. - var properties = signout.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = BuildRedirectUriIfRelative(Options.PostLogoutRedirectUri); @@ -292,19 +291,13 @@ protected virtual Task HandleSignOutCallbackAsync() /// Responds to a 401 Challenge. Sends an OpenIdConnect message to the 'identity authority' to obtain an identity. /// /// - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - Logger.EnteringOpenIdAuthenticationHandlerHandleUnauthorizedAsync(GetType().FullName); // order for local RedirectUri // 1. challenge.Properties.RedirectUri // 2. CurrentUri if RedirectUri is not set) - var properties = context.Properties; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs index b10435f18..03d7ae809 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs @@ -2,16 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore.Authentication.Twitter { - internal class TwitterConfigureOptions : ConfigureNamedOptions + internal class TwitterConfigureOptions : ConfigureDefaultOptions { // Bind to "Twitter" section by default public TwitterConfigureOptions(IConfiguration config) : base(TwitterDefaults.AuthenticationScheme, - options => config.GetSection(TwitterDefaults.AuthenticationScheme).Bind(options)) + options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+TwitterDefaults.AuthenticationScheme).Bind(options)) { } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index 3bcc80c3d..11586f984 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -5,22 +5,14 @@ using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { public static class TwitterExtensions { - /// - /// Adds Twitter authentication with options bound against the "Twitter" section - /// from the IConfiguration in the service container. - /// - /// - /// public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services) - { - services.AddSingleton, TwitterConfigureOptions>(); - return services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { }); - } + => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { }); public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, Action configureOptions) => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, configureOptions); @@ -28,6 +20,7 @@ public static IServiceCollection AddTwitterAuthentication(this IServiceCollectio public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterInitializer>()); + services.AddSingleton, TwitterConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index ff054d3c6..63a18e83b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -140,15 +140,8 @@ protected virtual async Task CreateTicketAsync( return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } - protected override async Task HandleUnauthorizedAsync(ChallengeContext context) + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - var properties = context.Properties; - if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index ba1c919fe..b09470919 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; @@ -178,44 +179,41 @@ protected async Task HandleAuthenticateOnceSafeAsync() protected abstract Task HandleAuthenticateAsync(); - public async Task SignInAsync(SignInContext context) + public async Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { - if (context == null) + if (user == null) { - throw new ArgumentNullException(nameof(context)); + throw new ArgumentNullException(nameof(user)); } - await HandleSignInAsync(context); + properties = properties ?? new AuthenticationProperties(); + await HandleSignInAsync(user, properties); Logger.AuthenticationSchemeSignedIn(Scheme.Name); } - protected virtual Task HandleSignInAsync(SignInContext context) + protected virtual Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { return TaskCache.CompletedTask; } - public async Task SignOutAsync(SignOutContext context) + public async Task SignOutAsync(AuthenticationProperties properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - await HandleSignOutAsync(context); + properties = properties ?? new AuthenticationProperties(); + await HandleSignOutAsync(properties); Logger.AuthenticationSchemeSignedOut(Scheme.Name); } - protected virtual Task HandleSignOutAsync(SignOutContext context) + protected virtual Task HandleSignOutAsync(AuthenticationProperties properties) { return TaskCache.CompletedTask; } /// - /// Override this method to deal with a challenge that is forbidden. + /// Override this method to handle Forbid. /// - /// + /// /// A Task. - protected virtual Task HandleForbiddenAsync(ChallengeContext context) + protected virtual Task HandleForbiddenAsync(AuthenticationProperties properties) { Response.StatusCode = 403; return TaskCache.CompletedTask; @@ -226,35 +224,26 @@ protected virtual Task HandleForbiddenAsync(ChallengeContext context) /// deals an authentication interaction as part of it's request flow. (like adding a response header, or /// changing the 401 result to 302 of a login page or external sign-in location.) /// - /// + /// /// A Task. - protected virtual Task HandleUnauthorizedAsync(ChallengeContext context) + protected virtual Task HandleChallengeAsync(AuthenticationProperties properties) { Response.StatusCode = 401; return TaskCache.CompletedTask; } - public async Task ChallengeAsync(ChallengeContext context) + public async Task ChallengeAsync(AuthenticationProperties properties) { - switch (context.Behavior) - { - case ChallengeBehavior.Automatic: - // If there is a principal already, invoke the forbidden code path - var result = await HandleAuthenticateOnceSafeAsync(); - if (result?.Principal != null) - { - goto case ChallengeBehavior.Forbidden; - } - goto case ChallengeBehavior.Unauthorized; - case ChallengeBehavior.Unauthorized: - await HandleUnauthorizedAsync(context); - Logger.AuthenticationSchemeChallenged(Scheme.Name); - break; - case ChallengeBehavior.Forbidden: - await HandleForbiddenAsync(context); - Logger.AuthenticationSchemeForbidden(Scheme.Name); - break; - } + properties = properties ?? new AuthenticationProperties(); + await HandleChallengeAsync(properties); + Logger.AuthenticationSchemeChallenged(Scheme.Name); + } + + public async Task ForbidAsync(AuthenticationProperties properties) + { + properties = properties ?? new AuthenticationProperties(); + await HandleForbiddenAsync(properties); + Logger.AuthenticationSchemeForbidden(Scheme.Name); } } } diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs new file mode 100644 index 000000000..cfe5809c5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs @@ -0,0 +1,41 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for authentication. + /// + public abstract class BaseAuthenticationContext : BaseContext + { + /// + /// Constructor. + /// + /// The context. + /// The name of the scheme. + /// The properties. + protected BaseAuthenticationContext(HttpContext context, string authenticationScheme, AuthenticationProperties properties) : base(context) + { + if (string.IsNullOrEmpty(authenticationScheme)) + { + throw new ArgumentException(nameof(authenticationScheme)); + } + + AuthenticationScheme = authenticationScheme; + Properties = properties ?? new AuthenticationProperties(); + } + + /// + /// The name of the scheme. + /// + public string AuthenticationScheme { get; } + + /// + /// Contains the extra meta-data arriving with the authentication. May be altered. + /// + public AuthenticationProperties Properties { get; protected set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs new file mode 100644 index 000000000..3d65f0dd7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs @@ -0,0 +1,49 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base class used by other context classes. + /// + public abstract class BaseContext + { + /// + /// Constructor. + /// + /// The request context. + protected BaseContext(HttpContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + HttpContext = context; + } + + /// + /// The context. + /// + public HttpContext HttpContext { get; } + + /// + /// The request. + /// + public HttpRequest Request + { + get { return HttpContext.Request; } + } + + /// + /// The response. + /// + public HttpResponse Response + { + get { return HttpContext.Response; } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index a7de95dfe..9394b7553 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Security.Claims; using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; @@ -173,18 +174,17 @@ protected override async Task HandleAuthenticateAsync() return AuthenticateResult.Fail("Remote authentication does not directly support AuthenticateAsync"); } - protected override Task HandleSignOutAsync(SignOutContext context) + protected override Task HandleSignOutAsync(AuthenticationProperties properties) { throw new NotSupportedException(); } - protected override Task HandleSignInAsync(SignInContext context) + protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotSupportedException(); } - // REVIEW: This behaviour needs a test (forwarding of forbidden to sign in scheme) - protected override Task HandleForbiddenAsync(ChallengeContext context) + protected override Task HandleForbiddenAsync(AuthenticationProperties properties) { return Context.ForbidAsync(SignInScheme); } diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs new file mode 100644 index 000000000..1717a0ae0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authorization.Policy +{ + /// + /// Base class for authorization handlers that need to be called for a specific requirement type. + /// + public interface IPolicyEvaluator + { + /// + /// Does authentication for and sets the resulting + /// to . If no schemes are set, this is a no-op. + /// + /// The . + /// The . + /// unless all schemes specified by fail to authenticate. + Task AuthenticateAsync(AuthorizationPolicy policy, HttpContext context); + + /// + /// Attempts authorization for a policy using . + /// + /// The . + /// The result of a call to . + /// The . + /// Returns if authorization succeeds. + /// Otherwise returns if , otherwise + /// returns + Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj new file mode 100644 index 000000000..5123b7069 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -0,0 +1,27 @@ + + + + + + ASP.NET Core authorization policy helper classes. + netstandard2.0 + $(NoWarn);CS1591 + true + aspnetcore;authorization + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs new file mode 100644 index 000000000..d7d481dcd --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyAuthorizationResult.cs @@ -0,0 +1,35 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNetCore.Authorization.Policy +{ + public class PolicyAuthorizationResult + { + private PolicyAuthorizationResult() { } + + /// + /// If true, means the callee should challenge and try again. + /// + public bool Challenged { get; private set; } + + /// + /// Authorization was forbidden. + /// + public bool Forbidden { get; private set; } + + /// + /// Authorization was successful. + /// + public bool Succeeded { get; private set; } + + public static PolicyAuthorizationResult Challenge() + => new PolicyAuthorizationResult { Challenged = true }; + + public static PolicyAuthorizationResult Forbid() + => new PolicyAuthorizationResult { Forbidden = true }; + + public static PolicyAuthorizationResult Success() + => new PolicyAuthorizationResult { Succeeded = true }; + + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs new file mode 100644 index 000000000..60f291f67 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs @@ -0,0 +1,92 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Internal; + +namespace Microsoft.AspNetCore.Authorization.Policy +{ + public class PolicyEvaluator : IPolicyEvaluator + { + private readonly IAuthorizationService _authorization; + + /// + /// Constructor + /// + /// The authorization service. + public PolicyEvaluator(IAuthorizationService authorization) + { + _authorization = authorization; + } + + /// + /// Does authentication for and sets the resulting + /// to . If no schemes are set, this is a no-op. + /// + /// The . + /// The . + /// unless all schemes specified by failed to authenticate. + public virtual async Task AuthenticateAsync(AuthorizationPolicy policy, HttpContext context) + { + if (policy.AuthenticationSchemes != null && policy.AuthenticationSchemes.Count > 0) + { + ClaimsPrincipal newPrincipal = null; + foreach (var scheme in policy.AuthenticationSchemes) + { + var result = await context.AuthenticateAsync(scheme); + if (result != null && result.Succeeded) + { + newPrincipal = SecurityHelper.MergeUserPrincipal(newPrincipal, result.Principal); + } + } + + if (newPrincipal != null) + { + context.User = newPrincipal; + return AuthenticateResult.Success(new AuthenticationTicket(newPrincipal, string.Join(";", policy.AuthenticationSchemes))); + } + else + { + context.User = new ClaimsPrincipal(new ClaimsIdentity()); + return AuthenticateResult.None(); + } + } + + return (context.User?.Identity?.IsAuthenticated ?? false) + ? AuthenticateResult.Success(new AuthenticationTicket(context.User, "context.User")) + : AuthenticateResult.None(); + } + + /// + /// Attempts authorization for a policy using . + /// + /// The . + /// The result of a call to . + /// The . + /// Returns if authorization succeeds. + /// Otherwise returns if , otherwise + /// returns + public virtual async Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context) + { + if (policy == null) + { + throw new ArgumentNullException(nameof(policy)); + } + + var result = await _authorization.AuthorizeAsync(context.User, context, policy); + if (result.Succeeded) + { + return PolicyAuthorizationResult.Success(); + } + + // If authentication was successful, return forbidden, otherwise challenge + return (authenticationResult.Succeeded) + ? PolicyAuthorizationResult.Forbid() + : PolicyAuthorizationResult.Challenge(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs new file mode 100644 index 000000000..9b72a5cab --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyServiceCollectionExtensions.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authorization.Policy; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace Microsoft.Extensions.DependencyInjection +{ + /// + /// Extension methods for setting up authorization services in an . + /// + public static class PolicyServiceCollectionExtensions + { + /// + /// Adds authorization policy services to the specified . + /// + /// The to add services to. + /// The so that additional calls can be chained. + public static IServiceCollection AddAuthorizationPolicyEvaluator(this IServiceCollection services) + { + if (services == null) + { + throw new ArgumentNullException(nameof(services)); + } + + services.TryAdd(ServiceDescriptor.Transient()); + return services; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs new file mode 100644 index 000000000..89956c9aa --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationFailure.cs @@ -0,0 +1,46 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Security.Claims; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// Encapsulates a failure result of . + /// + public class AuthorizationFailure + { + private AuthorizationFailure() { } + + /// + /// Failure was due to being called. + /// + public bool FailCalled { get; private set; } + + /// + /// Failure was due to these requirements not being met via . + /// + public IEnumerable FailedRequirements { get; private set; } + + /// + /// Return a failure due to being called. + /// + /// The failure. + public static AuthorizationFailure ExplicitFail() + => new AuthorizationFailure + { + FailCalled = true, + FailedRequirements = new IAuthorizationRequirement[0] + }; + + /// + /// Return a failure due to some requirements not being met via . + /// + /// The requirements that were not met. + /// The failure. + public static AuthorizationFailure Failed(IEnumerable failed) + => new AuthorizationFailure { FailedRequirements = failed }; + + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs index 5cba0fd9e..36e0ca7c3 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -143,7 +143,7 @@ public static async Task CombineAsync(IAuthorizationPolicyP policyBuilder.RequireRole(trimmedRolesSplit); useDefaultPolicy = false; } - var authTypesSplit = authorizeDatum.ActiveAuthenticationSchemes?.Split(','); + var authTypesSplit = authorizeDatum.AuthenticationSchemes?.Split(','); if (authTypesSplit != null && authTypesSplit.Any()) { foreach (var authType in authTypesSplit) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs new file mode 100644 index 000000000..46dca35fb --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationResult.cs @@ -0,0 +1,37 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Security.Claims; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// Encapsulates the result of . + /// + public class AuthorizationResult + { + private AuthorizationResult() { } + + /// + /// True if authorization was successful. + /// + public bool Succeeded { get; private set; } + + /// + /// Contains information about why authorization failed. + /// + public AuthorizationFailure Failure { get; private set; } + + /// + /// Returns a successful result. + /// + /// A successful result. + public static AuthorizationResult Success() => new AuthorizationResult { Succeeded = true }; + + public static AuthorizationResult Failed(AuthorizationFailure failure) => new AuthorizationResult { Failure = failure }; + + public static AuthorizationResult Failed() => new AuthorizationResult { Failure = AuthorizationFailure.ExplicitFail() }; + + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs index a9961b69e..c089fba28 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceCollectionExtensions.cs @@ -27,6 +27,7 @@ public static IServiceCollection AddAuthorization(this IServiceCollection servic services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); + services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); services.TryAddEnumerable(ServiceDescriptor.Transient()); diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs index 3b78c952e..c12815232 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -24,7 +24,7 @@ public static class AuthorizationServiceExtensions /// A flag indicating whether requirement evaluation has succeeded or failed. /// This value is true when the user fulfills the policy, otherwise false. /// - public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, IAuthorizationRequirement requirement) + public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, IAuthorizationRequirement requirement) { if (service == null) { @@ -50,7 +50,7 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai /// A flag indicating whether policy evaluation has succeeded or failed. /// This value is true when the user fulfills the policy, otherwise false. /// - public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, AuthorizationPolicy policy) + public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, object resource, AuthorizationPolicy policy) { if (service == null) { @@ -75,7 +75,7 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai /// A flag indicating whether policy evaluation has succeeded or failed. /// This value is true when the user fulfills the policy, otherwise false. /// - public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, AuthorizationPolicy policy) + public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, AuthorizationPolicy policy) { if (service == null) { @@ -100,7 +100,7 @@ public static Task AuthorizeAsync(this IAuthorizationService service, Clai /// A flag indicating whether policy evaluation has succeeded or failed. /// This value is true when the user fulfills the policy, otherwise false. /// - public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, string policyName) + public static Task AuthorizeAsync(this IAuthorizationService service, ClaimsPrincipal user, string policyName) { if (service == null) { diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs index c911dc56b..63bfa30d4 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs @@ -25,13 +25,29 @@ public AuthorizeAttribute(string policy) Policy = policy; } - /// + /// + /// Gets or sets the policy name that determines access to the resource. + /// public string Policy { get; set; } - /// + /// + /// Gets or sets a comma delimited list of roles that are allowed to access the resource. + /// public string Roles { get; set; } - /// - public string ActiveAuthenticationSchemes { get; set; } + /// + /// Gets or sets a comma delimited list of schemes from which user information is constructed. + /// + public string AuthenticationSchemes { get; set; } + + /// + /// Gets or sets a comma delimited list of schemes from which user information is constructed. + /// + [Obsolete("Use AuthenticationSchemes instead.", error: false)] + public string ActiveAuthenticationSchemes + { + get => AuthenticationSchemes; + set => AuthenticationSchemes = value; + } } } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs index 64cc695b8..4bbc283be 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationEvaluator.cs @@ -9,23 +9,15 @@ namespace Microsoft.AspNetCore.Authorization public class DefaultAuthorizationEvaluator : IAuthorizationEvaluator { /// - /// Returns true, if authorization has failed. + /// Determines whether the authorization result was successful or not. /// /// The authorization information. - /// True if authorization has failed. - public virtual bool HasFailed(AuthorizationHandlerContext context) - { - return context.HasFailed; - } - - /// - /// Returns true, if authorization has succeeded. - /// - /// The authorization information. - /// True if authorization has succeeded. - public virtual bool HasSucceeded(AuthorizationHandlerContext context) - { - return context.HasSucceeded; - } + /// The . + public AuthorizationResult Evaluate(AuthorizationHandlerContext context) + => context.HasSucceeded + ? AuthorizationResult.Success() + : AuthorizationResult.Failed(context.HasFailed + ? AuthorizationFailure.ExplicitFail() + : AuthorizationFailure.Failed(context.PendingRequirements)); } } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs new file mode 100644 index 000000000..d297d4cdc --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationHandlerProvider.cs @@ -0,0 +1,35 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// The default implementation of a handler provider, + /// which provides the s for an authorization request. + /// + public class DefaultAuthorizationHandlerProvider : IAuthorizationHandlerProvider + { + private readonly IEnumerable _handlers; + + /// + /// Creates a new instance of . + /// + /// The s. + public DefaultAuthorizationHandlerProvider(IEnumerable handlers) + { + if (handlers == null) + { + throw new ArgumentNullException(nameof(handlers)); + } + + _handlers = handlers; + } + + public Task> GetHandlersAsync(AuthorizationHandlerContext context) + => Task.FromResult(_handlers); + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 8980d51ac..3380f64b1 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Security.Claims; using System.Security.Principal; using System.Threading.Tasks; @@ -19,19 +18,11 @@ public class DefaultAuthorizationService : IAuthorizationService { private readonly AuthorizationOptions _options; private readonly IAuthorizationHandlerContextFactory _contextFactory; + private readonly IAuthorizationHandlerProvider _handlers; private readonly IAuthorizationEvaluator _evaluator; private readonly IAuthorizationPolicyProvider _policyProvider; - private readonly IList _handlers; private readonly ILogger _logger; - /// - /// Creates a new instance of . - /// - /// The used to provide policies. - /// The handlers used to fulfill s. - /// The logger used to log messages, warnings and errors. - public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger) : this(policyProvider, handlers, logger, new DefaultAuthorizationHandlerContextFactory(), new DefaultAuthorizationEvaluator(), Options.Create(new AuthorizationOptions())) { } - /// /// Creates a new instance of . /// @@ -41,7 +32,7 @@ public class DefaultAuthorizationService : IAuthorizationService /// The used to create the context to handle the authorization. /// The used to determine if authorzation was successful. /// The used. - public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IEnumerable handlers, ILogger logger, IAuthorizationHandlerContextFactory contextFactory, IAuthorizationEvaluator evaluator, IOptions options) + public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IAuthorizationHandlerProvider handlers, ILogger logger, IAuthorizationHandlerContextFactory contextFactory, IAuthorizationEvaluator evaluator, IOptions options) { if (options == null) { @@ -69,7 +60,7 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, } _options = options.Value; - _handlers = handlers.ToArray(); + _handlers = handlers; _policyProvider = policyProvider; _logger = logger; _evaluator = evaluator; @@ -86,7 +77,7 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, /// A flag indicating whether authorization has succeded. /// This value is true when the user fulfills the policy otherwise false. /// - public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) + public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) { if (requirements == null) { @@ -94,7 +85,8 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE } var authContext = _contextFactory.CreateContext(requirements, user, resource); - foreach (var handler in _handlers) + var handlers = await _handlers.GetHandlersAsync(authContext); + foreach (var handler in handlers) { await handler.HandleAsync(authContext); if (!_options.InvokeHandlersAfterFailure && authContext.HasFailed) @@ -103,16 +95,16 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IE } } - if (_evaluator.HasSucceeded(authContext)) + var result = _evaluator.Evaluate(authContext); + if (result.Succeeded) { _logger.UserAuthorizationSucceeded(GetUserNameForLogging(user)); - return true; } else { _logger.UserAuthorizationFailed(GetUserNameForLogging(user)); - return false; } + return result; } private string GetUserNameForLogging(ClaimsPrincipal user) @@ -147,7 +139,7 @@ private static string GetClaimValue(IIdentity identity, string claimsType) /// A flag indicating whether authorization has succeded. /// This value is true when the user fulfills the policy otherwise false. /// - public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) + public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) { if (policyName == null) { diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs index 7b2c5d1bc..baa6f828c 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationEvaluator.cs @@ -9,17 +9,10 @@ namespace Microsoft.AspNetCore.Authorization public interface IAuthorizationEvaluator { /// - /// Returns true, if authorization has failed. + /// Determines whether the authorization result was successful or not. /// /// The authorization information. - /// True if authorization has failed. - bool HasFailed(AuthorizationHandlerContext context); - - /// - /// Returns true, if authorization has succeeded. - /// - /// The authorization information. - /// True if authorization has succeeded. - bool HasSucceeded(AuthorizationHandlerContext context); + /// The . + AuthorizationResult Evaluate(AuthorizationHandlerContext context); } } diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs new file mode 100644 index 000000000..7f0d9f5d3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationHandlerProvider.cs @@ -0,0 +1,21 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Authorization +{ + /// + /// A type which can provide the s for an authorization request. + /// + public interface IAuthorizationHandlerProvider + { + /// + /// Return the handlers that will be called for the authorization request. + /// + /// The . + /// The list of handlers. + Task> GetHandlersAsync(AuthorizationHandlerContext context); + } +} diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs index a130c84b0..32af74607 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -29,7 +29,7 @@ public interface IAuthorizationService /// Resource is an optional parameter and may be null. Please ensure that you check it is not /// null before acting upon it. /// - Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements); + Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements); /// /// Checks if a user meets a specific authorization policy @@ -49,6 +49,6 @@ public interface IAuthorizationService /// Resource is an optional parameter and may be null. Please ensure that you check it is not /// null before acting upon it. /// - Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName); + Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs index b48449b5c..1196db82d 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizeData.cs @@ -21,6 +21,6 @@ public interface IAuthorizeData /// /// Gets or sets a comma delimited list of schemes from which user information is constructed. /// - string ActiveAuthenticationSchemes { get; set; } + string AuthenticationSchemes { get; set; } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs index c4720eb30..b09f13cab 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/AuthenticationMiddlewareTests.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; -using System.Net; +using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -77,7 +77,12 @@ public Task AuthenticateAsync() throw new NotImplementedException(); } - public Task ChallengeAsync(ChallengeContext context) + public Task ChallengeAsync(AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + + public Task ForbidAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -94,12 +99,12 @@ public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) return Task.FromResult(0); } - public Task SignInAsync(SignInContext context) + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotImplementedException(); } - public Task SignOutAsync(SignOutContext context) + public Task SignOutAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -114,7 +119,12 @@ public Task AuthenticateAsync() throw new NotImplementedException(); } - public Task ChallengeAsync(ChallengeContext context) + public Task ChallengeAsync(AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + + public Task ForbidAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -130,12 +140,12 @@ public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) return Task.FromResult(0); } - public Task SignInAsync(SignInContext context) + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotImplementedException(); } - public Task SignOutAsync(SignOutContext context) + public Task SignOutAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -150,7 +160,12 @@ public Task AuthenticateAsync() throw new NotImplementedException(); } - public Task ChallengeAsync(ChallengeContext context) + public Task ChallengeAsync(AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + + public Task ForbidAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } @@ -166,12 +181,12 @@ public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) return Task.FromResult(0); } - public Task SignInAsync(SignInContext context) + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { throw new NotImplementedException(); } - public Task SignOutAsync(SignOutContext context) + public Task SignOutAsync(AuthenticationProperties properties) { throw new NotImplementedException(); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index e38dc1587..677120e4b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -702,22 +702,6 @@ public async Task CookieUsesPathBaseByDefault() Assert.True(transaction1.SetCookie.Contains("path=/base")); } - [Fact] - public async Task CookieTurnsChallengeIntoForbidWithCookie() - { - var server = CreateServer(o => { }, SignInAsAlice); - - var transaction1 = await SendAsync(server, "http://example.com/testpath"); - - var url = "http://example.com/challenge"; - var transaction2 = await SendAsync(server, url, transaction1.CookieNameValue); - - Assert.Equal(HttpStatusCode.Redirect, transaction2.Response.StatusCode); - var location = transaction2.Response.Headers.Location; - Assert.Equal("/Account/AccessDenied", location.LocalPath); - Assert.Equal("?ReturnUrl=%2Fchallenge", location.Query); - } - [Fact] public async Task CookieChallengeRedirectsToLoginWithoutCookie() { @@ -744,25 +728,6 @@ public async Task CookieForbidRedirectsWithoutCookie() Assert.Equal("/Account/AccessDenied", location.LocalPath); } - [Fact] - public async Task CookieTurns401ToAccessDeniedWhenSetWithCookie() - { - var server = CreateServer(o => - { - o.AccessDeniedPath = new PathString("/accessdenied"); - }, - SignInAsAlice); - - var transaction1 = await SendAsync(server, "http://example.com/testpath"); - - var transaction2 = await SendAsync(server, "http://example.com/challenge", transaction1.CookieNameValue); - - Assert.Equal(HttpStatusCode.Redirect, transaction2.Response.StatusCode); - - var location = transaction2.Response.Headers.Location; - Assert.Equal("/accessdenied", location.LocalPath); - } - [Fact] public async Task CookieChallengeRedirectsWithLoginPath() { @@ -799,7 +764,8 @@ public async Task CookieChallengeWithUnauthorizedRedirectsToLoginIfNotAuthentica public async Task MapWillAffectChallengeOnlyWithUseAuth(bool useAuth) { var builder = new WebHostBuilder() - .Configure(app => { + .Configure(app => + { if (useAuth) { app.UseAuthentication(); @@ -1296,7 +1262,7 @@ private static TestServer CreateServerWithServices(Action co } else if (req.Path == new PathString("/unauthorized")) { - await context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties(), ChallengeBehavior.Unauthorized); + await context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme, new AuthenticationProperties()); } else if (req.Path == new PathString("/protected/CustomRedirect")) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 060eb649f..657c957bf 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -20,6 +20,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -44,23 +45,26 @@ public void AddCanBindAgainstDefaultConfig() { var dic = new Dictionary { - {"Facebook:AppId", ""}, - {"Facebook:AppSecret", ""}, - {"Facebook:AuthorizationEndpoint", ""}, - {"Facebook:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppId", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AuthorizationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:BackchannelTimeout", "0.0:0:30"}, //{"Facebook:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Facebook:ClaimsIssuer", ""}, - {"Facebook:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Facebook:SaveTokens", "true"}, - {"Facebook:SendAppSecretProof", "true"}, - {"Facebook:SignInScheme", ""}, - {"Facebook:TokenEndpoint", ""}, - {"Facebook:UserInformationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SaveTokens", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SendAppSecretProof", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SignInScheme", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:TokenEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:UserInformationEndpoint", ""}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddFacebookAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddFacebookAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(FacebookDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 2c86bc778..b316e6275 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -19,6 +19,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -43,23 +44,26 @@ public void AddCanBindAgainstDefaultConfig() { var dic = new Dictionary { - {"Google:ClientId", ""}, - {"Google:ClientSecret", ""}, - {"Google:AuthorizationEndpoint", ""}, - {"Google:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientId", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:AuthorizationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:BackchannelTimeout", "0.0:0:30"}, //{"Google:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Google:ClaimsIssuer", ""}, - {"Google:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Google:SaveTokens", "true"}, - {"Google:SendAppSecretProof", "true"}, - {"Google:SignInScheme", ""}, - {"Google:TokenEndpoint", ""}, - {"Google:UserInformationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:SaveTokens", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:SendAppSecretProof", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:SignInScheme", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:TokenEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Google:UserInformationEndpoint", ""}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddGoogleAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddGoogleAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(GoogleDefaults.AuthenticationScheme); @@ -883,42 +887,6 @@ public async Task AuthenticateGoogleWhenAlreadySignedInSucceeds() Assert.Equal("yup", transaction.FindClaimValue("xform")); } - [Fact] - public async Task ChallengeGoogleWhenAlreadySignedInReturnsForbidden() - { - var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); - var server = CreateServer(o => - { - o.ClientId = "Test Id"; - o.ClientSecret = "Test Secret"; - o.StateDataFormat = stateFormat; - o.SaveTokens = true; - o.BackchannelHttpHandler = CreateBackchannel(); - }); - - // Skip the challenge step, go directly to the callback path - - var properties = new AuthenticationProperties(); - var correlationKey = ".xsrf"; - var correlationValue = "TestCorrelationId"; - properties.Items.Add(correlationKey, correlationValue); - properties.RedirectUri = "/me"; - var state = stateFormat.Protect(properties); - var transaction = await server.SendAsync( - "https://example.com/signin-google?code=TestCode&state=" + UrlEncoder.Default.Encode(state), - $".AspNetCore.Correlation.Google.{correlationValue}=N"); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.Equal("/me", transaction.Response.Headers.GetValues("Location").First()); - Assert.Equal(2, transaction.SetCookie.Count); - Assert.Contains($".AspNetCore.Correlation.Google.{correlationValue}", transaction.SetCookie[0]); // Delete - Assert.Contains(".AspNetCore." + TestExtensions.CookieAuthenticationScheme, transaction.SetCookie[1]); - - var authCookie = transaction.AuthenticationCookieValue; - transaction = await server.SendAsync("https://example.com/challenge", authCookie); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.StartsWith("https://example.com/Account/AccessDenied?", transaction.Response.Headers.Location.OriginalString); - } - [Fact] public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 59f1e880c..6746f5c3f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -19,6 +19,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Microsoft.IdentityModel.Tokens; using Xunit; @@ -43,21 +44,24 @@ public void AddCanBindAgainstDefaultConfig() { var dic = new Dictionary { - {"Bearer:Audience", ""}, - {"Bearer:Authority", ""}, - {"Bearer:BackchannelTimeout", "0.0:0:30"}, - {"Bearer:Challenge", ""}, - {"Bearer:ClaimsIssuer", ""}, - {"Bearer:IncludeErrorDetails", "true"}, - {"Bearer:MetadataAddress", ""}, - {"Bearer:RefreshOnIssuerKeyNotFound", "true"}, - {"Bearer:RequireHttpsMetadata", "false"}, - {"Bearer:SaveToken", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Challenge", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:IncludeErrorDetails", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:MetadataAddress", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RefreshOnIssuerKeyNotFound", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:SaveToken", "true"}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddJwtBearerAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddJwtBearerAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); @@ -74,21 +78,26 @@ public void AddCanBindAgainstDefaultConfig() } [Fact] - public void AddWithDelegateIgnoresConfig() + public void AddWithDelegateOverridesConfig() { var dic = new Dictionary { - {"Bearer:Audience", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"} }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddJwtBearerAuthentication(o => o.IncludeErrorDetails = true).AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddJwtBearerAuthentication(o => o.Authority = "authority") + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); - Assert.Null(options.Audience); - Assert.True(options.IncludeErrorDetails); + Assert.Equal("", options.Audience); + Assert.Equal("authority", options.Authority); } [ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")] @@ -440,27 +449,6 @@ public async Task RetrievingTokenFromAlternateLocation() Assert.Equal("Bob le Tout Puissant", response.ResponseText); } - [Fact] - public async Task BearerTurns401To403IfAuthenticated() - { - var server = CreateServer(options => - { - options.SecurityTokenValidators.Clear(); - options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); - }); - - var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); - Assert.Equal(HttpStatusCode.Forbidden, response.Response.StatusCode); - } - - [Fact] - public async Task BearerDoesNothingTo401IfNotAuthenticated() - { - var server = CreateServer(); - var response = await SendAsync(server, "http://example.com/unauthorized"); - Assert.Equal(HttpStatusCode.Unauthorized, response.Response.StatusCode); - } - [Fact] public async Task EventOnMessageReceivedSkip_NoMoreEventsExecuted() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 062215ff4..0d49052f5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -20,6 +20,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -44,23 +45,26 @@ public void AddCanBindAgainstDefaultConfig() { var dic = new Dictionary { - {"Microsoft:ClientId", ""}, - {"Microsoft:ClientSecret", ""}, - {"Microsoft:AuthorizationEndpoint", ""}, - {"Microsoft:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientId", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:AuthorizationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:BackchannelTimeout", "0.0:0:30"}, //{"Microsoft:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:ClaimsIssuer", ""}, - {"Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:SaveTokens", "true"}, - {"Microsoft:SendAppSecretProof", "true"}, - {"Microsoft:SignInScheme", ""}, - {"Microsoft:TokenEndpoint", ""}, - {"Microsoft:UserInformationEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SaveTokens", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SendAppSecretProof", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SignInScheme", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:TokenEndpoint", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:UserInformationEndpoint", ""}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddMicrosoftAccountAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddMicrosoftAccountAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(MicrosoftAccountDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index b2459cf81..9dc597b85 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -15,6 +15,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; @@ -34,15 +35,18 @@ public void AddCanBindAgainstDefaultConfig() { var dic = new Dictionary { - {"OpenIdConnect:ClientId", ""}, - {"OpenIdConnect:ClientSecret", ""}, - {"OpenIdConnect:RequireHttpsMetadata", "false"}, - {"OpenIdConnect:Authority", ""} + {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientId", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:RequireHttpsMetadata", "false"}, + {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:Authority", ""} }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddOpenIdConnectAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddOpenIdConnectAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(OpenIdConnectDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs index 41429cd37..b37ae53d5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs @@ -5,7 +5,7 @@ using System.IO; using System.Linq; using System.Security.Claims; -using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Testing.xunit; using Xunit; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 1acddc5af..b8af66cdf 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Options.Infrastructure; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -37,20 +38,23 @@ public void AddCanBindAgainstDefaultConfig() { var dic = new Dictionary { - {"Twitter:ConsumerKey", ""}, - {"Twitter:ConsumerSecret", ""}, - {"Twitter:BackchannelTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerKey", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerSecret", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:BackchannelTimeout", "0.0:0:30"}, //{"Twitter:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Twitter:ClaimsIssuer", ""}, - {"Twitter:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Twitter:SaveTokens", "true"}, - {"Twitter:SendAppSecretProof", "true"}, - {"Twitter:SignInScheme", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ClaimsIssuer", ""}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:RemoteAuthenticationTimeout", "0.0:0:30"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SaveTokens", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SendAppSecretProof", "true"}, + {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SignInScheme", ""}, }; var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(dic); var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddTwitterAuthentication().AddSingleton(config); + var services = new ServiceCollection() + .AddSingleton, ConfigureDefaults>() + .AddTwitterAuthentication() + .AddSingleton(config); var sp = services.BuildServiceProvider(); var options = sp.GetRequiredService>().Get(TwitterDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs index 6825dd868..714b26c7e 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -25,9 +25,9 @@ public async Task CanCombineAuthorizeAttributes() // Arrange var attributes = new AuthorizeAttribute[] { new AuthorizeAttribute(), - new AuthorizeAttribute("1") { ActiveAuthenticationSchemes = "dupe" }, - new AuthorizeAttribute("2") { ActiveAuthenticationSchemes = "dupe" }, - new AuthorizeAttribute { Roles = "r1,r2", ActiveAuthenticationSchemes = "roles" }, + new AuthorizeAttribute("1") { AuthenticationSchemes = "dupe" }, + new AuthorizeAttribute("2") { AuthenticationSchemes = "dupe" }, + new AuthorizeAttribute { Roles = "r1,r2", AuthenticationSchemes = "roles" }, }; var options = new AuthorizationOptions(); options.AddPolicy("1", policy => policy.RequireClaim("1")); @@ -54,7 +54,7 @@ public async Task CanReplaceDefaultPolicy() // Arrange var attributes = new AuthorizeAttribute[] { new AuthorizeAttribute(), - new AuthorizeAttribute("2") { ActiveAuthenticationSchemes = "dupe" } + new AuthorizeAttribute("2") { AuthenticationSchemes = "dupe" } }; var options = new AuthorizationOptions(); options.DefaultPolicy = new AuthorizationPolicyBuilder("default").RequireClaim("default").Build(); @@ -100,7 +100,7 @@ public async Task CombineMustTrimAuthenticationScheme() { // Arrange var attributes = new AuthorizeAttribute[] { - new AuthorizeAttribute() { ActiveAuthenticationSchemes = "a1 , a2" } + new AuthorizeAttribute() { AuthenticationSchemes = "a1 , a2" } }; var options = new AuthorizationOptions(); @@ -120,7 +120,7 @@ public async Task CombineMustIgnoreEmptyAuthenticationScheme() { // Arrange var attributes = new AuthorizeAttribute[] { - new AuthorizeAttribute() { ActiveAuthenticationSchemes = "a1 , , ,,, a2" } + new AuthorizeAttribute() { AuthenticationSchemes = "a1 , , ,,, a2" } }; var options = new AuthorizationOptions(); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index 246eed9a5..ef17b9462 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -53,7 +53,7 @@ public async Task Authorize_ShouldAllowIfClaimIsPresent() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -76,7 +76,7 @@ public async Task Authorize_ShouldAllowIfClaimIsPresentWithSpecifiedAuthType() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -103,7 +103,7 @@ public async Task Authorize_ShouldAllowIfClaimIsAmongValues() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -126,7 +126,8 @@ public async Task Authorize_ShouldInvokeAllHandlersByDefault() var allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Custom"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); + Assert.True(allowed.Failure.FailCalled); Assert.True(handler1.Invoked); Assert.True(handler2.Invoked); } @@ -154,7 +155,7 @@ public async Task Authorize_ShouldInvokeAllHandlersDependingOnSetting(bool invok var allowed = await authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "Custom"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); Assert.True(handler1.Invoked); Assert.Equal(invokeAllHandlers, handler2.Invoked); } @@ -171,8 +172,6 @@ public Task HandleAsync(AuthorizationHandlerContext context) } } - - [Fact] public async Task Authorize_ShouldFailWhenAllRequirementsNotHandled() { @@ -196,7 +195,8 @@ public async Task Authorize_ShouldFailWhenAllRequirementsNotHandled() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); + Assert.IsType(allowed.Failure.FailedRequirements.First()); } [Fact] @@ -222,7 +222,7 @@ public async Task Authorize_ShouldNotAllowIfClaimTypeIsNotPresent() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -248,7 +248,7 @@ public async Task Authorize_ShouldNotAllowIfClaimValueIsNotPresent() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -272,7 +272,7 @@ public async Task Authorize_ShouldNotAllowIfNoClaims() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -291,7 +291,7 @@ public async Task Authorize_ShouldNotAllowIfUserIsNull() var allowed = await authorizationService.AuthorizeAsync(null, null, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -311,7 +311,7 @@ public async Task Authorize_ShouldNotAllowIfNotCorrectAuthType() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -337,7 +337,7 @@ public async Task Authorize_ShouldAllowWithNoAuthType() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -372,7 +372,7 @@ public async Task Authorize_CustomRolePolicy() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -393,7 +393,7 @@ public async Task Authorize_HasAnyClaimOfTypePolicy() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -410,7 +410,7 @@ public async Task Authorize_PolicyCanAuthenticationSchemeWithNameClaim() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -427,7 +427,7 @@ public async Task RolePolicyCanRequireSingleRole() var allowed = await authorizationService.AuthorizeAsync(user, null, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -443,7 +443,7 @@ public async Task RolePolicyCanRequireOneOfManyRoles() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -464,7 +464,7 @@ public async Task RolePolicyCanBlockWrongRole() var allowed = await authorizationService.AuthorizeAsync(user, policy.Build()); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -489,7 +489,7 @@ public async Task RolePolicyCanBlockNoRole() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -527,7 +527,7 @@ public async Task RequireUserNameFailsForWrongUserName() var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -553,7 +553,7 @@ public async Task CanRequireUserName() var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -575,7 +575,7 @@ public async Task CanRequireUserNameWithDiffClaimType() var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -597,7 +597,7 @@ public async Task CanRequireRoleWithDiffClaimType() var allowed = await authorizationService.AuthorizeAsync(user, "Hao"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -622,7 +622,7 @@ public async Task CanApproveAnyAuthenticatedUser() var allowed = await authorizationService.AuthorizeAsync(user, null, "Any"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -642,7 +642,7 @@ public async Task CanBlockNonAuthenticatedUser() var allowed = await authorizationService.AuthorizeAsync(user, null, "Any"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } public class CustomRequirement : IAuthorizationRequirement { } @@ -675,7 +675,7 @@ public async Task CustomReqWithNoHandlerFails() var allowed = await authorizationService.AuthorizeAsync(user, null, "Custom"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -696,7 +696,7 @@ public async Task CustomReqWithHandlerSucceeds() var allowed = await authorizationService.AuthorizeAsync(user, null, "Custom"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } public class PassThroughRequirement : AuthorizationHandler, IAuthorizationRequirement @@ -736,7 +736,7 @@ public async Task PassThroughRequirementWillSucceedWithoutCustomHandler(bool sho var allowed = await authorizationService.AuthorizeAsync(user, null, "Passthrough"); // Assert - Assert.Equal(shouldSucceed, allowed); + Assert.Equal(shouldSucceed, allowed.Succeeded); } [Fact] @@ -764,7 +764,7 @@ public async Task CanCombinePolicies() var allowed = await authorizationService.AuthorizeAsync(user, null, "Combined"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -791,7 +791,7 @@ public async Task CombinePoliciesWillFailIfBasePolicyFails() var allowed = await authorizationService.AuthorizeAsync(user, null, "Combined"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } [Fact] @@ -818,7 +818,7 @@ public async Task CombinedPoliciesWillFailIfExtraRequirementFails() var allowed = await authorizationService.AuthorizeAsync(user, null, "Combined"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } public class ExpenseReport { } @@ -880,9 +880,9 @@ public async Task CanAuthorizeAllSuperuserOperations() // Act // Assert - Assert.True(await authorizationService.AuthorizeAsync(user, null, Operations.Edit)); - Assert.True(await authorizationService.AuthorizeAsync(user, null, Operations.Delete)); - Assert.True(await authorizationService.AuthorizeAsync(user, null, Operations.Create)); + Assert.True((await authorizationService.AuthorizeAsync(user, null, Operations.Edit)).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, null, Operations.Delete)).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, null, Operations.Create)).Succeeded); } public class NotCalledHandler : AuthorizationHandler @@ -922,8 +922,8 @@ public async Task CanUseValueTypeResource() // Act // Assert - Assert.False(await authorizationService.AuthorizeAsync(user, 1, Operations.Edit)); - Assert.True(await authorizationService.AuthorizeAsync(user, 2, Operations.Edit)); + Assert.False((await authorizationService.AuthorizeAsync(user, 1, Operations.Edit)).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, 2, Operations.Edit)).Succeeded); } @@ -945,7 +945,7 @@ public async Task DoesNotCallHandlerWithWrongResourceType() // Act // Assert - Assert.False(await authorizationService.AuthorizeAsync(user, 1, Operations.Edit)); + Assert.False((await authorizationService.AuthorizeAsync(user, 1, Operations.Edit)).Succeeded); } [Fact] @@ -960,9 +960,9 @@ public async Task CanAuthorizeOnlyAllowedOperations() // Act // Assert - Assert.True(await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Edit)); - Assert.False(await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Delete)); - Assert.False(await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Create)); + Assert.True((await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Edit)).Succeeded); + Assert.False((await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Delete)).Succeeded); + Assert.False((await authorizationService.AuthorizeAsync(user, new ExpenseReport(), Operations.Create)).Succeeded); } [Fact] @@ -977,7 +977,7 @@ public async Task AuthorizeHandlerNotCalledWithNullResource() // Act // Assert - Assert.False(await authorizationService.AuthorizeAsync(user, null, Operations.Edit)); + Assert.False((await authorizationService.AuthorizeAsync(user, null, Operations.Edit)).Succeeded); } [Fact] @@ -996,7 +996,7 @@ public async Task CanAuthorizeWithAssertionRequirement() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } [Fact] @@ -1015,7 +1015,7 @@ public async Task CanAuthorizeWithAsyncAssertionRequirement() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.True(allowed); + Assert.True(allowed.Succeeded); } public class StaticPolicyProvider : IAuthorizationPolicyProvider @@ -1049,7 +1049,7 @@ public async Task CanReplaceDefaultPolicyProvider() var allowed = await authorizationService.AuthorizeAsync(user, "Basic"); // Assert - Assert.False(allowed); + Assert.False(allowed.Succeeded); } public class DynamicPolicyProvider : IAuthorizationPolicyProvider @@ -1081,23 +1081,15 @@ public async Task CanUseDynamicPolicyProvider() // Act // Assert - Assert.False(await authorizationService.AuthorizeAsync(user, "0")); - Assert.True(await authorizationService.AuthorizeAsync(user, "1")); - Assert.True(await authorizationService.AuthorizeAsync(user, "2")); - Assert.False(await authorizationService.AuthorizeAsync(user, "3")); + Assert.False((await authorizationService.AuthorizeAsync(user, "0")).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, "1")).Succeeded); + Assert.True((await authorizationService.AuthorizeAsync(user, "2")).Succeeded); + Assert.False((await authorizationService.AuthorizeAsync(user, "3")).Succeeded); } public class SuccessEvaluator : IAuthorizationEvaluator { - public bool HasFailed(AuthorizationHandlerContext context) - { - return false; - } - - public bool HasSucceeded(AuthorizationHandlerContext context) - { - return true; - } + public AuthorizationResult Evaluate(AuthorizationHandlerContext context) => AuthorizationResult.Success(); } [Fact] @@ -1108,7 +1100,8 @@ public async Task CanUseCustomEvaluatorThatOverridesRequirement() services.AddSingleton(); services.AddAuthorization(options => options.AddPolicy("Fail", p => p.RequireAssertion(c => false))); }); - Assert.True(await authorizationService.AuthorizeAsync(null, "Fail")); + var result = await authorizationService.AuthorizeAsync(null, "Fail"); + Assert.True(result.Succeeded); } @@ -1149,7 +1142,26 @@ public async Task CanUseCustomContextThatAlwaysFails() services.AddSingleton(); services.AddAuthorization(options => options.AddPolicy("Success", p => p.RequireAssertion(c => true))); }); - Assert.False(await authorizationService.AuthorizeAsync(null, "Success")); + Assert.False((await authorizationService.AuthorizeAsync(null, "Success")).Succeeded); + } + + public class SadHandlerProvider : IAuthorizationHandlerProvider + { + public Task> GetHandlersAsync(AuthorizationHandlerContext context) + { + return Task.FromResult>(new IAuthorizationHandler[1] { new FailHandler() }); + } + } + + [Fact] + public async Task CanUseCustomHandlerProvider() + { + var authorizationService = BuildAuthorizationService(services => + { + services.AddSingleton(); + services.AddAuthorization(options => options.AddPolicy("Success", p => p.RequireAssertion(c => true))); + }); + Assert.False((await authorizationService.AuthorizeAsync(null, "Success")).Succeeded); } } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 48b134740..6eb74aeeb 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -9,9 +9,11 @@ + + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs new file mode 100644 index 000000000..216fc1440 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs @@ -0,0 +1,179 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Authorization.Policy.Test +{ + public class PolicyEvaluatorTests + { + [Fact] + public async Task AuthenticateFailsIfNoPrincipalReturned() + { + // Arrange + var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var context = new DefaultHttpContext(); + var services = new ServiceCollection().AddSingleton(); + context.RequestServices = services.BuildServiceProvider(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthenticateAsync(policy, context); + + // Assert + Assert.False(result.Succeeded); + } + + [Fact] + public async Task AuthenticateMergeSchemes() + { + // Arrange + var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var context = new DefaultHttpContext(); + var services = new ServiceCollection().AddSingleton(); + context.RequestServices = services.BuildServiceProvider(); + var policy = new AuthorizationPolicyBuilder().AddAuthenticationSchemes("A","B","C").RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthenticateAsync(policy, context); + + // Assert + Assert.True(result.Succeeded); + Assert.Equal(3, result.Principal.Identities.Count()); + } + + + [Fact] + public async Task AuthorizeSucceedsEvenIfAuthenticationFails() + { + // Arrange + var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var context = new DefaultHttpContext(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context); + + // Assert + Assert.True(result.Succeeded); + Assert.False(result.Challenged); + Assert.False(result.Forbidden); + } + + [Fact] + public async Task AuthorizeChallengesIfAuthenticationFails() + { + // Arrange + var evaluator = new PolicyEvaluator(new SadAuthorization()); + var context = new DefaultHttpContext(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context); + + // Assert + Assert.False(result.Succeeded); + Assert.True(result.Challenged); + Assert.False(result.Forbidden); + } + + [Fact] + public async Task AuthorizeForbidsIfAuthenticationSuceeds() + { + // Arrange + var evaluator = new PolicyEvaluator(new SadAuthorization()); + var context = new DefaultHttpContext(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + + // Act + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "scheme")), context); + + // Assert + Assert.False(result.Succeeded); + Assert.False(result.Challenged); + Assert.True(result.Forbidden); + } + + public class HappyAuthorization : IAuthorizationService + { + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) + => Task.FromResult(AuthorizationResult.Success()); + + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) + => Task.FromResult(AuthorizationResult.Success()); + } + + public class SadAuthorization : IAuthorizationService + { + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) + => Task.FromResult(AuthorizationResult.Failed()); + + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) + => Task.FromResult(AuthorizationResult.Failed()); + } + + public class SadAuthentication : IAuthenticationService + { + public Task AuthenticateAsync(HttpContext context, string scheme) + { + return Task.FromResult(AuthenticateResult.Fail("Sad.")); + } + + public Task ChallengeAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task ForbidAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + } + + public class EchoAuthentication : IAuthenticationService + { + public Task AuthenticateAsync(HttpContext context, string scheme) + { + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(new ClaimsIdentity(scheme)), scheme))); + } + + public Task ChallengeAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task ForbidAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + + public Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new System.NotImplementedException(); + } + } + + } +} \ No newline at end of file From 0b41dd12896c386802c2d72d234bf7eb91966815 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 25 May 2017 20:25:04 -0700 Subject: [PATCH 011/248] Disable api check to unblock build --- .../Microsoft.AspNetCore.Authorization.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 93673ef00..0022d2743 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -11,6 +11,7 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute $(NoWarn);CS1591 true aspnetcore;authorization + false From 348cdf9da9810b768f79dcce6bc39b3918b0863e Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 25 May 2017 23:31:09 -0700 Subject: [PATCH 012/248] Fix sln --- Security.sln | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/Security.sln b/Security.sln index 61ea7b0c3..7c34ff070 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26510.0 +VisualStudioVersion = 15.0.26507.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -64,10 +64,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization.Policy", "src\Microsoft.AspNetCore.Authorization.Policy\Microsoft.AspNetCore.Authorization.Policy.csproj", "{58194599-F07D-47A3-9DF2-E21A22C5EF9E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Abstractions", "..\HttpAbstractions\src\Microsoft.AspNetCore.Authentication.Abstractions\Microsoft.AspNetCore.Authentication.Abstractions.csproj", "{97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Core", "..\HttpAbstractions\src\Microsoft.AspNetCore.Authentication.Core\Microsoft.AspNetCore.Authentication.Core.csproj", "{85545633-7E70-47EA-8CD2-30654C80112C}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -458,38 +454,6 @@ Global {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x64.Build.0 = Release|Any CPU {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.ActiveCfg = Release|Any CPU {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.Build.0 = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x64.ActiveCfg = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x64.Build.0 = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x86.ActiveCfg = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Debug|x86.Build.0 = Debug|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Any CPU.Build.0 = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x64.ActiveCfg = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x64.Build.0 = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x86.ActiveCfg = Release|Any CPU - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D}.Release|x86.Build.0 = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x64.ActiveCfg = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x64.Build.0 = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x86.ActiveCfg = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Debug|x86.Build.0 = Debug|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Any CPU.Build.0 = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x64.ActiveCfg = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x64.Build.0 = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x86.ActiveCfg = Release|Any CPU - {85545633-7E70-47EA-8CD2-30654C80112C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -519,7 +483,5 @@ Global {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} - {97D7B36D-1C0D-4F6D-A6A2-808BB7A4574D} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} - {85545633-7E70-47EA-8CD2-30654C80112C} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} EndGlobalSection EndGlobal From c5238390787afb31cc9be15f557ffd9dcc42b049 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 24 May 2017 17:04:14 -0700 Subject: [PATCH 013/248] Update default settings for SameSite - Need Lax policy for social authentication - Need None policy for OIDC --- .gitignore | 1 + .../OpenIdConnect.AzureAdSample/Program.cs | 1 + .../CookieAuthenticationOptions.cs | 18 +++--- .../OpenIdConnectHandler.cs | 6 +- .../TwitterHandler.cs | 2 +- .../RemoteAuthenticationHandler.cs | 8 +-- .../CookiePolicyOptions.cs | 2 +- .../CookiePolicyTests.cs | 56 +++++++++---------- 8 files changed, 49 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index bcc811de9..d5717b3f3 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,5 @@ project.lock.json .build/ .testPublish/ /.vs/ +.vscode/ global.json diff --git a/samples/OpenIdConnect.AzureAdSample/Program.cs b/samples/OpenIdConnect.AzureAdSample/Program.cs index 9de0185a4..0e1285a9c 100644 --- a/samples/OpenIdConnect.AzureAdSample/Program.cs +++ b/samples/OpenIdConnect.AzureAdSample/Program.cs @@ -15,6 +15,7 @@ public static void Main(string[] args) factory.AddFilter("Console", level => level >= LogLevel.Information); }) .UseKestrel() + .UseUrls("http://localhost:42023") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 02d0361b7..01a5ae9c9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -22,7 +22,8 @@ public CookieAuthenticationOptions() ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; - CookieSameSite = SameSiteMode.Strict; + // To support OAuth authentication, a lax mode is required, see https://github.com/aspnet/Security/issues/1231. + CookieSameSite = SameSiteMode.Lax; CookieHttpOnly = true; CookieSecure = CookieSecurePolicy.SameAsRequest; Events = new CookieAuthenticationEvents(); @@ -59,7 +60,8 @@ public string CookieName /// /// Determines if the browser should allow the cookie to be attached to same-site or cross-site requests. The - /// default is Strict, which means the cookie is only allowed to be attached to same-site requests. + /// default is Lax, which means the cookie is only allowed to be attached to cross-site requests using safe + /// HTTP methods and same-site requests. /// public SameSiteMode CookieSameSite { get; set; } @@ -84,8 +86,8 @@ public string CookieName /// /// Controls how much time the cookie will remain valid from the point it is created. The expiration - /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored - /// even if it is passed to the server after the browser should have purged it + /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored + /// even if it is passed to the server after the browser should have purged it /// public TimeSpan ExpireTimeSpan { get; set; } @@ -99,7 +101,7 @@ public string CookieName /// The LoginPath property informs the handler that it should change an outgoing 401 Unauthorized status /// code into a 302 redirection onto the given login path. The current url which generated the 401 is added /// to the LoginPath as a query string parameter named by the ReturnUrlParameter. Once a request to the - /// LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect the browser back + /// LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect the browser back /// to the url which caused the original unauthorized status code. /// public PathString LoginPath { get; set; } @@ -117,15 +119,15 @@ public string CookieName /// /// The ReturnUrlParameter determines the name of the query string parameter which is appended by the handler - /// when a 401 Unauthorized status code is changed to a 302 redirect onto the login path. This is also the query - /// string parameter looked for when a request arrives on the login path or logout path, in order to return to the + /// when a 401 Unauthorized status code is changed to a 302 redirect onto the login path. This is also the query + /// string parameter looked for when a request arrives on the login path or logout path, in order to return to the /// original url after the action is performed. /// public string ReturnUrlParameter { get; set; } /// /// The Provider may be assigned to an instance of an object created by the application at startup time. The handler - /// calls methods on the provider which give the application control at certain points where processing is occurring. + /// calls methods on the provider which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// public new CookieAuthenticationEvents Events diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 9c8f4ecc6..89d949a00 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -62,7 +62,7 @@ public OpenIdConnectHandler(IOptionsSnapshot options, ILog } /// - /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// protected new OpenIdConnectEvents Events @@ -892,7 +892,7 @@ private void WriteNonceCookie(string nonce) new CookieOptions { HttpOnly = true, - SameSite = Http.SameSiteMode.Lax, + SameSite = Http.SameSiteMode.None, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) }); @@ -924,7 +924,7 @@ private string ReadNonceCookie(string nonce) var cookieOptions = new CookieOptions { HttpOnly = true, - SameSite = Http.SameSiteMode.Lax, + SameSite = Http.SameSiteMode.None, Secure = Request.IsHttps }; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 63a18e83b..0eab83e41 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -31,7 +31,7 @@ internal class TwitterHandler : RemoteAuthenticationHandler private HttpClient Backchannel => Options.Backchannel; /// - /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// protected new TwitterEvents Events diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 9394b7553..2ff06062d 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Authentication { - public abstract class RemoteAuthenticationHandler : AuthenticationHandler, IAuthenticationRequestHandler + public abstract class RemoteAuthenticationHandler : AuthenticationHandler, IAuthenticationRequestHandler where TOptions : RemoteAuthenticationOptions, new() { private const string CorrelationPrefix = ".AspNetCore.Correlation."; @@ -25,7 +25,7 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand protected string SignInScheme => Options.SignInScheme; /// - /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// protected new RemoteAuthenticationEvents Events @@ -203,7 +203,7 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties var cookieOptions = new CookieOptions { HttpOnly = true, - SameSite = SameSiteMode.Lax, + SameSite = SameSiteMode.None, Secure = Request.IsHttps, Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; @@ -243,7 +243,7 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties var cookieOptions = new CookieOptions { HttpOnly = true, - SameSite = SameSiteMode.Lax, + SameSite = SameSiteMode.None, Secure = Request.IsHttps }; Response.Cookies.Delete(cookieName, cookieOptions); diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index 7203e73e6..1e474bfe2 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -15,7 +15,7 @@ public class CookiePolicyOptions /// /// Affects the cookie's same site attribute. /// - public SameSiteMode MinimumSameSitePolicy { get; set; } = SameSiteMode.Strict; + public SameSiteMode MinimumSameSitePolicy { get; set; } = SameSiteMode.Lax; /// /// Affects whether cookies must be HttpOnly. diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 737c12dc3..b6b2776a8 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -59,10 +59,10 @@ await RunTest("/secureAlways", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; secure; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=lax", transaction.SetCookie[3]); })); } @@ -79,10 +79,10 @@ await RunTest("/secureNone", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=lax", transaction.SetCookie[3]); })); } @@ -99,19 +99,19 @@ await RunTest("/secureSame", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax", transaction.SetCookie[3]); }), new RequestTest("https://example.com/secureSame", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; secure; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; secure; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; secure; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; secure; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; secure; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; secure; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; secure; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; secure; samesite=lax", transaction.SetCookie[3]); })); } @@ -128,10 +128,10 @@ await RunTest("/httpOnlyAlways", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; samesite=strict; httponly", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; samesite=strict; httponly", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; samesite=strict; httponly", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; samesite=strict; httponly", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=lax; httponly", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax; httponly", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax; httponly", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax; httponly", transaction.SetCookie[3]); })); } @@ -148,10 +148,10 @@ await RunTest("/httpOnlyNone", transaction => { Assert.NotNull(transaction.SetCookie); - Assert.Equal("A=A; path=/; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("B=B; path=/; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("C=C; path=/; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; samesite=strict; httponly", transaction.SetCookie[3]); + Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("D=D; path=/; samesite=lax; httponly", transaction.SetCookie[3]); })); } @@ -242,10 +242,10 @@ public async Task CookiePolicyCanHijackAppend() var transaction = await server.SendAsync("http://example.com/login"); Assert.NotNull(transaction.SetCookie); - Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[0]); - Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[1]); - Assert.Equal("Hao=Hao; path=/; samesite=strict", transaction.SetCookie[2]); - Assert.Equal("Hao=Hao; path=/; secure; samesite=strict", transaction.SetCookie[3]); + Assert.Equal("Hao=Hao; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("Hao=Hao; path=/; samesite=lax", transaction.SetCookie[1]); + Assert.Equal("Hao=Hao; path=/; samesite=lax", transaction.SetCookie[2]); + Assert.Equal("Hao=Hao; path=/; secure; samesite=lax", transaction.SetCookie[3]); } [Fact] From e65a67bb5c374512e9840f47ed1de2b2e1cc25e1 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Fri, 26 May 2017 12:44:31 -0700 Subject: [PATCH 014/248] Updated to use the latest shared runtime --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index f7e538a50..e804e1b39 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,6 +8,7 @@ 10.0.1 2.0.0-* 3.0.1 + 2.0.0-* 15.3.0-* 2.3.0-beta2-* From e573b8431016541f9ce3992020089af2593239b1 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:37:21 -0700 Subject: [PATCH 015/248] Branching for rel/2.0.0-preview2 --- NuGet.config | 5 +++-- build/dependencies.props | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index 93f1ac47d..c4bc056c4 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,8 +1,9 @@  - + + - + \ No newline at end of file diff --git a/build/dependencies.props b/build/dependencies.props index e804e1b39..02a36ec83 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 2.0.0-* + 2.0.0-preview2-* 4.4.0-* 3.13.8 2.1.3 From f8feee3783fc0220012e1db9d6af458674289611 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:53:33 -0700 Subject: [PATCH 016/248] Updating build scripts to point to 2.0.0-preview2 KoreBuild --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c11..3a2476b2b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb57..a40bdb87b 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 4034158c614ec1dfe2366afcc7763871a37cfda7 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 31 May 2017 22:11:21 -0700 Subject: [PATCH 017/248] Removed reference to System.Net.Http --- .../Microsoft.AspNetCore.Authentication.Test.csproj | 1 - .../Microsoft.Owin.Security.Interop.Test.csproj | 1 - 2 files changed, 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index c44069f43..1529dc803 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -23,7 +23,6 @@ - diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index d6e9d16e5..14c0aa2f1 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -14,7 +14,6 @@ - From 8bfab2b3785a3f84e9733dd4ea7c5139ab3a5794 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 1 Jun 2017 10:47:46 -0700 Subject: [PATCH 018/248] Updating versions to preview3 --- NuGet.config | 1 + version.props | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 93f1ac47d..4e8a1f6de 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,6 +1,7 @@  + diff --git a/version.props b/version.props index 0b2b8e001..90a2f5b5c 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview2 + preview3 \ No newline at end of file From db9ae6263233e1d95245cb911614d0e20a12edfa Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 2 Jun 2017 14:28:03 -0700 Subject: [PATCH 019/248] IInitializeOptions => IPostConfigureOptions --- ...s => CookieAuthenticationPostConfigureOptions.cs} | 12 ++++++------ .../CookieExtensions.cs | 2 +- .../FacebookExtensions.cs | 1 + .../{ => Internal}/FacebookConfigureOptions.cs | 4 ++-- .../GoogleExtensions.cs | 1 + .../{ => Internal}/GoogleConfigureOptions.cs | 4 ++-- .../{ => Internal}/JwtBearerConfigureOptions.cs | 4 ++-- .../JwtBearerExtensions.cs | 3 ++- ...itializer.cs => JwtBearerPostConfigureOptions.cs} | 10 +++++----- .../MicrosoftAccountConfigureOptions.cs | 4 ++-- .../MicrosoftAccountExtensions.cs | 1 + .../OAuthExtensions.cs | 2 +- ...thInitializer.cs => OAuthPostConfigureOptions.cs} | 6 +++--- .../{ => Internal}/OpenIdConnectConfigureOptions.cs | 2 +- .../OpenIdConnectExtensions.cs | 3 ++- ...lizer.cs => OpenIdConnectPostConfigureOptions.cs} | 12 ++++++------ .../{ => Internal}/TwitterConfigureOptions.cs | 4 ++-- .../TwitterExtensions.cs | 3 ++- ...Initializer.cs => TwitterPostConfigureOptions.cs} | 12 ++++++------ .../AuthenticationSchemeOptions.cs | 9 --------- .../AuthenticationServiceCollectionExtensions.cs | 8 +++----- 21 files changed, 51 insertions(+), 56 deletions(-) rename src/Microsoft.AspNetCore.Authentication.Cookies/{CookieAuthenticationInitializer.cs => CookieAuthenticationPostConfigureOptions.cs} (81%) rename src/Microsoft.AspNetCore.Authentication.Facebook/{ => Internal}/FacebookConfigureOptions.cs (78%) rename src/Microsoft.AspNetCore.Authentication.Google/{ => Internal}/GoogleConfigureOptions.cs (79%) rename src/Microsoft.AspNetCore.Authentication.JwtBearer/{ => Internal}/JwtBearerConfigureOptions.cs (79%) rename src/Microsoft.AspNetCore.Authentication.JwtBearer/{JwtBearerInitializer.cs => JwtBearerPostConfigureOptions.cs} (89%) rename src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/{ => Internal}/MicrosoftAccountConfigureOptions.cs (78%) rename src/Microsoft.AspNetCore.Authentication.OAuth/{OAuthInitializer.cs => OAuthPostConfigureOptions.cs} (86%) rename src/Microsoft.AspNetCore.Authentication.OpenIdConnect/{ => Internal}/OpenIdConnectConfigureOptions.cs (91%) rename src/Microsoft.AspNetCore.Authentication.OpenIdConnect/{OpenIdConnectInitializer.cs => OpenIdConnectPostConfigureOptions.cs} (91%) rename src/Microsoft.AspNetCore.Authentication.Twitter/{ => Internal}/TwitterConfigureOptions.cs (80%) rename src/Microsoft.AspNetCore.Authentication.Twitter/{TwitterInitializer.cs => TwitterPostConfigureOptions.cs} (81%) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs similarity index 81% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs index af4a85b19..38211e0f1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs @@ -10,21 +10,21 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Used to setup defaults for all . /// - public class CookieAuthenticationInitializer : IInitializeOptions + public class PostConfigureCookieAuthenticationOptions : IPostConfigureOptions { private readonly IDataProtectionProvider _dp; - public CookieAuthenticationInitializer(IDataProtectionProvider dataProtection) + public PostConfigureCookieAuthenticationOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } /// - /// Invoked to initialize a TOptions instance. + /// Invoked to post configure a TOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, CookieAuthenticationOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, CookieAuthenticationOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index b528dec9c..6f23abcc4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -21,7 +21,7 @@ public static IServiceCollection AddCookieAuthentication(this IServiceCollection public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, CookieAuthenticationInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); return services.AddScheme(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 1bb065414..7d6fb8442 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Facebook; +using Microsoft.AspNetCore.Authentication.Facebook.Internal; using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs similarity index 78% rename from src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs index 887789ebf..df1ab710b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.Facebook +namespace Microsoft.AspNetCore.Authentication.Facebook.Internal { - internal class FacebookConfigureOptions : ConfigureDefaultOptions + public class FacebookConfigureOptions : ConfigureDefaultOptions { public FacebookConfigureOptions(IConfiguration config) : base(FacebookDefaults.AuthenticationScheme, diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index c11b155d9..07d3e16d6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.AspNetCore.Authentication.Google.Internal; using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs similarity index 79% rename from src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs index 1041f1eec..bbc5e208a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.Google +namespace Microsoft.AspNetCore.Authentication.Google.Internal { - internal class GoogleConfigureOptions : ConfigureDefaultOptions + public class GoogleConfigureOptions : ConfigureDefaultOptions { public GoogleConfigureOptions(IConfiguration config) : base(GoogleDefaults.AuthenticationScheme, diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs similarity index 79% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs index d26bf6671..5c1e931f4 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.JwtBearer +namespace Microsoft.AspNetCore.Authentication.JwtBearer.Internal { - internal class JwtBearerConfigureOptions : ConfigureDefaultOptions + public class JwtBearerConfigureOptions : ConfigureDefaultOptions { // Bind to "Bearer" section by default public JwtBearerConfigureOptions(IConfiguration config) : diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 0bd3a9400..134e99920 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authentication.JwtBearer.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Infrastructure; @@ -19,7 +20,7 @@ public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollect public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); services.AddSingleton, JwtBearerConfigureOptions>(); return services.AddScheme(authenticationScheme, configureOptions); } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs similarity index 89% rename from src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs index 0aeed1183..8829bfac0 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerPostConfigureOptions.cs @@ -12,14 +12,14 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer /// /// Used to setup defaults for all . /// - public class JwtBearerInitializer : IInitializeOptions + public class JwtBearerPostConfigureOptions : IPostConfigureOptions { /// - /// Invoked to initialize a JwtBearerOptions instance. + /// Invoked to post configure a JwtBearerOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, JwtBearerOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, JwtBearerOptions options) { if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(options.Audience)) { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs similarity index 78% rename from src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs index b0be3de97..60591e1e4 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount +namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal { - internal class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions + public class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions { // Bind to "Microsoft" section by default public MicrosoftAccountConfigureOptions(IConfiguration config) : diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 1a7fee370..ff743c972 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; +using Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal; using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 257aed9cb..4ad0a8336 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -19,7 +19,7 @@ public static IServiceCollection AddOAuthAuthentication(this where TOptions : OAuthOptions, new() where THandler : OAuthHandler { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs similarity index 86% rename from src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs index 99f65253a..e97346413 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthPostConfigureOptions.cs @@ -12,18 +12,18 @@ namespace Microsoft.Extensions.DependencyInjection /// /// Used to setup defaults for the OAuthOptions. /// - public class OAuthInitializer : IInitializeOptions + public class OAuthPostConfigureOptions : IPostConfigureOptions where TOptions : OAuthOptions, new() where THandler : OAuthHandler { private readonly IDataProtectionProvider _dp; - public OAuthInitializer(IDataProtectionProvider dataProtection) + public OAuthPostConfigureOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } - public void Initialize(string name, TOptions options) + public void PostConfigure(string name, TOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; if (options.Backchannel == null) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs similarity index 91% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs index 1a6450b7b..c39518515 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal { internal class OpenIdConnectConfigureOptions : ConfigureDefaultOptions { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index b4ac4b9fb..6c965f047 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Infrastructure; @@ -19,7 +20,7 @@ public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCol public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); services.AddSingleton, OpenIdConnectConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs similarity index 91% rename from src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs index 7421af9c0..b79f1d1ed 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectPostConfigureOptions.cs @@ -14,21 +14,21 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// Used to setup defaults for all . /// - public class OpenIdConnectInitializer : IInitializeOptions + public class OpenIdConnectPostConfigureOptions : IPostConfigureOptions { private readonly IDataProtectionProvider _dp; - public OpenIdConnectInitializer(IDataProtectionProvider dataProtection) + public OpenIdConnectPostConfigureOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } /// - /// Invoked to initialize a TOptions instance. + /// Invoked to post configure a TOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, OpenIdConnectOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, OpenIdConnectOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs similarity index 80% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs index 03d7ae809..62982fa19 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs @@ -4,9 +4,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options.Infrastructure; -namespace Microsoft.AspNetCore.Authentication.Twitter +namespace Microsoft.AspNetCore.Authentication.Twitter.Internal { - internal class TwitterConfigureOptions : ConfigureDefaultOptions + public class TwitterConfigureOptions : ConfigureDefaultOptions { // Bind to "Twitter" section by default public TwitterConfigureOptions(IConfiguration config) : diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index 11586f984..dac9ee351 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNetCore.Authentication.Twitter; +using Microsoft.AspNetCore.Authentication.Twitter.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Infrastructure; @@ -19,7 +20,7 @@ public static IServiceCollection AddTwitterAuthentication(this IServiceCollectio public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { - services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterInitializer>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); services.AddSingleton, TwitterConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs similarity index 81% rename from src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs rename to src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs index 08e9c5b83..09db5699f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterInitializer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterPostConfigureOptions.cs @@ -10,21 +10,21 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Used to setup defaults for all . /// - public class TwitterInitializer : IInitializeOptions + public class TwitterPostConfigureOptions : IPostConfigureOptions { private readonly IDataProtectionProvider _dp; - public TwitterInitializer(IDataProtectionProvider dataProtection) + public TwitterPostConfigureOptions(IDataProtectionProvider dataProtection) { _dp = dataProtection; } /// - /// Invoked to initialize a TOptions instance. + /// Invoked to post configure a TOptions instance. /// - /// The name of the options instance being initialized. - /// The options instance to initialize. - public void Initialize(string name, TwitterOptions options) + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, TwitterOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs index 55bc09d8a..0e86b3a9f 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -2,18 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Authentication { - public class InitializeAuthenticationSchemeOptions : InitializeOptions - where TOptions : AuthenticationSchemeOptions - { - public InitializeAuthenticationSchemeOptions(string name) - : base(name, options => options.ClaimsIssuer = options.ClaimsIssuer ?? name) - { } - } - /// /// Contains the options used by the . /// diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index ff367f555..7ebc979f1 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -79,12 +77,12 @@ public static IServiceCollection AddRemoteScheme(this IServi where TOptions : RemoteAuthenticationOptions, new() where THandler : RemoteAuthenticationHandler { - services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); + services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); return services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); } // Used to ensure that there's always a default data protection provider - private class EnsureSignInScheme : IInitializeOptions where TOptions : RemoteAuthenticationOptions + private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { private readonly AuthenticationOptions _authOptions; @@ -93,7 +91,7 @@ public EnsureSignInScheme(IOptions authOptions) _authOptions = authOptions.Value; } - public void Initialize(string name, TOptions options) + public void PostConfigure(string name, TOptions options) { options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme; } From ae3dfcdb32647473e24f7c03aa6cb13e83bb7577 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 5 Jun 2017 11:34:35 -0700 Subject: [PATCH 020/248] Remote ConfigureDefaultOptions --- .../FacebookExtensions.cs | 7 +-- .../Internal/FacebookConfigureOptions.cs | 16 ----- ....AspNetCore.Authentication.Facebook.csproj | 1 - .../GoogleExtensions.cs | 7 +-- .../Internal/GoogleConfigureOptions.cs | 16 ----- ...ft.AspNetCore.Authentication.Google.csproj | 1 - .../Internal/JwtBearerConfigureOptions.cs | 17 ----- .../JwtBearerExtensions.cs | 3 - ...AspNetCore.Authentication.JwtBearer.csproj | 1 - .../MicrosoftAccountConfigureOptions.cs | 17 ----- ...ore.Authentication.MicrosoftAccount.csproj | 1 - .../MicrosoftAccountExtensions.cs | 7 +-- .../Internal/OpenIdConnectConfigureOptions.cs | 17 ----- ...etCore.Authentication.OpenIdConnect.csproj | 1 - .../OpenIdConnectExtensions.cs | 3 - .../Internal/TwitterConfigureOptions.cs | 17 ----- ...t.AspNetCore.Authentication.Twitter.csproj | 1 - .../TwitterExtensions.cs | 3 - .../FacebookTests.cs | 63 ------------------- .../GoogleTests.cs | 60 ------------------ .../JwtBearerTests.cs | 62 ------------------ .../MicrosoftAccountTests.cs | 60 ------------------ .../OpenIdConnect/OpenIdConnectTests.cs | 28 --------- .../TwitterTests.cs | 54 ---------------- 24 files changed, 3 insertions(+), 460 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 7d6fb8442..4f30b9ba9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -3,8 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.Facebook; -using Microsoft.AspNetCore.Authentication.Facebook.Internal; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -17,9 +15,6 @@ public static IServiceCollection AddFacebookAuthentication(this IServiceCollecti => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.AddSingleton, FacebookConfigureOptions>(); - return services.AddOAuthAuthentication(authenticationScheme, configureOptions); - } + => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs deleted file mode 100644 index df1ab710b..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Internal/FacebookConfigureOptions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.Facebook.Internal -{ - public class FacebookConfigureOptions : ConfigureDefaultOptions - { - public FacebookConfigureOptions(IConfiguration config) : - base(FacebookDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+FacebookDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index e39b31e90..a939958e2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index 07d3e16d6..be40822c5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -3,8 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.Google; -using Microsoft.AspNetCore.Authentication.Google.Internal; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -17,9 +15,6 @@ public static IServiceCollection AddGoogleAuthentication(this IServiceCollection => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.AddSingleton, GoogleConfigureOptions>(); - return services.AddOAuthAuthentication(authenticationScheme, configureOptions); - } + => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs deleted file mode 100644 index bbc5e208a..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/Internal/GoogleConfigureOptions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.Google.Internal -{ - public class GoogleConfigureOptions : ConfigureDefaultOptions - { - public GoogleConfigureOptions(IConfiguration config) : - base(GoogleDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+GoogleDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index c4f1e7ad8..9f4cee9d5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs deleted file mode 100644 index 5c1e931f4..000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Internal/JwtBearerConfigureOptions.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.JwtBearer.Internal -{ - public class JwtBearerConfigureOptions : ConfigureDefaultOptions - { - // Bind to "Bearer" section by default - public JwtBearerConfigureOptions(IConfiguration config) : - base(JwtBearerDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+JwtBearerDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 134e99920..582eb6314 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -3,10 +3,8 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Authentication.JwtBearer.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -21,7 +19,6 @@ public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollect public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); - services.AddSingleton, JwtBearerConfigureOptions>(); return services.AddScheme(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 5b25e00e8..73d8fdd00 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -11,7 +11,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs deleted file mode 100644 index 60591e1e4..000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Internal/MicrosoftAccountConfigureOptions.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal -{ - public class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions - { - // Bind to "Microsoft" section by default - public MicrosoftAccountConfigureOptions(IConfiguration config) : - base(MicrosoftAccountDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+MicrosoftAccountDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 1a954c850..1accdf8f1 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index ff743c972..a4ad5692c 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -3,8 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; -using Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -17,9 +15,6 @@ public static IServiceCollection AddMicrosoftAccountAuthentication(this IService => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.AddSingleton, MicrosoftAccountConfigureOptions>(); - return services.AddOAuthAuthentication(authenticationScheme, configureOptions); - } + => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs deleted file mode 100644 index c39518515..000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Internal/OpenIdConnectConfigureOptions.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal -{ - internal class OpenIdConnectConfigureOptions : ConfigureDefaultOptions - { - // Bind to "OpenIdConnect" section by default - public OpenIdConnectConfigureOptions(IConfiguration config) : - base(OpenIdConnectDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+OpenIdConnectDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 0ce2fe34e..8e4fb774d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -12,6 +12,5 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index 6c965f047..d57640904 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -3,10 +3,8 @@ using System; using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -21,7 +19,6 @@ public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCol public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); - services.AddSingleton, OpenIdConnectConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs deleted file mode 100644 index 62982fa19..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Internal/TwitterConfigureOptions.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore.Authentication.Twitter.Internal -{ - public class TwitterConfigureOptions : ConfigureDefaultOptions - { - // Bind to "Twitter" section by default - public TwitterConfigureOptions(IConfiguration config) : - base(TwitterDefaults.AuthenticationScheme, - options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+TwitterDefaults.AuthenticationScheme).Bind(options)) - { } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index b78de6597..6bf4a66d3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index dac9ee351..d8b78398f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -3,10 +3,8 @@ using System; using Microsoft.AspNetCore.Authentication.Twitter; -using Microsoft.AspNetCore.Authentication.Twitter.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.Extensions.DependencyInjection { @@ -21,7 +19,6 @@ public static IServiceCollection AddTwitterAuthentication(this IServiceCollectio public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); - services.AddSingleton, TwitterConfigureOptions>(); return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 657c957bf..b463ef891 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -20,7 +20,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -40,68 +39,6 @@ public async Task VerifySchemeDefaults() Assert.Equal(FacebookDefaults.AuthenticationScheme, scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppId", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AuthorizationEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:BackchannelTimeout", "0.0:0:30"}, - //{"Facebook:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SaveTokens", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SendAppSecretProof", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SignInScheme", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:TokenEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Facebook:UserInformationEndpoint", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddFacebookAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(FacebookDefaults.AuthenticationScheme); - Assert.Equal("", options.AppId); - Assert.Equal("", options.AppSecret); - Assert.Equal("", options.AuthorizationEndpoint); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert - Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.ClientId); - Assert.Equal("", options.ClientSecret); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); - Assert.True(options.SaveTokens); - Assert.True(options.SendAppSecretProof); - Assert.Equal("", options.SignInScheme); - Assert.Equal("", options.TokenEndpoint); - Assert.Equal("", options.UserInformationEndpoint); - } - - [Fact] - public void AddWithDelegateIgnoresConfig() - { - var dic = new Dictionary - { - {"Facebook:AppId", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddFacebookAuthentication(o => o.SaveTokens = false).AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(FacebookDefaults.AuthenticationScheme); - Assert.Null(options.AppId); - Assert.False(options.SaveTokens); - } - [Fact] public async Task ThrowsIfAppIdMissing() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index b316e6275..501fdf603 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -19,7 +19,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -39,65 +38,6 @@ public async Task VerifySchemeDefaults() Assert.Equal(GoogleDefaults.AuthenticationScheme, scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientId", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:AuthorizationEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:BackchannelTimeout", "0.0:0:30"}, - //{"Google:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:AspNetCore:Authentication:Schemes:Google:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:SaveTokens", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:SendAppSecretProof", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:SignInScheme", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:TokenEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Google:UserInformationEndpoint", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddGoogleAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(GoogleDefaults.AuthenticationScheme); - Assert.Equal("", options.AuthorizationEndpoint); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert - Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.ClientId); - Assert.Equal("", options.ClientSecret); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); - Assert.True(options.SaveTokens); - Assert.Equal("", options.SignInScheme); - Assert.Equal("", options.TokenEndpoint); - Assert.Equal("", options.UserInformationEndpoint); - } - - [Fact] - public void AddWithDelegateIgnoresConfig() - { - var dic = new Dictionary - { - {"Google:ClientId", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddGoogleAuthentication(o => o.SaveTokens = false).AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(GoogleDefaults.AuthenticationScheme); - Assert.Null(options.ClientId); - Assert.False(options.SaveTokens); - } - [Fact] public async Task ChallengeWillTriggerRedirection() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 6746f5c3f..3149e9875 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -19,7 +19,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Microsoft.IdentityModel.Tokens; using Xunit; @@ -39,67 +38,6 @@ public async Task VerifySchemeDefaults() Assert.Null(scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:BackchannelTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Challenge", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:IncludeErrorDetails", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:MetadataAddress", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RefreshOnIssuerKeyNotFound", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:SaveToken", "true"}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddJwtBearerAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - Assert.Equal("", options.Audience); - Assert.Equal("", options.Authority); - Assert.Equal("", options.Challenge); - Assert.Equal("", options.ClaimsIssuer); - Assert.True(options.IncludeErrorDetails); - Assert.Equal("", options.MetadataAddress); - Assert.True(options.RefreshOnIssuerKeyNotFound); - Assert.False(options.RequireHttpsMetadata); - Assert.True(options.SaveToken); - } - - [Fact] - public void AddWithDelegateOverridesConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"} - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddJwtBearerAuthentication(o => o.Authority = "authority") - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(JwtBearerDefaults.AuthenticationScheme); - Assert.Equal("", options.Audience); - Assert.Equal("authority", options.Authority); - } - [ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")] [FrameworkSkipCondition(RuntimeFrameworks.Mono)] // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179 diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 0d49052f5..bf15c91b0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -20,7 +20,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Newtonsoft.Json; using Xunit; @@ -40,65 +39,6 @@ public async Task VerifySchemeDefaults() Assert.Equal(MicrosoftAccountDefaults.AuthenticationScheme, scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientId", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:AuthorizationEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:BackchannelTimeout", "0.0:0:30"}, - //{"Microsoft:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SaveTokens", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SendAppSecretProof", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SignInScheme", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:TokenEndpoint", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:UserInformationEndpoint", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddMicrosoftAccountAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(MicrosoftAccountDefaults.AuthenticationScheme); - Assert.Equal("", options.AuthorizationEndpoint); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert - Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.ClientId); - Assert.Equal("", options.ClientSecret); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); - Assert.True(options.SaveTokens); - Assert.Equal("", options.SignInScheme); - Assert.Equal("", options.TokenEndpoint); - Assert.Equal("", options.UserInformationEndpoint); - } - - [Fact] - public void AddWithDelegateIgnoresConfig() - { - var dic = new Dictionary - { - {"Microsoft:ClientId", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddMicrosoftAccountAuthentication(o => o.SaveTokens = true).AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(MicrosoftAccountDefaults.AuthenticationScheme); - Assert.Null(options.ClientId); - Assert.True(options.SaveTokens); - } - [Fact] public async Task ChallengeWillTriggerApplyRedirectEvent() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 9dc597b85..1708e604e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -15,7 +15,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; @@ -30,33 +29,6 @@ public class OpenIdConnectTests const string Signin = "/signin"; const string Signout = "/signout"; - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientId", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:RequireHttpsMetadata", "false"}, - {"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:Authority", ""} - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddOpenIdConnectAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(OpenIdConnectDefaults.AuthenticationScheme); - Assert.Equal("", options.ClientId); - Assert.Equal("", options.ClientSecret); - Assert.Equal("", options.Authority); - Assert.False(options.RequireHttpsMetadata); - } - - /// /// Tests RedirectForSignOutContext replaces the OpenIdConnectMesssage correctly. /// summary> diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index b8af66cdf..8fcc0780d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -14,7 +14,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -33,59 +32,6 @@ public async Task VerifySchemeDefaults() Assert.Equal(TwitterDefaults.AuthenticationScheme, scheme.DisplayName); } - [Fact] - public void AddCanBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerKey", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerSecret", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:BackchannelTimeout", "0.0:0:30"}, - //{"Twitter:CallbackPath", "/callbackpath"}, // PathString doesn't convert - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ClaimsIssuer", ""}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:RemoteAuthenticationTimeout", "0.0:0:30"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SaveTokens", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SendAppSecretProof", "true"}, - {"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SignInScheme", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton, ConfigureDefaults>() - .AddTwitterAuthentication() - .AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(TwitterDefaults.AuthenticationScheme); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout); - //Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert - Assert.Equal("", options.ClaimsIssuer); - Assert.Equal("", options.ConsumerKey); - Assert.Equal("", options.ConsumerSecret); - Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout); - Assert.True(options.SaveTokens); - Assert.Equal("", options.SignInScheme); - } - - [Fact] - public void AddWithDelegateIgnoresConfig() - { - var dic = new Dictionary - { - {"Twitter:ConsumerKey", ""}, - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection().AddTwitterAuthentication(o => o.SaveTokens = true).AddSingleton(config); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Get(TwitterDefaults.AuthenticationScheme); - Assert.Null(options.ConsumerKey); - Assert.True(options.SaveTokens); - } - [Fact] public async Task ChallengeWillTriggerApplyRedirectEvent() { From b7958935429487f04e28b729d3214ddebc36a0eb Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 5 Jun 2017 14:04:33 -0700 Subject: [PATCH 021/248] Remove rogue using --- .../GoogleAppBuilderExtensions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs index d2687239b..ec7e8a7aa 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -3,7 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.Google; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; From a561da0b3f86b8b242768f47d3283319311ddc2c Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 6 Jun 2017 15:41:17 -0700 Subject: [PATCH 022/248] Remove itemgroup from csproj with unreachable code --- .../Microsoft.AspNetCore.Authorization.Policy.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index 5123b7069..b8447e415 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -20,8 +20,4 @@ - - - - From 4a258b4565aedd084df05243f679e7dc81e3919b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 8 Jun 2017 08:43:38 -0700 Subject: [PATCH 023/248] Remove usage of TaskCache --- .../CookieAuthenticationHandler.cs | 5 +---- .../Events/CookieAuthenticationEvents.cs | 17 ++++++++--------- ...t.AspNetCore.Authentication.Cookies.csproj | 1 - .../Events/JwtBearerEvents.cs | 9 ++++----- .../JwtBearerAppBuilderExtensions.cs | 1 - ...AspNetCore.Authentication.JwtBearer.csproj | 1 - .../Events/OAuthEvents.cs | 5 ++--- ...oft.AspNetCore.Authentication.OAuth.csproj | 1 - .../Events/OpenIdConnectEvents.cs | 19 +++++++++---------- ...etCore.Authentication.OpenIdConnect.csproj | 1 - .../Events/TwitterEvents.cs | 5 ++--- ...t.AspNetCore.Authentication.Twitter.csproj | 1 - .../AuthenticationHandler.cs | 11 +++++------ .../Events/RemoteAuthenticationEvents.cs | 5 ++--- ...Microsoft.AspNetCore.Authentication.csproj | 1 - ...oft.AspNetCore.Authorization.Policy.csproj | 1 - .../ClaimsAuthorizationRequirement.cs | 3 +-- .../DenyAnonymousAuthorizationRequirement.cs | 3 +-- .../NameAuthorizationRequirement.cs | 3 +-- .../RolesAuthorizationRequirement.cs | 3 +-- .../Microsoft.AspNetCore.Authorization.csproj | 1 - 21 files changed, 37 insertions(+), 60 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index bb2c10fee..9b04026cd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -6,11 +6,8 @@ using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; @@ -50,7 +47,7 @@ protected override Task InitializeHandlerAsync() { // Cookies needs to finish the response Context.Response.OnStarting(FinishResponseAsync); - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs index 5cb933ce1..c7c375de2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs @@ -4,7 +4,6 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -18,22 +17,22 @@ public class CookieAuthenticationEvents /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnValidatePrincipal { get; set; } = context => TaskCache.CompletedTask; + public Func OnValidatePrincipal { get; set; } = context => Task.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnSigningIn { get; set; } = context => TaskCache.CompletedTask; + public Func OnSigningIn { get; set; } = context => Task.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnSignedIn { get; set; } = context => TaskCache.CompletedTask; + public Func OnSignedIn { get; set; } = context => Task.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnSigningOut { get; set; } = context => TaskCache.CompletedTask; + public Func OnSigningOut { get; set; } = context => Task.CompletedTask; /// /// A delegate assigned to this property will be invoked when the related method is called. @@ -49,7 +48,7 @@ public class CookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// @@ -66,7 +65,7 @@ public class CookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// @@ -82,7 +81,7 @@ public class CookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// @@ -98,7 +97,7 @@ public class CookieAuthenticationEvents { context.Response.Redirect(context.RedirectUri); } - return TaskCache.CompletedTask; + return Task.CompletedTask; }; private static bool IsAjaxRequest(HttpRequest request) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 41c4ff790..95aebf38b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -18,7 +18,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs index c4e2e7b5a..a9b35c310 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerEvents.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.JwtBearer { @@ -15,22 +14,22 @@ public class JwtBearerEvents /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. /// - public Func OnAuthenticationFailed { get; set; } = context => TaskCache.CompletedTask; + public Func OnAuthenticationFailed { get; set; } = context => Task.CompletedTask; /// /// Invoked when a protocol message is first received. /// - public Func OnMessageReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnMessageReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. /// - public Func OnTokenValidated { get; set; } = context => TaskCache.CompletedTask; + public Func OnTokenValidated { get; set; } = context => Task.CompletedTask; /// /// Invoked before a challenge is sent back to the caller. /// - public Func OnChallenge { get; set; } = context => TaskCache.CompletedTask; + public Func OnChallenge { get; set; } = context => Task.CompletedTask; public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index 6b1b1afd4..9755c5cb7 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -3,7 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 73d8fdd00..3c55004a4 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -11,6 +11,5 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs index 4e94a15bc..b3572cab4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.OAuth { @@ -15,7 +14,7 @@ public class OAuthEvents : RemoteAuthenticationEvents /// /// Gets or sets the function that is invoked when the CreatingTicket method is invoked. /// - public Func OnCreatingTicket { get; set; } = context => TaskCache.CompletedTask; + public Func OnCreatingTicket { get; set; } = context => Task.CompletedTask; /// /// Gets or sets the delegate that is invoked when the RedirectToAuthorizationEndpoint method is invoked. @@ -23,7 +22,7 @@ public class OAuthEvents : RemoteAuthenticationEvents public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 508c815fe..88d6794e9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index f6386aeec..660eba0b3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { @@ -15,47 +14,47 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents /// /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. /// - public Func OnAuthenticationFailed { get; set; } = context => TaskCache.CompletedTask; + public Func OnAuthenticationFailed { get; set; } = context => Task.CompletedTask; /// /// Invoked after security token validation if an authorization code is present in the protocol message. /// - public Func OnAuthorizationCodeReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnAuthorizationCodeReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked when a protocol message is first received. /// - public Func OnMessageReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnMessageReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked before redirecting to the identity provider to authenticate. /// - public Func OnRedirectToIdentityProvider { get; set; } = context => TaskCache.CompletedTask; + public Func OnRedirectToIdentityProvider { get; set; } = context => Task.CompletedTask; /// /// Invoked before redirecting to the identity provider to sign out. /// - public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => TaskCache.CompletedTask; + public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => Task.CompletedTask; /// /// Invoked when a request is received on the RemoteSignOutPath. /// - public Func OnRemoteSignOut { get; set; } = context => TaskCache.CompletedTask; + public Func OnRemoteSignOut { get; set; } = context => Task.CompletedTask; /// /// Invoked after "authorization code" is redeemed for tokens at the token endpoint. /// - public Func OnTokenResponseReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnTokenResponseReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked when an IdToken has been validated and produced an AuthenticationTicket. /// - public Func OnTokenValidated { get; set; } = context => TaskCache.CompletedTask; + public Func OnTokenValidated { get; set; } = context => Task.CompletedTask; /// /// Invoked when user information is retrieved from the UserInfoEndpoint. /// - public Func OnUserInformationReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnUserInformationReceived { get; set; } = context => Task.CompletedTask; public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 8e4fb774d..d3789cd50 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -10,7 +10,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs index 2c8b30e9f..c079ebb14 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication.Twitter { @@ -15,7 +14,7 @@ public class TwitterEvents : RemoteAuthenticationEvents /// /// Gets or sets the function that is invoked when the Authenticated method is invoked. /// - public Func OnCreatingTicket { get; set; } = context => TaskCache.CompletedTask; + public Func OnCreatingTicket { get; set; } = context => Task.CompletedTask; /// /// Gets or sets the delegate that is invoked when the ApplyRedirect method is invoked. @@ -23,7 +22,7 @@ public class TwitterEvents : RemoteAuthenticationEvents public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); - return TaskCache.CompletedTask; + return Task.CompletedTask; }; /// diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 6bf4a66d3..8d834ee8d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -13,7 +13,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index b09470919..788df7e19 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -119,7 +118,7 @@ protected virtual async Task InitializeEventsAsync() /// A task protected virtual Task InitializeHandlerAsync() { - return TaskCache.CompletedTask; + return Task.CompletedTask; } protected string BuildRedirectUri(string targetPath) @@ -193,7 +192,7 @@ public async Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties pro protected virtual Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } public async Task SignOutAsync(AuthenticationProperties properties) @@ -205,7 +204,7 @@ public async Task SignOutAsync(AuthenticationProperties properties) protected virtual Task HandleSignOutAsync(AuthenticationProperties properties) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// @@ -216,7 +215,7 @@ protected virtual Task HandleSignOutAsync(AuthenticationProperties properties) protected virtual Task HandleForbiddenAsync(AuthenticationProperties properties) { Response.StatusCode = 403; - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// @@ -229,7 +228,7 @@ protected virtual Task HandleForbiddenAsync(AuthenticationProperties properties) protected virtual Task HandleChallengeAsync(AuthenticationProperties properties) { Response.StatusCode = 401; - return TaskCache.CompletedTask; + return Task.CompletedTask; } public async Task ChallengeAsync(AuthenticationProperties properties) diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs index a130c1b14..83a6507d4 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -3,15 +3,14 @@ using System; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authentication { public class RemoteAuthenticationEvents { - public Func OnRemoteFailure { get; set; } = context => TaskCache.CompletedTask; + public Func OnRemoteFailure { get; set; } = context => Task.CompletedTask; - public Func OnTicketReceived { get; set; } = context => TaskCache.CompletedTask; + public Func OnTicketReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked when there is a remote failure diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index cbdb05b58..adbd5b3f1 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -19,7 +19,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index b8447e415..83530a2be 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -17,7 +17,6 @@ - diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs index 4248e4813..93b1deea6 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/ClaimsAuthorizationRequirement.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -68,7 +67,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte context.Succeed(requirement); } } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs index 5bae319b3..e88cce7aa 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/DenyAnonymousAuthorizationRequirement.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -28,7 +27,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte { context.Succeed(requirement); } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs index 9fb295082..02ab946fa 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/NameAuthorizationRequirement.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -47,7 +46,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte context.Succeed(requirement); } } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs index 44e2b9a22..811e17aac 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/RolesAuthorizationRequirement.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Authorization.Infrastructure { @@ -62,7 +61,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte context.Succeed(requirement); } } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 0022d2743..15100fbbc 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -17,7 +17,6 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - From d6f2767d1aefde024279a3bcb6774f8f2b46e7c1 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 9 Jun 2017 15:45:35 -0700 Subject: [PATCH 024/248] Update Microsoft.IdentityModel.Clients.ActiveDirectory version to 3.13.9 --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 02a36ec83..1fd0f3155 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,7 +2,7 @@ 2.0.0-preview2-* 4.4.0-* - 3.13.8 + 3.13.9 2.1.3 2.1.0-* 10.0.1 From bc3c4e9f12f432f69abc5a9d6ee42573cef5818e Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 9 Jun 2017 16:23:47 -0700 Subject: [PATCH 025/248] #1200 Doc comments for OnRedirectToIdentityProvider --- .../Events/OpenIdConnectEvents.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index 660eba0b3..d8467be8d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -27,7 +27,9 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents public Func OnMessageReceived { get; set; } = context => Task.CompletedTask; /// - /// Invoked before redirecting to the identity provider to authenticate. + /// Invoked before redirecting to the identity provider to authenticate. This can be used to set ProtocolMessage.State + /// that will be persisted through the authentication process. The ProtocolMessage can also be used to add or customize + /// parameters sent to the identity provider. /// public Func OnRedirectToIdentityProvider { get; set; } = context => Task.CompletedTask; From 9797d4bc5f3e54ffca3487c038044990585e278c Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 12 Jun 2017 14:58:11 -0700 Subject: [PATCH 026/248] Reenable API check --- ...t.AspNetCore.Authentication.Cookies.csproj | 1 - .../breakingchanges.netcore.json | 87 ++++++++++++ ....AspNetCore.Authentication.Facebook.csproj | 1 - .../breakingchanges.netcore.json | 19 +++ ...ft.AspNetCore.Authentication.Google.csproj | 1 - .../breakingchanges.netcore.json | 40 ++++++ ...AspNetCore.Authentication.JwtBearer.csproj | 1 - .../breakingchanges.netcore.json | 58 ++++++++ ...ore.Authentication.MicrosoftAccount.csproj | 1 - .../breakingchanges.netcore.json | 19 +++ ...oft.AspNetCore.Authentication.OAuth.csproj | 1 - .../breakingchanges.netcore.json | 46 +++++++ ...etCore.Authentication.OpenIdConnect.csproj | 1 - .../breakingchanges.netcore.json | 117 ++++++++++++++++ ...t.AspNetCore.Authentication.Twitter.csproj | 1 - .../breakingchanges.netcore.json | 62 +++++++++ ...Microsoft.AspNetCore.Authentication.csproj | 1 - .../breakingchanges.netcore.json | 126 ++++++++++++++++++ 18 files changed, 574 insertions(+), 9 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 95aebf38b..712aa8177 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -9,7 +9,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json new file mode 100644 index 000000000..c223c035c --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json @@ -0,0 +1,87 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext : Microsoft.AspNetCore.Authentication.BaseContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents : Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.CookieAuthenticationOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions, Microsoft.Extensions.Options.IOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Authentication.AuthenticationTicket ticket, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, Microsoft.AspNetCore.Http.CookieOptions cookieOptions)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String authenticationScheme, System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String authenticationScheme, System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, Microsoft.AspNetCore.Http.CookieOptions cookieOptions)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String redirectUri, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseCookieAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index a939958e2..a9ec57199 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json new file mode 100644 index 000000000..f64e6b834 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json @@ -0,0 +1,19 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.FacebookOptions : Microsoft.AspNetCore.Builder.OAuthOptions", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseFacebookAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.FacebookOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index 9f4cee9d5..805de682f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json new file mode 100644 index 000000000..db3d1fcf0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json @@ -0,0 +1,40 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.GoogleOptions : Microsoft.AspNetCore.Builder.OAuthOptions", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.GoogleAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseGoogleAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.GoogleOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetFamilyName(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetGivenName(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetId(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetName(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "MemberId": "public static System.String GetProfile(Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 3c55004a4..fe0bda164 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -6,7 +6,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json new file mode 100644 index 000000000..d810a2bb9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json @@ -0,0 +1,58 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents : Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.JwtBearerOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public Microsoft.AspNetCore.Builder.JwtBearerOptions get_Options()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJwtBearerAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 1accdf8f1..9437b5727 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json new file mode 100644 index 000000000..66f2a77b4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json @@ -0,0 +1,19 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.MicrosoftAccountOptions : Microsoft.AspNetCore.Builder.OAuthOptions", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.MicrosoftAccountAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseMicrosoftAccountAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.MicrosoftAccountOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 88d6794e9..a15a75ee6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json new file mode 100644 index 000000000..96fd03e98 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json @@ -0,0 +1,46 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext : Microsoft.AspNetCore.Authentication.BaseContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.OAuthOptions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware where T0 : Microsoft.AspNetCore.Builder.OAuthOptions, new()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.OAuthOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OAuthOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, System.String redirectUri)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public Microsoft.AspNetCore.Builder.OAuthOptions get_Options()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOAuthAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OAuthOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index d3789cd50..ae8ffd8d5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -6,7 +6,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json new file mode 100644 index 000000000..4ba3fb756 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json @@ -0,0 +1,117 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.OpenIdConnectOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public Microsoft.AspNetCore.Builder.OpenIdConnectOptions get_Options()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage message)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOpenIdConnectAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index 8d834ee8d..d9c5cd0b3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json new file mode 100644 index 000000000..2023eb0b7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json @@ -0,0 +1,62 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext : Microsoft.AspNetCore.Authentication.BaseContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.TwitterOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.TwitterOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, System.String redirectUri)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.TwitterOptions options, System.String userId, System.String screenName, System.String accessToken, System.String accessTokenSecret, Newtonsoft.Json.Linq.JObject user)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseTwitterAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.TwitterOptions options)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index adbd5b3f1..8a1f97042 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -8,7 +8,6 @@ $(NoWarn);CS1591 true aspnetcore;authentication;security - false diff --git a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json new file mode 100644 index 000000000..0eb0bfaf5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json @@ -0,0 +1,126 @@ + [ + { + "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.AuthenticationHandler : Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.AuthenticationMiddleware where T0 : Microsoft.AspNetCore.Builder.AuthenticationOptions, new()", + "Kind": "Removal" + }, + { + "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public abstract class Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticateResult", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticationToken", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler : Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformer : Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.PropertiesDataFormat : Microsoft.AspNetCore.Authentication.SecureDataFormat", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.PropertiesSerializer : Microsoft.AspNetCore.Authentication.IDataSerializer", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Kind": "Removal" + }, + { + "TypeId": "public interface Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions options, Microsoft.AspNetCore.Authentication.AuthenticationTicket ticket)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions get_Options()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public System.Void set_Options(Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configureOptions)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public System.Boolean CheckEventResult(out Microsoft.AspNetCore.Authentication.AuthenticateResult result)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", + "MemberId": "public System.Void SkipToNextMiddleware()", + "Kind": "Removal" + } + ] \ No newline at end of file From 200ce723120a9e5672aa9d2ee07ce5422bcb0a5e Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 13 Jun 2017 11:51:00 -0700 Subject: [PATCH 027/248] Rename PostLogoutRedirectUri to avoid spec confusion --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- .../OpenIdConnectHandler.cs | 2 +- .../OpenIdConnectOptions.cs | 5 +++-- .../OpenIdConnect/OpenIdConnectTests.cs | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index ebb59c060..e6ad7804d 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -58,7 +58,7 @@ public void ConfigureServices(IServiceCollection services) o.ClientSecret = ClientSecret; // for code flow o.Authority = Authority; o.ResponseType = OpenIdConnectResponseType.CodeIdToken; - o.PostLogoutRedirectUri = "/signed-out"; + o.SignedOutRedirectUri = "/signed-out"; // GetClaimsFromUserInfoEndpoint = true, o.Events = new OpenIdConnectEvents() { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 89d949a00..f4dcea4c8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -182,7 +182,7 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper // Get the post redirect URI. if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = BuildRedirectUriIfRelative(Options.PostLogoutRedirectUri); + properties.RedirectUri = BuildRedirectUriIfRelative(Options.SignedOutRedirectUri); if (string.IsNullOrWhiteSpace(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index b2d69d524..a199016dd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -167,15 +167,16 @@ public override void Validate() /// /// The request path within the application's base path where the user agent will be returned after sign out from the identity provider. + /// See post_logout_redirect_uri from http://openid.net/specs/openid-connect-session-1_0.html#RedirectionAfterLogout. /// public PathString SignedOutCallbackPath { get; set; } /// - /// The uri where the user agent will be returned to after application is signed out from the identity provider. + /// The uri where the user agent will be redirected to after application is signed out from the identity provider. /// The redirect will happen after the SignedOutCallbackPath is invoked. /// /// This URI can be out of the application's domain. By default it points to the root. - public string PostLogoutRedirectUri { get; set; } = "/"; + public string SignedOutRedirectUri { get; set; } = "/"; /// /// Gets or sets if a metadata refresh should be attempted after a SecurityTokenSignatureKeyNotFoundException. This allows for automatic diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 1708e604e..99bc1ec8c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -119,7 +119,7 @@ public async Task SignOutWithCustomRedirectUri() o.Configuration = configuration; o.StateDataFormat = stateFormat; o.SignedOutCallbackPath = "/thelogout"; - o.PostLogoutRedirectUri = "https://example.com/postlogout"; + o.SignedOutRedirectUri = "https://example.com/postlogout"; }); var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); @@ -150,7 +150,7 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite o.StateDataFormat = stateFormat; o.ClientId = "Test Id"; o.Configuration = configuration; - o.PostLogoutRedirectUri = "https://example.com/postlogout"; + o.SignedOutRedirectUri = "https://example.com/postlogout"; }); var transaction = await server.SendAsync("https://example.com/signout_with_specific_redirect_uri"); From 879f0b7f4053a34b44e34bd22c788c6129115175 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Tue, 13 Jun 2017 09:10:14 -0700 Subject: [PATCH 028/248] [Fixes #1133] Limit the path on the nonce and correlation id cookies --- .../OpenIdConnectHandler.cs | 22 ++-- .../OpenIdConnectOptions.cs | 6 + .../TwitterHandler.cs | 4 + .../TwitterOptions.cs | 6 + .../RemoteAuthenticationHandler.cs | 7 ++ .../RemoteAuthenticationOptions.cs | 6 + .../OAuthTests.cs | 65 +++++++++++ .../OpenIdConnect/OpenIdConnectTests.cs | 105 +++++++++++++++++- 8 files changed, 213 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index f4dcea4c8..1dec54197 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -886,16 +886,21 @@ private void WriteNonceCookie(string nonce) throw new ArgumentNullException(nameof(nonce)); } + var options = new CookieOptions + { + HttpOnly = true, + SameSite = Http.SameSiteMode.None, + Path = OriginalPathBase + Options.CallbackPath, + Secure = Request.IsHttps, + Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) + }; + + Options.ConfigureNonceCookie?.Invoke(Context, options); + Response.Cookies.Append( OpenIdConnectDefaults.CookieNoncePrefix + Options.StringDataFormat.Protect(nonce), NonceProperty, - new CookieOptions - { - HttpOnly = true, - SameSite = Http.SameSiteMode.None, - Secure = Request.IsHttps, - Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) - }); + options); } /// @@ -924,10 +929,13 @@ private string ReadNonceCookie(string nonce) var cookieOptions = new CookieOptions { HttpOnly = true, + Path = OriginalPathBase + Options.CallbackPath, SameSite = Http.SameSiteMode.None, Secure = Request.IsHttps }; + Options.ConfigureNonceCookie?.Invoke(Context, cookieOptions); + Response.Cookies.Delete(nonceKey, cookieOptions); return nonce; } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a199016dd..a42f0eba3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -262,5 +262,11 @@ public override void Validate() /// remote OpenID Connect provider as an authorization/logout request parameter. /// public bool DisableTelemetry { get; set; } + + /// + /// Gets or sets an action that can override the nonce cookie options before the + /// cookie gets added to the response. + /// + public Action ConfigureNonceCookie { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 0eab83e41..baa4320d1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -87,6 +87,8 @@ protected override async Task HandleRemoteAuthenticateAsync( Secure = Request.IsHttps }; + Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); + Response.Cookies.Delete(StateCookie, cookieOptions); var accessToken = await ObtainAccessTokenAsync(requestToken, oauthVerifier); @@ -159,6 +161,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; + Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); + Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions); var redirectContext = new TwitterRedirectToAuthorizationEndpointContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index cf1bf4856..8b57f2502 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -58,6 +58,12 @@ public TwitterOptions() /// public ISecureDataFormat StateDataFormat { get; set; } + /// + /// Gets or sets an action that can override the state cookie options before the + /// cookie gets added to the response. + /// + public Action ConfigureStateCookie { get; set; } + /// /// Gets or sets the used to handle authentication events. /// diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 2ff06062d..69c926cc0 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -205,9 +205,12 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties HttpOnly = true, SameSite = SameSiteMode.None, Secure = Request.IsHttps, + Path = OriginalPathBase + Options.CallbackPath, Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), }; + Options.ConfigureCorrelationIdCookie?.Invoke(Context, cookieOptions); + properties.Items[CorrelationProperty] = correlationId; var cookieName = CorrelationPrefix + Scheme.Name + "." + correlationId; @@ -243,9 +246,13 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties var cookieOptions = new CookieOptions { HttpOnly = true, + Path = OriginalPathBase + Options.CallbackPath, SameSite = SameSiteMode.None, Secure = Request.IsHttps }; + + Options.ConfigureCorrelationIdCookie?.Invoke(Context, cookieOptions); + Response.Cookies.Delete(cookieName, cookieOptions); if (!string.Equals(correlationCookie, CorrelationMarker, StringComparison.Ordinal)) diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 65cf6f2ec..066ca963a 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -87,5 +87,11 @@ public override void Validate() /// the size of the final authentication cookie. /// public bool SaveTokens { get; set; } + + /// + /// Gets or sets an action that can override the correlation id cookie options before the + /// cookie gets added to the response. + /// + public Action ConfigureCorrelationIdCookie { get; set; } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 2381fd6cd..dcc96c094 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -4,6 +4,7 @@ using System; using System.Net; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -165,6 +166,70 @@ public async Task ThrowsIfSignInSchemeMissing() Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] + public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallBackPath() + { + var server = CreateServer( + app => { }, + s => s.AddOAuthAuthentication( + "Weblie", + opt => + { + opt.ClientId = "Test Id"; + opt.ClientSecret = "secret"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.AuthorizationEndpoint = "https://example.com/provider/login"; + opt.TokenEndpoint = "https://example.com/provider/token"; + opt.CallbackPath = "/oauth-callback"; + }), + ctx => + { + ctx.ChallengeAsync("Weblie").ConfigureAwait(false).GetAwaiter().GetResult(); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var correlation = Assert.Single(setCookie.Value, v => v.StartsWith(".AspNetCore.Correlation.")); + Assert.Contains("path=/oauth-callback", correlation); + } + + [Fact] + public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOverriden() + { + var server = CreateServer( + app => { }, + s => s.AddOAuthAuthentication( + "Weblie", + opt => + { + opt.ClientId = "Test Id"; + opt.ClientSecret = "secret"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.AuthorizationEndpoint = "https://example.com/provider/login"; + opt.TokenEndpoint = "https://example.com/provider/token"; + opt.CallbackPath = "/oauth-callback"; + opt.ConfigureCorrelationIdCookie = (ctx, options) => options.Path = "/"; + }), + ctx => + { + ctx.ChallengeAsync("Weblie").ConfigureAwait(false).GetAwaiter().GetResult(); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var correlation = Assert.Single(setCookie.Value, v => v.StartsWith(".AspNetCore.Correlation.")); + Assert.Contains("path=/", correlation); + } private static TestServer CreateServer(Action configure, Action configureServices, Func handler) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 99bc1ec8c..6cfda3b85 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -60,6 +60,108 @@ public async Task SignOutSettingMessage() OpenIdConnectParameterNames.VersionTelemetry); } + [Fact] + public async Task RedirectToIdentityProvider_SetsNonceCookiePath_ToCallBackPath() + { + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.Configuration = new OpenIdConnectConfiguration + { + AuthorizationEndpoint = "https://example.com/provider/login" + }; + }); + + var server = setting.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Challenge); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var nonce = Assert.Single(setCookie.Value, v => v.StartsWith(OpenIdConnectDefaults.CookieNoncePrefix)); + Assert.Contains("path=/signin-oidc", nonce); + } + + [Fact] + public async Task RedirectToIdentityProvider_NonceCookieOptions_CanBeOverriden() + { + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.Configuration = new OpenIdConnectConfiguration + { + AuthorizationEndpoint = "https://example.com/provider/login" + }; + opt.ConfigureNonceCookie = (ctx, options) => options.Path = "/"; + }); + + var server = setting.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Challenge); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var nonce = Assert.Single(setCookie.Value, v => v.StartsWith(OpenIdConnectDefaults.CookieNoncePrefix)); + Assert.Contains("path=/", nonce); + } + + [Fact] + public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallBackPath() + { + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.Configuration = new OpenIdConnectConfiguration + { + AuthorizationEndpoint = "https://example.com/provider/login" + }; + }); + + var server = setting.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Challenge); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var correlation = Assert.Single(setCookie.Value, v => v.StartsWith(".AspNetCore.Correlation.")); + Assert.Contains("path=/signin-oidc", correlation); + } + + [Fact] + public async Task RedirectToIdentityProvider_CorrelationIdCookieOptions_CanBeOverriden() + { + var setting = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.Configuration = new OpenIdConnectConfiguration + { + AuthorizationEndpoint = "https://example.com/provider/login" + }; + opt.ConfigureCorrelationIdCookie = (ctx, options) => options.Path = "/"; + }); + + var server = setting.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Challenge); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.NotNull(res.Headers.Location); + var setCookie = Assert.Single(res.Headers, h => h.Key == "Set-Cookie"); + var correlation = Assert.Single(setCookie.Value, v => v.StartsWith(".AspNetCore.Correlation.")); + Assert.Contains("path=/", correlation); + } + [Fact] public async Task EndSessionRequestDoesNotIncludeTelemetryParametersWhenDisabled() { @@ -173,7 +275,8 @@ public async Task SignOutWith_Specific_RedirectUri_From_Authentication_Properite [Fact] public async Task SignOut_WithMissingConfig_Throws() { - var setting = new TestSettings(opt => { + var setting = new TestSettings(opt => + { opt.ClientId = "Test Id"; opt.Configuration = new OpenIdConnectConfiguration(); }); From 05c6cbe46697ff298aa7e416f7c2873791a03063 Mon Sep 17 00:00:00 2001 From: Gerardo Saca Date: Fri, 23 Jun 2017 09:00:31 -0700 Subject: [PATCH 029/248] Fix documentation for JwtBearerOptions.Events (#1249) --- .../JwtBearerOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs index 9a480763d..0d0a88e24 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerOptions.cs @@ -47,7 +47,7 @@ public class JwtBearerOptions : AuthenticationSchemeOptions /// /// The object provided by the application to process events raised by the bearer authentication handler. - /// The application may implement the interface fully, or it may create an instance of JwtBearerAuthenticationEvents + /// The application may implement the interface fully, or it may create an instance of JwtBearerEvents /// and assign delegates only to the events it wants to process. /// public new JwtBearerEvents Events From 717625c948a7b333b1a4aeda8d5a092d7ba5eca0 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 26 Jun 2017 09:42:10 -0700 Subject: [PATCH 030/248] Adding libunwind8 to .travis.yml [skip appveyor] --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2a4610467..b10be1421 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ os: - linux - osx osx_image: xcode8.2 +addons: + apt: + packages: + - libunwind8 branches: only: - master From 80383606d3988095abb74ff726439261f168ce43 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 27 Jun 2017 10:31:08 -0700 Subject: [PATCH 031/248] AuthZ: Eliminate extra ToArray() --- .../AuthorizationServiceExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs index c12815232..866b5dbc5 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationServiceExtensions.cs @@ -62,7 +62,7 @@ public static Task AuthorizeAsync(this IAuthorizationServic throw new ArgumentNullException(nameof(policy)); } - return service.AuthorizeAsync(user, resource, policy.Requirements.ToArray()); + return service.AuthorizeAsync(user, resource, policy.Requirements); } /// From e1cd8c9bc4ae33704bc8fd44bfdacd12618e172a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 29 Jun 2017 08:50:23 -0700 Subject: [PATCH 032/248] Add NETStandardImplicitPackageVersion --- build/dependencies.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8f40044d1..f00799700 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,4 +1,4 @@ - + 2.0.0-* 4.4.0-* @@ -6,6 +6,7 @@ 2.1.3 2.1.0-* 10.0.1 + 2.0.0-* 2.0.0-* 3.0.1 2.0.0-* From ff9f145a8e89c9756ea12ff10c6d47f2f7eb345f Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 29 Jun 2017 16:27:03 -0700 Subject: [PATCH 033/248] Refactor Events + Add IAuthenticationBuilder --- samples/CookieSample/Startup.cs | 4 +- samples/CookieSessionSample/Startup.cs | 4 +- samples/JwtBearerSample/Startup.cs | 6 +- .../OpenIdConnect.AzureAdSample/Startup.cs | 8 +- samples/OpenIdConnectSample/Startup.cs | 8 +- samples/SocialSample/Startup.cs | 83 ++- .../CookieAuthenticationHandler.cs | 40 +- .../CookieExtensions.cs | 22 +- .../Events/BaseCookieContext.cs | 30 -- .../Events/CookieAuthenticationEvents.cs | 16 +- .../Events/CookieSignedInContext.cs | 15 +- .../Events/CookieSigningInContext.cs | 14 +- .../Events/CookieSigningOutContext.cs | 8 +- .../Events/CookieValidatePrincipalContext.cs | 30 +- .../LoggingExtensions.cs | 35 ++ ...stConfigureCookieAuthenticationOptions.cs} | 1 - .../breakingchanges.netcore.json | 50 +- .../FacebookExtensions.cs | 12 + .../FacebookHandler.cs | 6 +- .../GoogleExtensions.cs | 13 + .../GoogleHandler.cs | 7 +- .../Events/AuthenticationFailedContext.cs | 11 +- .../Events/BaseJwtBearerContext.cs | 32 -- .../Events/JwtBearerChallengeContext.cs | 25 +- .../Events/MessageReceivedContext.cs | 11 +- .../Events/TokenValidatedContext.cs | 11 +- .../JwtBearerExtensions.cs | 15 + .../JwtBearerHandler.cs | 46 +- .../breakingchanges.netcore.json | 25 +- .../MicrosoftAccountExtensions.cs | 13 + .../MicrosoftAccountHandler.cs | 5 +- .../Events/OAuthCreatingTicketContext.cs | 61 +-- .../Events/OAuthEvents.cs | 6 +- .../OAuthRedirectToAuthorizationContext.cs | 41 -- .../OAuthExtensions.cs | 13 + .../OAuthHandler.cs | 27 +- .../breakingchanges.netcore.json | 15 +- .../Events/AuthenticationFailedContext.cs | 11 +- .../AuthorizationCodeReceivedContext.cs | 16 +- .../Events/BaseOpenIdConnectContext.cs | 25 - .../Events/MessageReceivedContext.cs | 17 +- .../Events/RedirectContext.cs | 26 +- .../Events/RemoteSignoutContext.cs | 16 +- .../Events/TokenResponseReceivedContext.cs | 13 +- .../Events/TokenValidatedContext.cs | 17 +- .../Events/UserInformationReceivedContext.cs | 13 +- .../LoggingExtensions.cs | 30 +- .../OpenIdConnectExtensions.cs | 14 + .../OpenIdConnectHandler.cs | 314 ++++++------ .../OpenIdConnectOptions.cs | 5 - .../breakingchanges.netcore.json | 128 ++--- .../Events/BaseTwitterContext.cs | 30 -- .../Events/TwitterCreatingTicketContext.cs | 15 +- .../Events/TwitterEvents.cs | 4 +- ...rRedirectToAuthorizationEndpointContext.cs | 35 -- .../TwitterExtensions.cs | 14 + .../TwitterHandler.cs | 25 +- .../breakingchanges.netcore.json | 29 +- .../AuthenticationBuilder.cs | 103 ++++ .../AuthenticationHandler.cs | 29 -- ...thenticationServiceCollectionExtensions.cs | 11 +- .../Events/BaseAuthenticationContext.cs | 41 -- .../Events/BaseContext.cs | 38 +- .../Events/BaseControlContext.cs | 78 --- .../Events/EventResultState.cs | 23 - .../Events/HandleRequestContext.cs | 32 ++ .../Events/PrincipalContext.cs | 30 ++ .../Events/PropertiesContext.cs | 31 ++ .../Events/RedirectContext.cs} | 18 +- .../Events/RemoteAuthenticationContext.cs | 49 ++ .../Events/RemoteAuthenticationEvents.cs | 4 +- ...lureContext.cs => RemoteFailureContext.cs} | 10 +- .../Events/ResultContext.cs | 65 +++ .../Events/TicketReceivedContext.cs | 25 +- .../LoggingExtensions.cs | 60 --- .../RemoteAuthenticationHandler.cs | 73 ++- .../RemoteAuthenticationOptions.cs | 5 - .../RemoteAuthenticationResult.cs | 78 +++ .../breakingchanges.netcore.json | 24 +- .../PolicyEvaluator.cs | 4 +- .../CookieTests.cs | 45 +- .../FacebookTests.cs | 35 +- .../GoogleTests.cs | 26 +- .../JwtBearerTests.cs | 79 ++- .../MicrosoftAccountTests.cs | 14 +- .../OAuthTests.cs | 23 - .../OpenIdConnectChallengeTests.cs | 4 +- .../OpenIdConnectConfigurationTests.cs | 23 +- .../OpenIdConnect/OpenIdConnectEventTests.cs | 484 ++++++++++++++++-- .../OpenIdConnect/OpenIdConnectTests.cs | 4 - .../OpenIdConnect/TestServerBuilder.cs | 6 +- .../TokenExtensionTests.cs | 6 +- .../TwitterTests.cs | 13 +- .../CookiePolicyTests.cs | 4 +- .../CookieInteropTests.cs | 8 +- 95 files changed, 1712 insertions(+), 1459 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs rename src/Microsoft.AspNetCore.Authentication.Cookies/{CookieAuthenticationPostConfigureOptions.cs => PostConfigureCookieAuthenticationOptions.cs} (99%) delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs rename src/{Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs => Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs} (62%) create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs rename src/Microsoft.AspNetCore.Authentication/Events/{FailureContext.cs => RemoteFailureContext.cs} (64%) create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index 79d1b3c3f..a91791070 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -18,9 +18,7 @@ public void ConfigureServices(IServiceCollection services) { options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(); + }).AddCookie(); } public void Configure(IApplicationBuilder app) diff --git a/samples/CookieSessionSample/Startup.cs b/samples/CookieSessionSample/Startup.cs index c35dfd999..f7b8f2bb8 100644 --- a/samples/CookieSessionSample/Startup.cs +++ b/samples/CookieSessionSample/Startup.cs @@ -19,9 +19,7 @@ public void ConfigureServices(IServiceCollection services) { options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(o => o.SessionStore = new MemoryCacheTicketStore()); + }).AddCookie(o => o.SessionStore = new MemoryCacheTicketStore()); } public void Configure(IApplicationBuilder app) diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 030e640c9..6f2c5e2ec 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -48,9 +48,7 @@ public void ConfigureServices(IServiceCollection services) { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - }); - - services.AddJwtBearerAuthentication(o => + }).AddJwtBearer(o => { // You also need to update /wwwroot/app/scripts/app.js o.Authority = Configuration["jwt:authority"]; @@ -59,7 +57,7 @@ public void ConfigureServices(IServiceCollection services) { OnAuthenticationFailed = c => { - c.HandleResponse(); + c.NoResult(); c.Response.StatusCode = 500; c.Response.ContentType = "text/plain"; diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index e6ad7804d..aab6e60df 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -48,11 +48,9 @@ public void ConfigureServices(IServiceCollection services) sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(); - - services.AddOpenIdConnectAuthentication(o => + }) + .AddCookie() + .AddOpenIdConnect(o => { o.ClientId = ClientId; o.ClientSecret = ClientSecret; // for code flow diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index af1406289..bc5af750d 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -45,11 +45,9 @@ public void ConfigureServices(IServiceCollection services) sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(); - - services.AddOpenIdConnectAuthentication(o => + }) + .AddCookie() + .AddOpenIdConnect(o => { o.ClientId = Configuration["oidc:clientid"]; o.ClientSecret = Configuration["oidc:clientsecret"]; // for code flow diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 003972009..dcf76263d 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -55,13 +55,11 @@ public void ConfigureServices(IServiceCollection services) options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - - services.AddCookieAuthentication(o => o.LoginPath = new PathString("/login")); - - // You must first create an app with Facebook and add its ID and Secret to your user-secrets. - // https://developers.facebook.com/apps/ - services.AddFacebookAuthentication(o => + }) + .AddCookie(o => o.LoginPath = new PathString("/login")) + // You must first create an app with Facebook and add its ID and Secret to your user-secrets. + // https://developers.facebook.com/apps/ + .AddFacebook(o => { o.AppId = Configuration["facebook:appid"]; o.AppSecret = Configuration["facebook:appsecret"]; @@ -69,11 +67,10 @@ public void ConfigureServices(IServiceCollection services) o.Fields.Add("name"); o.Fields.Add("email"); o.SaveTokens = true; - }); - - // You must first create an app with Google and add its ID and Secret to your user-secrets. - // https://console.developers.google.com/project - services.AddOAuthAuthentication("Google-AccessToken", o => + }) + // You must first create an app with Google and add its ID and Secret to your user-secrets. + // https://console.developers.google.com/project + .AddOAuth("Google-AccessToken", o => { o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; @@ -84,11 +81,10 @@ public void ConfigureServices(IServiceCollection services) o.Scope.Add("profile"); o.Scope.Add("email"); o.SaveTokens = true; - }); - - // You must first create an app with Google and add its ID and Secret to your user-secrets. - // https://console.developers.google.com/project - services.AddGoogleAuthentication(o => + }) + // You must first create an app with Google and add its ID and Secret to your user-secrets. + // https://console.developers.google.com/project + .AddGoogle(o => { o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; @@ -104,11 +100,10 @@ public void ConfigureServices(IServiceCollection services) }; o.ClaimActions.MapJsonSubKey("urn:google:image", "image", "url"); o.ClaimActions.Remove(ClaimTypes.GivenName); - }); - - // You must first create an app with Twitter and add its key and Secret to your user-secrets. - // https://apps.twitter.com/ - services.AddTwitterAuthentication(o => + }) + // You must first create an app with Twitter and add its key and Secret to your user-secrets. + // https://apps.twitter.com/ + .AddTwitter(o => { o.ConsumerKey = Configuration["twitter:consumerkey"]; o.ConsumerSecret = Configuration["twitter:consumersecret"]; @@ -126,15 +121,14 @@ public void ConfigureServices(IServiceCollection services) return Task.FromResult(0); } }; - }); - - /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. - Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL: - https://localhost:44318/ - */ - // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. - // https://apps.dev.microsoft.com/ - services.AddOAuthAuthentication("Microsoft-AccessToken", o => + }) + /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. + Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL: + https://localhost:44318/ + */ + // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. + // https://apps.dev.microsoft.com/ + .AddOAuth("Microsoft-AccessToken", o => { o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; @@ -143,20 +137,18 @@ public void ConfigureServices(IServiceCollection services) o.TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; o.Scope.Add("https://graph.microsoft.com/user.read"); o.SaveTokens = true; - }); - - // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. - // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/ - services.AddMicrosoftAccountAuthentication(o => + }) + // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. + // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/ + .AddMicrosoftAccount(o => { o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; o.SaveTokens = true; - }); - - // You must first create an app with GitHub and add its ID and Secret to your user-secrets. - // https://github.com/settings/applications/ - services.AddOAuthAuthentication("GitHub-AccessToken", o => + }) + // You must first create an app with GitHub and add its ID and Secret to your user-secrets. + // https://github.com/settings/applications/ + .AddOAuth("GitHub-AccessToken", o => { o.ClientId = Configuration["github-token:clientid"]; o.ClientSecret = Configuration["github-token:clientsecret"]; @@ -164,11 +156,10 @@ public void ConfigureServices(IServiceCollection services) o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; o.TokenEndpoint = "https://github.com/login/oauth/access_token"; o.SaveTokens = true; - }); - - // You must first create an app with GitHub and add its ID and Secret to your user-secrets. - // https://github.com/settings/applications/ - services.AddOAuthAuthentication("GitHub", o => + }) + // You must first create an app with GitHub and add its ID and Secret to your user-secrets. + // https://github.com/settings/applications/ + .AddOAuth("GitHub", o => { o.ClientId = Configuration["github:clientid"]; o.ClientSecret = Configuration["github:clientsecret"]; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 9b04026cd..4751c6f85 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -14,7 +14,10 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { - public class CookieAuthenticationHandler : AuthenticationHandler + public class CookieAuthenticationHandler : + AuthenticationHandler, + IAuthenticationSignInHandler, + IAuthenticationSignOutHandler { private const string HeaderValueNoCache = "no-cache"; private const string HeaderValueMinusOne = "-1"; @@ -104,7 +107,7 @@ private async Task ReadCookieTicket() var cookie = Options.CookieManager.GetRequestCookie(Context, Options.CookieName); if (string.IsNullOrEmpty(cookie)) { - return AuthenticateResult.None(); + return AuthenticateResult.NoResult(); } var ticket = Options.TicketDataFormat.Unprotect(cookie, GetTlsTokenBinding()); @@ -155,7 +158,7 @@ protected override async Task HandleAuthenticateAsync() return result; } - var context = new CookieValidatePrincipalContext(Context, Scheme, result.Ticket, Options); + var context = new CookieValidatePrincipalContext(Context, Scheme, Options, result.Ticket); await Events.ValidatePrincipal(context); if (context.Principal == null) @@ -244,8 +247,15 @@ protected virtual async Task FinishResponseAsync() } } - protected override async Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { + if (user == null) + { + throw new ArgumentNullException(nameof(user)); + } + + properties = properties ?? new AuthenticationProperties(); + _signInCalled = true; // Process the request cookie to initialize members like _sessionKey. @@ -284,7 +294,8 @@ protected override async Task HandleSignInAsync(ClaimsPrincipal user, Authentica signInContext.CookieOptions.Expires = expiresUtc.ToUniversalTime(); } - var ticket = new AuthenticationTicket(signInContext.Principal, signInContext.Properties, signInContext.AuthenticationScheme); + var ticket = new AuthenticationTicket(signInContext.Principal, signInContext.Properties, signInContext.Scheme.Name); + if (Options.SessionStore != null) { if (_sessionKey != null) @@ -310,20 +321,23 @@ protected override async Task HandleSignInAsync(ClaimsPrincipal user, Authentica var signedInContext = new CookieSignedInContext( Context, Scheme, - Options, - Scheme.Name, signInContext.Principal, - signInContext.Properties); + signInContext.Properties, + Options); await Events.SignedIn(signedInContext); // Only redirect on the login path var shouldRedirect = Options.LoginPath.HasValue && OriginalPath == Options.LoginPath; await ApplyHeaders(shouldRedirect, signedInContext.Properties); + + Logger.SignedIn(Scheme.Name); } - protected override async Task HandleSignOutAsync(AuthenticationProperties properties) + public async virtual Task SignOutAsync(AuthenticationProperties properties) { + properties = properties ?? new AuthenticationProperties(); + _signOutCalled = true; // Process the request cookie to initialize members like _sessionKey. @@ -351,6 +365,8 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper // Only redirect on the logout path var shouldRedirect = Options.LogoutPath.HasValue && OriginalPath == Options.LogoutPath; await ApplyHeaders(shouldRedirect, context.Properties); + + Logger.SignedOut(Scheme.Name); } private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationProperties properties) @@ -380,7 +396,7 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr if (redirectUri != null) { await Events.RedirectToReturnUrl( - new CookieRedirectContext(Context, Scheme, Options, redirectUri, properties)); + new RedirectContext(Context, Scheme, Options, properties, redirectUri)); } } } @@ -406,7 +422,7 @@ protected override async Task HandleForbiddenAsync(AuthenticationProperties prop returnUrl = OriginalPathBase + Request.Path + Request.QueryString; } var accessDeniedUri = Options.AccessDeniedPath + QueryString.Create(Options.ReturnUrlParameter, returnUrl); - var redirectContext = new CookieRedirectContext(Context, Scheme, Options, BuildRedirectUri(accessDeniedUri), properties); + var redirectContext = new RedirectContext(Context, Scheme, Options, properties, BuildRedirectUri(accessDeniedUri)); await Events.RedirectToAccessDenied(redirectContext); } @@ -419,7 +435,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop } var loginUri = Options.LoginPath + QueryString.Create(Options.ReturnUrlParameter, redirectUri); - var redirectContext = new CookieRedirectContext(Context, Scheme, Options, BuildRedirectUri(loginUri), properties); + var redirectContext = new RedirectContext(Context, Scheme, Options, properties, BuildRedirectUri(loginUri)); await Events.RedirectToLogin(redirectContext); } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index 6f23abcc4..67c4416eb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -2,16 +2,32 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.Extensions.Options; using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.AspNetCore.Authentication; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection { public static class CookieExtensions { + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder) + => builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme); + + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme) + => builder.AddCookie(authenticationScheme, configureOptions: null); + + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); + return builder.AddScheme(authenticationScheme, configureOptions); + } + + + // REMOVE below once callers have been updated public static IServiceCollection AddCookieAuthentication(this IServiceCollection services) => services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme); public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme) => services.AddCookieAuthentication(authenticationScheme, configureOptions: null); diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs deleted file mode 100644 index 4c949bb08..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/BaseCookieContext.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.Cookies -{ - public class BaseCookieContext : BaseAuthenticationContext - { - public BaseCookieContext( - HttpContext context, - AuthenticationScheme scheme, - CookieAuthenticationOptions options, - AuthenticationProperties properties) - : base(context, scheme.Name, properties) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - Options = options; - } - - public CookieAuthenticationOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs index c7c375de2..2b8b0416b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieAuthenticationEvents.cs @@ -37,7 +37,7 @@ public class CookieAuthenticationEvents /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnRedirectToLogin { get; set; } = context => + public Func, Task> OnRedirectToLogin { get; set; } = context => { if (IsAjaxRequest(context.Request)) { @@ -54,7 +54,7 @@ public class CookieAuthenticationEvents /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnRedirectToAccessDenied { get; set; } = context => + public Func, Task> OnRedirectToAccessDenied { get; set; } = context => { if (IsAjaxRequest(context.Request)) { @@ -71,7 +71,7 @@ public class CookieAuthenticationEvents /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnRedirectToLogout { get; set; } = context => + public Func, Task> OnRedirectToLogout { get; set; } = context => { if (IsAjaxRequest(context.Request)) { @@ -87,7 +87,7 @@ public class CookieAuthenticationEvents /// /// A delegate assigned to this property will be invoked when the related method is called. /// - public Func OnRedirectToReturnUrl { get; set; } = context => + public Func, Task> OnRedirectToReturnUrl { get; set; } = context => { if (IsAjaxRequest(context.Request)) { @@ -135,24 +135,24 @@ private static bool IsAjaxRequest(HttpRequest request) /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToLogout(CookieRedirectContext context) => OnRedirectToLogout(context); + public virtual Task RedirectToLogout(RedirectContext context) => OnRedirectToLogout(context); /// /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToLogin(CookieRedirectContext context) => OnRedirectToLogin(context); + public virtual Task RedirectToLogin(RedirectContext context) => OnRedirectToLogin(context); /// /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToReturnUrl(CookieRedirectContext context) => OnRedirectToReturnUrl(context); + public virtual Task RedirectToReturnUrl(RedirectContext context) => OnRedirectToReturnUrl(context); /// /// Implements the interface method by invoking the related delegate method. /// /// Contains information about the event - public virtual Task RedirectToAccessDenied(CookieRedirectContext context) => OnRedirectToAccessDenied(context); + public virtual Task RedirectToAccessDenied(RedirectContext context) => OnRedirectToAccessDenied(context); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs index 0e610c8b2..98c31dd19 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSignedInContext.cs @@ -9,32 +9,25 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Context object passed to the ICookieAuthenticationEvents method SignedIn. /// - public class CookieSignedInContext : BaseCookieContext + public class CookieSignedInContext : PrincipalContext { /// /// Creates a new instance of the context object. /// /// The HTTP request context /// The scheme data - /// The handler options - /// Initializes AuthenticationScheme property /// Initializes Principal property /// Initializes Properties property + /// The handler options public CookieSignedInContext( HttpContext context, AuthenticationScheme scheme, - CookieAuthenticationOptions options, - string authenticationScheme, ClaimsPrincipal principal, - AuthenticationProperties properties) + AuthenticationProperties properties, + CookieAuthenticationOptions options) : base(context, scheme, options, properties) { Principal = principal; } - - /// - /// Contains the claims that were converted into the outgoing cookie. - /// - public ClaimsPrincipal Principal { get; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs index b91cb7e18..41d7b4f6a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningInContext.cs @@ -7,9 +7,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { /// - /// Context object passed to the ICookieAuthenticationEvents method SigningIn. + /// Context object passed to the . /// - public class CookieSigningInContext : BaseCookieContext + public class CookieSigningInContext : PrincipalContext { /// /// Creates a new instance of the context object. @@ -18,7 +18,7 @@ public class CookieSigningInContext : BaseCookieContext /// The scheme data /// The handler options /// Initializes Principal property - /// Initializes Extra property + /// The authentication properties. /// Initializes options for the authentication cookie. public CookieSigningInContext( HttpContext context, @@ -29,16 +29,10 @@ public CookieSigningInContext( CookieOptions cookieOptions) : base(context, scheme, options, properties) { - Principal = principal; CookieOptions = cookieOptions; + Principal = principal; } - /// - /// Contains the claims about to be converted into the outgoing cookie. - /// May be replaced or altered during the SigningIn call. - /// - public ClaimsPrincipal Principal { get; set; } - /// /// The options for creating the outgoing cookie. /// May be replace or altered during the SigningIn call. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs index 0f4f4c7dc..34f6e49ab 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieSigningOutContext.cs @@ -6,9 +6,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { /// - /// Context object passed to the ICookieAuthenticationEvents method SigningOut + /// Context object passed to the /// - public class CookieSigningOutContext : BaseCookieContext + public class CookieSigningOutContext : PropertiesContext { /// /// @@ -25,9 +25,7 @@ public CookieSigningOutContext( AuthenticationProperties properties, CookieOptions cookieOptions) : base(context, scheme, options, properties) - { - CookieOptions = cookieOptions; - } + => CookieOptions = cookieOptions; /// /// The options for creating the outgoing cookie. diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs index 3232ba52f..d2161e42a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieValidatePrincipalContext.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// /// Context object passed to the CookieAuthenticationEvents ValidatePrincipal method. /// - public class CookieValidatePrincipalContext : BaseCookieContext + public class CookieValidatePrincipalContext : PrincipalContext { /// /// Creates a new instance of the context object. @@ -19,33 +19,17 @@ public class CookieValidatePrincipalContext : BaseCookieContext /// /// Contains the initial values for identity and extra data /// - public CookieValidatePrincipalContext(HttpContext context, AuthenticationScheme scheme, AuthenticationTicket ticket, CookieAuthenticationOptions options) + public CookieValidatePrincipalContext(HttpContext context, AuthenticationScheme scheme, CookieAuthenticationOptions options, AuthenticationTicket ticket) : base(context, scheme, options, ticket?.Properties) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - if (ticket == null) { throw new ArgumentNullException(nameof(ticket)); } - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - Principal = ticket.Principal; } - /// - /// Contains the claims principal arriving with the request. May be altered to change the - /// details of the authenticated user. - /// - public ClaimsPrincipal Principal { get; private set; } - /// /// If true, the cookie will be renewed /// @@ -56,18 +40,12 @@ public CookieValidatePrincipalContext(HttpContext context, AuthenticationScheme /// Principal property, which determines the identity of the authenticated request. /// /// The used as the replacement - public void ReplacePrincipal(ClaimsPrincipal principal) - { - Principal = principal; - } + public void ReplacePrincipal(ClaimsPrincipal principal) => Principal = principal; /// /// Called to reject the incoming principal. This may be done if the application has determined the /// account is no longer active, and the request should be treated as if it was anonymous. /// - public void RejectPrincipal() - { - Principal = null; - } + public void RejectPrincipal() => Principal = null; } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs new file mode 100644 index 000000000..d12735443 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/LoggingExtensions.cs @@ -0,0 +1,35 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _authSchemeSignedIn; + private static Action _authSchemeSignedOut; + + static LoggingExtensions() + { + _authSchemeSignedIn = LoggerMessage.Define( + eventId: 10, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} signed in."); + _authSchemeSignedOut = LoggerMessage.Define( + eventId: 11, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); + } + + public static void SignedIn(this ILogger logger, string authenticationScheme) + { + _authSchemeSignedIn(logger, authenticationScheme, null); + } + + public static void SignedOut(this ILogger logger, string authenticationScheme) + { + _authSchemeSignedOut(logger, authenticationScheme, null); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs similarity index 99% rename from src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs rename to src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs index 38211e0f1..e6a62d1b6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationPostConfigureOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs @@ -55,6 +55,5 @@ public void PostConfigure(string name, CookieAuthenticationOptions options) options.AccessDeniedPath = CookieAuthenticationDefaults.AccessDeniedPath; } } - } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json index c223c035c..91781d2dd 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json @@ -20,68 +20,28 @@ "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Authentication.AuthenticationTicket ticket, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, Microsoft.AspNetCore.Http.CookieOptions cookieOptions)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "TypeId": "public static class Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseCookieAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String authenticationScheme, System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String authenticationScheme, System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, Microsoft.AspNetCore.Http.CookieOptions cookieOptions)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options, System.String redirectUri, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", "Kind": "Removal" }, { - "TypeId": "public static class Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseCookieAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 4f30b9ba9..e4dcbfee8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -2,12 +2,24 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Facebook; namespace Microsoft.Extensions.DependencyInjection { public static class FacebookAuthenticationOptionsExtensions { + public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder) + => builder.AddFacebook(FacebookDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddFacebook(FacebookDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOAuth(authenticationScheme, configureOptions); + + + // REMOVE below once callers have been updated public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services) => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index c94048f9b..8a1f29bbe 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -42,13 +42,13 @@ protected override async Task CreateTicketAsync(ClaimsIden var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Scheme.Name); - var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens, payload); + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens, payload); context.RunClaimActions(); await Events.CreatingTicket(context); - return context.Ticket; + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + } private string GenerateAppSecretProof(string accessToken) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index be40822c5..ee42c5564 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -2,12 +2,25 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Google; namespace Microsoft.Extensions.DependencyInjection { public static class GoogleExtensions { + public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder) + => builder.AddGoogle(GoogleDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddGoogle(GoogleDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOAuth(authenticationScheme, configureOptions); + + + // REMOVE below once callers have been updated + public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services) => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 3a93c5cbf..aa5e59649 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -39,14 +39,11 @@ protected override async Task CreateTicketAsync( var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var principal = new ClaimsPrincipal(identity); - var ticket = new AuthenticationTicket(principal, properties, Scheme.Name); - var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens, payload); + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens, payload); context.RunClaimActions(); await Events.CreatingTicket(context); - - return context.Ticket; + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } // TODO: Abstract this properties override pattern into the base class? diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs index b47a9bab0..1c2efd6c7 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/AuthenticationFailedContext.cs @@ -6,12 +6,13 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class AuthenticationFailedContext : BaseJwtBearerContext + public class AuthenticationFailedContext : ResultContext { - public AuthenticationFailedContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) - : base(context, scheme, options) - { - } + public AuthenticationFailedContext( + HttpContext context, + AuthenticationScheme scheme, + JwtBearerOptions options) + : base(context, scheme, options) { } public Exception Exception { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs deleted file mode 100644 index 313e999d0..000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/BaseJwtBearerContext.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.JwtBearer -{ - public class BaseJwtBearerContext : BaseControlContext - { - public BaseJwtBearerContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) - : base(context) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - if (scheme == null) - { - throw new ArgumentNullException(nameof(scheme)); - } - - Options = options; - Scheme = scheme; - } - - public JwtBearerOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs index e6f931f6d..6500e1e3f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/JwtBearerChallengeContext.cs @@ -6,15 +6,14 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class JwtBearerChallengeContext : BaseJwtBearerContext + public class JwtBearerChallengeContext : PropertiesContext { - public JwtBearerChallengeContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options, AuthenticationProperties properties) - : base(context, scheme, options) - { - Properties = properties; - } - - public AuthenticationProperties Properties { get; } + public JwtBearerChallengeContext( + HttpContext context, + AuthenticationScheme scheme, + JwtBearerOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } /// /// Any failures encountered during the authentication process. @@ -40,5 +39,15 @@ public JwtBearerChallengeContext(HttpContext context, AuthenticationScheme schem /// WWW-Authenticate header. This property is always null unless explicitly set. /// public string ErrorUri { get; set; } + + /// + /// If true, will skip any default logic for this challenge. + /// + public bool Handled { get; private set; } + + /// + /// Skips any default logic for this challenge. + /// + public void HandleResponse() => Handled = true; } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs index 530a945ca..3c263f6b2 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -5,12 +5,13 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class MessageReceivedContext : BaseJwtBearerContext + public class MessageReceivedContext : ResultContext { - public MessageReceivedContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) - : base(context, scheme, options) - { - } + public MessageReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + JwtBearerOptions options) + : base(context, scheme, options) { } /// /// Bearer Token. This will give application an opportunity to retrieve token from an alternation location. diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs index 3667865da..39b677b96 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/TokenValidatedContext.cs @@ -6,12 +6,13 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class TokenValidatedContext : BaseJwtBearerContext + public class TokenValidatedContext : ResultContext { - public TokenValidatedContext(HttpContext context, AuthenticationScheme scheme, JwtBearerOptions options) - : base(context, scheme, options) - { - } + public TokenValidatedContext( + HttpContext context, + AuthenticationScheme scheme, + JwtBearerOptions options) + : base(context, scheme, options) { } public SecurityToken SecurityToken { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 582eb6314..4f051bd39 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -10,6 +11,20 @@ namespace Microsoft.Extensions.DependencyInjection { public static class JwtBearerExtensions { + public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder) + => builder.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); + return builder.AddScheme(authenticationScheme, configureOptions); + } + + + // REMOVE once callers updated public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services) => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 0087d38d0..999d323e1 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net.Http; using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; @@ -13,7 +12,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -47,7 +45,6 @@ public JwtBearerHandler(IOptionsSnapshot options, ILoggerFacto protected override async Task HandleAuthenticateAsync() { string token = null; - AuthenticateResult result = null; try { // Give application opportunity to find from a different location, adjust, or reject token @@ -55,9 +52,9 @@ protected override async Task HandleAuthenticateAsync() // event can set the token await Events.MessageReceived(messageReceivedContext); - if (messageReceivedContext.IsProcessingComplete(out result)) + if (messageReceivedContext.Result != null) { - return result; + return messageReceivedContext.Result; } // If application retrieved token from somewhere else, use that. @@ -70,7 +67,7 @@ protected override async Task HandleAuthenticateAsync() // If no authorization header found, nothing to process further if (string.IsNullOrEmpty(authorization)) { - return AuthenticateResult.None(); + return AuthenticateResult.NoResult(); } if (authorization.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)) @@ -81,7 +78,7 @@ protected override async Task HandleAuthenticateAsync() // If no token found, no further work possible if (string.IsNullOrEmpty(token)) { - return AuthenticateResult.None(); + return AuthenticateResult.NoResult(); } } @@ -138,29 +135,28 @@ protected override async Task HandleAuthenticateAsync() Logger.TokenValidationSucceeded(); - var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name); var tokenValidatedContext = new TokenValidatedContext(Context, Scheme, Options) { - Ticket = ticket, - SecurityToken = validatedToken, + Principal = principal, + SecurityToken = validatedToken }; await Events.TokenValidated(tokenValidatedContext); - if (tokenValidatedContext.IsProcessingComplete(out result)) + if (tokenValidatedContext.Result != null) { - return result; + return tokenValidatedContext.Result; } - ticket = tokenValidatedContext.Ticket; if (Options.SaveToken) { - ticket.Properties.StoreTokens(new[] + tokenValidatedContext.Properties.StoreTokens(new[] { new AuthenticationToken { Name = "access_token", Value = token } }); } - return AuthenticateResult.Success(ticket); + tokenValidatedContext.Success(); + return tokenValidatedContext.Result; } } @@ -172,9 +168,9 @@ protected override async Task HandleAuthenticateAsync() }; await Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.IsProcessingComplete(out result)) + if (authenticationFailedContext.Result != null) { - return result; + return authenticationFailedContext.Result; } return AuthenticateResult.Fail(authenticationFailedContext.Exception); @@ -192,9 +188,9 @@ protected override async Task HandleAuthenticateAsync() }; await Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.IsProcessingComplete(out result)) + if (authenticationFailedContext.Result != null) { - return result; + return authenticationFailedContext.Result; } throw; @@ -217,7 +213,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop } await Events.Challenge(eventContext); - if (eventContext.IsProcessingComplete(out var ignored)) + if (eventContext.Handled) { return; } @@ -329,15 +325,5 @@ private static string CreateErrorDescription(Exception authFailure) return string.Join("; ", messages); } - - protected override Task HandleSignOutAsync(AuthenticationProperties properties) - { - throw new NotSupportedException(); - } - - protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - { - throw new NotSupportedException(); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json index d810a2bb9..223ff401b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json @@ -16,43 +16,28 @@ "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "TypeId": "public static class Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJwtBearerAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Builder.JwtBearerOptions get_Options()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.JwtBearerOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", "Kind": "Removal" }, { - "TypeId": "public static class Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJwtBearerAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index a4ad5692c..9a53fd770 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -2,12 +2,25 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; namespace Microsoft.Extensions.DependencyInjection { public static class MicrosoftAccountExtensions { + public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder) + => builder.AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOAuth(authenticationScheme, configureOptions); + + + // REMOVE below once callers have been updated + public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services) => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 815b94bf4..45fae3d0e 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -32,12 +32,11 @@ protected override async Task CreateTicketAsync(ClaimsIden var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Scheme.Name); - var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens, payload); + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens, payload); context.RunClaimActions(); await Events.CreatingTicket(context); - return context.Ticket; + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs index 6e3105639..f660dd224 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthCreatingTicketContext.cs @@ -13,32 +13,34 @@ namespace Microsoft.AspNetCore.Authentication.OAuth /// /// Contains information about the login session as well as the user . /// - public class OAuthCreatingTicketContext : BaseAuthenticationContext + public class OAuthCreatingTicketContext : ResultContext { /// /// Initializes a new . /// - /// The . + /// The . + /// The . /// The HTTP environment. /// The authentication scheme. /// The options used by the authentication middleware. /// The HTTP client used by the authentication middleware /// The tokens returned from the token endpoint. public OAuthCreatingTicketContext( - AuthenticationTicket ticket, + ClaimsPrincipal principal, + AuthenticationProperties properties, HttpContext context, AuthenticationScheme scheme, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens) - : this(ticket, context, scheme, options, backchannel, tokens, user: new JObject()) - { - } + : this(principal, properties, context, scheme, options, backchannel, tokens, user: new JObject()) + { } /// /// Initializes a new . /// - /// The . + /// The . + /// The . /// The HTTP environment. /// The authentication scheme. /// The options used by the authentication middleware. @@ -46,25 +48,16 @@ public OAuthCreatingTicketContext( /// The tokens returned from the token endpoint. /// The JSON-serialized user. public OAuthCreatingTicketContext( - AuthenticationTicket ticket, + ClaimsPrincipal principal, + AuthenticationProperties properties, HttpContext context, AuthenticationScheme scheme, OAuthOptions options, HttpClient backchannel, OAuthTokenResponse tokens, JObject user) - : base(context, scheme.Name, ticket.Properties) + : base(context, scheme, options) { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - if (backchannel == null) { throw new ArgumentNullException(nameof(backchannel)); @@ -80,23 +73,13 @@ public OAuthCreatingTicketContext( throw new ArgumentNullException(nameof(user)); } - if (scheme == null) - { - throw new ArgumentNullException(nameof(scheme)); - } - TokenResponse = tokens; Backchannel = backchannel; User = user; - Options = options; - Scheme = scheme; - Ticket = ticket; + Principal = principal; + Properties = properties; } - public OAuthOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - /// /// Gets the JSON-serialized user or an empty /// if it is not available. @@ -146,20 +129,12 @@ public TimeSpan? ExpiresIn public HttpClient Backchannel { get; } /// - /// The that will be created. + /// Gets the main identity exposed by the authentication ticket. + /// This property returns null when the ticket is null. /// - public AuthenticationTicket Ticket { get; set; } + public ClaimsIdentity Identity => Principal?.Identity as ClaimsIdentity; - /// - /// Gets the main identity exposed by . - /// This property returns null when is null. - /// - public ClaimsIdentity Identity => Ticket?.Principal.Identity as ClaimsIdentity; - - public void RunClaimActions() - { - RunClaimActions(User); - } + public void RunClaimActions() => RunClaimActions(User); public void RunClaimActions(JObject userData) { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs index b3572cab4..9e194491b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthEvents.cs @@ -19,7 +19,7 @@ public class OAuthEvents : RemoteAuthenticationEvents /// /// Gets or sets the delegate that is invoked when the RedirectToAuthorizationEndpoint method is invoked. /// - public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => + public Func, Task> OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); return Task.CompletedTask; @@ -35,7 +35,7 @@ public class OAuthEvents : RemoteAuthenticationEvents /// /// Called when a Challenge causes a redirect to authorize endpoint in the OAuth handler. /// - /// Contains redirect URI and of the challenge. - public virtual Task RedirectToAuthorizationEndpoint(OAuthRedirectToAuthorizationContext context) => OnRedirectToAuthorizationEndpoint(context); + /// Contains redirect URI and of the challenge. + public virtual Task RedirectToAuthorizationEndpoint(RedirectContext context) => OnRedirectToAuthorizationEndpoint(context); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs deleted file mode 100644 index 5d5e0e701..000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Events/OAuthRedirectToAuthorizationContext.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.OAuth -{ - /// - /// Context passed when a Challenge causes a redirect to authorize endpoint in the handler. - /// - public class OAuthRedirectToAuthorizationContext : BaseContext - { - /// - /// Creates a new context object. - /// - /// The HTTP request context. - /// The . - /// The authentication properties of the challenge. - /// The initial redirect URI. - public OAuthRedirectToAuthorizationContext(HttpContext context, OAuthOptions options, AuthenticationProperties properties, string redirectUri) - : base(context) - { - RedirectUri = redirectUri; - Properties = properties; - Options = options; - } - - public OAuthOptions Options { get; } - - /// - /// Gets the URI used for the redirect operation. - /// - public string RedirectUri { get; private set; } - - /// - /// Gets the authentication properties of the challenge. - /// - public AuthenticationProperties Properties { get; private set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 4ad0a8336..5720d8e4f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -10,6 +11,18 @@ namespace Microsoft.Extensions.DependencyInjection { public static class OAuthExtensions { + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOAuth>(authenticationScheme, configureOptions); + + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + where TOptions : OAuthOptions, new() + where THandler : OAuthHandler + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); + return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + } + + // REMOVE below once callers have been updated public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) { return services.AddOAuthAuthentication>(authenticationScheme, configureOptions); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index bbe4f4038..b61d57537 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -42,7 +42,7 @@ public OAuthHandler(IOptionsSnapshot options, ILoggerFactory logger, U /// A new instance of the events instance. protected override Task CreateEventsAsync() => Task.FromResult(new OAuthEvents()); - protected override async Task HandleRemoteAuthenticateAsync() + protected override async Task HandleRemoteAuthenticateAsync() { AuthenticationProperties properties = null; var query = Request.Query; @@ -63,7 +63,7 @@ protected override async Task HandleRemoteAuthenticateAsync( failureMessage.Append(";Uri=").Append(errorUri); } - return AuthenticateResult.Fail(failureMessage.ToString()); + return HandleRequestResult.Fail(failureMessage.ToString()); } var code = query["code"]; @@ -72,30 +72,30 @@ protected override async Task HandleRemoteAuthenticateAsync( properties = Options.StateDataFormat.Unprotect(state); if (properties == null) { - return AuthenticateResult.Fail("The oauth state was missing or invalid."); + return HandleRequestResult.Fail("The oauth state was missing or invalid."); } // OAuth2 10.12 CSRF if (!ValidateCorrelationId(properties)) { - return AuthenticateResult.Fail("Correlation failed."); + return HandleRequestResult.Fail("Correlation failed."); } if (StringValues.IsNullOrEmpty(code)) { - return AuthenticateResult.Fail("Code was not found."); + return HandleRequestResult.Fail("Code was not found."); } var tokens = await ExchangeCodeAsync(code, BuildRedirectUri(Options.CallbackPath)); if (tokens.Error != null) { - return AuthenticateResult.Fail(tokens.Error); + return HandleRequestResult.Fail(tokens.Error); } if (string.IsNullOrEmpty(tokens.AccessToken)) { - return AuthenticateResult.Fail("Failed to retrieve access token."); + return HandleRequestResult.Fail("Failed to retrieve access token."); } var identity = new ClaimsIdentity(ClaimsIssuer); @@ -137,11 +137,11 @@ protected override async Task HandleRemoteAuthenticateAsync( var ticket = await CreateTicketAsync(identity, properties, tokens); if (ticket != null) { - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(ticket); } else { - return AuthenticateResult.Fail("Failed to retrieve user information from remote server."); + return HandleRequestResult.Fail("Failed to retrieve user information from remote server."); } } @@ -185,10 +185,9 @@ private static async Task Display(HttpResponseMessage response) protected virtual async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) { - var ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), properties, Scheme.Name); - var context = new OAuthCreatingTicketContext(ticket, Context, Scheme, Options, Backchannel, tokens); + var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens); await Events.CreatingTicket(context); - return context.Ticket; + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } protected override async Task HandleChallengeAsync(AuthenticationProperties properties) @@ -202,8 +201,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop GenerateCorrelationId(properties); var authorizationEndpoint = BuildChallengeUrl(properties, BuildRedirectUri(Options.CallbackPath)); - var redirectContext = new OAuthRedirectToAuthorizationContext( - Context, Options, + var redirectContext = new RedirectContext( + Context, Scheme, Options, properties, authorizationEndpoint); await Events.RedirectToAuthorizationEndpoint(redirectContext); } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json index 96fd03e98..3124d7fe7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json @@ -24,23 +24,12 @@ "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OAuthOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, System.String redirectUri)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public Microsoft.AspNetCore.Builder.OAuthOptions get_Options()", + "TypeId": "public static class Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOAuthAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OAuthOptions options)", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOAuthAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OAuthOptions options)", "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs index 0c7d96863..203da93c5 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthenticationFailedContext.cs @@ -2,17 +2,18 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class AuthenticationFailedContext : BaseOpenIdConnectContext + public class AuthenticationFailedContext : RemoteAuthenticationContext { public AuthenticationFailedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + : base(context, scheme, options, new AuthenticationProperties()) + { } + + public OpenIdConnectMessage ProtocolMessage { get; set; } public Exception Exception { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs index 0ccfc3ab7..bdf6e4a7f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/AuthorizationCodeReceivedContext.cs @@ -3,9 +3,7 @@ using System.IdentityModel.Tokens.Jwt; using System.Net.Http; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect @@ -13,17 +11,19 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// This Context can be used to be informed when an 'AuthorizationCode' is received over the OpenIdConnect protocol. /// - public class AuthorizationCodeReceivedContext : BaseOpenIdConnectContext + public class AuthorizationCodeReceivedContext : RemoteAuthenticationContext { /// /// Creates a /// - public AuthorizationCodeReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + public AuthorizationCodeReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + OpenIdConnectOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } - public AuthenticationProperties Properties { get; set; } + public OpenIdConnectMessage ProtocolMessage { get; set; } /// /// Gets or sets the that was received in the authentication response, if any. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs deleted file mode 100644 index 63f815d9e..000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/BaseOpenIdConnectContext.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Http; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; - -namespace Microsoft.AspNetCore.Authentication.OpenIdConnect -{ - public class BaseOpenIdConnectContext : BaseControlContext - { - public BaseOpenIdConnectContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context) - { - Options = options ?? throw new ArgumentNullException(nameof(options)); - Scheme = scheme ?? throw new ArgumentNullException(nameof(scheme)); - } - - public OpenIdConnectOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - - public OpenIdConnectMessage ProtocolMessage { get; set; } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs index f0298ed05..106ecb8c0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs @@ -2,21 +2,24 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class MessageReceivedContext : BaseOpenIdConnectContext + public class MessageReceivedContext : RemoteAuthenticationContext { - public MessageReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + public MessageReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + OpenIdConnectOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } + + public OpenIdConnectMessage ProtocolMessage { get; set; } /// /// Bearer Token. This will give application an opportunity to retrieve token from an alternation location. /// public string Token { get; set; } - - public AuthenticationProperties Properties { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs index 59b00827a..9961c237d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RedirectContext.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { @@ -9,14 +10,25 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// When a user configures the to be notified prior to redirecting to an IdentityProvider /// an instance of is passed to the 'RedirectToAuthenticationEndpoint' or 'RedirectToEndSessionEndpoint' events. /// - public class RedirectContext : BaseOpenIdConnectContext + public class RedirectContext : PropertiesContext { - public RedirectContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, AuthenticationProperties properties) - : base(context, scheme, options) - { - Properties = properties; - } + public RedirectContext( + HttpContext context, + AuthenticationScheme scheme, + OpenIdConnectOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } - public AuthenticationProperties Properties { get; } + public OpenIdConnectMessage ProtocolMessage { get; set; } + + /// + /// If true, will skip any default logic for this redirect. + /// + public bool Handled { get; private set; } + + /// + /// Skips any default logic for this redirect. + /// + public void HandleResponse() => Handled = true; } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs index 5c0172673..26720a58f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/RemoteSignoutContext.cs @@ -6,16 +6,12 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class RemoteSignOutContext : BaseOpenIdConnectContext + public class RemoteSignOutContext : RemoteAuthenticationContext { - public RemoteSignOutContext( - HttpContext context, - AuthenticationScheme scheme, - OpenIdConnectOptions options, - OpenIdConnectMessage message) - : base(context, scheme, options) - { - ProtocolMessage = message; - } + public RemoteSignOutContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, OpenIdConnectMessage message) + : base(context, scheme, options, new AuthenticationProperties()) + => ProtocolMessage = message; + + public OpenIdConnectMessage ProtocolMessage { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs index 7c0d51fbb..2bebdb8dc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenResponseReceivedContext.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Security.Claims; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Protocols.OpenIdConnect; @@ -9,18 +10,16 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// This Context can be used to be informed when an 'AuthorizationCode' is redeemed for tokens at the token endpoint. /// - public class TokenResponseReceivedContext : BaseOpenIdConnectContext + public class TokenResponseReceivedContext : RemoteAuthenticationContext { /// /// Creates a /// - public TokenResponseReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, AuthenticationProperties properties) - : base(context, scheme, options) - { - Properties = properties; - } + public TokenResponseReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, ClaimsPrincipal user, AuthenticationProperties properties) + : base(context, scheme, options, properties) + => Principal = user; - public AuthenticationProperties Properties { get; } + public OpenIdConnectMessage ProtocolMessage { get; set; } /// /// Gets or sets the that contains the tokens received after redeeming the code at the token endpoint. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs index fea89298c..853857dc7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/TokenValidatedContext.cs @@ -2,26 +2,23 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.IdentityModel.Tokens.Jwt; -using System.Net.Http; -using Microsoft.AspNetCore.Builder; +using System.Security.Claims; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.IdentityModel.Protocols.OpenIdConnect; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class TokenValidatedContext : BaseOpenIdConnectContext + public class TokenValidatedContext : RemoteAuthenticationContext { /// /// Creates a /// - public TokenValidatedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + public TokenValidatedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, ClaimsPrincipal principal, AuthenticationProperties properties) + : base(context, scheme, options, properties) + => Principal = principal; + + public OpenIdConnectMessage ProtocolMessage { get; set; } - public AuthenticationProperties Properties { get; set; } - public JwtSecurityToken SecurityToken { get; set; } public OpenIdConnectMessage TokenEndpointResponse { get; set; } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs index ee80cb71f..0b855eaf3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/UserInformationReceivedContext.cs @@ -1,17 +1,20 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Security.Claims; using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Newtonsoft.Json.Linq; namespace Microsoft.AspNetCore.Authentication.OpenIdConnect { - public class UserInformationReceivedContext : BaseOpenIdConnectContext + public class UserInformationReceivedContext : RemoteAuthenticationContext { - public UserInformationReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options) - : base(context, scheme, options) - { - } + public UserInformationReceivedContext(HttpContext context, AuthenticationScheme scheme, OpenIdConnectOptions options, ClaimsPrincipal principal, AuthenticationProperties properties) + : base(context, scheme, options, properties) + => Principal = principal; + + public OpenIdConnectMessage ProtocolMessage { get; set; } public JObject User { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs index aa6d0cbaa..458cfd73e 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -8,9 +8,7 @@ namespace Microsoft.Extensions.Logging internal static class LoggingExtensions { private static Action _redirectToIdentityProviderForSignOutHandledResponse; - private static Action _redirectToIdentityProviderForSignOutSkipped; private static Action _redirectToIdentityProviderHandledResponse; - private static Action _redirectToIdentityProviderSkipped; private static Action _updatingConfiguration; private static Action _receivedIdToken; private static Action _redeemingCodeForTokens; @@ -55,6 +53,7 @@ internal static class LoggingExtensions private static Action _remoteSignOut; private static Action _remoteSignOutSessionIdMissing; private static Action _remoteSignOutSessionIdInvalid; + private static Action _signOut; static LoggingExtensions() { @@ -63,10 +62,6 @@ static LoggingExtensions() eventId: 1, logLevel: LogLevel.Debug, formatString: "RedirectToIdentityProviderForSignOut.HandledResponse"); - _redirectToIdentityProviderForSignOutSkipped = LoggerMessage.Define( - eventId: 2, - logLevel: LogLevel.Debug, - formatString: "RedirectToIdentityProviderForSignOut.Skipped"); _invalidLogoutQueryStringRedirectUrl = LoggerMessage.Define( eventId: 3, logLevel: LogLevel.Warning, @@ -87,10 +82,6 @@ static LoggingExtensions() eventId: 6, logLevel: LogLevel.Debug, formatString: "RedirectToIdentityProvider.HandledResponse"); - _redirectToIdentityProviderSkipped = LoggerMessage.Define( - eventId: 7, - logLevel: LogLevel.Debug, - formatString: "RedirectToIdentityProvider.Skipped"); _invalidAuthenticationRequestUrl = LoggerMessage.Define( eventId: 8, logLevel: LogLevel.Warning, @@ -253,6 +244,10 @@ static LoggingExtensions() logLevel: LogLevel.Error, formatString: "The remote signout request was ignored because the 'sid' parameter didn't match " + "the expected value, which may indicate an unsolicited logout."); + _signOut = LoggerMessage.Define( + eventId: 49, + logLevel: LogLevel.Information, + formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); } public static void UpdatingConfiguration(this ILogger logger) @@ -345,21 +340,11 @@ public static void RedirectToIdentityProviderForSignOutHandledResponse(this ILog _redirectToIdentityProviderForSignOutHandledResponse(logger, null); } - public static void RedirectToIdentityProviderForSignOutSkipped(this ILogger logger) - { - _redirectToIdentityProviderForSignOutSkipped(logger, null); - } - public static void RedirectToIdentityProviderHandledResponse(this ILogger logger) { _redirectToIdentityProviderHandledResponse(logger, null); } - public static void RedirectToIdentityProviderSkipped(this ILogger logger) - { - _redirectToIdentityProviderSkipped(logger, null); - } - public static void UserInformationReceivedHandledResponse(this ILogger logger) { _userInformationReceivedHandledResponse(logger, null); @@ -494,5 +479,10 @@ public static void RemoteSignOutSessionIdInvalid(this ILogger logger) { _remoteSignOutSessionIdInvalid(logger, null); } + + public static void SignedOut(this ILogger logger, string authenticationScheme) + { + _signOut(logger, authenticationScheme, null); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index d57640904..7ba262bf3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -10,6 +11,19 @@ namespace Microsoft.Extensions.DependencyInjection { public static class OpenIdConnectExtensions { + public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder) + => builder.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); + return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + } + + // REMOVE once callers have been updated public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services) => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 1dec54197..341abbf5a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// /// A per-request authentication handler for the OpenIdConnectAuthenticationMiddleware. /// - public class OpenIdConnectHandler : RemoteAuthenticationHandler + public class OpenIdConnectHandler : RemoteAuthenticationHandler, IAuthenticationSignOutHandler { private const string NonceProperty = "N"; private const string UriSchemeDelimiter = "://"; @@ -110,15 +110,18 @@ protected virtual async Task HandleRemoteSignOutAsync() var remoteSignOutContext = new RemoteSignOutContext(Context, Scheme, Options, message); await Events.RemoteSignOut(remoteSignOutContext); - if (remoteSignOutContext.HandledResponse) + if (remoteSignOutContext.Result != null) { - Logger.RemoteSignOutHandledResponse(); - return true; - } - if (remoteSignOutContext.Skipped) - { - Logger.RemoteSignOutSkipped(); - return false; + if (remoteSignOutContext.Result.Handled) + { + Logger.RemoteSignOutHandledResponse(); + return true; + } + if (remoteSignOutContext.Result.Skipped) + { + Logger.RemoteSignOutSkipped(); + return false; + } } if (message == null) @@ -161,8 +164,10 @@ protected virtual async Task HandleRemoteSignOutAsync() /// Redirect user to the identity provider for sign out /// /// A task executing the sign out procedure - protected override async Task HandleSignOutAsync(AuthenticationProperties properties) + public async virtual Task SignOutAsync(AuthenticationProperties properties) { + properties = properties ?? new AuthenticationProperties(); + Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); if (_configuration == null && Options.ConfigurationManager != null) @@ -199,16 +204,11 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper }; await Events.RedirectToIdentityProviderForSignOut(redirectContext); - if (redirectContext.HandledResponse) + if (redirectContext.Handled) { Logger.RedirectToIdentityProviderForSignOutHandledResponse(); return; } - else if (redirectContext.Skipped) - { - Logger.RedirectToIdentityProviderForSignOutSkipped(); - return; - } message = redirectContext.ProtocolMessage; @@ -221,8 +221,7 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper if (string.IsNullOrEmpty(message.IssuerAddress)) { - throw new InvalidOperationException( - "Cannot redirect to the end session endpoint, the configuration may be missing or invalid."); + throw new InvalidOperationException("Cannot redirect to the end session endpoint, the configuration may be missing or invalid."); } if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet) @@ -266,6 +265,8 @@ protected override async Task HandleSignOutAsync(AuthenticationProperties proper { throw new NotImplementedException($"An unsupported authentication method has been configured: {Options.AuthenticationMethod}"); } + + Logger.SignedOut(Scheme.Name); } /// @@ -343,16 +344,11 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop }; await Events.RedirectToIdentityProvider(redirectContext); - if (redirectContext.HandledResponse) + if (redirectContext.Handled) { Logger.RedirectToIdentityProviderHandledResponse(); return; } - else if (redirectContext.Skipped) - { - Logger.RedirectToIdentityProviderSkipped(); - return; - } message = redirectContext.ProtocolMessage; @@ -418,8 +414,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop /// /// Invoked to process incoming OpenIdConnect messages. /// - /// An if successful. - protected override async Task HandleRemoteAuthenticateAsync() + /// An . + protected override async Task HandleRemoteAuthenticateAsync() { Logger.EnteringOpenIdAuthenticationHandlerHandleRemoteAuthenticateAsync(GetType().FullName); @@ -437,9 +433,9 @@ protected override async Task HandleRemoteAuthenticateAsync( if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.None(); + return HandleRequestResult.SkipHandler(); } - return AuthenticateResult.Fail("An OpenID Connect response cannot contain an " + + return HandleRequestResult.Fail("An OpenID Connect response cannot contain an " + "identity token or an access token when using response_mode=query"); } } @@ -459,13 +455,11 @@ protected override async Task HandleRemoteAuthenticateAsync( if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.None(); + return HandleRequestResult.SkipHandler(); } - return AuthenticateResult.Fail("No message."); + return HandleRequestResult.Fail("No message."); } - AuthenticateResult result; - try { AuthenticationProperties properties = null; @@ -475,9 +469,9 @@ protected override async Task HandleRemoteAuthenticateAsync( } var messageReceivedContext = await RunMessageReceivedEventAsync(authorizationResponse, properties); - if (messageReceivedContext.IsProcessingComplete(out result)) + if (messageReceivedContext.Result != null) { - return result; + return messageReceivedContext.Result; } authorizationResponse = messageReceivedContext.ProtocolMessage; properties = messageReceivedContext.Properties; @@ -491,9 +485,9 @@ protected override async Task HandleRemoteAuthenticateAsync( Logger.NullOrEmptyAuthorizationResponseState(); if (Options.SkipUnrecognizedRequests) { - return AuthenticateResult.None(); + return HandleRequestResult.SkipHandler(); } - return AuthenticateResult.Fail(Resources.MessageStateIsNullOrEmpty); + return HandleRequestResult.Fail(Resources.MessageStateIsNullOrEmpty); } // if state exists and we failed to 'unprotect' this is not a message we should process. @@ -506,9 +500,9 @@ protected override async Task HandleRemoteAuthenticateAsync( if (Options.SkipUnrecognizedRequests) { // Not for us? - return AuthenticateResult.None(); + return HandleRequestResult.SkipHandler(); } - return AuthenticateResult.Fail(Resources.MessageStateIsInvalid); + return HandleRequestResult.Fail(Resources.MessageStateIsInvalid); } string userstate = null; @@ -517,13 +511,13 @@ protected override async Task HandleRemoteAuthenticateAsync( if (!ValidateCorrelationId(properties)) { - return AuthenticateResult.Fail("Correlation failed."); + return HandleRequestResult.Fail("Correlation failed."); } // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(authorizationResponse.Error)) { - return AuthenticateResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null)); + return HandleRequestResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null)); } if (_configuration == null && Options.ConfigurationManager != null) @@ -534,7 +528,7 @@ protected override async Task HandleRemoteAuthenticateAsync( PopulateSessionProperties(authorizationResponse, properties); - AuthenticationTicket ticket = null; + ClaimsPrincipal user = null; JwtSecurityToken jwt = null; string nonce = null; var validationParameters = Options.TokenValidationParameters.Clone(); @@ -543,7 +537,7 @@ protected override async Task HandleRemoteAuthenticateAsync( if (!string.IsNullOrEmpty(authorizationResponse.IdToken)) { Logger.ReceivedIdToken(); - ticket = ValidateToken(authorizationResponse.IdToken, properties, validationParameters, out jwt); + user = ValidateToken(authorizationResponse.IdToken, properties, validationParameters, out jwt); nonce = jwt.Payload.Nonce; if (!string.IsNullOrEmpty(nonce)) @@ -551,14 +545,14 @@ protected override async Task HandleRemoteAuthenticateAsync( nonce = ReadNonceCookie(nonce); } - var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, null, properties, ticket, jwt, nonce); - if (tokenValidatedContext.IsProcessingComplete(out result)) + var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, null, user, properties, jwt, nonce); + if (tokenValidatedContext.Result != null) { - return result; + return tokenValidatedContext.Result; } authorizationResponse = tokenValidatedContext.ProtocolMessage; + user = tokenValidatedContext.Principal; properties = tokenValidatedContext.Properties; - ticket = tokenValidatedContext.Ticket; jwt = tokenValidatedContext.SecurityToken; nonce = tokenValidatedContext.Nonce; } @@ -576,17 +570,17 @@ protected override async Task HandleRemoteAuthenticateAsync( // Authorization Code or Hybrid flow if (!string.IsNullOrEmpty(authorizationResponse.Code)) { - var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(authorizationResponse, properties, ticket, jwt); - if (authorizationCodeReceivedContext.IsProcessingComplete(out result)) + var authorizationCodeReceivedContext = await RunAuthorizationCodeReceivedEventAsync(authorizationResponse, user, properties, jwt); + if (authorizationCodeReceivedContext.Result != null) { - return result; + return authorizationCodeReceivedContext.Result; } authorizationResponse = authorizationCodeReceivedContext.ProtocolMessage; + user = authorizationCodeReceivedContext.Principal; properties = authorizationCodeReceivedContext.Properties; var tokenEndpointRequest = authorizationCodeReceivedContext.TokenEndpointRequest; // If the developer redeemed the code themselves... tokenEndpointResponse = authorizationCodeReceivedContext.TokenEndpointResponse; - ticket = authorizationCodeReceivedContext.Ticket; jwt = authorizationCodeReceivedContext.JwtSecurityToken; if (!authorizationCodeReceivedContext.HandledCodeRedemption) @@ -594,14 +588,16 @@ protected override async Task HandleRemoteAuthenticateAsync( tokenEndpointResponse = await RedeemAuthorizationCodeAsync(tokenEndpointRequest); } - var tokenResponseReceivedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, properties, ticket); - if (tokenResponseReceivedContext.IsProcessingComplete(out result)) + var tokenResponseReceivedContext = await RunTokenResponseReceivedEventAsync(authorizationResponse, tokenEndpointResponse, user, properties); + if (tokenResponseReceivedContext.Result != null) { - return result; + return tokenResponseReceivedContext.Result; } authorizationResponse = tokenResponseReceivedContext.ProtocolMessage; tokenEndpointResponse = tokenResponseReceivedContext.TokenEndpointResponse; + user = tokenResponseReceivedContext.Principal; + properties = tokenResponseReceivedContext.Properties; // no need to validate signature when token is received using "code flow" as per spec // [http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation]. @@ -610,10 +606,10 @@ protected override async Task HandleRemoteAuthenticateAsync( // At least a cursory validation is required on the new IdToken, even if we've already validated the one from the authorization response. // And we'll want to validate the new JWT in ValidateTokenResponse. JwtSecurityToken tokenEndpointJwt; - var tokenEndpointTicket = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out tokenEndpointJwt); + var tokenEndpointUser = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out tokenEndpointJwt); // Avoid reading & deleting the nonce cookie, running the event, etc, if it was already done as part of the authorization response validation. - if (ticket == null) + if (user == null) { nonce = tokenEndpointJwt.Payload.Nonce; if (!string.IsNullOrEmpty(nonce)) @@ -621,15 +617,15 @@ protected override async Task HandleRemoteAuthenticateAsync( nonce = ReadNonceCookie(nonce); } - var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, tokenEndpointResponse, properties, tokenEndpointTicket, tokenEndpointJwt, nonce); - if (tokenValidatedContext.IsProcessingComplete(out result)) + var tokenValidatedContext = await RunTokenValidatedEventAsync(authorizationResponse, tokenEndpointResponse, tokenEndpointUser, properties, tokenEndpointJwt, nonce); + if (tokenValidatedContext.Result != null) { - return result; + return tokenValidatedContext.Result; } authorizationResponse = tokenValidatedContext.ProtocolMessage; tokenEndpointResponse = tokenValidatedContext.TokenEndpointResponse; + user = tokenValidatedContext.Principal; properties = tokenValidatedContext.Properties; - ticket = tokenValidatedContext.Ticket; jwt = tokenValidatedContext.SecurityToken; nonce = tokenValidatedContext.Nonce; } @@ -658,23 +654,23 @@ protected override async Task HandleRemoteAuthenticateAsync( if (Options.SaveTokens) { - SaveTokens(ticket.Properties, tokenEndpointResponse ?? authorizationResponse); + SaveTokens(properties, tokenEndpointResponse ?? authorizationResponse); } if (Options.GetClaimsFromUserInfoEndpoint) { - return await GetUserInformationAsync(tokenEndpointResponse ?? authorizationResponse, jwt, ticket); + return await GetUserInformationAsync(tokenEndpointResponse ?? authorizationResponse, jwt, user, properties); } else { - var identity = (ClaimsIdentity)ticket.Principal.Identity; + var identity = (ClaimsIdentity)user.Identity; foreach (var action in Options.ClaimActions) { action.Run(null, identity, ClaimsIssuer); } } - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(new AuthenticationTicket(user, properties, Scheme.Name)); } catch (Exception exception) { @@ -691,12 +687,12 @@ protected override async Task HandleRemoteAuthenticateAsync( } var authenticationFailedContext = await RunAuthenticationFailedEventAsync(authorizationResponse, exception); - if (authenticationFailedContext.IsProcessingComplete(out result)) + if (authenticationFailedContext.Result != null) { - return result; + return authenticationFailedContext.Result; } - return AuthenticateResult.Fail(exception); + return HandleRequestResult.Fail(exception); } } @@ -765,21 +761,24 @@ protected virtual async Task RedeemAuthorizationCodeAsync( /// /// message that is being processed /// The . - /// authentication ticket with claims principal and identities - /// Authentication ticket with identity with additional claims, if any. - protected virtual async Task GetUserInformationAsync(OpenIdConnectMessage message, JwtSecurityToken jwt, AuthenticationTicket ticket) + /// The claims principal and identities. + /// The authentication properties. + /// which is used to determine if the remote authentication was successful. + protected virtual async Task GetUserInformationAsync( + OpenIdConnectMessage message, JwtSecurityToken jwt, + ClaimsPrincipal principal, AuthenticationProperties properties) { var userInfoEndpoint = _configuration?.UserInfoEndpoint; if (string.IsNullOrEmpty(userInfoEndpoint)) { Logger.UserInfoEndpointNotSet(); - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(new AuthenticationTicket(principal, properties, Scheme.Name)); } if (string.IsNullOrEmpty(message.AccessToken)) { Logger.AccessTokenNotAvailable(); - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(new AuthenticationTicket(principal, properties, Scheme.Name)); } Logger.RetrievingClaims(); var requestMessage = new HttpRequestMessage(HttpMethod.Get, userInfoEndpoint); @@ -801,16 +800,16 @@ protected virtual async Task GetUserInformationAsync(OpenIdC } else { - return AuthenticateResult.Fail("Unknown response type: " + contentType.MediaType); + return HandleRequestResult.Fail("Unknown response type: " + contentType.MediaType); } - var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(ticket, message, user); - AuthenticateResult result; - if (userInformationReceivedContext.IsProcessingComplete(out result)) + var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(principal, properties, message, user); + if (userInformationReceivedContext.Result != null) { - return result; + return userInformationReceivedContext.Result; } - ticket = userInformationReceivedContext.Ticket; + principal = userInformationReceivedContext.Principal; + properties = userInformationReceivedContext.Properties; user = userInformationReceivedContext.User; Options.ProtocolValidator.ValidateUserInfoResponse(new OpenIdConnectProtocolValidationContext() @@ -819,14 +818,14 @@ protected virtual async Task GetUserInformationAsync(OpenIdC ValidatedIdToken = jwt, }); - var identity = (ClaimsIdentity)ticket.Principal.Identity; + var identity = (ClaimsIdentity)principal.Identity; foreach (var action in Options.ClaimActions) { action.Run(user, identity, ClaimsIssuer); } - return AuthenticateResult.Success(ticket); + return HandleRequestResult.Success(new AuthenticationTicket(principal, properties, Scheme.Name)); } /// @@ -983,51 +982,54 @@ private AuthenticationProperties GetPropertiesFromState(string state) private async Task RunMessageReceivedEventAsync(OpenIdConnectMessage message, AuthenticationProperties properties) { Logger.MessageReceived(message.BuildRedirectUrl()); - var messageReceivedContext = new MessageReceivedContext(Context, Scheme, Options) + var context = new MessageReceivedContext(Context, Scheme, Options, properties) { ProtocolMessage = message, - Properties = properties, }; - await Events.MessageReceived(messageReceivedContext); - if (messageReceivedContext.HandledResponse) + await Events.MessageReceived(context); + if (context.Result != null) { - Logger.MessageReceivedContextHandledResponse(); - } - else if (messageReceivedContext.Skipped) - { - Logger.MessageReceivedContextSkipped(); + if (context.Result.Handled) + { + Logger.MessageReceivedContextHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.MessageReceivedContextSkipped(); + } } - return messageReceivedContext; + return context; } - private async Task RunTokenValidatedEventAsync(OpenIdConnectMessage authorizationResponse, OpenIdConnectMessage tokenEndpointResponse, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt, string nonce) + private async Task RunTokenValidatedEventAsync(OpenIdConnectMessage authorizationResponse, OpenIdConnectMessage tokenEndpointResponse, ClaimsPrincipal user, AuthenticationProperties properties, JwtSecurityToken jwt, string nonce) { - var tokenValidatedContext = new TokenValidatedContext(Context, Scheme, Options) + var context = new TokenValidatedContext(Context, Scheme, Options, user, properties) { ProtocolMessage = authorizationResponse, TokenEndpointResponse = tokenEndpointResponse, - Properties = properties, - Ticket = ticket, SecurityToken = jwt, Nonce = nonce, }; - await Events.TokenValidated(tokenValidatedContext); - if (tokenValidatedContext.HandledResponse) + await Events.TokenValidated(context); + if (context.Result != null) { - Logger.TokenValidatedHandledResponse(); - } - else if (tokenValidatedContext.Skipped) - { - Logger.TokenValidatedSkipped(); + if (context.Result.Handled) + { + Logger.TokenValidatedHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.TokenValidatedSkipped(); + } } - return tokenValidatedContext; + return context; } - private async Task RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage authorizationResponse, AuthenticationProperties properties, AuthenticationTicket ticket, JwtSecurityToken jwt) + private async Task RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage authorizationResponse, ClaimsPrincipal user, AuthenticationProperties properties, JwtSecurityToken jwt) { Logger.AuthorizationCodeReceived(); @@ -1041,102 +1043,112 @@ private async Task RunAuthorizationCodeReceive RedirectUri = properties.Items[OpenIdConnectDefaults.RedirectUriForCodePropertiesKey] }; - var authorizationCodeReceivedContext = new AuthorizationCodeReceivedContext(Context, Scheme, Options) + var context = new AuthorizationCodeReceivedContext(Context, Scheme, Options, properties) { ProtocolMessage = authorizationResponse, - Properties = properties, TokenEndpointRequest = tokenEndpointRequest, - Ticket = ticket, + Principal = user, JwtSecurityToken = jwt, - Backchannel = Backchannel, + Backchannel = Backchannel }; - await Events.AuthorizationCodeReceived(authorizationCodeReceivedContext); - if (authorizationCodeReceivedContext.HandledResponse) - { - Logger.AuthorizationCodeReceivedContextHandledResponse(); - } - else if (authorizationCodeReceivedContext.Skipped) + await Events.AuthorizationCodeReceived(context); + if (context.Result != null) { - Logger.AuthorizationCodeReceivedContextSkipped(); + if (context.Result.Handled) + { + Logger.AuthorizationCodeReceivedContextHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.AuthorizationCodeReceivedContextSkipped(); + } } - return authorizationCodeReceivedContext; + return context; } private async Task RunTokenResponseReceivedEventAsync( OpenIdConnectMessage message, OpenIdConnectMessage tokenEndpointResponse, - AuthenticationProperties properties, - AuthenticationTicket ticket) + ClaimsPrincipal user, + AuthenticationProperties properties) { Logger.TokenResponseReceived(); - var eventContext = new TokenResponseReceivedContext(Context, Scheme, Options, properties) + var context = new TokenResponseReceivedContext(Context, Scheme, Options, user, properties) { ProtocolMessage = message, TokenEndpointResponse = tokenEndpointResponse, - Ticket = ticket }; - await Events.TokenResponseReceived(eventContext); - if (eventContext.HandledResponse) - { - Logger.TokenResponseReceivedHandledResponse(); - } - else if (eventContext.Skipped) + await Events.TokenResponseReceived(context); + if (context.Result != null) { - Logger.TokenResponseReceivedSkipped(); + if (context.Result.Handled) + { + Logger.TokenResponseReceivedHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.TokenResponseReceivedSkipped(); + } } - return eventContext; + return context; } - private async Task RunUserInformationReceivedEventAsync(AuthenticationTicket ticket, OpenIdConnectMessage message, JObject user) + private async Task RunUserInformationReceivedEventAsync(ClaimsPrincipal principal, AuthenticationProperties properties, OpenIdConnectMessage message, JObject user) { Logger.UserInformationReceived(user.ToString()); - var userInformationReceivedContext = new UserInformationReceivedContext(Context, Scheme, Options) + var context = new UserInformationReceivedContext(Context, Scheme, Options, principal, properties) { - Ticket = ticket, ProtocolMessage = message, User = user, }; - await Events.UserInformationReceived(userInformationReceivedContext); - if (userInformationReceivedContext.HandledResponse) + await Events.UserInformationReceived(context); + if (context.Result != null) { - Logger.UserInformationReceivedHandledResponse(); - } - else if (userInformationReceivedContext.Skipped) - { - Logger.UserInformationReceivedSkipped(); + if (context.Result.Handled) + { + Logger.UserInformationReceivedHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.UserInformationReceivedSkipped(); + } } - return userInformationReceivedContext; + return context; } private async Task RunAuthenticationFailedEventAsync(OpenIdConnectMessage message, Exception exception) { - var authenticationFailedContext = new AuthenticationFailedContext(Context, Scheme, Options) + var context = new AuthenticationFailedContext(Context, Scheme, Options) { ProtocolMessage = message, Exception = exception }; - await Events.AuthenticationFailed(authenticationFailedContext); - if (authenticationFailedContext.HandledResponse) + await Events.AuthenticationFailed(context); + if (context.Result != null) { - Logger.AuthenticationFailedContextHandledResponse(); - } - else if (authenticationFailedContext.Skipped) - { - Logger.AuthenticationFailedContextSkipped(); + if (context.Result.Handled) + { + Logger.AuthenticationFailedContextHandledResponse(); + } + else if (context.Result.Skipped) + { + Logger.AuthenticationFailedContextSkipped(); + } } - return authenticationFailedContext; + return context; } - private AuthenticationTicket ValidateToken(string idToken, AuthenticationProperties properties, TokenValidationParameters validationParameters, out JwtSecurityToken jwt) + // Note this modifies properties if Options.UseTokenLifetime + private ClaimsPrincipal ValidateToken(string idToken, AuthenticationProperties properties, TokenValidationParameters validationParameters, out JwtSecurityToken jwt) { if (!Options.SecurityTokenValidator.CanReadToken(idToken)) { @@ -1173,24 +1185,22 @@ private AuthenticationTicket ValidateToken(string idToken, AuthenticationPropert throw new SecurityTokenException(string.Format(CultureInfo.InvariantCulture, Resources.UnableToValidateToken, idToken)); } - var ticket = new AuthenticationTicket(principal, properties, Scheme.Name); - if (Options.UseTokenLifetime) { var issued = validatedToken.ValidFrom; if (issued != DateTime.MinValue) { - ticket.Properties.IssuedUtc = issued; + properties.IssuedUtc = issued; } var expires = validatedToken.ValidTo; if (expires != DateTime.MinValue) { - ticket.Properties.ExpiresUtc = expires; + properties.ExpiresUtc = expires; } } - return ticket; + return principal; } /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a42f0eba3..8bcedaec2 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -4,13 +4,8 @@ using System; using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; -using System.Security.Claims; -using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth.Claims; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json index 4ba3fb756..0f50b1210 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json @@ -19,99 +19,45 @@ "TypeId": "public interface Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", "Kind": "Removal" }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Builder.OpenIdConnectOptions get_Options()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options, Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage message)", - "Kind": "Removal" - }, { "TypeId": "public static class Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOpenIdConnectAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", "Kind": "Removal" - } + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Kind": "Removal" + } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs deleted file mode 100644 index b71b8655b..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/BaseTwitterContext.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.Twitter -{ - /// - /// Base class for other Twitter contexts. - /// - public class BaseTwitterContext : BaseAuthenticationContext - { - /// - /// Initializes a - /// - /// The HTTP environment - /// The scheme data - /// The options for Twitter - /// The AuthenticationProperties - public BaseTwitterContext(HttpContext context, AuthenticationScheme scheme, TwitterOptions options, AuthenticationProperties properties) - : base(context, scheme.Name, properties) - { - Options = options; - } - - public TwitterOptions Options { get; } - - public AuthenticationScheme Scheme { get; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs index eaf704bcb..67f28d529 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterCreatingTicketContext.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// /// Contains information about the login session as well as the user . /// - public class TwitterCreatingTicketContext : BaseTwitterContext + public class TwitterCreatingTicketContext : ResultContext { /// /// Initializes a @@ -19,29 +19,33 @@ public class TwitterCreatingTicketContext : BaseTwitterContext /// The HTTP environment /// The scheme data /// The options for Twitter + /// The . + /// The . /// Twitter user ID /// Twitter screen name /// Twitter access token /// Twitter access token secret /// User details - /// AuthenticationProperties. public TwitterCreatingTicketContext( HttpContext context, AuthenticationScheme scheme, TwitterOptions options, + ClaimsPrincipal principal, AuthenticationProperties properties, string userId, string screenName, string accessToken, string accessTokenSecret, JObject user) - : base(context, scheme, options, properties) + : base(context, scheme, options) { UserId = userId; ScreenName = screenName; AccessToken = accessToken; AccessTokenSecret = accessTokenSecret; User = user ?? new JObject(); + Principal = principal; + Properties = properties; } /// @@ -69,10 +73,5 @@ public TwitterCreatingTicketContext( /// if it is not available. /// public JObject User { get; } - - /// - /// Gets the representing the user - /// - public ClaimsPrincipal Principal { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs index c079ebb14..744c48c5f 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterEvents.cs @@ -19,7 +19,7 @@ public class TwitterEvents : RemoteAuthenticationEvents /// /// Gets or sets the delegate that is invoked when the ApplyRedirect method is invoked. /// - public Func OnRedirectToAuthorizationEndpoint { get; set; } = context => + public Func, Task> OnRedirectToAuthorizationEndpoint { get; set; } = context => { context.Response.Redirect(context.RedirectUri); return Task.CompletedTask; @@ -36,6 +36,6 @@ public class TwitterEvents : RemoteAuthenticationEvents /// Called when a Challenge causes a redirect to authorize endpoint in the Twitter handler /// /// Contains redirect URI and of the challenge - public virtual Task RedirectToAuthorizationEndpoint(TwitterRedirectToAuthorizationEndpointContext context) => OnRedirectToAuthorizationEndpoint(context); + public virtual Task RedirectToAuthorizationEndpoint(RedirectContext context) => OnRedirectToAuthorizationEndpoint(context); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs deleted file mode 100644 index fe181fe7b..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Events/TwitterRedirectToAuthorizationEndpointContext.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication.Twitter -{ - /// - /// The Context passed when a Challenge causes a redirect to authorize endpoint in the Twitter handler. - /// - public class TwitterRedirectToAuthorizationEndpointContext : BaseTwitterContext - { - /// - /// Creates a new context object. - /// - /// The HTTP request context. - /// The scheme data - /// The Twitter handler options. - /// The authentication properties of the challenge. - /// The initial redirect URI. - public TwitterRedirectToAuthorizationEndpointContext(HttpContext context, AuthenticationScheme scheme, - - TwitterOptions options, AuthenticationProperties properties, string redirectUri) - : base(context, scheme, options, properties) - { - RedirectUri = redirectUri; - Properties = properties; - } - - /// - /// Gets the URI used for the redirect operation. - /// - public string RedirectUri { get; private set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index d8b78398f..e49244920 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; @@ -10,6 +11,19 @@ namespace Microsoft.Extensions.DependencyInjection { public static class TwitterExtensions { + public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder) + => builder.AddTwitter(TwitterDefaults.AuthenticationScheme, _ => { }); + + public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddTwitter(TwitterDefaults.AuthenticationScheme, configureOptions); + + public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); + return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + } + + // REMOVE below once callers have been updated. public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services) => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { }); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index baa4320d1..7fcc01eee 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -46,7 +46,7 @@ public TwitterHandler(IOptionsSnapshot options, ILoggerFactory l protected override Task CreateEventsAsync() => Task.FromResult(new TwitterEvents()); - protected override async Task HandleRemoteAuthenticateAsync() + protected override async Task HandleRemoteAuthenticateAsync() { AuthenticationProperties properties = null; var query = Request.Query; @@ -56,7 +56,7 @@ protected override async Task HandleRemoteAuthenticateAsync( if (requestToken == null) { - return AuthenticateResult.Fail("Invalid state cookie."); + return HandleRequestResult.Fail("Invalid state cookie."); } properties = requestToken.Properties; @@ -66,18 +66,18 @@ protected override async Task HandleRemoteAuthenticateAsync( var returnedToken = query["oauth_token"]; if (StringValues.IsNullOrEmpty(returnedToken)) { - return AuthenticateResult.Fail("Missing oauth_token"); + return HandleRequestResult.Fail("Missing oauth_token"); } if (!string.Equals(returnedToken, requestToken.Token, StringComparison.Ordinal)) { - return AuthenticateResult.Fail("Unmatched token"); + return HandleRequestResult.Fail("Unmatched token"); } var oauthVerifier = query["oauth_verifier"]; if (StringValues.IsNullOrEmpty(oauthVerifier)) { - return AuthenticateResult.Fail("Missing or blank oauth_verifier"); + return HandleRequestResult.Fail("Missing or blank oauth_verifier"); } var cookieOptions = new CookieOptions @@ -116,7 +116,7 @@ protected override async Task HandleRemoteAuthenticateAsync( }); } - return AuthenticateResult.Success(await CreateTicketAsync(identity, properties, accessToken, user)); + return HandleRequestResult.Success(await CreateTicketAsync(identity, properties, accessToken, user)); } protected virtual async Task CreateTicketAsync( @@ -127,18 +127,9 @@ protected virtual async Task CreateTicketAsync( action.Run(user, identity, ClaimsIssuer); } - var context = new TwitterCreatingTicketContext(Context, Scheme, Options, properties, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user) - { - Principal = new ClaimsPrincipal(identity) - }; - + var context = new TwitterCreatingTicketContext(Context, Scheme, Options, new ClaimsPrincipal(identity), properties, token.UserId, token.ScreenName, token.Token, token.TokenSecret, user); await Events.CreatingTicket(context); - if (context.Principal?.Identity == null) - { - return null; - } - return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); } @@ -165,7 +156,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions); - var redirectContext = new TwitterRedirectToAuthorizationEndpointContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint); + var redirectContext = new RedirectContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint); await Events.RedirectToAuthorizationEndpoint(redirectContext); } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json index 2023eb0b7..6b8440911 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json @@ -20,43 +20,26 @@ "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.TwitterOptions options, Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties properties, System.String redirectUri)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.TwitterOptions options, System.String userId, System.String screenName, System.String accessToken, System.String accessTokenSecret, Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "TypeId": "public static class Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", + "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseTwitterAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.TwitterOptions options)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", "Kind": "Removal" }, { - "TypeId": "public static class Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseTwitterAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.TwitterOptions options)", + "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs new file mode 100644 index 000000000..c29bdeae2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -0,0 +1,103 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Used to configure authentication + /// + public class AuthenticationBuilder + { + /// + /// Constructor. + /// + /// The services being configured. + public AuthenticationBuilder(IServiceCollection services) + => Services = services; + + /// + /// The services being configured. + /// + public virtual IServiceCollection Services { get; } + + /// + /// Adds a which can be used by . + /// + /// The type to configure the handler."/>. + /// The used to handle this scheme. + /// The name of this scheme. + /// The display name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddScheme(string authenticationScheme, string displayName, Action configureOptions) + where TOptions : AuthenticationSchemeOptions, new() + where THandler : AuthenticationHandler + { + Services.Configure(o => + { + o.AddScheme(authenticationScheme, scheme => { + scheme.HandlerType = typeof(THandler); + scheme.DisplayName = displayName; + }); + }); + if (configureOptions != null) + { + Services.Configure(authenticationScheme, configureOptions); + } + Services.AddTransient(); + return this; + } + + /// + /// Adds a which can be used by . + /// + /// The type to configure the handler."/>. + /// The used to handle this scheme. + /// The name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddScheme(string authenticationScheme, Action configureOptions) + where TOptions : AuthenticationSchemeOptions, new() + where THandler : AuthenticationHandler + => AddScheme(authenticationScheme, displayName: null, configureOptions: configureOptions); + + /// + /// Adds a based that supports remote authentication + /// which can be used by . + /// + /// The type to configure the handler."/>. + /// The used to handle this scheme. + /// The name of this scheme. + /// The display name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddRemoteScheme(string authenticationScheme, string displayName, Action configureOptions) + where TOptions : RemoteAuthenticationOptions, new() + where THandler : RemoteAuthenticationHandler + { + Services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); + return AddScheme(authenticationScheme, displayName, configureOptions: configureOptions); + } + + // Used to ensure that there's always a default data protection provider + private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions + { + private readonly AuthenticationOptions _authOptions; + + public EnsureSignInScheme(IOptions authOptions) + { + _authOptions = authOptions.Value; + } + + public void PostConfigure(string name, TOptions options) + { + options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme; + } + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 788df7e19..aeb70cb0d 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -178,35 +178,6 @@ protected async Task HandleAuthenticateOnceSafeAsync() protected abstract Task HandleAuthenticateAsync(); - public async Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - { - if (user == null) - { - throw new ArgumentNullException(nameof(user)); - } - - properties = properties ?? new AuthenticationProperties(); - await HandleSignInAsync(user, properties); - Logger.AuthenticationSchemeSignedIn(Scheme.Name); - } - - protected virtual Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - { - return Task.CompletedTask; - } - - public async Task SignOutAsync(AuthenticationProperties properties) - { - properties = properties ?? new AuthenticationProperties(); - await HandleSignOutAsync(properties); - Logger.AuthenticationSchemeSignedOut(Scheme.Name); - } - - protected virtual Task HandleSignOutAsync(AuthenticationProperties properties) - { - return Task.CompletedTask; - } - /// /// Override this method to handle Forbid. /// diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 7ebc979f1..28291f419 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -13,7 +13,7 @@ namespace Microsoft.Extensions.DependencyInjection /// public static class AuthenticationServiceCollectionExtensions { - public static IServiceCollection AddAuthentication(this IServiceCollection services) + public static AuthenticationBuilder AddAuthentication(this IServiceCollection services) { if (services == null) { @@ -24,10 +24,10 @@ public static IServiceCollection AddAuthentication(this IServiceCollection servi services.AddDataProtection(); services.AddWebEncoders(); services.TryAddSingleton(); - return services; + return new AuthenticationBuilder(services); } - public static IServiceCollection AddAuthentication(this IServiceCollection services, Action configureOptions) { + public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, Action configureOptions) { if (services == null) { throw new ArgumentNullException(nameof(services)); @@ -38,11 +38,12 @@ public static IServiceCollection AddAuthentication(this IServiceCollection servi throw new ArgumentNullException(nameof(configureOptions)); } - services.AddAuthentication(); + var builder = services.AddAuthentication(); services.Configure(configureOptions); - return services; + return builder; } + // REMOVE below once callers have been updated public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureScheme, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs deleted file mode 100644 index cfe5809c5..000000000 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseAuthenticationContext.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Base context for authentication. - /// - public abstract class BaseAuthenticationContext : BaseContext - { - /// - /// Constructor. - /// - /// The context. - /// The name of the scheme. - /// The properties. - protected BaseAuthenticationContext(HttpContext context, string authenticationScheme, AuthenticationProperties properties) : base(context) - { - if (string.IsNullOrEmpty(authenticationScheme)) - { - throw new ArgumentException(nameof(authenticationScheme)); - } - - AuthenticationScheme = authenticationScheme; - Properties = properties ?? new AuthenticationProperties(); - } - - /// - /// The name of the scheme. - /// - public string AuthenticationScheme { get; } - - /// - /// Contains the extra meta-data arriving with the authentication. May be altered. - /// - public AuthenticationProperties Properties { get; protected set; } - } -} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs index 3d65f0dd7..915fc2377 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/BaseContext.cs @@ -9,22 +9,44 @@ namespace Microsoft.AspNetCore.Authentication /// /// Base class used by other context classes. /// - public abstract class BaseContext + public abstract class BaseContext where TOptions : AuthenticationSchemeOptions { /// /// Constructor. /// - /// The request context. - protected BaseContext(HttpContext context) + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + protected BaseContext(HttpContext context, AuthenticationScheme scheme, TOptions options) { if (context == null) { throw new ArgumentNullException(nameof(context)); } + if (scheme == null) + { + throw new ArgumentNullException(nameof(scheme)); + } + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } HttpContext = context; + Scheme = scheme; + Options = options; } + /// + /// The authentication scheme. + /// + public AuthenticationScheme Scheme { get; } + + /// + /// Gets the authentication options associated with the scheme. + /// + public TOptions Options { get; } + /// /// The context. /// @@ -33,17 +55,11 @@ protected BaseContext(HttpContext context) /// /// The request. /// - public HttpRequest Request - { - get { return HttpContext.Request; } - } + public HttpRequest Request => HttpContext.Request; /// /// The response. /// - public HttpResponse Response - { - get { return HttpContext.Response; } - } + public HttpResponse Response => HttpContext.Response; } } diff --git a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs deleted file mode 100644 index fa582a304..000000000 --- a/src/Microsoft.AspNetCore.Authentication/Events/BaseControlContext.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication -{ - public class BaseControlContext : BaseContext - { - protected BaseControlContext(HttpContext context) : base(context) - { - } - - public EventResultState State { get; set; } - - public bool HandledResponse - { - get { return State == EventResultState.HandledResponse; } - } - - public bool Skipped - { - get { return State == EventResultState.Skipped; } - } - - /// - /// Discontinue all processing for this request and return to the client. - /// The caller is responsible for generating the full response. - /// Set the to trigger SignIn. - /// - public void HandleResponse() - { - State = EventResultState.HandledResponse; - } - - /// - /// Discontinue processing the request in the current handler. - /// SignIn will not be called. - /// - public void Skip() - { - State = EventResultState.Skipped; - } - - /// - /// Gets or set the to return if this event signals it handled the event. - /// - public AuthenticationTicket Ticket { get; set; } - - /// - /// Returns true if the handler should be done processing. - /// - /// The result. - /// Whether the handler should be done processing. - public bool IsProcessingComplete(out AuthenticateResult result) - { - if (HandledResponse) - { - if (Ticket == null) - { - result = AuthenticateResult.Handle(); - } - else - { - result = AuthenticateResult.Success(Ticket); - } - return true; - } - else if (Skipped) - { - result = AuthenticateResult.None(); - return true; - } - result = null; - return false; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs b/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs deleted file mode 100644 index dad4c40fe..000000000 --- a/src/Microsoft.AspNetCore.Authentication/Events/EventResultState.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Microsoft.AspNetCore.Authentication -{ - public enum EventResultState - { - /// - /// Continue with normal processing. - /// - Continue, - - /// - /// Discontinue processing the request. - /// - Skipped, - - /// - /// Discontinue all processing for this request. - /// - HandledResponse - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs new file mode 100644 index 000000000..52dd9ce12 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/HandleRequestContext.cs @@ -0,0 +1,32 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + public class HandleRequestContext : BaseContext where TOptions : AuthenticationSchemeOptions + { + protected HandleRequestContext( + HttpContext context, + AuthenticationScheme scheme, + TOptions options) + : base(context, scheme, options) { } + + /// + /// The which is used by the handler. + /// + public HandleRequestResult Result { get; protected set; } + + /// + /// Discontinue all processing for this request and return to the client. + /// The caller is responsible for generating the full response. + /// + public void HandleResponse() => Result = HandleRequestResult.Handle(); + + /// + /// Discontinue processing the request in the current handler. + /// + public void SkipHandler() => Result = HandleRequestResult.SkipHandler(); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs new file mode 100644 index 000000000..8bf40760a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/PrincipalContext.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for authentication events which deal with a ClaimsPrincipal. + /// + public abstract class PrincipalContext : PropertiesContext where TOptions : AuthenticationSchemeOptions + { + /// + /// Constructor. + /// + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + /// The authentication properties. + protected PrincipalContext(HttpContext context, AuthenticationScheme scheme, TOptions options, AuthenticationProperties properties) + : base(context, scheme, options, properties) { } + + /// + /// Gets the containing the user claims. + /// + public virtual ClaimsPrincipal Principal { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs new file mode 100644 index 000000000..f1730d0d7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/PropertiesContext.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for authentication events which contain . + /// + public abstract class PropertiesContext : BaseContext where TOptions : AuthenticationSchemeOptions + { + /// + /// Constructor. + /// + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + /// The authentication properties. + protected PropertiesContext(HttpContext context, AuthenticationScheme scheme, TOptions options, AuthenticationProperties properties) + : base(context, scheme, options) + { + Properties = properties ?? new AuthenticationProperties(); + } + + /// + /// Gets or sets the . + /// + public virtual AuthenticationProperties Properties { get; protected set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs similarity index 62% rename from src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs rename to src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs index e4259d181..dac24cafa 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Events/CookieRedirectContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RedirectContext.cs @@ -1,28 +1,32 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; -namespace Microsoft.AspNetCore.Authentication.Cookies +namespace Microsoft.AspNetCore.Authentication { /// - /// Context passed when a Challenge, SignIn, or SignOut causes a redirect in the cookie handler + /// Context passed for redirect events. /// - public class CookieRedirectContext : BaseCookieContext + public class RedirectContext : PropertiesContext where TOptions : AuthenticationSchemeOptions { /// /// Creates a new context object. /// /// The HTTP request context /// The scheme data - /// The cookie handler options + /// The handler options /// The initial redirect URI /// The . - public CookieRedirectContext(HttpContext context, AuthenticationScheme scheme, CookieAuthenticationOptions options, string redirectUri, AuthenticationProperties properties) + public RedirectContext( + HttpContext context, + AuthenticationScheme scheme, + TOptions options, + AuthenticationProperties properties, + string redirectUri) : base(context, scheme, options, properties) { + Properties = properties; RedirectUri = redirectUri; } diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs new file mode 100644 index 000000000..b7a016879 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationContext.cs @@ -0,0 +1,49 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for remote authentication. + /// + public abstract class RemoteAuthenticationContext : HandleRequestContext where TOptions : AuthenticationSchemeOptions + { + /// + /// Constructor. + /// + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + /// The authentication properties. + protected RemoteAuthenticationContext( + HttpContext context, + AuthenticationScheme scheme, + TOptions options, + AuthenticationProperties properties) + : base(context, scheme, options) + => Properties = properties ?? new AuthenticationProperties(); + + /// + /// Gets the containing the user claims. + /// + public ClaimsPrincipal Principal { get; set; } + + /// + /// Gets or sets the . + /// + public virtual AuthenticationProperties Properties { get; set; } + + /// + /// Calls success creating a ticket with the and . + /// + public void Success() => Result = HandleRequestResult.Success(new AuthenticationTicket(Principal, Properties, Scheme.Name)); + + public void Fail(Exception failure) => Result = HandleRequestResult.Fail(failure); + + public void Fail(string failureMessage) => Result = HandleRequestResult.Fail(failureMessage); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs index 83a6507d4..ca0f4a5c0 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -8,14 +8,14 @@ namespace Microsoft.AspNetCore.Authentication { public class RemoteAuthenticationEvents { - public Func OnRemoteFailure { get; set; } = context => Task.CompletedTask; + public Func OnRemoteFailure { get; set; } = context => Task.CompletedTask; public Func OnTicketReceived { get; set; } = context => Task.CompletedTask; /// /// Invoked when there is a remote failure /// - public virtual Task RemoteFailure(FailureContext context) => OnRemoteFailure(context); + public virtual Task RemoteFailure(RemoteFailureContext context) => OnRemoteFailure(context); /// /// Invoked after the remote ticket has been received. diff --git a/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs similarity index 64% rename from src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs rename to src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs index 5d2b30f13..becdfb543 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/FailureContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs @@ -9,10 +9,14 @@ namespace Microsoft.AspNetCore.Authentication /// /// Provides failure context information to handler providers. /// - public class FailureContext : BaseControlContext + public class RemoteFailureContext : HandleRequestContext { - public FailureContext(HttpContext context, Exception failure) - : base(context) + public RemoteFailureContext( + HttpContext context, + AuthenticationScheme scheme, + RemoteAuthenticationOptions options, + Exception failure) + : base(context, scheme, options) { Failure = failure; } diff --git a/src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs new file mode 100644 index 000000000..12b21f4bf --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/ResultContext.cs @@ -0,0 +1,65 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Base context for events that produce AuthenticateResults. + /// + public abstract class ResultContext : BaseContext where TOptions : AuthenticationSchemeOptions + { + /// + /// Constructor. + /// + /// The context. + /// The authentication scheme. + /// The authentication options associated with the scheme. + protected ResultContext(HttpContext context, AuthenticationScheme scheme, TOptions options) + : base(context, scheme, options) { } + + /// + /// Gets or sets the containing the user claims. + /// + public ClaimsPrincipal Principal { get; set; } + + private AuthenticationProperties _properties; + /// + /// Gets or sets the . + /// + public AuthenticationProperties Properties { + get => _properties ?? (_properties = new AuthenticationProperties()); + set => _properties = value; + } + + /// + /// Gets the result. + /// + public AuthenticateResult Result { get; private set; } + + /// + /// Calls success creating a ticket with the and . + /// + public void Success() => Result = HandleRequestResult.Success(new AuthenticationTicket(Principal, Properties, Scheme.Name)); + + /// + /// Indicates that there was no information returned for this authentication scheme. + /// + public void NoResult() => Result = AuthenticateResult.NoResult(); + + /// + /// Indicates that there was a failure during authentication. + /// + /// + public void Fail(Exception failure) => Result = AuthenticateResult.Fail(failure); + + /// + /// Indicates that there was a failure during authentication. + /// + /// + public void Fail(string failureMessage) => Result = AuthenticateResult.Fail(failureMessage); + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs index c0797ea9c..51b77a37f 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/TicketReceivedContext.cs @@ -3,30 +3,21 @@ using System.Security.Claims; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication { /// /// Provides context information to handler providers. /// - public class TicketReceivedContext : BaseControlContext + public class TicketReceivedContext : RemoteAuthenticationContext { - public TicketReceivedContext(HttpContext context, RemoteAuthenticationOptions options, AuthenticationTicket ticket) - : base(context) - { - Options = options; - Ticket = ticket; - if (ticket != null) - { - Principal = ticket.Principal; - Properties = ticket.Properties; - } - } - - public ClaimsPrincipal Principal { get; set; } - public AuthenticationProperties Properties { get; set; } - public RemoteAuthenticationOptions Options { get; set; } + public TicketReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + RemoteAuthenticationOptions options, + AuthenticationTicket ticket) + : base(context, scheme, options, ticket?.Properties) + => Principal = ticket?.Principal; public string ReturnUri { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs index 49fc8db05..ed15e6190 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -9,14 +9,8 @@ internal static class LoggingExtensions { private static Action _authSchemeAuthenticated; private static Action _authSchemeNotAuthenticated; - private static Action _authSchemeNotAuthenticatedWithFailure; - private static Action _authSchemeSignedIn; - private static Action _authSchemeSignedOut; private static Action _authSchemeChallenged; private static Action _authSchemeForbidden; - private static Action _userAuthorizationFailed; - private static Action _userAuthorizationSucceeded; - private static Action _userPrincipalMerged; private static Action _remoteAuthenticationError; private static Action _signInHandled; private static Action _signInSkipped; @@ -26,18 +20,6 @@ internal static class LoggingExtensions static LoggingExtensions() { - _userAuthorizationSucceeded = LoggerMessage.Define( - eventId: 1, - logLevel: LogLevel.Information, - formatString: "Authorization was successful for user: {UserName}."); - _userAuthorizationFailed = LoggerMessage.Define( - eventId: 2, - logLevel: LogLevel.Information, - formatString: "Authorization failed for user: {UserName}."); - _userPrincipalMerged = LoggerMessage.Define( - eventId: 3, - logLevel: LogLevel.Information, - formatString: "HttpContext.User merged via AutomaticAuthentication from authenticationScheme: {AuthenticationScheme}."); _remoteAuthenticationError = LoggerMessage.Define( eventId: 4, logLevel: LogLevel.Information, @@ -50,10 +32,6 @@ static LoggingExtensions() eventId: 6, logLevel: LogLevel.Debug, formatString: "The SigningIn event returned Skipped."); - _authSchemeNotAuthenticatedWithFailure = LoggerMessage.Define( - eventId: 7, - logLevel: LogLevel.Information, - formatString: "{AuthenticationScheme} was not authenticated. Failure message: {FailureMessage}"); _authSchemeAuthenticated = LoggerMessage.Define( eventId: 8, logLevel: LogLevel.Information, @@ -62,14 +40,6 @@ static LoggingExtensions() eventId: 9, logLevel: LogLevel.Debug, formatString: "AuthenticationScheme: {AuthenticationScheme} was not authenticated."); - _authSchemeSignedIn = LoggerMessage.Define( - eventId: 10, - logLevel: LogLevel.Information, - formatString: "AuthenticationScheme: {AuthenticationScheme} signed in."); - _authSchemeSignedOut = LoggerMessage.Define( - eventId: 11, - logLevel: LogLevel.Information, - formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); _authSchemeChallenged = LoggerMessage.Define( eventId: 12, logLevel: LogLevel.Information, @@ -102,21 +72,6 @@ public static void AuthenticationSchemeNotAuthenticated(this ILogger logger, str _authSchemeNotAuthenticated(logger, authenticationScheme, null); } - public static void AuthenticationSchemeNotAuthenticatedWithFailure(this ILogger logger, string authenticationScheme, string failureMessage) - { - _authSchemeNotAuthenticatedWithFailure(logger, authenticationScheme, failureMessage, null); - } - - public static void AuthenticationSchemeSignedIn(this ILogger logger, string authenticationScheme) - { - _authSchemeSignedIn(logger, authenticationScheme, null); - } - - public static void AuthenticationSchemeSignedOut(this ILogger logger, string authenticationScheme) - { - _authSchemeSignedOut(logger, authenticationScheme, null); - } - public static void AuthenticationSchemeChallenged(this ILogger logger, string authenticationScheme) { _authSchemeChallenged(logger, authenticationScheme, null); @@ -127,21 +82,6 @@ public static void AuthenticationSchemeForbidden(this ILogger logger, string aut _authSchemeForbidden(logger, authenticationScheme, null); } - public static void UserAuthorizationSucceeded(this ILogger logger, string userName) - { - _userAuthorizationSucceeded(logger, userName, null); - } - - public static void UserAuthorizationFailed(this ILogger logger, string userName) - { - _userAuthorizationFailed(logger, userName, null); - } - - public static void UserPrinicpalMerged(this ILogger logger, string authenticationScheme) - { - _userPrincipalMerged(logger, authenticationScheme, null); - } - public static void RemoteAuthenticationError(this ILogger logger, string errorMessage) { _remoteAuthenticationError(logger, errorMessage, null); diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 69c926cc0..62213a171 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Security.Claims; using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; @@ -35,19 +34,13 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand } protected RemoteAuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) - : base(options, logger, encoder, clock) - { - } + : base(options, logger, encoder, clock) { } protected override Task CreateEventsAsync() - { - return Task.FromResult(new RemoteAuthenticationEvents()); - } + => Task.FromResult(new RemoteAuthenticationEvents()); public virtual Task ShouldHandleRequestAsync() - { - return Task.FromResult(Options.CallbackPath == Request.Path); - } + => Task.FromResult(Options.CallbackPath == Request.Path); public virtual async Task HandleRequestAsync() { @@ -69,7 +62,7 @@ public virtual async Task HandleRequestAsync() { return true; } - else if (authResult.Nothing) + else if (authResult.Skipped || authResult.None) { return false; } @@ -89,25 +82,28 @@ public virtual async Task HandleRequestAsync() if (exception != null) { Logger.RemoteAuthenticationError(exception.Message); - var errorContext = new FailureContext(Context, exception); + var errorContext = new RemoteFailureContext(Context, Scheme, Options, exception); await Events.RemoteFailure(errorContext); - if (errorContext.HandledResponse) - { - return true; - } - else if (errorContext.Skipped) + if (errorContext.Result != null) { - return false; + if (errorContext.Result.Handled) + { + return true; + } + else if (errorContext.Result.Skipped) + { + return false; + } } - throw new AggregateException("Unhandled remote failure.", exception); + throw exception; } // We have a ticket if we get here - var ticketContext = new TicketReceivedContext(Context, Options, ticket) + var ticketContext = new TicketReceivedContext(Context, Scheme, Options, ticket) { - ReturnUri = ticket.Properties.RedirectUri, + ReturnUri = ticket.Properties.RedirectUri }; // REVIEW: is this safe or good? ticket.Properties.RedirectUri = null; @@ -117,15 +113,18 @@ public virtual async Task HandleRequestAsync() await Events.TicketReceived(ticketContext); - if (ticketContext.HandledResponse) + if (ticketContext.Result != null) { - Logger.SigninHandled(); - return true; - } - else if (ticketContext.Skipped) - { - Logger.SigninSkipped(); - return false; + if (ticketContext.Result.Handled) + { + Logger.SigninHandled(); + return true; + } + else if (ticketContext.Result.Skipped) + { + Logger.SigninSkipped(); + return false; + } } await Context.SignInAsync(SignInScheme, ticketContext.Principal, ticketContext.Properties); @@ -145,7 +144,7 @@ public virtual async Task HandleRequestAsync() /// /// The method process the request on the endpoint defined by CallbackPath. /// - protected abstract Task HandleRemoteAuthenticateAsync(); + protected abstract Task HandleRemoteAuthenticateAsync(); protected override async Task HandleAuthenticateAsync() { @@ -174,20 +173,8 @@ protected override async Task HandleAuthenticateAsync() return AuthenticateResult.Fail("Remote authentication does not directly support AuthenticateAsync"); } - protected override Task HandleSignOutAsync(AuthenticationProperties properties) - { - throw new NotSupportedException(); - } - - protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - { - throw new NotSupportedException(); - } - protected override Task HandleForbiddenAsync(AuthenticationProperties properties) - { - return Context.ForbidAsync(SignInScheme); - } + => Context.ForbidAsync(SignInScheme); protected virtual void GenerateCorrelationId(AuthenticationProperties properties) { diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 066ca963a..a5f0bb44b 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -23,11 +23,6 @@ public override void Validate() { throw new ArgumentException(Resources.FormatException_OptionMustBeProvided(nameof(CallbackPath)), nameof(CallbackPath)); } - - if (string.IsNullOrEmpty(SignInScheme)) - { - throw new ArgumentException(Resources.FormatException_OptionMustBeProvided(nameof(SignInScheme)), nameof(SignInScheme)); - } } /// diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs new file mode 100644 index 000000000..8bcd2be01 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs @@ -0,0 +1,78 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Contains the result of an Authenticate call + /// + public class HandleRequestResult : AuthenticateResult + { + /// + /// Indicates that stage of authentication was directly handled by + /// user intervention and no further processing should be attempted. + /// + public bool Handled { get; private set; } + + /// + /// Indicates that the default authentication logic should be + /// skipped and that the rest of the pipeline should be invoked. + /// + public bool Skipped { get; private set; } + + /// + /// Indicates that authentication was successful. + /// + /// The ticket representing the authentication result. + /// The result. + public static new HandleRequestResult Success(AuthenticationTicket ticket) + { + if (ticket == null) + { + throw new ArgumentNullException(nameof(ticket)); + } + return new HandleRequestResult() { Ticket = ticket }; + } + + /// + /// Indicates that there was a failure during authentication. + /// + /// The failure exception. + /// The result. + public static new HandleRequestResult Fail(Exception failure) + { + return new HandleRequestResult() { Failure = failure }; + } + + /// + /// Indicates that there was a failure during authentication. + /// + /// The failure message. + /// The result. + public static new HandleRequestResult Fail(string failureMessage) + { + return new HandleRequestResult() { Failure = new Exception(failureMessage) }; + } + + /// + /// Discontinue all processing for this request and return to the client. + /// The caller is responsible for generating the full response. + /// + /// The result. + public static HandleRequestResult Handle() + { + return new HandleRequestResult() { Handled = true }; + } + + /// + /// Discontinue processing the request in the current handler. + /// + /// The result. + public static HandleRequestResult SkipHandler() + { + return new HandleRequestResult() { Skipped = true }; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json index 0eb0bfaf5..81dc1133e 100644 --- a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json @@ -84,43 +84,33 @@ "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public .ctor(Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions options, Microsoft.AspNetCore.Authentication.AuthenticationTicket ticket)", + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configureOptions)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions get_Options()", + "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.BaseContext", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", + "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public System.Void set_Options(Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions value)", + "TypeId": "public class Microsoft.AspNetCore.Authentication.FailureContext : Microsoft.AspNetCore.Authentication.BaseControlContext", "Kind": "Removal" }, { "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", "Kind": "Removal" }, { "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", - "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configureOptions)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public System.Boolean CheckEventResult(out Microsoft.AspNetCore.Authentication.AuthenticateResult result)", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)", "Kind": "Removal" }, { - "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", - "MemberId": "public System.Void SkipToNextMiddleware()", + "TypeId": "public enum Microsoft.AspNetCore.Authentication.EventResultState", "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs index 60f291f67..f93c2d92a 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs @@ -52,13 +52,13 @@ public virtual async Task AuthenticateAsync(AuthorizationPol else { context.User = new ClaimsPrincipal(new ClaimsIdentity()); - return AuthenticateResult.None(); + return AuthenticateResult.NoResult(); } } return (context.User?.Identity?.IsAuthenticated ?? false) ? AuthenticateResult.Success(new AuthenticationTicket(context.User, "context.User")) - : AuthenticateResult.None(); + : AuthenticateResult.NoResult(); } /// diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 677120e4b..7dade96ee 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics; using System.Linq; using System.Net; using System.Net.Http; @@ -29,7 +30,8 @@ public class CookieTests [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddCookieAuthentication(); + var services = new ServiceCollection(); + services.AddAuthentication().AddCookie(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(CookieAuthenticationDefaults.AuthenticationScheme); @@ -124,7 +126,7 @@ private Task SignOutAsWrong(HttpContext context) [Fact] public async Task SignInCausesDefaultCookieToBeCreated() { - var server = CreateServerWithServices(s => s.AddCookieAuthentication(o => + var server = CreateServerWithServices(s => s.AddAuthentication().AddCookie(o => { o.LoginPath = new PathString("/login"); o.CookieName = "TestCookie"; @@ -772,7 +774,7 @@ public async Task MapWillAffectChallengeOnlyWithUseAuth(bool useAuth) } app.Map("/login", signoutApp => signoutApp.Run(context => context.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); }) - .ConfigureServices(s => s.AddCookieAuthentication(o => o.LoginPath = new PathString("/page"))); + .ConfigureServices(s => s.AddAuthentication().AddCookie(o => o.LoginPath = new PathString("/page"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/login"); @@ -803,7 +805,7 @@ public async Task ChallengeDoesNotSet401OnUnauthorized() await Assert.ThrowsAsync(() => context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme)); }); }) - .ConfigureServices(services => services.AddCookieAuthentication()); + .ConfigureServices(services => services.AddAuthentication().AddCookie()); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com"); @@ -821,7 +823,7 @@ public async Task CanConfigureDefaultCookieInstance() }) .ConfigureServices(services => { - services.AddCookieAuthentication(); + services.AddAuthentication().AddCookie(); services.Configure(CookieAuthenticationDefaults.AuthenticationScheme, o => o.CookieName = "One"); }); @@ -844,7 +846,7 @@ public async Task CanConfigureNamedCookieInstance() }) .ConfigureServices(services => { - services.AddCookieAuthentication("Cookie1"); + services.AddAuthentication().AddCookie("Cookie1"); services.Configure("Cookie1", o => o.CookieName = "One"); }); @@ -866,7 +868,7 @@ public async Task MapWithSignInOnlyRedirectToReturnUrlOnLoginPath() app.Map("/notlogin", signoutApp => signoutApp.Run(context => context.SignInAsync("Cookies", new ClaimsPrincipal()))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LoginPath = new PathString("/login"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LoginPath = new PathString("/login"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/notlogin?ReturnUrl=%2Fpage"); @@ -883,7 +885,7 @@ public async Task MapWillNotAffectSignInRedirectToReturnUrl() app.UseAuthentication(); app.Map("/login", signoutApp => signoutApp.Run(context => context.SignInAsync("Cookies", new ClaimsPrincipal()))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LoginPath = new PathString("/login"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LoginPath = new PathString("/login"))); var server = new TestServer(builder); @@ -905,7 +907,7 @@ public async Task MapWithSignOutOnlyRedirectToReturnUrlOnLogoutPath() app.UseAuthentication(); app.Map("/notlogout", signoutApp => signoutApp.Run(context => context.SignOutAsync("Cookies"))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LogoutPath = new PathString("/logout"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LogoutPath = new PathString("/logout"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/notlogout?ReturnUrl=%2Fpage"); @@ -922,7 +924,7 @@ public async Task MapWillNotAffectSignOutRedirectToReturnUrl() app.UseAuthentication(); app.Map("/logout", signoutApp => signoutApp.Run(context => context.SignOutAsync("Cookies"))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LogoutPath = new PathString("/logout"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LogoutPath = new PathString("/logout"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/logout?ReturnUrl=%2Fpage"); @@ -943,7 +945,7 @@ public async Task MapWillNotAffectAccessDenied() app.UseAuthentication(); app.Map("/forbid", signoutApp => signoutApp.Run(context => context.ForbidAsync("Cookies"))); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.AccessDeniedPath = new PathString("/denied"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.AccessDeniedPath = new PathString("/denied"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/forbid"); @@ -963,7 +965,7 @@ public async Task NestedMapWillNotAffectLogin() map.UseAuthentication(); map.Map("/login", signoutApp => signoutApp.Run(context => context.ChallengeAsync("Cookies", new AuthenticationProperties() { RedirectUri = "/" }))); })) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.LoginPath = new PathString("/page"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.LoginPath = new PathString("/page"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/base/login"); @@ -1073,7 +1075,7 @@ public async Task NestedMapWillNotAffectAccessDenied() map.UseAuthentication(); map.Map("/forbid", signoutApp => signoutApp.Run(context => context.ForbidAsync("Cookies"))); })) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.AccessDeniedPath = new PathString("/denied"))); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.AccessDeniedPath = new PathString("/denied"))); var server = new TestServer(builder); var transaction = await server.SendAsync("http://example.com/base/forbid"); @@ -1097,7 +1099,7 @@ public async Task CanSpecifyAndShareDataProtector() new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), new AuthenticationProperties())); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => { o.TicketDataFormat = new TicketDataFormat(dp); o.CookieName = "Cookie"; @@ -1117,7 +1119,7 @@ public async Task CanSpecifyAndShareDataProtector() Describe(context.Response, result); }); }) - .ConfigureServices(services => services.AddCookieAuthentication("Cookies", o => + .ConfigureServices(services => services.AddAuthentication().AddCookie("Cookies", o => { o.CookieName = "Cookie"; o.TicketDataFormat = new TicketDataFormat(dp); @@ -1132,7 +1134,7 @@ public async Task CanSpecifyAndShareDataProtector() public async Task NullExpiresUtcPropertyIsGuarded() { var builder = new WebHostBuilder() - .ConfigureServices(services => services.AddCookieAuthentication(o => + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => { o.Events = new CookieAuthenticationEvents { @@ -1229,7 +1231,7 @@ private TestServer CreateServer(Action configureOpt => CreateServerWithServices(s => { s.AddSingleton(_clock); - s.AddCookieAuthentication(configureOptions); + s.AddAuthentication().AddCookie(configureOptions); s.AddSingleton(); }, testpath, baseAddress); @@ -1281,6 +1283,15 @@ private static TestServer CreateServerWithServices(Action co { await testpath(context); } + else if (req.Path == new PathString("/checkforerrors")) + { + var result = await context.AuthenticateAsync(CookieAuthenticationDefaults.AuthenticationScheme); // this used to be "Automatic" + if (result.Failure != null) + { + throw new Exception("Failed to authenticate", result.Failure); + } + return; + } else { await next(); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index b463ef891..e6b5574df 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -85,9 +85,9 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() { options.DefaultSignInScheme = "External"; options.DefaultAuthenticateScheme = "External"; - }); - services.AddCookieAuthentication("External", o => { }); - services.AddFacebookAuthentication(o => + }) + .AddCookie("External", o => { }) + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; @@ -123,12 +123,12 @@ public async Task NestedMapWillNotAffectRedirect() }), services => { - services.AddCookieAuthentication("External", o => { }); - services.AddFacebookAuthentication(o => + services.AddAuthentication() + .AddCookie("External", o => { }) + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; - o.SignInScheme = "External"; }); }, handler: null); @@ -155,8 +155,9 @@ public async Task MapWillNotAffectRedirect() }, services => { - services.AddCookieAuthentication("External", o => { }); - services.AddFacebookAuthentication(o => + services.AddAuthentication() + .AddCookie("External", o => { }) + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; @@ -185,9 +186,9 @@ public async Task ChallengeWillTriggerRedirection() services.AddAuthentication(options => { options.DefaultSignInScheme = "External"; - }); - services.AddCookieAuthentication(); - services.AddFacebookAuthentication(o => + }) + .AddCookie() + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; @@ -217,19 +218,15 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() var finalUserInfoEndpoint = string.Empty; var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("FacebookTest")); var server = CreateServer( - app => - { - app.UseAuthentication(); - }, + app => app.UseAuthentication(), services => { services.AddAuthentication(options => { - options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - services.AddCookieAuthentication(); - services.AddFacebookAuthentication(o => + }) + .AddCookie() + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 501fdf603..2eae26670 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -516,7 +516,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() OnCreatingTicket = context => { var refreshToken = context.RefreshToken; - context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Google") }, "Google")); + context.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Google") }, "Google")); return Task.FromResult(0); } }; @@ -595,7 +595,7 @@ public async Task NullRedirectUriWillRedirectToSlash() { OnTicketReceived = context => { - context.Ticket.Properties.RedirectUri = null; + context.Properties.RedirectUri = null; return Task.FromResult(0); } }; @@ -985,7 +985,7 @@ private static TestServer CreateServer(Action configureOptions, F else if (req.Path == new PathString("/tokens")) { var result = await context.AuthenticateAsync(TestExtensions.CookieAuthenticationScheme); - var tokens = result.Ticket.Properties.GetTokens(); + var tokens = result.Properties.GetTokens(); res.Describe(tokens); } else if (req.Path == new PathString("/me")) @@ -995,17 +995,17 @@ private static TestServer CreateServer(Action configureOptions, F else if (req.Path == new PathString("/authenticate")) { var result = await context.AuthenticateAsync(TestExtensions.CookieAuthenticationScheme); - res.Describe(result.Ticket.Principal); + res.Describe(result.Principal); } else if (req.Path == new PathString("/authenticateGoogle")) { var result = await context.AuthenticateAsync("Google"); - res.Describe(result?.Ticket?.Principal); + res.Describe(result?.Principal); } else if (req.Path == new PathString("/authenticateFacebook")) { var result = await context.AuthenticateAsync("Facebook"); - res.Describe(result?.Ticket?.Principal); + res.Describe(result?.Principal); } else if (req.Path == new PathString("/unauthorized")) { @@ -1024,15 +1024,15 @@ private static TestServer CreateServer(Action configureOptions, F } else if (req.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.SignInAsync("Google", new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync("Google", new ClaimsPrincipal())); } else if (req.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.SignOutAsync("Google")); + await Assert.ThrowsAsync(() => context.SignOutAsync("Google")); } else if (req.Path == new PathString("/forbid")) { - await Assert.ThrowsAsync(() => context.ForbidAsync("Google")); + await Assert.ThrowsAsync(() => context.ForbidAsync("Google")); } else if (testpath != null) { @@ -1050,12 +1050,12 @@ private static TestServer CreateServer(Action configureOptions, F services.AddAuthentication(o => { o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; - o.DefaultSignInScheme = TestExtensions.CookieAuthenticationScheme; o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme; }); - services.AddCookieAuthentication(TestExtensions.CookieAuthenticationScheme); - services.AddGoogleAuthentication(configureOptions); - services.AddFacebookAuthentication(o => + services.AddAuthentication() + .AddCookie(TestExtensions.CookieAuthenticationScheme) + .AddGoogle(configureOptions) + .AddFacebook(o => { o.AppId = "Test AppId"; o.AppSecret = "Test AppSecrent"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 3149e9875..a9b158d2b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -127,11 +127,8 @@ public async Task CustomHeaderReceived() new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)), - new AuthenticationProperties(), context.Scheme.Name); - - context.HandleResponse(); + context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); + context.Success(); return Task.FromResult(null); } @@ -338,7 +335,7 @@ public async Task CustomTokenValidated() { // Retrieve the NameIdentifier claim from the identity // returned by the custom security token validator. - var identity = (ClaimsIdentity)context.Ticket.Principal.Identity; + var identity = (ClaimsIdentity)context.Principal.Identity; var identifier = identity.FindFirst(ClaimTypes.NameIdentifier); Assert.Equal("Bob le Tout Puissant", identifier.Value); @@ -396,7 +393,7 @@ public async Task EventOnMessageReceivedSkip_NoMoreEventsExecuted() { OnMessageReceived = context => { - context.Skip(); + context.NoResult(); return Task.FromResult(0); }, OnTokenValidated = context => @@ -420,7 +417,7 @@ public async Task EventOnMessageReceivedSkip_NoMoreEventsExecuted() } [Fact] - public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() + public async Task EventOnMessageReceivedReject_NoMoreEventsExecuted() { var server = CreateServer(options => { @@ -428,7 +425,7 @@ public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() { OnMessageReceived = context => { - context.HandleResponse(); + context.Fail("Authentication was aborted from user code."); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -447,9 +444,12 @@ public async Task EventOnMessageReceivedHandled_NoMoreEventsExecuted() }; }); - var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); - Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); - Assert.Equal(string.Empty, response.ResponseText); + var exception = await Assert.ThrowsAsync(delegate + { + return SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); } [Fact] @@ -461,7 +461,7 @@ public async Task EventOnTokenValidatedSkip_NoMoreEventsExecuted() { OnTokenValidated = context => { - context.Skip(); + context.NoResult(); return Task.FromResult(0); }, OnAuthenticationFailed = context => @@ -483,7 +483,7 @@ public async Task EventOnTokenValidatedSkip_NoMoreEventsExecuted() } [Fact] - public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() + public async Task EventOnTokenValidatedReject_NoMoreEventsExecuted() { var server = CreateServer(options => { @@ -491,7 +491,7 @@ public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() { OnTokenValidated = context => { - context.HandleResponse(); + context.Fail("Authentication was aborted from user code."); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -508,9 +508,12 @@ public async Task EventOnTokenValidatedHandled_NoMoreEventsExecuted() options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); }); - var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); - Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); - Assert.Equal(string.Empty, response.ResponseText); + var exception = await Assert.ThrowsAsync(delegate + { + return SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); } [Fact] @@ -526,7 +529,7 @@ public async Task EventOnAuthenticationFailedSkip_NoMoreEventsExecuted() }, OnAuthenticationFailed = context => { - context.Skip(); + context.NoResult(); return Task.FromResult(0); }, OnChallenge = context => @@ -544,7 +547,7 @@ public async Task EventOnAuthenticationFailedSkip_NoMoreEventsExecuted() } [Fact] - public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() + public async Task EventOnAuthenticationFailedReject_NoMoreEventsExecuted() { var server = CreateServer(options => { @@ -556,7 +559,7 @@ public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() }, OnAuthenticationFailed = context => { - context.HandleResponse(); + context.Fail("Authentication was aborted from user code."); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -569,35 +572,16 @@ public async Task EventOnAuthenticationFailedHandled_NoMoreEventsExecuted() options.SecurityTokenValidators.Add(new BlobTokenValidator("JWT")); }); - var response = await SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); - Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); - Assert.Equal(string.Empty, response.ResponseText); - } - - [Fact] - public async Task EventOnChallengeSkip_ResponseNotModified() - { - var server = CreateServer(o => + var exception = await Assert.ThrowsAsync(delegate { - o.Events = new JwtBearerEvents() - { - OnChallenge = context => - { - context.Skip(); - return Task.FromResult(0); - }, - }; + return SendAsync(server, "http://example.com/checkforerrors", "Bearer Token"); }); - var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); - Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); - Assert.Empty(response.Response.Headers.WwwAuthenticate); - Assert.Equal(string.Empty, response.ResponseText); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); } - [Fact] - public async Task EventOnChallengeHandled_ResponseNotModified() + public async Task EventOnChallengeSkip_ResponseNotModified() { var server = CreateServer(o => { @@ -606,14 +590,13 @@ public async Task EventOnChallengeHandled_ResponseNotModified() OnChallenge = context => { context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, }; }); var response = await SendAsync(server, "http://example.com/unauthorized", "Bearer Token"); - Assert.Equal(HttpStatusCode.Accepted, response.Response.StatusCode); + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); Assert.Empty(response.Response.Headers.WwwAuthenticate); Assert.Equal(string.Empty, response.ResponseText); } @@ -752,11 +735,11 @@ private static TestServer CreateServer(Action options = null, } else if (context.Request.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); } else if (context.Request.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.SignOutAsync(JwtBearerDefaults.AuthenticationScheme)); + await Assert.ThrowsAsync(() => context.SignOutAsync(JwtBearerDefaults.AuthenticationScheme)); } else { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index bf15c91b0..f51694043 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -159,7 +159,7 @@ public async Task AuthenticatedEventCanGetRefreshToken() OnCreatingTicket = context => { var refreshToken = context.RefreshToken; - context.Ticket.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft")); + context.Principal.AddIdentity(new ClaimsIdentity(new Claim[] { new Claim("RefreshToken", refreshToken, ClaimValueTypes.String, "Microsoft") }, "Microsoft")); return Task.FromResult(null); } }; @@ -205,15 +205,15 @@ private static TestServer CreateServer(Action configure } else if (req.Path == new PathString("/signIn")) { - await Assert.ThrowsAsync(() => context.SignInAsync("Microsoft", new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync("Microsoft", new ClaimsPrincipal())); } else if (req.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.SignOutAsync("Microsoft")); + await Assert.ThrowsAsync(() => context.SignOutAsync("Microsoft")); } else if (req.Path == new PathString("/forbid")) { - await Assert.ThrowsAsync(() => context.ForbidAsync("Microsoft")); + await Assert.ThrowsAsync(() => context.ForbidAsync("Microsoft")); } else { @@ -226,10 +226,10 @@ private static TestServer CreateServer(Action configure services.AddAuthentication(o => { o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; - o.DefaultSignInScheme = TestExtensions.CookieAuthenticationScheme; }); - services.AddCookieAuthentication(TestExtensions.CookieAuthenticationScheme, o => { }); - services.AddMicrosoftAccountAuthentication(configureOptions); + services.AddAuthentication() + .AddCookie(TestExtensions.CookieAuthenticationScheme, o => { }) + .AddMicrosoftAccount(configureOptions); }); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index dcc96c094..bdd79533b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -143,29 +143,6 @@ public async Task ThrowsIfAuthorizationEndpointMissing() Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } - [Fact] - public async Task ThrowsIfSignInSchemeMissing() - { - var server = CreateServer( - app => { }, - services => services.AddOAuthAuthentication("weeblie", o => - { - o.ClientId = "Whatever;"; - o.ClientSecret = "Whatever;"; - o.CallbackPath = "/"; - o.TokenEndpoint = "/"; - o.AuthorizationEndpoint = "/"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("SignInScheme", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - } - [Fact] public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallBackPath() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index 3c0146b08..d21a1f424 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -335,7 +335,7 @@ public async Task OnRedirectToIdentityProviderEventHandlesResponse() // This test can be further refined. When one auth handler skips, the authentication responsibility // will be flowed to the next one. A dummy auth handler can be added to ensure the correct logic. [Fact] - public async Task OnRedirectToIdentityProviderEventSkipResponse() + public async Task OnRedirectToIdentityProviderEventHandleResponse() { var settings = new TestSettings( opts => @@ -346,7 +346,7 @@ public async Task OnRedirectToIdentityProviderEventSkipResponse() { OnRedirectToIdentityProvider = context => { - context.Skip(); + context.HandleResponse(); return Task.FromResult(0); } }; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 3ceb4a533..74f00c8f9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -22,8 +22,9 @@ public async Task MetadataAddressIsGeneratedFromAuthorityWhenMissing() var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(); - services.AddOpenIdConnectAuthentication(o => + services.AddAuthentication() + .AddCookie() + .AddOpenIdConnect(o => { o.Authority = TestServerBuilder.DefaultAuthority; o.ClientId = Guid.NewGuid().ToString(); @@ -45,19 +46,6 @@ public async Task MetadataAddressIsGeneratedFromAuthorityWhenMissing() Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } - [Fact] - public Task ThrowsWhenSignInSchemeIsMissing() - { - return TestConfigurationException( - o => - { - o.ClientId = "Test Id"; - o.Authority = TestServerBuilder.DefaultAuthority; - o.CallbackPath = "/"; - }, - ex => Assert.Equal("SignInScheme", ex.ParamName)); - } - [Fact] public Task ThrowsWhenClientIdIsMissing() { @@ -119,8 +107,9 @@ private TestServer BuildTestServer(Action options) var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(); - services.AddOpenIdConnectAuthentication(options); + services.AddAuthentication() + .AddCookie() + .AddOpenIdConnect(options); }) .Configure(app => app.UseAuthentication()); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index 607e9bb62..4ea69369e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -34,7 +34,7 @@ public class OpenIdConnectEventTests private readonly Func UserNotImpl = context => { throw new NotImplementedException("User"); }; private readonly Func FailedNotImpl = context => { throw new NotImplementedException("Failed", context.Exception); }; private readonly Func TicketNotImpl = context => { throw new NotImplementedException("Ticket"); }; - private readonly Func FailureNotImpl = context => { throw new NotImplementedException("Failure", context.Failure); }; + private readonly Func FailureNotImpl = context => { throw new NotImplementedException("Failure", context.Failure); }; private readonly Func RedirectNotImpl = context => { throw new NotImplementedException("Redirect"); }; private readonly Func RemoteSignOutNotImpl = context => { throw new NotImplementedException("Remote"); }; private readonly RequestDelegate AppNotImpl = context => { throw new NotImplementedException("App"); }; @@ -48,7 +48,7 @@ public async Task OnMessageReceived_Skip_NoMoreEventsRun() OnMessageReceived = context => { messageReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnTokenValidated = TokenNotImpl, @@ -75,6 +75,51 @@ public async Task OnMessageReceived_Skip_NoMoreEventsRun() Assert.True(messageReceived); } + [Fact] + public async Task OnMessageReceived_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnTokenValidated = TokenNotImpl, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", ""); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(remoteFailure); + } + [Fact] public async Task OnMessageReceived_Handled_NoMoreEventsRun() { @@ -124,7 +169,7 @@ public async Task OnTokenValidated_Skip_NoMoreEventsRun() OnTokenValidated = context => { tokenValidated = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnAuthorizationCodeReceived = CodeNotImpl, @@ -151,6 +196,57 @@ public async Task OnTokenValidated_Skip_NoMoreEventsRun() Assert.True(tokenValidated); } + [Fact] + public async Task OnTokenValidated_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(remoteFailure); + } + [Fact] public async Task OnTokenValidated_HandledWithoutTicket_NoMoreEventsRun() { @@ -167,7 +263,7 @@ public async Task OnTokenValidated_HandledWithoutTicket_NoMoreEventsRun() { tokenValidated = true; context.HandleResponse(); - context.Ticket = null; + context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -209,8 +305,7 @@ public async Task OnTokenValidated_HandledWithTicket_SkipToTicketReceived() OnTokenValidated = context => { tokenValidated = true; - context.HandleResponse(); - // context.Ticket = null; + context.Success(); return Task.FromResult(0); }, OnAuthorizationCodeReceived = CodeNotImpl, @@ -262,7 +357,7 @@ public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() OnAuthorizationCodeReceived = context => { codeReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnTokenResponseReceived = TokenResponseNotImpl, @@ -289,6 +384,63 @@ public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() Assert.True(codeReceived); } + [Fact] + public async Task OnAuthorizationCodeReceived_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(remoteFailure); + } + [Fact] public async Task OnAuthorizationCodeReceived_HandledWithoutTicket_NoMoreEventsRun() { @@ -311,7 +463,7 @@ public async Task OnAuthorizationCodeReceived_HandledWithoutTicket_NoMoreEventsR { codeReceived = true; context.HandleResponse(); - context.Ticket = null; + context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); }, @@ -358,8 +510,7 @@ public async Task OnAuthorizationCodeReceived_HandledWithTicket_SkipToTicketRece OnAuthorizationCodeReceived = context => { codeReceived = true; - context.HandleResponse(); - // context.Ticket = null; + context.Success(); return Task.FromResult(0); }, OnTokenResponseReceived = TokenResponseNotImpl, @@ -417,7 +568,7 @@ public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() OnTokenResponseReceived = context => { tokenResponseReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -444,6 +595,69 @@ public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() Assert.True(tokenResponseReceived); } + [Fact] + public async Task OnTokenResponseReceived_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(remoteFailure); + } + [Fact] public async Task OnTokenResponseReceived_HandledWithoutTicket_NoMoreEventsRun() { @@ -471,7 +685,7 @@ public async Task OnTokenResponseReceived_HandledWithoutTicket_NoMoreEventsRun() OnTokenResponseReceived = context => { tokenResponseReceived = true; - context.Ticket = null; + context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -525,8 +739,7 @@ public async Task OnTokenResponseReceived_HandledWithTicket_SkipToTicketReceived OnTokenResponseReceived = context => { tokenResponseReceived = true; - // context.Ticket = null; - context.HandleResponse(); + context.Success(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -584,7 +797,7 @@ public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() OnTokenValidated = context => { tokenValidated = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -611,6 +824,69 @@ public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() Assert.True(tokenValidated); } + [Fact] + public async Task OnTokenValidatedBackchannel_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var codeReceived = false; + var tokenResponseReceived = false; + var tokenValidated = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(tokenValidated); + Assert.True(remoteFailure); + } + [Fact] public async Task OnTokenValidatedBackchannel_HandledWithoutTicket_NoMoreEventsRun() { @@ -638,7 +914,7 @@ public async Task OnTokenValidatedBackchannel_HandledWithoutTicket_NoMoreEventsR OnTokenValidated = context => { tokenValidated = true; - context.Ticket = null; + context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -692,8 +968,7 @@ public async Task OnTokenValidatedBackchannel_HandledWithTicket_SkipToTicketRece OnTokenValidated = context => { tokenValidated = true; - // context.Ticket = null; - context.HandleResponse(); + context.Success(); return Task.FromResult(0); }, OnUserInformationReceived = UserNotImpl, @@ -757,7 +1032,7 @@ public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() OnUserInformationReceived = context => { userInfoReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnAuthenticationFailed = FailedNotImpl, @@ -784,6 +1059,75 @@ public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() Assert.True(userInfoReceived); } + [Fact] + public async Task OnUserInformationReceived_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(remoteFailure); + } + [Fact] public async Task OnUserInformationReceived_HandledWithoutTicket_NoMoreEventsRun() { @@ -817,7 +1161,7 @@ public async Task OnUserInformationReceived_HandledWithoutTicket_NoMoreEventsRun OnUserInformationReceived = context => { userInfoReceived = true; - context.Ticket = null; + context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -878,7 +1222,7 @@ public async Task OnUserInformationReceived_HandledWithTicket_SkipToTicketReceiv { userInfoReceived = true; // context.Ticket = null; - context.HandleResponse(); + context.Success(); return Task.FromResult(0); }, OnAuthenticationFailed = FailedNotImpl, @@ -949,7 +1293,7 @@ public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnRemoteFailure = FailureNotImpl, @@ -976,6 +1320,82 @@ public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() Assert.True(authFailed); } + [Fact] + public async Task OnAuthenticationFailed_Reject_NoMoreEventsRun() + { + var messageReceived = false; + var tokenValidated = false; + var codeReceived = false; + var tokenResponseReceived = false; + var userInfoReceived = false; + var authFailed = false; + var remoteFailure = false; + var server = CreateServer(new OpenIdConnectEvents() + { + OnMessageReceived = context => + { + messageReceived = true; + return Task.FromResult(0); + }, + OnTokenValidated = context => + { + tokenValidated = true; + return Task.FromResult(0); + }, + OnAuthorizationCodeReceived = context => + { + codeReceived = true; + return Task.FromResult(0); + }, + OnTokenResponseReceived = context => + { + tokenResponseReceived = true; + return Task.FromResult(0); + }, + OnUserInformationReceived = context => + { + userInfoReceived = true; + throw new NotImplementedException("TestException"); + }, + OnAuthenticationFailed = context => + { + authFailed = true; + Assert.Equal("TestException", context.Exception.Message); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }, + OnRemoteFailure = context => + { + remoteFailure = true; + return Task.FromResult(0); + }, + OnTicketReceived = TicketNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + }, + context => + { + return context.Response.WriteAsync(context.Request.Path); + }); + + var exception = await Assert.ThrowsAsync(delegate + { + return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); + }); + + Assert.Equal("Authentication was aborted from user code.", exception.Message); + + Assert.True(messageReceived); + Assert.True(tokenValidated); + Assert.True(codeReceived); + Assert.True(tokenResponseReceived); + Assert.True(userInfoReceived); + Assert.True(authFailed); + Assert.True(remoteFailure); + } + [Fact] public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() { @@ -1016,7 +1436,7 @@ public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - Assert.Null(context.Ticket); + Assert.Null(context.Principal); context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -1083,7 +1503,7 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( { authFailed = true; Assert.Equal("TestException", context.Exception.Message); - Assert.Null(context.Ticket); + Assert.Null(context.Principal); var claims = new[] { @@ -1092,11 +1512,8 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - context.Ticket = new AuthenticationTicket( - new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)), - new AuthenticationProperties(), context.Scheme.Name); - - context.HandleResponse(); + context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); + context.Success(); return Task.FromResult(0); }, OnRemoteFailure = FailureNotImpl, @@ -1174,7 +1591,7 @@ public async Task OnRemoteFailure_Skip_NoMoreEventsRun() { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, OnTicketReceived = TicketNotImpl, @@ -1314,7 +1731,7 @@ public async Task OnTicketReceived_Skip_NoMoreEventsRun() OnTicketReceived = context => { ticektReceived = true; - context.Skip(); + context.SkipHandler(); return Task.FromResult(0); }, @@ -1408,8 +1825,9 @@ private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appC var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(); - services.AddOpenIdConnectAuthentication(o => + services.AddAuthentication() + .AddCookie() + .AddOpenIdConnect(o => { o.Events = events; o.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 6cfda3b85..7f9d42b1c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net; @@ -11,10 +10,7 @@ using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.DataProtection; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs index aa7f6179b..1ffb9ff68 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -112,10 +112,10 @@ await context.SignOutAsync( services.AddAuthentication(o => { o.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; }); - services.AddCookieAuthentication(); - services.AddOpenIdConnectAuthentication(options); + services.AddAuthentication() + .AddCookie() + .AddOpenIdConnect(options); }); return new TestServer(builder); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs index afdef0a40..05e5708de 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -134,7 +134,7 @@ public void UpdateTokenValueReturnsFalseForUnknownToken() // return Task.FromResult(0); // } - // public Task ChallengeAsync(ChallengeContext context) + // public Task ChallengeAsync(AuthenticationProperties properties) // { // throw new NotImplementedException(); // } @@ -144,12 +144,12 @@ public void UpdateTokenValueReturnsFalseForUnknownToken() // throw new NotImplementedException(); // } - // public Task SignInAsync(SignInContext context) + // public Task SignInAsync(ClaimsPrincipal principal, AuthenticationProperties properties) // { // throw new NotImplementedException(); // } - // public Task SignOutAsync(SignOutContext context) + // public Task SignOutAsync(AuthenticationProperties properties) // { // throw new NotImplementedException(); // } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 8fcc0780d..76f6b1aad 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Security.Claims; @@ -13,7 +12,6 @@ using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -177,15 +175,15 @@ private static TestServer CreateServer(Action options, Func(() => context.SignInAsync("Twitter", new ClaimsPrincipal())); + await Assert.ThrowsAsync(() => context.SignInAsync("Twitter", new ClaimsPrincipal())); } else if (req.Path == new PathString("/signOut")) { - await Assert.ThrowsAsync(() => context.SignOutAsync("Twitter")); + await Assert.ThrowsAsync(() => context.SignOutAsync("Twitter")); } else if (req.Path == new PathString("/forbid")) { - await Assert.ThrowsAsync(() => context.ForbidAsync("Twitter")); + await Assert.ThrowsAsync(() => context.ForbidAsync("Twitter")); } else if (handler == null || !handler(context)) { @@ -195,13 +193,14 @@ private static TestServer CreateServer(Action options, Func { - services.AddCookieAuthentication("External", _ => { }); Action wrapOptions = o => { o.SignInScheme = "External"; options(o); }; - services.AddTwitterAuthentication(wrapOptions); + services.AddAuthentication() + .AddCookie("External", _ => { }) + .AddTwitter(wrapOptions); }); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index b6b2776a8..5c2458c52 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -312,7 +312,7 @@ public async Task CookiePolicyAppliesToCookieAuth() var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(o => + services.AddAuthentication().AddCookie(o => { o.CookieName = "TestCookie"; o.CookieHttpOnly = false; @@ -352,7 +352,7 @@ public async Task CookiePolicyAppliesToCookieAuthChunks() var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddCookieAuthentication(o => + services.AddAuthentication().AddCookie(o => { o.CookieName = "TestCookie"; o.CookieHttpOnly = false; diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index ae5e6f018..e2e4fd7d0 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -68,7 +68,7 @@ public async Task AspNetCoreWithInteropCookieContainsIdentity() await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); }); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); @@ -123,7 +123,7 @@ public async Task AspNetCoreWithLargeInteropCookieContainsIdentity() await context.Response.WriteAsync(result.Ticket.Principal.Identity.Name); }); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com/login"); @@ -155,7 +155,7 @@ public async Task InteropWithNewCookieContainsIdentity() app.UseAuthentication(); app.Run(context => context.SignInAsync("Cookies", user)); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); @@ -202,7 +202,7 @@ public async Task InteropWithLargeNewCookieContainsIdentity() app.UseAuthentication(); app.Run(context => context.SignInAsync("Cookies", user)); }) - .ConfigureServices(services => services.AddCookieAuthentication(o => o.DataProtectionProvider = dataProtection)); + .ConfigureServices(services => services.AddAuthentication().AddCookie(o => o.DataProtectionProvider = dataProtection)); var newServer = new AspNetCore.TestHost.TestServer(builder); var cookies = await SendAndGetCookies(newServer, "http://example.com/login"); From 96f6436a677aba66f4b5a39da4bc9153921eeab6 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 3 Jul 2017 14:07:57 -0700 Subject: [PATCH 034/248] Update LICENSE.txt text --- LICENSE.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 0bdc1962b..7b2956ece 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,10 +1,12 @@ -Copyright (c) .NET Foundation. All rights reserved. +Copyright (c) .NET Foundation and Contributors + +All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use -these files except in compliance with the License. You may obtain a copy of the +this file except in compliance with the License. You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR From 66b939725ed6d1b4eb8ce5d4823b635990c086b4 Mon Sep 17 00:00:00 2001 From: Murat Girgin Date: Mon, 3 Jul 2017 15:42:40 -0700 Subject: [PATCH 035/248] https://github.com/aspnet/Security/issues/1265. Check Auth failures and log them. --- .../AuthenticationHandler.cs | 4 ++++ .../LoggingExtensions.cs | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index aeb70cb0d..a258d0aca 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -142,6 +142,10 @@ public async Task AuthenticateAsync() Logger.AuthenticationSchemeNotAuthenticated(Scheme.Name); } } + else if (result?.Failure != null) + { + Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Scheme.Name, result.Failure.Message); + } return result; } diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs index ed15e6190..46223d647 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -9,6 +9,7 @@ internal static class LoggingExtensions { private static Action _authSchemeAuthenticated; private static Action _authSchemeNotAuthenticated; + private static Action _authSchemeNotAuthenticatedWithFailure; private static Action _authSchemeChallenged; private static Action _authSchemeForbidden; private static Action _remoteAuthenticationError; @@ -32,6 +33,10 @@ static LoggingExtensions() eventId: 6, logLevel: LogLevel.Debug, formatString: "The SigningIn event returned Skipped."); + _authSchemeNotAuthenticatedWithFailure = LoggerMessage.Define( + eventId: 7, + logLevel: LogLevel.Information, + formatString: "{AuthenticationScheme} was not authenticated. Failure message: {FailureMessage}"); _authSchemeAuthenticated = LoggerMessage.Define( eventId: 8, logLevel: LogLevel.Information, @@ -72,6 +77,11 @@ public static void AuthenticationSchemeNotAuthenticated(this ILogger logger, str _authSchemeNotAuthenticated(logger, authenticationScheme, null); } + public static void AuthenticationSchemeNotAuthenticatedWithFailure(this ILogger logger, string authenticationScheme, string failureMessage) + { + _authSchemeNotAuthenticatedWithFailure(logger, authenticationScheme, failureMessage, null); + } + public static void AuthenticationSchemeChallenged(this ILogger logger, string authenticationScheme) { _authSchemeChallenged(logger, authenticationScheme, null); From 968237d75126b7b5d8a5383677431d06452c1dc8 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 29 Jun 2017 16:23:31 -0700 Subject: [PATCH 036/248] Replace configure method on Twitter, RemoteAuthentication, and OpenIdConnect options with CookieBuilder --- .../OpenIdConnectHandler.cs | 42 ++++---------- .../OpenIdConnectOptions.cs | 50 +++++++++++++++-- .../TwitterHandler.cs | 27 ++------- .../TwitterOptions.cs | 53 ++++++++++++++---- .../Internal/RequestPathBaseCookieBuilder.cs | 38 +++++++++++++ .../RemoteAuthenticationHandler.cs | 32 ++--------- .../RemoteAuthenticationOptions.cs | 55 +++++++++++++++++-- .../OAuthTests.cs | 2 +- .../OpenIdConnect/OpenIdConnectTests.cs | 4 +- 9 files changed, 202 insertions(+), 101 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 341abbf5a..9e6d34bc9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -275,8 +275,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) /// A task executing the callback procedure protected virtual Task HandleSignOutCallbackAsync() { - StringValues protectedState; - if (Request.Query.TryGetValue(OpenIdConnectParameterNames.State, out protectedState)) + if (Request.Query.TryGetValue(OpenIdConnectParameterNames.State, out StringValues protectedState)) { var properties = Options.StateDataFormat.Unprotect(protectedState); if (!string.IsNullOrEmpty(properties?.RedirectUri)) @@ -505,8 +504,7 @@ protected override async Task HandleRemoteAuthenticateAsync return HandleRequestResult.Fail(Resources.MessageStateIsInvalid); } - string userstate = null; - properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out userstate); + properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out string userstate); authorizationResponse.State = userstate; if (!ValidateCorrelationId(properties)) @@ -859,8 +857,7 @@ private void SaveTokens(AuthenticationProperties properties, OpenIdConnectMessag if (!string.IsNullOrEmpty(message.ExpiresIn)) { - int value; - if (int.TryParse(message.ExpiresIn, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) + if (int.TryParse(message.ExpiresIn, NumberStyles.Integer, CultureInfo.InvariantCulture, out int value)) { var expiresAt = Clock.UtcNow + TimeSpan.FromSeconds(value); // https://www.w3.org/TR/xmlschema-2/#dateTime @@ -885,21 +882,12 @@ private void WriteNonceCookie(string nonce) throw new ArgumentNullException(nameof(nonce)); } - var options = new CookieOptions - { - HttpOnly = true, - SameSite = Http.SameSiteMode.None, - Path = OriginalPathBase + Options.CallbackPath, - Secure = Request.IsHttps, - Expires = Clock.UtcNow.Add(Options.ProtocolValidator.NonceLifetime) - }; - - Options.ConfigureNonceCookie?.Invoke(Context, options); + var cookieOptions = Options.NonceCookie.Build(Context, Clock.UtcNow); Response.Cookies.Append( - OpenIdConnectDefaults.CookieNoncePrefix + Options.StringDataFormat.Protect(nonce), + Options.NonceCookie.Name + Options.StringDataFormat.Protect(nonce), NonceProperty, - options); + cookieOptions); } /// @@ -918,23 +906,14 @@ private string ReadNonceCookie(string nonce) foreach (var nonceKey in Request.Cookies.Keys) { - if (nonceKey.StartsWith(OpenIdConnectDefaults.CookieNoncePrefix)) + if (nonceKey.StartsWith(Options.NonceCookie.Name)) { try { - var nonceDecodedValue = Options.StringDataFormat.Unprotect(nonceKey.Substring(OpenIdConnectDefaults.CookieNoncePrefix.Length, nonceKey.Length - OpenIdConnectDefaults.CookieNoncePrefix.Length)); + var nonceDecodedValue = Options.StringDataFormat.Unprotect(nonceKey.Substring(Options.NonceCookie.Name.Length, nonceKey.Length - Options.NonceCookie.Name.Length)); if (nonceDecodedValue == nonce) { - var cookieOptions = new CookieOptions - { - HttpOnly = true, - Path = OriginalPathBase + Options.CallbackPath, - SameSite = Http.SameSiteMode.None, - Secure = Request.IsHttps - }; - - Options.ConfigureNonceCookie?.Invoke(Context, cookieOptions); - + var cookieOptions = Options.NonceCookie.Build(Context, Clock.UtcNow); Response.Cookies.Delete(nonceKey, cookieOptions); return nonce; } @@ -1170,8 +1149,7 @@ private ClaimsPrincipal ValidateToken(string idToken, AuthenticationProperties p validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(_configuration.SigningKeys) ?? _configuration.SigningKeys; } - SecurityToken validatedToken = null; - var principal = Options.SecurityTokenValidator.ValidateToken(idToken, validationParameters, out validatedToken); + var principal = Options.SecurityTokenValidator.ValidateToken(idToken, validationParameters, out SecurityToken validatedToken); jwt = validatedToken as JwtSecurityToken; if (jwt == null) { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 8bcedaec2..23169b5bc 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; +using Microsoft.AspNetCore.Authentication.Internal; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Protocols; @@ -17,6 +18,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect /// public class OpenIdConnectOptions : RemoteAuthenticationOptions { + private CookieBuilder _nonceCookieBuilder; + /// /// Initializes a new /// @@ -65,6 +68,14 @@ public OpenIdConnectOptions() ClaimActions.MapUniqueJsonKey("family_name", "family_name"); ClaimActions.MapUniqueJsonKey("profile", "profile"); ClaimActions.MapUniqueJsonKey("email", "email"); + + _nonceCookieBuilder = new OpenIdConnectNonceCookieBuilder(this) + { + Name = OpenIdConnectDefaults.CookieNoncePrefix, + HttpOnly = true, + SameSite = SameSiteMode.None, + SecurePolicy = CookieSecurePolicy.SameAsRequest, + }; } /// @@ -145,8 +156,8 @@ public override void Validate() /// public new OpenIdConnectEvents Events { - get { return (OpenIdConnectEvents)base.Events; } - set { base.Events = value; } + get => (OpenIdConnectEvents)base.Events; + set => base.Events = value; } /// @@ -259,9 +270,40 @@ public override void Validate() public bool DisableTelemetry { get; set; } /// - /// Gets or sets an action that can override the nonce cookie options before the + /// Determines the settings used to create the nonce cookie before the /// cookie gets added to the response. /// - public Action ConfigureNonceCookie { get; set; } + /// + /// The value of is treated as the prefix to the cookie name, and defaults to . + /// + public CookieBuilder NonceCookie + { + get => _nonceCookieBuilder; + set => _nonceCookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); + } + + private class OpenIdConnectNonceCookieBuilder : RequestPathBaseCookieBuilder + { + private readonly OpenIdConnectOptions _options; + + public OpenIdConnectNonceCookieBuilder(OpenIdConnectOptions oidcOptions) + { + _options = oidcOptions; + } + + protected override string AdditionalPath => _options.CallbackPath; + + public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom) + { + var cookieOptions = base.Build(context, expiresFrom); + + if (!Expiration.HasValue || !cookieOptions.Expires.HasValue) + { + cookieOptions.Expires = expiresFrom.Add(_options.ProtocolValidator.NonceLifetime); + } + + return cookieOptions; + } + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 7fcc01eee..ddcd095d5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -10,7 +10,6 @@ using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; @@ -23,7 +22,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter internal class TwitterHandler : RemoteAuthenticationHandler { private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - private const string StateCookie = "__TwitterState"; private const string RequestTokenEndpoint = "https://api.twitter.com/oauth/request_token"; private const string AuthenticationEndpoint = "https://api.twitter.com/oauth/authenticate?oauth_token="; private const string AccessTokenEndpoint = "https://api.twitter.com/oauth/access_token"; @@ -50,7 +48,7 @@ protected override async Task HandleRemoteAuthenticateAsync { AuthenticationProperties properties = null; var query = Request.Query; - var protectedRequestToken = Request.Cookies[StateCookie]; + var protectedRequestToken = Request.Cookies[Options.StateCookie.Name]; var requestToken = Options.StateDataFormat.Unprotect(protectedRequestToken); @@ -80,16 +78,9 @@ protected override async Task HandleRemoteAuthenticateAsync return HandleRequestResult.Fail("Missing or blank oauth_verifier"); } - var cookieOptions = new CookieOptions - { - HttpOnly = true, - SameSite = SameSiteMode.Lax, - Secure = Request.IsHttps - }; - - Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); + var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); - Response.Cookies.Delete(StateCookie, cookieOptions); + Response.Cookies.Delete(Options.StateCookie.Name, cookieOptions); var accessToken = await ObtainAccessTokenAsync(requestToken, oauthVerifier); @@ -144,17 +135,9 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop var requestToken = await ObtainRequestTokenAsync(BuildRedirectUri(Options.CallbackPath), properties); var twitterAuthenticationEndpoint = AuthenticationEndpoint + requestToken.Token; - var cookieOptions = new CookieOptions - { - HttpOnly = true, - SameSite = SameSiteMode.Lax, - Secure = Request.IsHttps, - Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), - }; - - Options.ConfigureStateCookie?.Invoke(Context, cookieOptions); + var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); - Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions); + Response.Cookies.Append(Options.StateCookie.Name, Options.StateDataFormat.Protect(requestToken), cookieOptions); var redirectContext = new RedirectContext(Context, Scheme, Options, properties, twitterAuthenticationEndpoint); await Events.RedirectToAuthorizationEndpoint(redirectContext); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 8b57f2502..0190f21a6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -3,10 +3,7 @@ using System; using System.Security.Claims; -using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth.Claims; -using Microsoft.AspNetCore.Authentication.Twitter; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -16,6 +13,10 @@ namespace Microsoft.AspNetCore.Authentication.Twitter /// public class TwitterOptions : RemoteAuthenticationOptions { + private const string DefaultStateCookieName = "__TwitterState"; + + private CookieBuilder _stateCookieBuilder; + /// /// Initializes a new instance of the class. /// @@ -26,6 +27,14 @@ public TwitterOptions() Events = new TwitterEvents(); ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email); + + _stateCookieBuilder = new TwitterCookieBuilder(this) + { + Name = DefaultStateCookieName, + SecurePolicy = CookieSecurePolicy.SameAsRequest, + HttpOnly = true, + SameSite = SameSiteMode.Lax, + }; } /// @@ -59,18 +68,42 @@ public TwitterOptions() public ISecureDataFormat StateDataFormat { get; set; } /// - /// Gets or sets an action that can override the state cookie options before the - /// cookie gets added to the response. + /// Gets or sets the used to handle authentication events. /// - public Action ConfigureStateCookie { get; set; } + public new TwitterEvents Events + { + get => (TwitterEvents)base.Events; + set => base.Events = value; + } /// - /// Gets or sets the used to handle authentication events. + /// Determines the settings used to create the state cookie before the + /// cookie gets added to the response. /// - public new TwitterEvents Events + public CookieBuilder StateCookie + { + get => _stateCookieBuilder; + set => _stateCookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); + } + + private class TwitterCookieBuilder : CookieBuilder { - get { return (TwitterEvents)base.Events; } - set { base.Events = value; } + private readonly TwitterOptions _twitterOptions; + + public TwitterCookieBuilder(TwitterOptions twitterOptions) + { + _twitterOptions = twitterOptions; + } + + public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom) + { + var options = base.Build(context, expiresFrom); + if (!Expiration.HasValue) + { + options.Expires = expiresFrom.Add(_twitterOptions.RemoteAuthenticationTimeout); + } + return options; + } } } } diff --git a/src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs b/src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs new file mode 100644 index 000000000..f42617cb2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Internal/RequestPathBaseCookieBuilder.cs @@ -0,0 +1,38 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication.Internal +{ + /// + /// A cookie builder that sets to the request path base. + /// + public class RequestPathBaseCookieBuilder : CookieBuilder + { + /// + /// Gets an optional value that is appended to the request path base. + /// + protected virtual string AdditionalPath { get; } + + public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom) + { + // check if the user has overridden the default value of path. If so, use that instead of our default value. + var path = Path; + if (path == null) + { + var originalPathBase = context.Features.Get()?.OriginalPathBase ?? context.Request.PathBase; + path = originalPathBase + AdditionalPath; + } + + var options = base.Build(context, expiresFrom); + + options.Path = !string.IsNullOrEmpty(path) + ? path + : "/"; + + return options; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 62213a171..7bd3b0773 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -5,7 +5,6 @@ using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -14,7 +13,6 @@ namespace Microsoft.AspNetCore.Authentication public abstract class RemoteAuthenticationHandler : AuthenticationHandler, IAuthenticationRequestHandler where TOptions : RemoteAuthenticationOptions, new() { - private const string CorrelationPrefix = ".AspNetCore.Correlation."; private const string CorrelationProperty = ".xsrf"; private const string CorrelationMarker = "N"; private const string AuthSchemeKey = ".AuthScheme"; @@ -187,20 +185,11 @@ protected virtual void GenerateCorrelationId(AuthenticationProperties properties CryptoRandom.GetBytes(bytes); var correlationId = Base64UrlTextEncoder.Encode(bytes); - var cookieOptions = new CookieOptions - { - HttpOnly = true, - SameSite = SameSiteMode.None, - Secure = Request.IsHttps, - Path = OriginalPathBase + Options.CallbackPath, - Expires = Clock.UtcNow.Add(Options.RemoteAuthenticationTimeout), - }; - - Options.ConfigureCorrelationIdCookie?.Invoke(Context, cookieOptions); + var cookieOptions = Options.CorrelationCookie.Build(Context, Clock.UtcNow); properties.Items[CorrelationProperty] = correlationId; - var cookieName = CorrelationPrefix + Scheme.Name + "." + correlationId; + var cookieName = Options.CorrelationCookie.Name + Scheme.Name + "." + correlationId; Response.Cookies.Append(cookieName, CorrelationMarker, cookieOptions); } @@ -212,16 +201,15 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties throw new ArgumentNullException(nameof(properties)); } - string correlationId; - if (!properties.Items.TryGetValue(CorrelationProperty, out correlationId)) + if (!properties.Items.TryGetValue(CorrelationProperty, out string correlationId)) { - Logger.CorrelationPropertyNotFound(CorrelationPrefix); + Logger.CorrelationPropertyNotFound(Options.CorrelationCookie.Name); return false; } properties.Items.Remove(CorrelationProperty); - var cookieName = CorrelationPrefix + Scheme.Name + "." + correlationId; + var cookieName = Options.CorrelationCookie.Name + Scheme.Name + "." + correlationId; var correlationCookie = Request.Cookies[cookieName]; if (string.IsNullOrEmpty(correlationCookie)) @@ -230,15 +218,7 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties return false; } - var cookieOptions = new CookieOptions - { - HttpOnly = true, - Path = OriginalPathBase + Options.CallbackPath, - SameSite = SameSiteMode.None, - Secure = Request.IsHttps - }; - - Options.ConfigureCorrelationIdCookie?.Invoke(Context, cookieOptions); + var cookieOptions = Options.CorrelationCookie.Build(Context, Clock.UtcNow); Response.Cookies.Delete(cookieName, cookieOptions); diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index a5f0bb44b..3b34cf43e 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -3,6 +3,7 @@ using System; using System.Net.Http; +using Microsoft.AspNetCore.Authentication.Internal; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; @@ -13,6 +14,24 @@ namespace Microsoft.AspNetCore.Authentication /// public class RemoteAuthenticationOptions : AuthenticationSchemeOptions { + private const string CorrelationPrefix = ".AspNetCore.Correlation."; + + private CookieBuilder _correlationCookieBuilder; + + /// + /// Initializes a new . + /// + public RemoteAuthenticationOptions() + { + _correlationCookieBuilder = new CorrelationCookieBuilder(this) + { + Name = CorrelationPrefix, + HttpOnly = true, + SameSite = SameSiteMode.None, + SecurePolicy = CookieSecurePolicy.SameAsRequest, + }; + } + /// /// Check that the options are valid. Should throw an exception if things are not ok. /// @@ -71,8 +90,8 @@ public override void Validate() public new RemoteAuthenticationEvents Events { - get { return (RemoteAuthenticationEvents)base.Events; } - set { base.Events = value; } + get => (RemoteAuthenticationEvents)base.Events; + set => base.Events = value; } /// @@ -84,9 +103,37 @@ public override void Validate() public bool SaveTokens { get; set; } /// - /// Gets or sets an action that can override the correlation id cookie options before the + /// Determines the settings used to create the correlation cookie before the /// cookie gets added to the response. /// - public Action ConfigureCorrelationIdCookie { get; set; } + public CookieBuilder CorrelationCookie + { + get => _correlationCookieBuilder; + set => _correlationCookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); + } + + private class CorrelationCookieBuilder : RequestPathBaseCookieBuilder + { + private readonly RemoteAuthenticationOptions _options; + + public CorrelationCookieBuilder(RemoteAuthenticationOptions remoteAuthenticationOptions) + { + _options = remoteAuthenticationOptions; + } + + protected override string AdditionalPath => _options.CallbackPath; + + public override CookieOptions Build(HttpContext context, DateTimeOffset expiresFrom) + { + var cookieOptions = base.Build(context, expiresFrom); + + if (!Expiration.HasValue || !cookieOptions.Expires.HasValue) + { + cookieOptions.Expires = expiresFrom.Add(_options.RemoteAuthenticationTimeout); + } + + return cookieOptions; + } + } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index bdd79533b..62d11e52a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -190,7 +190,7 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv opt.AuthorizationEndpoint = "https://example.com/provider/login"; opt.TokenEndpoint = "https://example.com/provider/token"; opt.CallbackPath = "/oauth-callback"; - opt.ConfigureCorrelationIdCookie = (ctx, options) => options.Path = "/"; + opt.CorrelationCookie.Path = "/"; }), ctx => { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 7f9d42b1c..b7ac1f82d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -92,7 +92,7 @@ public async Task RedirectToIdentityProvider_NonceCookieOptions_CanBeOverriden() { AuthorizationEndpoint = "https://example.com/provider/login" }; - opt.ConfigureNonceCookie = (ctx, options) => options.Path = "/"; + opt.NonceCookie.Path = "/"; }); var server = setting.CreateTestServer(); @@ -143,7 +143,7 @@ public async Task RedirectToIdentityProvider_CorrelationIdCookieOptions_CanBeOve { AuthorizationEndpoint = "https://example.com/provider/login" }; - opt.ConfigureCorrelationIdCookie = (ctx, options) => options.Path = "/"; + opt.CorrelationCookie.Path = "/"; }); var server = setting.CreateTestServer(); From a7bf561b1c76aaee3d68c7448d780bc925ee283e Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 29 Jun 2017 17:24:23 -0700 Subject: [PATCH 037/248] Add CookieBuilder to CookieAuthenticationOptions and obsolete the duplicated properties --- Security.sln | 6 +- .../CookieAuthenticationHandler.cs | 39 ++-- .../CookieAuthenticationOptions.cs | 183 ++++++++++++------ ...t.AspNetCore.Authentication.Cookies.csproj | 4 + ...ostConfigureCookieAuthenticationOptions.cs | 4 +- .../Properties/Resources.Designer.cs | 62 ------ .../CookieTests.cs | 69 ++++--- .../CookiePolicyTests.cs | 12 +- 8 files changed, 188 insertions(+), 191 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs diff --git a/Security.sln b/Security.sln index 7c34ff070..2e5ee56d0 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26507.0 +VisualStudioVersion = 15.0.26621.2 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" EndProject @@ -59,6 +59,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build\common.props = build\common.props build\dependencies.props = build\dependencies.props build\Key.snk = build\Key.snk + NuGet.config = NuGet.config build\repo.props = build\repo.props EndProjectSection EndProject @@ -484,4 +485,7 @@ Global {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ABF8089E-43D0-4010-84A7-7A9DCFE49357} + EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 4751c6f85..e093e87b7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -14,9 +14,9 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { - public class CookieAuthenticationHandler : - AuthenticationHandler, - IAuthenticationSignInHandler, + public class CookieAuthenticationHandler : + AuthenticationHandler, + IAuthenticationSignInHandler, IAuthenticationSignOutHandler { private const string HeaderValueNoCache = "no-cache"; @@ -37,7 +37,7 @@ public CookieAuthenticationHandler(IOptionsSnapshot { } /// - /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. /// If it is not provided a default instance is supplied which does nothing when the methods are called. /// protected new CookieAuthenticationEvents Events @@ -104,7 +104,7 @@ private void RequestRefresh(AuthenticationTicket ticket) private async Task ReadCookieTicket() { - var cookie = Options.CookieManager.GetRequestCookie(Context, Options.CookieName); + var cookie = Options.CookieManager.GetRequestCookie(Context, Options.Cookie.Name); if (string.IsNullOrEmpty(cookie)) { return AuthenticateResult.NoResult(); @@ -176,22 +176,9 @@ protected override async Task HandleAuthenticateAsync() private CookieOptions BuildCookieOptions() { - var cookieOptions = new CookieOptions - { - Domain = Options.CookieDomain, - SameSite = Options.CookieSameSite, - HttpOnly = Options.CookieHttpOnly, - Path = Options.CookiePath ?? (OriginalPathBase.HasValue ? OriginalPathBase.ToString() : "/"), - }; - - if (Options.CookieSecure == CookieSecurePolicy.SameAsRequest) - { - cookieOptions.Secure = Request.IsHttps; - } - else - { - cookieOptions.Secure = Options.CookieSecure == CookieSecurePolicy.Always; - } + var cookieOptions = Options.Cookie.Build(Context); + // ignore the 'Expires' value as this will be computed elsewhere + cookieOptions.Expires = null; return cookieOptions; } @@ -239,7 +226,7 @@ protected virtual async Task FinishResponseAsync() Options.CookieManager.AppendResponseCookie( Context, - Options.CookieName, + Options.Cookie.Name, cookieValue, cookieOptions); @@ -283,14 +270,14 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper if (!signInContext.Properties.ExpiresUtc.HasValue) { - signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.ExpireTimeSpan); + signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.Cookie.Expiration ?? default(TimeSpan)); } await Events.SigningIn(signInContext); if (signInContext.Properties.IsPersistent) { - var expiresUtc = signInContext.Properties.ExpiresUtc ?? issuedUtc.Add(Options.ExpireTimeSpan); + var expiresUtc = signInContext.Properties.ExpiresUtc ?? issuedUtc.Add(Options.Cookie.Expiration ?? default(TimeSpan)); signInContext.CookieOptions.Expires = expiresUtc.ToUniversalTime(); } @@ -314,7 +301,7 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper Options.CookieManager.AppendResponseCookie( Context, - Options.CookieName, + Options.Cookie.Name, cookieValue, signInContext.CookieOptions); @@ -359,7 +346,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) Options.CookieManager.DeleteCookie( Context, - Options.CookieName, + Options.Cookie.Name, context.CookieOptions); // Only redirect on the logout path diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 01a5ae9c9..4f8b201ad 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Authentication.Internal; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Http; @@ -12,7 +13,16 @@ namespace Microsoft.AspNetCore.Authentication.Cookies /// public class CookieAuthenticationOptions : AuthenticationSchemeOptions { - private string _cookieName; + private CookieBuilder _cookieBuilder = new RequestPathBaseCookieBuilder + { + // the default name is configured in PostConfigureCookieAuthenticationOptions + + // To support OAuth authentication, a lax mode is required, see https://github.com/aspnet/Security/issues/1231. + SameSite = SameSiteMode.Lax, + HttpOnly = true, + SecurePolicy = CookieSecurePolicy.SameAsRequest, + Expiration = TimeSpan.FromDays(14), + }; /// /// Create an instance of the options initialized with the default values @@ -20,77 +30,52 @@ public class CookieAuthenticationOptions : AuthenticationSchemeOptions public CookieAuthenticationOptions() { ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; - ExpireTimeSpan = TimeSpan.FromDays(14); SlidingExpiration = true; - // To support OAuth authentication, a lax mode is required, see https://github.com/aspnet/Security/issues/1231. - CookieSameSite = SameSiteMode.Lax; - CookieHttpOnly = true; - CookieSecure = CookieSecurePolicy.SameAsRequest; Events = new CookieAuthenticationEvents(); } /// - /// Determines the cookie name used to persist the identity. The default value is ".AspNetCore.Cookies". + /// + /// Determines the settings used to create the cookie. + /// + /// + /// defaults to . + /// defaults to true. + /// defaults to . + /// defaults to 14 days. + /// + /// + /// + /// + /// The default value for cookie name is ".AspNetCore.Cookies". /// This value should be changed if you change the name of the AuthenticationScheme, especially if your /// system uses the cookie authentication handler multiple times. - /// - public string CookieName + /// + /// + /// determines if the browser should allow the cookie to be attached to same-site or cross-site requests. + /// The default is Lax, which means the cookie is only allowed to be attached to cross-site requests using safe HTTP methods and same-site requests. + /// + /// + /// determines if the browser should allow the cookie to be accessed by client-side javascript. + /// The default is true, which means the cookie will only be passed to http requests and is not made available to script on the page. + /// + /// + /// controls how much time the cookie will remain valid from the point it is created. The expiration + /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored + /// even if it is passed to the server after the browser should have purged it + /// + /// + public CookieBuilder Cookie { - get { return _cookieName; } - set - { - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } - - _cookieName = value; - } + get => _cookieBuilder; + set => _cookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); } - /// - /// Determines the domain used to create the cookie. Is not provided by default. - /// - public string CookieDomain { get; set; } - - /// - /// Determines the path used to create the cookie. The default value is "/" for highest browser compatibility. - /// - public string CookiePath { get; set; } - - /// - /// Determines if the browser should allow the cookie to be attached to same-site or cross-site requests. The - /// default is Lax, which means the cookie is only allowed to be attached to cross-site requests using safe - /// HTTP methods and same-site requests. - /// - public SameSiteMode CookieSameSite { get; set; } - - /// - /// Determines if the browser should allow the cookie to be accessed by client-side javascript. The - /// default is true, which means the cookie will only be passed to http requests and is not made available - /// to script on the page. - /// - public bool CookieHttpOnly { get; set; } - - /// - /// Determines if the cookie should only be transmitted on HTTPS request. The default is to limit the cookie - /// to HTTPS requests if the page which is doing the SignIn is also HTTPS. If you have an HTTPS sign in page - /// and portions of your site are HTTP you may need to change this value. - /// - public CookieSecurePolicy CookieSecure { get; set; } - /// /// If set this will be used by the CookieAuthenticationHandler for data protection. /// public IDataProtectionProvider DataProtectionProvider { get; set; } - /// - /// Controls how much time the cookie will remain valid from the point it is created. The expiration - /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored - /// even if it is passed to the server after the browser should have purged it - /// - public TimeSpan ExpireTimeSpan { get; set; } - /// /// The SlidingExpiration is set to true to instruct the handler to re-issue a new cookie with a new /// expiration time any time it processes a request which is more than halfway through the expiration window. @@ -132,8 +117,8 @@ public string CookieName /// public new CookieAuthenticationEvents Events { - get { return (CookieAuthenticationEvents)base.Events; } - set { base.Events = value; } + get => (CookieAuthenticationEvents)base.Events; + set => base.Events = value; } /// @@ -154,5 +139,85 @@ public string CookieName /// to the client. This can be used to mitigate potential problems with very large identities. /// public ITicketStore SessionStore { get; set; } + + #region Obsolete API + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines the cookie name used to persist the identity. The default value is ".AspNetCore.Cookies". + /// This value should be changed if you change the name of the AuthenticationScheme, especially if your + /// system uses the cookie authentication handler multiple times. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Domain) + ".")] + public string CookieName { get => Cookie.Name; set => Cookie.Name = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines the domain used to create the cookie. Is not provided by default. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Domain) + ".")] + public string CookieDomain { get => Cookie.Domain; set => Cookie.Domain = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines the path used to create the cookie. The default value is "/" for highest browser compatibility. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Path) + ".")] + public string CookiePath { get => Cookie.Path; set => Cookie.Path = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines if the browser should allow the cookie to be accessed by client-side javascript. The + /// default is true, which means the cookie will only be passed to http requests and is not made available + /// to script on the page. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.SameSite) + ".")] + public bool CookieHttpOnly { get => Cookie.HttpOnly; set => Cookie.HttpOnly = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Determines if the cookie should only be transmitted on HTTPS request. The default is to limit the cookie + /// to HTTPS requests if the page which is doing the SignIn is also HTTPS. If you have an HTTPS sign in page + /// and portions of your site are HTTP you may need to change this value. + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.SecurePolicy) + ".")] + public CookieSecurePolicy CookieSecure { get => Cookie.SecurePolicy; set => Cookie.SecurePolicy = value; } + + /// + /// + /// This property is obsolete and will be removed in a future version. The recommended alternative is on . + /// + /// + /// Controls how much time the cookie will remain valid from the point it is created. The expiration + /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored + /// even if it is passed to the server after the browser should have purged it + /// + /// + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Expiration) + ".")] + public TimeSpan ExpireTimeSpan + { + get => Cookie.Expiration ?? default(TimeSpan); + set => Cookie.Expiration = value; + } + #endregion } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 712aa8177..fb20a55b9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -19,4 +19,8 @@ + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs index e6a62d1b6..48895072e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/PostConfigureCookieAuthenticationOptions.cs @@ -28,9 +28,9 @@ public void PostConfigure(string name, CookieAuthenticationOptions options) { options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; - if (String.IsNullOrEmpty(options.CookieName)) + if (string.IsNullOrEmpty(options.Cookie.Name)) { - options.CookieName = CookieAuthenticationDefaults.CookiePrefix + name; + options.Cookie.Name = CookieAuthenticationDefaults.CookiePrefix + name; } if (options.TicketDataFormat == null) { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs deleted file mode 100644 index e2719f39d..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Properties/Resources.Designer.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -namespace Microsoft.AspNetCore.Authentication.Cookies -{ - using System.Globalization; - using System.Reflection; - using System.Resources; - - internal static class Resources - { - private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNetCore.Authentication.Cookies.Resources", typeof(Resources).GetTypeInfo().Assembly); - - /// - /// The cookie key and options are larger than ChunksSize, leaving no room for data. - /// - internal static string Exception_CookieLimitTooSmall - { - get { return GetString("Exception_CookieLimitTooSmall"); } - } - - /// - /// The cookie key and options are larger than ChunksSize, leaving no room for data. - /// - internal static string FormatException_CookieLimitTooSmall() - { - return GetString("Exception_CookieLimitTooSmall"); - } - - /// - /// The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded. - /// - internal static string Exception_ImcompleteChunkedCookie - { - get { return GetString("Exception_ImcompleteChunkedCookie"); } - } - - /// - /// The chunked cookie is incomplete. Only {0} of the expected {1} chunks were found, totaling {2} characters. A client size limit may have been exceeded. - /// - internal static string FormatException_ImcompleteChunkedCookie(object p0, object p1, object p2) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_ImcompleteChunkedCookie"), p0, p1, p2); - } - - private static string GetString(string name, params string[] formatterNames) - { - var value = _resourceManager.GetString(name); - - System.Diagnostics.Debug.Assert(value != null); - - if (formatterNames != null) - { - for (var i = 0; i < formatterNames.Length; i++) - { - value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); - } - } - - return value; - } - } -} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 7dade96ee..1471caf44 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -18,7 +18,6 @@ using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Xunit; namespace Microsoft.AspNetCore.Authentication.Cookies @@ -129,7 +128,7 @@ public async Task SignInCausesDefaultCookieToBeCreated() var server = CreateServerWithServices(s => s.AddAuthentication().AddCookie(o => { o.LoginPath = new PathString("/login"); - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }), SignInAsAlice); var transaction = await SendAsync(server, "http://example.com/testpath"); @@ -150,7 +149,7 @@ public async Task SignInWrongAuthTypeThrows() var server = CreateServer(o => { o.LoginPath = new PathString("/login"); - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, SignInAsWrong); await Assert.ThrowsAsync(async () => await SendAsync(server, "http://example.com/testpath")); @@ -162,7 +161,7 @@ public async Task SignOutWrongAuthTypeThrows() var server = CreateServer(o => { o.LoginPath = new PathString("/login"); - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, SignOutAsWrong); await Assert.ThrowsAsync(async () => await SendAsync(server, "http://example.com/testpath")); @@ -183,8 +182,8 @@ public async Task SecureSignInCausesSecureOnlyCookieByDefault( var server = CreateServer(o => { o.LoginPath = new PathString("/login"); - o.CookieName = "TestCookie"; - o.CookieSecure = cookieSecurePolicy; + o.Cookie.Name = "TestCookie"; + o.Cookie.SecurePolicy = cookieSecurePolicy; }, SignInAsAlice); var transaction = await SendAsync(server, requestUri); @@ -205,12 +204,12 @@ public async Task CookieOptionsAlterSetCookieHeader() { var server1 = CreateServer(o => { - o.CookieName = "TestCookie"; - o.CookiePath = "/foo"; - o.CookieDomain = "another.com"; - o.CookieSecure = CookieSecurePolicy.Always; - o.CookieSameSite = SameSiteMode.None; - o.CookieHttpOnly = true; + o.Cookie.Name = "TestCookie"; + o.Cookie.Path = "/foo"; + o.Cookie.Domain = "another.com"; + o.Cookie.SecurePolicy = CookieSecurePolicy.Always; + o.Cookie.SameSite = SameSiteMode.None; + o.Cookie.HttpOnly = true; }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); var transaction1 = await SendAsync(server1, "http://example.com/base/testpath"); @@ -226,10 +225,10 @@ public async Task CookieOptionsAlterSetCookieHeader() var server2 = CreateServer(o => { - o.CookieName = "SecondCookie"; - o.CookieSecure = CookieSecurePolicy.None; - o.CookieSameSite = SameSiteMode.Strict; - o.CookieHttpOnly = false; + o.Cookie.Name = "SecondCookie"; + o.Cookie.SecurePolicy = CookieSecurePolicy.None; + o.Cookie.SameSite = SameSiteMode.Strict; + o.Cookie.HttpOnly = false; }, SignInAsAlice, baseAddress: new Uri("http://example.com/base")); var transaction2 = await SendAsync(server2, "http://example.com/base/testpath"); @@ -278,7 +277,7 @@ public async Task CookieStopsWorkingAfterExpiration() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, SignInAsAlice); @@ -307,7 +306,7 @@ public async Task CookieExpirationCanBeOverridenInSignin() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, context => @@ -340,7 +339,7 @@ public async Task ExpiredCookieWithValidatorStillExpired() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => @@ -368,7 +367,7 @@ public async Task CookieCanBeRejectedAndSignedOutByValidator() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -396,7 +395,7 @@ public async Task CookieNotRenewedAfterSignOut() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -432,7 +431,7 @@ public async Task CookieCanBeRenewedByValidator() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -477,7 +476,7 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => @@ -521,7 +520,7 @@ public async Task CookieValidatorOnlyCalledOnce() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -570,7 +569,7 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) DateTimeOffset? lastExpiresDate = null; var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = sliding; o.Events = new CookieAuthenticationEvents { @@ -620,7 +619,7 @@ public async Task CookieExpirationCanBeOverridenInEvent() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents() { @@ -657,7 +656,7 @@ public async Task CookieIsRenewedWithSlidingExpiration() { var server = CreateServer(o => { - o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Cookie.Expiration = TimeSpan.FromMinutes(10); o.SlidingExpiration = true; }, SignInAsAlice); @@ -825,7 +824,7 @@ public async Task CanConfigureDefaultCookieInstance() { services.AddAuthentication().AddCookie(); services.Configure(CookieAuthenticationDefaults.AuthenticationScheme, - o => o.CookieName = "One"); + o => o.Cookie.Name = "One"); }); var server = new TestServer(builder); @@ -848,7 +847,7 @@ public async Task CanConfigureNamedCookieInstance() { services.AddAuthentication().AddCookie("Cookie1"); services.Configure("Cookie1", - o => o.CookieName = "One"); + o => o.Cookie.Name = "One"); }); var server = new TestServer(builder); @@ -984,7 +983,7 @@ public async Task RedirectUriIsHoneredAfterSignin(string redirectUrl) var server = CreateServer(o => { o.LoginPath = "/testpath"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => await context.SignInAsync( @@ -1006,7 +1005,7 @@ public async Task RedirectUriInQueryIsHoneredAfterSignin() { o.LoginPath = "/testpath"; o.ReturnUrlParameter = "return"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => { @@ -1028,7 +1027,7 @@ public async Task AbsoluteRedirectUriInQueryStringIsRejected() { o.LoginPath = "/testpath"; o.ReturnUrlParameter = "return"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => { @@ -1049,7 +1048,7 @@ public async Task EnsurePrecedenceOfRedirectUriAfterSignin() { o.LoginPath = "/testpath"; o.ReturnUrlParameter = "return"; - o.CookieName = "TestCookie"; + o.Cookie.Name = "TestCookie"; }, async context => { @@ -1102,7 +1101,7 @@ public async Task CanSpecifyAndShareDataProtector() .ConfigureServices(services => services.AddAuthentication().AddCookie(o => { o.TicketDataFormat = new TicketDataFormat(dp); - o.CookieName = "Cookie"; + o.Cookie.Name = "Cookie"; })); var server1 = new TestServer(builder1); @@ -1121,7 +1120,7 @@ public async Task CanSpecifyAndShareDataProtector() }) .ConfigureServices(services => services.AddAuthentication().AddCookie("Cookies", o => { - o.CookieName = "Cookie"; + o.Cookie.Name = "Cookie"; o.TicketDataFormat = new TicketDataFormat(dp); })); var server2 = new TestServer(builder2); diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 5c2458c52..49089234e 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -314,9 +314,9 @@ public async Task CookiePolicyAppliesToCookieAuth() { services.AddAuthentication().AddCookie(o => { - o.CookieName = "TestCookie"; - o.CookieHttpOnly = false; - o.CookieSecure = CookieSecurePolicy.None; + o.Cookie.Name = "TestCookie"; + o.Cookie.HttpOnly = false; + o.Cookie.SecurePolicy = CookieSecurePolicy.None; }); }) .Configure(app => @@ -354,9 +354,9 @@ public async Task CookiePolicyAppliesToCookieAuthChunks() { services.AddAuthentication().AddCookie(o => { - o.CookieName = "TestCookie"; - o.CookieHttpOnly = false; - o.CookieSecure = CookieSecurePolicy.None; + o.Cookie.Name = "TestCookie"; + o.Cookie.HttpOnly = false; + o.Cookie.SecurePolicy = CookieSecurePolicy.None; }); }) .Configure(app => From 1c30f33c925a97b105b3f9d34497218b0c9342b6 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 3 Jul 2017 12:56:39 -0700 Subject: [PATCH 038/248] Remove AddXyzAuth extension methods --- .../CookieExtensions.cs | 15 --------------- .../FacebookExtensions.cs | 11 ----------- .../GoogleExtensions.cs | 12 ------------ .../JwtBearerExtensions.cs | 14 -------------- .../MicrosoftAccountExtensions.cs | 12 ------------ .../OAuthExtensions.cs | 14 -------------- .../OpenIdConnectExtensions.cs | 13 ------------- .../TwitterExtensions.cs | 13 ------------- .../AuthenticationMiddleware.cs | 2 -- .../FacebookTests.cs | 10 ++++------ .../GoogleTests.cs | 3 ++- .../JwtBearerTests.cs | 5 +++-- .../MicrosoftAccountTests.cs | 3 ++- .../OAuthTests.cs | 17 +++++++++-------- .../TwitterTests.cs | 4 ++-- 15 files changed, 22 insertions(+), 126 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index 67c4416eb..61f72e361 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -25,20 +25,5 @@ public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); return builder.AddScheme(authenticationScheme, configureOptions); } - - - // REMOVE below once callers have been updated - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services) => services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme); - - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme) => services.AddCookieAuthentication(authenticationScheme, configureOptions: null); - - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, Action configureOptions) => - services.AddCookieAuthentication(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddCookieAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); - return services.AddScheme(authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index e4dcbfee8..1cb1ef03e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -17,16 +17,5 @@ public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder build public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) => builder.AddOAuth(authenticationScheme, configureOptions); - - - // REMOVE below once callers have been updated - public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services) - => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index ee42c5564..7bb9b7beb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -17,17 +17,5 @@ public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) => builder.AddOAuth(authenticationScheme, configureOptions); - - - // REMOVE below once callers have been updated - - public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services) - => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 4f051bd39..698c0118e 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -22,19 +22,5 @@ public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder buil builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); return builder.AddScheme(authenticationScheme, configureOptions); } - - - // REMOVE once callers updated - public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services) - => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddJwtBearerAuthentication(JwtBearerDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); - return services.AddScheme(authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 9a53fd770..8da6daaac 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -17,17 +17,5 @@ public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuild public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) => builder.AddOAuth(authenticationScheme, configureOptions); - - - // REMOVE below once callers have been updated - - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services) - => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - => services.AddOAuthAuthentication(authenticationScheme, configureOptions); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 5720d8e4f..8c9d34c5f 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -21,19 +21,5 @@ public static AuthenticationBuilder AddOAuth(this Authentica builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } - - // REMOVE below once callers have been updated - public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - return services.AddOAuthAuthentication>(authenticationScheme, configureOptions); - } - - public static IServiceCollection AddOAuthAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - where TOptions : OAuthOptions, new() - where THandler : OAuthHandler - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); - return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index 7ba262bf3..43059b3ff 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -22,18 +22,5 @@ public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } - - // REMOVE once callers have been updated - public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services) - => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddOpenIdConnectAuthentication(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); - return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index e49244920..bd0a3b1e2 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -22,18 +22,5 @@ public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builde builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); } - - // REMOVE below once callers have been updated. - public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services) - => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { }); - - public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, Action configureOptions) - => services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, configureOptions); - - public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action configureOptions) - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); - return services.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); - } } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs index eba561d1d..0c62cc3c3 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationMiddleware.cs @@ -37,8 +37,6 @@ public async Task Invoke(HttpContext context) OriginalPathBase = context.Request.PathBase }); - // REVIEW: alternatively could depend on a routing middleware to do this - // Give any IAuthenticationRequestHandler schemes a chance to handle the request var handlers = context.RequestServices.GetRequiredService(); foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync()) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index e6b5574df..43c52b0fd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; @@ -16,10 +15,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; using Newtonsoft.Json; using Xunit; @@ -30,7 +27,8 @@ public class FacebookTests [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddFacebookAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddFacebook(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(FacebookDefaults.AuthenticationScheme); @@ -44,7 +42,7 @@ public async Task ThrowsIfAppIdMissing() { var server = CreateServer( app => { }, - services => services.AddFacebookAuthentication(o => o.SignInScheme = "Whatever"), + services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = "Whatever"), context => { // REVIEW: Gross. @@ -60,7 +58,7 @@ public async Task ThrowsIfAppSecretMissing() { var server = CreateServer( app => { }, - services => services.AddFacebookAuthentication(o => o.AppId = "Whatever"), + services => services.AddAuthentication().AddFacebook(o => o.AppId = "Whatever"), context => { // REVIEW: Gross. diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 2eae26670..3bfea45df 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -29,7 +29,8 @@ public class GoogleTests [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddGoogleAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddGoogle(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(GoogleDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index a9b158d2b..c7153ded3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -29,7 +29,8 @@ public class JwtBearerTests [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddJwtBearerAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddJwtBearer(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(JwtBearerDefaults.AuthenticationScheme); @@ -747,7 +748,7 @@ private static TestServer CreateServer(Action options = null, } }); }) - .ConfigureServices(services => services.AddJwtBearerAuthentication(options)); + .ConfigureServices(services => services.AddAuthentication().AddJwtBearer(options)); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index f51694043..941dd1348 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -30,7 +30,8 @@ public class MicrosoftAccountTests [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddMicrosoftAccountAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddMicrosoftAccount(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(MicrosoftAccountDefaults.AuthenticationScheme); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 62d11e52a..ea0c941c9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -19,7 +19,8 @@ public class OAuthTests [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddOAuthAuthentication("oauth", o => { }); + var services = new ServiceCollection(); + services.AddAuthentication().AddOAuth("oauth", o => { }); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync("oauth"); @@ -33,7 +34,7 @@ public async Task ThrowsIfClientIdMissing() { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; o.CallbackPath = "/"; @@ -56,7 +57,7 @@ public async Task ThrowsIfClientSecretMissing() { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; o.ClientId = "Whatever;"; @@ -79,7 +80,7 @@ public async Task ThrowsIfCallbackPathMissing() { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; o.ClientSecret = "Whatever;"; @@ -102,7 +103,7 @@ public async Task ThrowsIfTokenEndpointMissing() { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; o.ClientSecret = "Whatever;"; @@ -125,7 +126,7 @@ public async Task ThrowsIfAuthorizationEndpointMissing() { var server = CreateServer( app => { }, - services => services.AddOAuthAuthentication("weeblie", o => + services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; o.ClientSecret = "Whatever;"; @@ -148,7 +149,7 @@ public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallB { var server = CreateServer( app => { }, - s => s.AddOAuthAuthentication( + s => s.AddAuthentication().AddOAuth( "Weblie", opt => { @@ -180,7 +181,7 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv { var server = CreateServer( app => { }, - s => s.AddOAuthAuthentication( + s => s.AddAuthentication().AddOAuth( "Weblie", opt => { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 76f6b1aad..1c387d889 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -21,7 +20,8 @@ public class TwitterTests [Fact] public async Task VerifySchemeDefaults() { - var services = new ServiceCollection().AddTwitterAuthentication().AddSingleton(new ConfigurationBuilder().Build()); + var services = new ServiceCollection(); + services.AddAuthentication().AddTwitter(); var sp = services.BuildServiceProvider(); var schemeProvider = sp.GetRequiredService(); var scheme = await schemeProvider.GetSchemeAsync(TwitterDefaults.AuthenticationScheme); From 658f4621b17e14e5eba007c83426764d1fd8a5a6 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 28 Jun 2017 10:50:52 -0700 Subject: [PATCH 039/248] #1208 Clean up JWT and OIDC issuer handling --- .../JwtBearerHandler.cs | 14 ++++---------- .../OpenIdConnectHandler.cs | 13 ++++--------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 999d323e1..1cb1ea449 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -90,17 +90,11 @@ protected override async Task HandleAuthenticateAsync() var validationParameters = Options.TokenValidationParameters.Clone(); if (_configuration != null) { - if (validationParameters.ValidIssuer == null && !string.IsNullOrEmpty(_configuration.Issuer)) - { - validationParameters.ValidIssuer = _configuration.Issuer; - } - else - { - var issuers = new[] { _configuration.Issuer }; - validationParameters.ValidIssuers = (validationParameters.ValidIssuers == null ? issuers : validationParameters.ValidIssuers.Concat(issuers)); - } + var issuers = new[] { _configuration.Issuer }; + validationParameters.ValidIssuers = validationParameters.ValidIssuers?.Concat(issuers) ?? issuers; - validationParameters.IssuerSigningKeys = (validationParameters.IssuerSigningKeys == null ? _configuration.SigningKeys : validationParameters.IssuerSigningKeys.Concat(_configuration.SigningKeys)); + validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(_configuration.SigningKeys) + ?? _configuration.SigningKeys; } List validationFailures = null; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 9e6d34bc9..068593837 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -1137,16 +1137,11 @@ private ClaimsPrincipal ValidateToken(string idToken, AuthenticationProperties p if (_configuration != null) { - if (string.IsNullOrEmpty(validationParameters.ValidIssuer)) - { - validationParameters.ValidIssuer = _configuration.Issuer; - } - else if (!string.IsNullOrEmpty(_configuration.Issuer)) - { - validationParameters.ValidIssuers = validationParameters.ValidIssuers?.Concat(new[] { _configuration.Issuer }) ?? new[] { _configuration.Issuer }; - } + var issuer = new[] { _configuration.Issuer }; + validationParameters.ValidIssuers = validationParameters.ValidIssuers?.Concat(issuer) ?? issuer; - validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(_configuration.SigningKeys) ?? _configuration.SigningKeys; + validationParameters.IssuerSigningKeys = validationParameters.IssuerSigningKeys?.Concat(_configuration.SigningKeys) + ?? _configuration.SigningKeys; } var principal = Options.SecurityTokenValidator.ValidateToken(idToken, validationParameters, out SecurityToken validatedToken); From bd19ba9533cfd3ffd81e4ef2c874109e8b3dbccd Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 5 Jul 2017 15:43:43 -0700 Subject: [PATCH 040/248] Revert obsoleting CookieAuthenticationOptions.ExpireTimeSpan (#1296) - Revert the obsoleting of CookieAuthenticationOptions.ExpireTimeSpan in aspnet/Security#1285 - Add test to ensure Cookie.Expiration is ignored --- .../CookieAuthenticationHandler.cs | 4 +- .../CookieAuthenticationOptions.cs | 37 +++++++----------- ...t.AspNetCore.Authentication.Cookies.csproj | 4 -- .../CookieTests.cs | 39 +++++++++++++------ 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index e093e87b7..f41199752 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -270,14 +270,14 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper if (!signInContext.Properties.ExpiresUtc.HasValue) { - signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.Cookie.Expiration ?? default(TimeSpan)); + signInContext.Properties.ExpiresUtc = issuedUtc.Add(Options.ExpireTimeSpan); } await Events.SigningIn(signInContext); if (signInContext.Properties.IsPersistent) { - var expiresUtc = signInContext.Properties.ExpiresUtc ?? issuedUtc.Add(Options.Cookie.Expiration ?? default(TimeSpan)); + var expiresUtc = signInContext.Properties.ExpiresUtc ?? issuedUtc.Add(Options.ExpireTimeSpan); signInContext.CookieOptions.Expires = expiresUtc.ToUniversalTime(); } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 4f8b201ad..ec67ecc18 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -21,7 +21,6 @@ public class CookieAuthenticationOptions : AuthenticationSchemeOptions SameSite = SameSiteMode.Lax, HttpOnly = true, SecurePolicy = CookieSecurePolicy.SameAsRequest, - Expiration = TimeSpan.FromDays(14), }; /// @@ -29,6 +28,7 @@ public class CookieAuthenticationOptions : AuthenticationSchemeOptions /// public CookieAuthenticationOptions() { + ExpireTimeSpan = TimeSpan.FromDays(14); ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; SlidingExpiration = true; Events = new CookieAuthenticationEvents(); @@ -42,7 +42,6 @@ public CookieAuthenticationOptions() /// defaults to . /// defaults to true. /// defaults to . - /// defaults to 14 days. /// /// /// @@ -60,9 +59,7 @@ public CookieAuthenticationOptions() /// The default is true, which means the cookie will only be passed to http requests and is not made available to script on the page. /// /// - /// controls how much time the cookie will remain valid from the point it is created. The expiration - /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored - /// even if it is passed to the server after the browser should have purged it + /// is currently ignored. Use to control lifetime of cookie authentication. /// /// public CookieBuilder Cookie @@ -140,6 +137,19 @@ public CookieBuilder Cookie /// public ITicketStore SessionStore { get; set; } + /// + /// + /// Controls how much time the authentication ticket stored in the cookie will remain valid from the point it is created + /// The expiration information is stored in the protected cookie ticket. Because of that an expired cookie will be ignored + /// even if it is passed to the server after the browser should have purged it. + /// + /// + /// This is separate from the value of , which specifies + /// how long the browser will keep the cookie. + /// + /// + public TimeSpan ExpireTimeSpan { get; set; } + #region Obsolete API /// /// @@ -201,23 +211,6 @@ public CookieBuilder Cookie /// [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.SecurePolicy) + ".")] public CookieSecurePolicy CookieSecure { get => Cookie.SecurePolicy; set => Cookie.SecurePolicy = value; } - - /// - /// - /// This property is obsolete and will be removed in a future version. The recommended alternative is on . - /// - /// - /// Controls how much time the cookie will remain valid from the point it is created. The expiration - /// information is in the protected cookie ticket. Because of that an expired cookie will be ignored - /// even if it is passed to the server after the browser should have purged it - /// - /// - [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Expiration) + ".")] - public TimeSpan ExpireTimeSpan - { - get => Cookie.Expiration ?? default(TimeSpan); - set => Cookie.Expiration = value; - } #endregion } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index fb20a55b9..712aa8177 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 1471caf44..c2d843bf1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -143,6 +143,23 @@ public async Task SignInCausesDefaultCookieToBeCreated() Assert.DoesNotContain("; secure", setCookie); } + [Fact] + public async Task CookieExpirationOptionIsIgnored() + { + var server = CreateServerWithServices(s => s.AddAuthentication().AddCookie(o => + { + o.Cookie.Name = "TestCookie"; + // this is currently ignored. Users should set o.ExpireTimeSpan instead + o.Cookie.Expiration = TimeSpan.FromDays(10); + }), SignInAsAlice); + + var transaction = await SendAsync(server, "http://example.com/testpath"); + + var setCookie = transaction.SetCookie; + Assert.StartsWith("TestCookie=", setCookie); + Assert.DoesNotContain("; expires=", setCookie); + } + [Fact] public async Task SignInWrongAuthTypeThrows() { @@ -277,7 +294,7 @@ public async Task CookieStopsWorkingAfterExpiration() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, SignInAsAlice); @@ -306,7 +323,7 @@ public async Task CookieExpirationCanBeOverridenInSignin() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; }, context => @@ -339,7 +356,7 @@ public async Task ExpiredCookieWithValidatorStillExpired() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => @@ -367,7 +384,7 @@ public async Task CookieCanBeRejectedAndSignedOutByValidator() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -395,7 +412,7 @@ public async Task CookieNotRenewedAfterSignOut() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -431,7 +448,7 @@ public async Task CookieCanBeRenewedByValidator() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -476,7 +493,7 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.Events = new CookieAuthenticationEvents { OnValidatePrincipal = ctx => @@ -520,7 +537,7 @@ public async Task CookieValidatorOnlyCalledOnce() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents { @@ -569,7 +586,7 @@ public async Task ShouldRenewUpdatesIssuedExpiredUtc(bool sliding) DateTimeOffset? lastExpiresDate = null; var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = sliding; o.Events = new CookieAuthenticationEvents { @@ -619,7 +636,7 @@ public async Task CookieExpirationCanBeOverridenInEvent() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = false; o.Events = new CookieAuthenticationEvents() { @@ -656,7 +673,7 @@ public async Task CookieIsRenewedWithSlidingExpiration() { var server = CreateServer(o => { - o.Cookie.Expiration = TimeSpan.FromMinutes(10); + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); o.SlidingExpiration = true; }, SignInAsAlice); From fd502195a4320150a1d328e9b6d055dd3a9b419f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 6 Jul 2017 10:39:16 -0700 Subject: [PATCH 041/248] React to aspnet/BuildTools#293 [ci skip] --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index f00799700..44605092c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 4.4.0-* 3.13.9 2.1.3 - 2.1.0-* + 2.0.1-* 10.0.1 2.0.0-* 2.0.0-* From 23da47617624cfed065cd1cdd552d34e5ea5b821 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 6 Jul 2017 13:41:47 -0700 Subject: [PATCH 042/248] Switch to IOptionsMonitor (#1295) --- .../CookieAuthenticationHandler.cs | 2 +- .../FacebookHandler.cs | 2 +- .../GoogleHandler.cs | 2 +- .../JwtBearerHandler.cs | 2 +- .../MicrosoftAccountHandler.cs | 2 +- .../OAuthHandler.cs | 2 +- .../OpenIdConnectHandler.cs | 2 +- .../TwitterHandler.cs | 2 +- .../AuthenticationHandler.cs | 8 +-- .../RemoteAuthenticationHandler.cs | 2 +- .../DynamicSchemeTests.cs | 72 ++++++++++++++++--- 11 files changed, 76 insertions(+), 22 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index f41199752..996c334a7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -32,7 +32,7 @@ public class CookieAuthenticationHandler : private string _sessionKey; private Task _readCookieTask; - public CookieAuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public CookieAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 8a1f29bbe..9004fc09c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { internal class FacebookHandler : OAuthHandler { - public FacebookHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public FacebookHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index aa5e59649..7a2e1a2d1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { internal class GoogleHandler : OAuthHandler { - public GoogleHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public GoogleHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 1cb1ea449..9cf73182b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -22,7 +22,7 @@ internal class JwtBearerHandler : AuthenticationHandler { private OpenIdConnectConfiguration _configuration; - public JwtBearerHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + public JwtBearerHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 45fae3d0e..8204bf07b 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { internal class MicrosoftAccountHandler : OAuthHandler { - public MicrosoftAccountHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public MicrosoftAccountHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index b61d57537..007d7dbef 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Authentication.OAuth set { base.Events = value; } } - public OAuthHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public OAuthHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 068593837..65e1e1951 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -55,7 +55,7 @@ public class OpenIdConnectHandler : RemoteAuthenticationHandler options, ILoggerFactory logger, HtmlEncoder htmlEncoder, UrlEncoder encoder, ISystemClock clock) + public OpenIdConnectHandler(IOptionsMonitor options, ILoggerFactory logger, HtmlEncoder htmlEncoder, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { HtmlEncoder = htmlEncoder; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index ddcd095d5..1e1dd08d8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -38,7 +38,7 @@ internal class TwitterHandler : RemoteAuthenticationHandler set { base.Events = value; } } - public TwitterHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + public TwitterHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index a258d0aca..d1d09f074 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -40,7 +40,7 @@ protected HttpResponse Response protected ISystemClock Clock { get; } - protected IOptionsSnapshot OptionsSnapshot { get; } + protected IOptionsMonitor OptionsMonitor { get; } /// /// The handler calls methods on the events which give the application control at certain points where processing is occurring. @@ -58,12 +58,12 @@ protected string CurrentUri } } - protected AuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + protected AuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) { Logger = logger.CreateLogger(this.GetType().FullName); UrlEncoder = encoder; Clock = clock; - OptionsSnapshot = options; + OptionsMonitor = options; } /// @@ -86,7 +86,7 @@ public async Task InitializeAsync(AuthenticationScheme scheme, HttpContext conte Scheme = scheme; Context = context; - Options = OptionsSnapshot.Get(Scheme.Name) ?? new TOptions(); + Options = OptionsMonitor.Get(Scheme.Name) ?? new TOptions(); Options.Validate(); await InitializeEventsAsync(); diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 7bd3b0773..bcd598364 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -31,7 +31,7 @@ public abstract class RemoteAuthenticationHandler : AuthenticationHand set { base.Events = value; } } - protected RemoteAuthenticationHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + protected RemoteAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } protected override Task CreateEventsAsync() diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs index d239d85f8..fe7443679 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs @@ -18,6 +18,42 @@ namespace Microsoft.AspNetCore.Authentication { public class DynamicSchemeTests { + [Fact] + public async Task OptionsAreConfiguredOnce() + { + var server = CreateServer(s => + { + s.Configure("One", o => o.Instance = new Singleton()); + s.Configure("Two", o => o.Instance = new Singleton()); + }); + // Add One scheme + var response = await server.CreateClient().GetAsync("http://example.com/add/One"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + var transaction = await server.SendAsync("http://example.com/auth/One"); + Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); + Assert.Equal("1", transaction.FindClaimValue("Count")); + + // Verify option is not recreated + transaction = await server.SendAsync("http://example.com/auth/One"); + Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); + Assert.Equal("1", transaction.FindClaimValue("Count")); + + // Add Two scheme + response = await server.CreateClient().GetAsync("http://example.com/add/Two"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + transaction = await server.SendAsync("http://example.com/auth/Two"); + Assert.Equal("Two", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "Two")); + Assert.Equal("2", transaction.FindClaimValue("Count")); + + // Verify options are not recreated + transaction = await server.SendAsync("http://example.com/auth/One"); + Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); + Assert.Equal("1", transaction.FindClaimValue("Count")); + transaction = await server.SendAsync("http://example.com/auth/Two"); + Assert.Equal("Two", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "Two")); + Assert.Equal("2", transaction.FindClaimValue("Count")); + } + [Fact] public async Task CanAddAndRemoveSchemes() { @@ -48,7 +84,6 @@ public async Task CanAddAndRemoveSchemes() Assert.Equal(HttpStatusCode.OK, response.StatusCode); await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/Two")); await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/One")); - } [Fact] @@ -69,9 +104,27 @@ public async Task VerifyDefaultBehavior() await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth")); } - private class TestHandler : AuthenticationHandler + public class TestOptions : AuthenticationSchemeOptions + { + public Singleton Instance { get; set; } + } + + public class Singleton { - public TestHandler(IOptionsSnapshot options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + public static int _count; + + public Singleton() + { + _count++; + Count = _count; + } + + public int Count { get; } + } + + private class TestHandler : AuthenticationHandler + { + public TestHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } @@ -80,12 +133,16 @@ protected override Task HandleAuthenticateAsync() var principal = new ClaimsPrincipal(); var id = new ClaimsIdentity(); id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + if (Options.Instance != null) + { + id.AddClaim(new Claim("Count", Options.Instance.Count.ToString())); + } principal.AddIdentity(id); return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); } } - private static TestServer CreateServer(Action configureAuth = null) + private static TestServer CreateServer(Action configureServices = null) { var builder = new WebHostBuilder() .Configure(app => @@ -122,11 +179,8 @@ private static TestServer CreateServer(Action configureAu }) .ConfigureServices(services => { - if (configureAuth == null) - { - configureAuth = o => { }; - } - services.AddAuthentication(configureAuth); + configureServices?.Invoke(services); + services.AddAuthentication(); }); return new TestServer(builder); } From 184ccb8f4a83b21eab0812ccc84714f14aaf0092 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 6 Jul 2017 12:26:50 -0700 Subject: [PATCH 043/248] Set "TreatWarningsAsErrors" before NuGet restore * Ensures our build stays clean of NuGet warnings --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index dc4ad9a78..1555ad638 100644 --- a/build/common.props +++ b/build/common.props @@ -10,6 +10,7 @@ true true $(VersionSuffix)-$(BuildNumber) + true From bfe067432567f25f148149b78f90a0a5c1d9a5fb Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 6 Jul 2017 15:08:51 -0700 Subject: [PATCH 044/248] Update version suffix for 2.0.0 RTM release --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 90a2f5b5c..b94223e00 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview3 + rtm \ No newline at end of file From d433f034fab3daea2cfd5e2661bd1512cd0d2efc Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 6 Jul 2017 15:44:03 -0700 Subject: [PATCH 045/248] Remove NETStandard.Library.NETFramework --- build/common.props | 4 ---- samples/CookieSample/CookieSample.csproj | 4 ---- samples/CookieSessionSample/CookieSessionSample.csproj | 4 ---- samples/JwtBearerSample/JwtBearerSample.csproj | 4 ---- .../OpenIdConnect.AzureAdSample.csproj | 4 ---- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 4 ---- samples/SocialSample/SocialSample.csproj | 4 ---- 7 files changed, 28 deletions(-) diff --git a/build/common.props b/build/common.props index 1555ad638..f7497c8f4 100644 --- a/build/common.props +++ b/build/common.props @@ -17,8 +17,4 @@ - - - - diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index d251b844e..64438de77 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index a2d0490f1..cb07f4385 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -19,8 +19,4 @@ - - - - diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index c2f73fd96..fe2a5fa9d 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -20,8 +20,4 @@ - - - - diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 785724908..ece748d0d 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -23,8 +23,4 @@ - - - - diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 03384f567..9f62a06b5 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -33,8 +33,4 @@ - - - - diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 999dc91a6..d35796f75 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -35,8 +35,4 @@ - - - - From 38d33cfbf2d639e22ea0316a50a72a642cc7196d Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 7 Jul 2017 11:28:41 -0700 Subject: [PATCH 046/248] Fix tests to work with new default --- .../CookieTests.cs | 2 +- .../DynamicSchemeTests.cs | 18 ------------------ .../FacebookTests.cs | 5 ++--- .../GoogleTests.cs | 2 +- .../JwtBearerTests.cs | 2 +- .../MicrosoftAccountTests.cs | 2 +- .../OpenIdConnect/TestServerBuilder.cs | 2 +- 7 files changed, 7 insertions(+), 26 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index c2d843bf1..83083cbf0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -1247,7 +1247,7 @@ private TestServer CreateServer(Action configureOpt => CreateServerWithServices(s => { s.AddSingleton(_clock); - s.AddAuthentication().AddCookie(configureOptions); + s.AddAuthentication(o => o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions); s.AddSingleton(); }, testpath, baseAddress); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs index fe7443679..d658609b0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/DynamicSchemeTests.cs @@ -86,24 +86,6 @@ public async Task CanAddAndRemoveSchemes() await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/One")); } - [Fact] - public async Task VerifyDefaultBehavior() - { - var server = CreateServer(); - - await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth")); - - var response = await server.CreateClient().GetAsync("http://example.com/add/One"); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - var transaction = await server.SendAsync("http://example.com/auth"); - Assert.Equal("One", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "One")); - response = await server.CreateClient().GetAsync("http://example.com/add/Two"); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - - // Default will blow up since now there's two - await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth")); - } - public class TestOptions : AuthenticationSchemeOptions { public Singleton Instance { get; set; } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 43c52b0fd..35752ec6b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -81,8 +81,7 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() { services.AddAuthentication(options => { - options.DefaultSignInScheme = "External"; - options.DefaultAuthenticateScheme = "External"; + options.DefaultScheme = "External"; }) .AddCookie("External", o => { }) .AddFacebook(o => @@ -221,7 +220,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() { services.AddAuthentication(options => { - options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddCookie() .AddFacebook(o => diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 3bfea45df..f1038bb51 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -1050,7 +1050,7 @@ private static TestServer CreateServer(Action configureOptions, F services.AddTransient(); services.AddAuthentication(o => { - o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; + o.DefaultScheme = TestExtensions.CookieAuthenticationScheme; o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme; }); services.AddAuthentication() diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index c7153ded3..e001bd995 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -748,7 +748,7 @@ private static TestServer CreateServer(Action options = null, } }); }) - .ConfigureServices(services => services.AddAuthentication().AddJwtBearer(options)); + .ConfigureServices(services => services.AddAuthentication(o => o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options)); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 941dd1348..b63ad1f7d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -226,7 +226,7 @@ private static TestServer CreateServer(Action configure { services.AddAuthentication(o => { - o.DefaultAuthenticateScheme = TestExtensions.CookieAuthenticationScheme; + o.DefaultScheme = TestExtensions.CookieAuthenticationScheme; }); services.AddAuthentication() .AddCookie(TestExtensions.CookieAuthenticationScheme, o => { }) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs index 1ffb9ff68..4d6a26821 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -111,7 +111,7 @@ await context.SignOutAsync( { services.AddAuthentication(o => { - o.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; }); services.AddAuthentication() .AddCookie() From df325deaf355f99239c1319932bc28eb3a837372 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 7 Jul 2017 12:04:32 -0700 Subject: [PATCH 047/248] Add AddAuthentication(defaultScheme) overload --- .../AuthenticationServiceCollectionExtensions.cs | 3 +++ .../CookieTests.cs | 2 +- .../FacebookTests.cs | 10 ++-------- .../JwtBearerTests.cs | 2 +- .../MicrosoftAccountTests.cs | 6 +----- .../OpenIdConnect/TestServerBuilder.cs | 6 +----- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 28291f419..e1beea7b6 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -27,6 +27,9 @@ public static AuthenticationBuilder AddAuthentication(this IServiceCollection se return new AuthenticationBuilder(services); } + public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, string defaultScheme) + => services.AddAuthentication(o => o.DefaultScheme = defaultScheme); + public static AuthenticationBuilder AddAuthentication(this IServiceCollection services, Action configureOptions) { if (services == null) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 83083cbf0..c711fde49 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -1247,7 +1247,7 @@ private TestServer CreateServer(Action configureOpt => CreateServerWithServices(s => { s.AddSingleton(_clock); - s.AddAuthentication(o => o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions); + s.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions); s.AddSingleton(); }, testpath, baseAddress); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 35752ec6b..75de0652e 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -79,10 +79,7 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() }, services => { - services.AddAuthentication(options => - { - options.DefaultScheme = "External"; - }) + services.AddAuthentication("External") .AddCookie("External", o => { }) .AddFacebook(o => { @@ -218,10 +215,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() app => app.UseAuthentication(), services => { - services.AddAuthentication(options => - { - options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }) + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie() .AddFacebook(o => { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index e001bd995..97adb2105 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -748,7 +748,7 @@ private static TestServer CreateServer(Action options = null, } }); }) - .ConfigureServices(services => services.AddAuthentication(o => o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options)); + .ConfigureServices(services => services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options)); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index b63ad1f7d..2e249a833 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -224,11 +224,7 @@ private static TestServer CreateServer(Action configure }) .ConfigureServices(services => { - services.AddAuthentication(o => - { - o.DefaultScheme = TestExtensions.CookieAuthenticationScheme; - }); - services.AddAuthentication() + services.AddAuthentication(TestExtensions.CookieAuthenticationScheme) .AddCookie(TestExtensions.CookieAuthenticationScheme, o => { }) .AddMicrosoftAccount(configureOptions); }); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs index 4d6a26821..c37da8c04 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestServerBuilder.cs @@ -109,11 +109,7 @@ await context.SignOutAsync( }) .ConfigureServices(services => { - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }); - services.AddAuthentication() + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie() .AddOpenIdConnect(options); }); From 979475fbf3461cd64607d9f5fa7987bd3279e04a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:46:06 -0700 Subject: [PATCH 048/248] Branching for 2.0.0 rtm --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de..37f0d27ea 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,7 +2,7 @@ - + From 72bf2507d8829cdddf43ade87493497e8c1464e8 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:58:01 -0700 Subject: [PATCH 049/248] Updating KoreBuild branch --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c11..178533438 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb57..5e27ed8ef 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From a894c38f7a8ec58d70fd24d2c54f5279eacf5684 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 7 Jul 2017 14:57:59 -0700 Subject: [PATCH 050/248] Skip first time experience on Appveyor --- appveyor.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 1041615c6..31efd8196 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true branches: only: @@ -9,6 +9,10 @@ branches: build_script: - ps: .\build.ps1 clone_depth: 1 +environment: + global: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 test: off deploy: off os: Visual Studio 2017 From 5485846b5c119a365ac3d004effc8aa97d987fce Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 12 Jul 2017 09:56:25 -0700 Subject: [PATCH 051/248] Update IdentityModel versions to latest, fix samples. --- build/dependencies.props | 4 ++-- samples/OpenIdConnect.AzureAdSample/Startup.cs | 3 +-- samples/OpenIdConnectSample/Startup.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 44605092c..3ceeb8708 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,8 +2,8 @@ 2.0.0-* 4.4.0-* - 3.13.9 - 2.1.3 + 3.14.1 + 2.1.4 2.0.1-* 10.0.1 2.0.0-* diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index aab6e60df..6a6abd7c3 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -45,8 +45,7 @@ public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(sharedOptions => { - sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; - sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) .AddCookie() diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index bc5af750d..3325ea3c3 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -147,7 +147,7 @@ await WriteHtmlAsync(context.Response, async res => // Authenticated, but not authorized if (context.Request.Path.Equals("/restricted") && !user.Identities.Any(identity => identity.HasClaim("special", "true"))) { - await context.ChallengeAsync(); + await context.ForbidAsync(); return; } From 36d3d97b9935b2cefb22731084adc4754d1e61e9 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 13 Jul 2017 12:25:36 -0700 Subject: [PATCH 052/248] #1319 Add DisplayName overloads --- samples/OpenIdConnect.AzureAdSample/Startup.cs | 2 +- samples/SocialSample/Startup.cs | 6 +++--- .../CookieExtensions.cs | 5 ++++- .../FacebookDefaults.cs | 2 ++ .../FacebookExtensions.cs | 5 ++++- .../GoogleDefaults.cs | 2 ++ .../GoogleExtensions.cs | 5 ++++- .../JwtBearerExtensions.cs | 5 ++++- .../MicrosoftAccountDefaults.cs | 2 ++ .../MicrosoftAccountExtensions.cs | 5 ++++- .../OAuthDefaults.cs | 10 ++++++++++ .../OAuthExtensions.cs | 10 +++++++++- .../OpenIdConnectDefaults.cs | 4 ++-- .../OpenIdConnectExtensions.cs | 5 ++++- .../OpenIdConnectOptions.cs | 1 - .../breakingchanges.netcore.json | 5 +++++ .../TwitterDefaults.cs | 2 ++ .../TwitterExtensions.cs | 5 ++++- .../OAuthTests.cs | 2 +- 19 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs diff --git a/samples/OpenIdConnect.AzureAdSample/Startup.cs b/samples/OpenIdConnect.AzureAdSample/Startup.cs index 6a6abd7c3..c3fa3c719 100644 --- a/samples/OpenIdConnect.AzureAdSample/Startup.cs +++ b/samples/OpenIdConnect.AzureAdSample/Startup.cs @@ -49,7 +49,7 @@ public void ConfigureServices(IServiceCollection services) sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) .AddCookie() - .AddOpenIdConnect(o => + .AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, "AAD", o => { o.ClientId = ClientId; o.ClientSecret = ClientSecret; // for code flow diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index dcf76263d..8a59928c4 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -70,7 +70,7 @@ public void ConfigureServices(IServiceCollection services) }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project - .AddOAuth("Google-AccessToken", o => + .AddOAuth("Google-AccessToken", "Google AccessToken only", o => { o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; @@ -128,7 +128,7 @@ public void ConfigureServices(IServiceCollection services) */ // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. // https://apps.dev.microsoft.com/ - .AddOAuth("Microsoft-AccessToken", o => + .AddOAuth("Microsoft-AccessToken", "Microsoft AccessToken only", o => { o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; @@ -148,7 +148,7 @@ public void ConfigureServices(IServiceCollection services) }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ - .AddOAuth("GitHub-AccessToken", o => + .AddOAuth("GitHub-AccessToken", "GitHub AccessToken only", o => { o.ClientId = Configuration["github-token:clientid"]; o.ClientSecret = Configuration["github-token:clientsecret"]; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs index 61f72e361..4c41f54a9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieExtensions.cs @@ -21,9 +21,12 @@ public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder => builder.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddCookie(authenticationScheme, displayName: null, configureOptions: configureOptions); + + public static AuthenticationBuilder AddCookie(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureCookieAuthenticationOptions>()); - return builder.AddScheme(authenticationScheme, configureOptions); + return builder.AddScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs index 012f95dcc..6143a4f23 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -7,6 +7,8 @@ public static class FacebookDefaults { public const string AuthenticationScheme = "Facebook"; + public static readonly string DisplayName = "Facebook"; + public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.6/dialog/oauth"; public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.6/oauth/access_token"; diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs index 1cb1ef03e..2273724a4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookExtensions.cs @@ -16,6 +16,9 @@ public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder build => builder.AddFacebook(FacebookDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) - => builder.AddOAuth(authenticationScheme, configureOptions); + => builder.AddFacebook(authenticationScheme, FacebookDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddFacebook(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + => builder.AddOAuth(authenticationScheme, displayName, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index 77d68aed9..e4bd66615 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -10,6 +10,8 @@ public static class GoogleDefaults { public const string AuthenticationScheme = "Google"; + public static readonly string DisplayName = "Google"; + public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/auth"; public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"; diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs index 7bb9b7beb..95547014c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleExtensions.cs @@ -16,6 +16,9 @@ public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder => builder.AddGoogle(GoogleDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) - => builder.AddOAuth(authenticationScheme, configureOptions); + => builder.AddGoogle(authenticationScheme, GoogleDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddGoogle(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + => builder.AddOAuth(authenticationScheme, displayName, configureOptions); } } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs index 698c0118e..334407c0d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerExtensions.cs @@ -18,9 +18,12 @@ public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder buil => builder.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddJwtBearer(authenticationScheme, displayName: null, configureOptions: configureOptions); + + public static AuthenticationBuilder AddJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); - return builder.AddScheme(authenticationScheme, configureOptions); + return builder.AddScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs index 0d272f979..1b0859c5b 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs @@ -7,6 +7,8 @@ public static class MicrosoftAccountDefaults { public const string AuthenticationScheme = "Microsoft"; + public static readonly string DisplayName = "Microsoft"; + public static readonly string AuthorizationEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"; public static readonly string TokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token"; diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs index 8da6daaac..7f24e5af7 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountExtensions.cs @@ -16,6 +16,9 @@ public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuild => builder.AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) - => builder.AddOAuth(authenticationScheme, configureOptions); + => builder.AddMicrosoftAccount(authenticationScheme, MicrosoftAccountDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddMicrosoftAccount(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + => builder.AddOAuth(authenticationScheme, displayName, configureOptions); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs new file mode 100644 index 000000000..376f8ab01 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthDefaults.cs @@ -0,0 +1,10 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNetCore.Authentication.OAuth +{ + public static class OAuthDefaults + { + public static readonly string DisplayName = "OAuth"; + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs index 8c9d34c5f..22c541a0a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthExtensions.cs @@ -14,12 +14,20 @@ public static class OAuthExtensions public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) => builder.AddOAuth>(authenticationScheme, configureOptions); + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + => builder.AddOAuth>(authenticationScheme, displayName, configureOptions); + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) where TOptions : OAuthOptions, new() where THandler : OAuthHandler + => builder.AddOAuth(authenticationScheme, OAuthDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + where TOptions : OAuthOptions, new() + where THandler : OAuthHandler { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OAuthPostConfigureOptions>()); - return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + return builder.AddRemoteScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs index c5baca4db..f98ba87e0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectDefaults.cs @@ -19,9 +19,9 @@ public static class OpenIdConnectDefaults public const string AuthenticationScheme = "OpenIdConnect"; /// - /// The default value for OpenIdConnectOptions.Caption. + /// The default value for the display name. /// - public static readonly string Caption = "OpenIdConnect"; + public static readonly string DisplayName = "OpenIdConnect"; /// /// The prefix used to for the nonce in the cookie. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs index 43059b3ff..f427bebaf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectExtensions.cs @@ -18,9 +18,12 @@ public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder => builder.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddOpenIdConnect(authenticationScheme, OpenIdConnectDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, OpenIdConnectPostConfigureOptions>()); - return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + return builder.AddRemoteScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index 23169b5bc..a8545e35a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -27,7 +27,6 @@ public class OpenIdConnectOptions : RemoteAuthenticationOptions /// Defaults: /// AddNonceToRequest: true. /// BackchannelTimeout: 1 minute. - /// Caption: . /// ProtocolValidator: new . /// RefreshOnIssuerKeyNotFound: true /// ResponseType: diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json index 0f50b1210..931a7b079 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json @@ -59,5 +59,10 @@ { "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", + "MemberId": "public static readonly System.String Caption", + "Kind": "Removal" } ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs index 0610ccfc9..a39a3f036 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs @@ -6,5 +6,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter public static class TwitterDefaults { public const string AuthenticationScheme = "Twitter"; + + public static readonly string DisplayName = "Twitter"; } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs index bd0a3b1e2..724380569 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterExtensions.cs @@ -18,9 +18,12 @@ public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builde => builder.AddTwitter(TwitterDefaults.AuthenticationScheme, configureOptions); public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddTwitter(authenticationScheme, TwitterDefaults.DisplayName, configureOptions); + + public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, TwitterPostConfigureOptions>()); - return builder.AddRemoteScheme(authenticationScheme, authenticationScheme, configureOptions); + return builder.AddRemoteScheme(authenticationScheme, displayName, configureOptions); } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index ea0c941c9..aeb313daa 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -26,7 +26,7 @@ public async Task VerifySchemeDefaults() var scheme = await schemeProvider.GetSchemeAsync("oauth"); Assert.NotNull(scheme); Assert.Equal("OAuthHandler`1", scheme.HandlerType.Name); - Assert.Equal("oauth", scheme.DisplayName); + Assert.Equal(OAuthDefaults.DisplayName, scheme.DisplayName); } [Fact] From 04a40b54543b9260c11c822b680bfa86d5f54f1d Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 13 Jul 2017 15:10:12 -0700 Subject: [PATCH 053/248] Removed DotNetCliToolReference from the samples to fix build break --- .../OpenIdConnect.AzureAdSample.csproj | 1 - samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 1 - 2 files changed, 2 deletions(-) diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index ece748d0d..cd8b6976f 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -20,7 +20,6 @@ - diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 9f62a06b5..b3d875d47 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -26,7 +26,6 @@ - From b61f1ee7817b2b6f3c55237f03af3854927b3b44 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 14 Jul 2017 16:34:20 -0700 Subject: [PATCH 054/248] Enable Travis and AppVeyor for rel branches (#1324) --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index b10be1421..6c59666f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ branches: - release - dev - /^(.*\/)?ci-.*$/ + - /^rel\/.*/ before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: diff --git a/appveyor.yml b/appveyor.yml index 1041615c6..04dfabcb0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,7 @@ branches: - release - dev - /^(.*\/)?ci-.*$/ + - /^rel\/.*/ build_script: - ps: .\build.ps1 clone_depth: 1 From fcd9f0c3ff5693f453fde62c9e16c1991085ce93 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 14 Jul 2017 16:55:07 -0700 Subject: [PATCH 055/248] Update Owin to latest (#1323) --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3ceeb8708..85abdc894 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,7 +8,7 @@ 10.0.1 2.0.0-* 2.0.0-* - 3.0.1 + 3.1.0 2.0.0-* 15.3.0-* 2.3.0-beta2-* From ba7739f14de51662134f4a101e2475d3984a222c Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 14 Jul 2017 18:14:22 -0700 Subject: [PATCH 056/248] Revert "Update Owin to latest (#1323)" This reverts commit fcd9f0c3ff5693f453fde62c9e16c1991085ce93. --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 85abdc894..3ceeb8708 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,7 +8,7 @@ 10.0.1 2.0.0-* 2.0.0-* - 3.1.0 + 3.0.1 2.0.0-* 15.3.0-* 2.3.0-beta2-* From 644f34e90d35b369efdce9c11ab1db42e0a7f4a7 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 20 Jul 2017 11:07:01 -0700 Subject: [PATCH 057/248] AuthZ PolicyEvalutor should take resource --- .../IPolicyEvaluator.cs | 6 ++- .../PolicyEvaluator.cs | 8 ++- .../PolicyEvaluatorTests.cs | 50 +++++++++++++++---- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs index 1717a0ae0..dd5e6fc03 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization.Policy/IPolicyEvaluator.cs @@ -28,9 +28,13 @@ public interface IPolicyEvaluator /// The . /// The result of a call to . /// The . + /// + /// An optional resource the policy should be checked with. + /// If a resource is not required for policy evaluation you may pass null as the value. + /// /// Returns if authorization succeeds. /// Otherwise returns if , otherwise /// returns - Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context); + Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, object resource); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs index f93c2d92a..3100ff4d3 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs +++ b/src/Microsoft.AspNetCore.Authorization.Policy/PolicyEvaluator.cs @@ -67,17 +67,21 @@ public virtual async Task AuthenticateAsync(AuthorizationPol /// The . /// The result of a call to . /// The . + /// + /// An optional resource the policy should be checked with. + /// If a resource is not required for policy evaluation you may pass null as the value. + /// /// Returns if authorization succeeds. /// Otherwise returns if , otherwise /// returns - public virtual async Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context) + public virtual async Task AuthorizeAsync(AuthorizationPolicy policy, AuthenticateResult authenticationResult, HttpContext context, object resource) { if (policy == null) { throw new ArgumentNullException(nameof(policy)); } - var result = await _authorization.AuthorizeAsync(context.User, context, policy); + var result = await _authorization.AuthorizeAsync(context.User, resource, policy); if (result.Succeeded) { return PolicyAuthorizationResult.Success(); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs index 216fc1440..2384e6db5 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/PolicyEvaluatorTests.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; @@ -18,7 +19,7 @@ public class PolicyEvaluatorTests public async Task AuthenticateFailsIfNoPrincipalReturned() { // Arrange - var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); var services = new ServiceCollection().AddSingleton(); context.RequestServices = services.BuildServiceProvider(); @@ -35,7 +36,7 @@ public async Task AuthenticateFailsIfNoPrincipalReturned() public async Task AuthenticateMergeSchemes() { // Arrange - var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); var services = new ServiceCollection().AddSingleton(); context.RequestServices = services.BuildServiceProvider(); @@ -54,12 +55,12 @@ public async Task AuthenticateMergeSchemes() public async Task AuthorizeSucceedsEvenIfAuthenticationFails() { // Arrange - var evaluator = new PolicyEvaluator(new HappyAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); // Act - var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context); + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context, resource: null); // Assert Assert.True(result.Succeeded); @@ -67,16 +68,34 @@ public async Task AuthorizeSucceedsEvenIfAuthenticationFails() Assert.False(result.Forbidden); } + [Fact] + public async Task AuthorizeSucceedsOnlyIfResourceSpecified() + { + // Arrange + var evaluator = BuildEvaluator(); + var context = new DefaultHttpContext(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(c => c.Resource != null).Build(); + var success = AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "whatever")); + + // Act + var result = await evaluator.AuthorizeAsync(policy, success, context, resource: null); + var result2 = await evaluator.AuthorizeAsync(policy, success, context, resource: new object()); + + // Assert + Assert.False(result.Succeeded); + Assert.True(result2.Succeeded); + } + [Fact] public async Task AuthorizeChallengesIfAuthenticationFails() { // Arrange - var evaluator = new PolicyEvaluator(new SadAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); - var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => false).Build(); // Act - var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context); + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Fail("Nooo"), context, resource: null); // Assert Assert.False(result.Succeeded); @@ -88,12 +107,12 @@ public async Task AuthorizeChallengesIfAuthenticationFails() public async Task AuthorizeForbidsIfAuthenticationSuceeds() { // Arrange - var evaluator = new PolicyEvaluator(new SadAuthorization()); + var evaluator = BuildEvaluator(); var context = new DefaultHttpContext(); - var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => false).Build(); // Act - var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "scheme")), context); + var result = await evaluator.AuthorizeAsync(policy, AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(), "scheme")), context, resource: null); // Assert Assert.False(result.Succeeded); @@ -101,6 +120,17 @@ public async Task AuthorizeForbidsIfAuthenticationSuceeds() Assert.True(result.Forbidden); } + private IPolicyEvaluator BuildEvaluator(Action setupServices = null) + { + var services = new ServiceCollection() + .AddAuthorization() + .AddAuthorizationPolicyEvaluator() + .AddLogging() + .AddOptions(); + setupServices?.Invoke(services); + return services.BuildServiceProvider().GetRequiredService(); + } + public class HappyAuthorization : IAuthorizationService { public Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) From 827852efdb4e61f255770ac1b9d6e2bf7c77fa23 Mon Sep 17 00:00:00 2001 From: richstokoe Date: Mon, 24 Jul 2017 16:49:49 +0100 Subject: [PATCH 058/248] Corrected typos in XML Docs in MessageReceivedContext for events in JwtBearer and OpenIdConnect middlesware. (#1336) --- .../Events/MessageReceivedContext.cs | 2 +- .../Events/MessageReceivedContext.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs index 3c263f6b2..1850ad049 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Events/MessageReceivedContext.cs @@ -14,7 +14,7 @@ public MessageReceivedContext( : base(context, scheme, options) { } /// - /// Bearer Token. This will give application an opportunity to retrieve token from an alternation location. + /// Bearer Token. This will give the application an opportunity to retrieve a token from an alternative location. /// public string Token { get; set; } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs index 106ecb8c0..7d06e4479 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/MessageReceivedContext.cs @@ -18,7 +18,7 @@ public MessageReceivedContext( public OpenIdConnectMessage ProtocolMessage { get; set; } /// - /// Bearer Token. This will give application an opportunity to retrieve token from an alternation location. + /// Bearer Token. This will give the application an opportunity to retrieve a token from an alternative location. /// public string Token { get; set; } } From b787344b905d90981ad50b51a00fc6b12e8f1c19 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 21 Jul 2017 13:02:43 -0700 Subject: [PATCH 059/248] 2.0.0-rtm to 2.1.0-preview1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index b94223e00..cb77b4393 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.0.0 - rtm + 2.1.0 + preview1 \ No newline at end of file From b7d29e4f7b968722127948052c24d423ee19026d Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 24 Jul 2017 17:58:45 -0700 Subject: [PATCH 060/248] Set AspNetCoreVersion --- build/dependencies.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3ceeb8708..4a2338b8b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - + - 2.0.0-* + 2.1.0-* 4.4.0-* 3.14.1 2.1.4 From 10b2e70f4c36293aa2ff341b0453a2fe8125ab7d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Jul 2017 15:14:51 -0700 Subject: [PATCH 061/248] Updating to InternalAspNetCoreSdkVersion 2.1.1-* --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4a2338b8b..a97cae9f6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 4.4.0-* 3.14.1 2.1.4 - 2.0.1-* + 2.1.1-* 10.0.1 2.0.0-* 2.0.0-* From b9153be7453b871acd9043b5c373f86368fa8154 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 25 Jul 2017 16:34:44 -0700 Subject: [PATCH 062/248] Update bootstrappers to use the compiled version of KoreBuild [ci skip] --- .gitignore | 1 + build.cmd | 2 +- build.ps1 | 206 +++++++++++++++++++++++++++++++++---------- build.sh | 212 ++++++++++++++++++++++++++++++++++++++------- build/common.props | 2 +- version.props | 7 -- version.xml | 8 ++ 7 files changed, 350 insertions(+), 88 deletions(-) delete mode 100644 version.props create mode 100644 version.xml diff --git a/.gitignore b/.gitignore index d5717b3f3..bac5b7505 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ project.lock.json /.vs/ .vscode/ global.json +korebuild-lock.txt diff --git a/build.cmd b/build.cmd index 7d4894cb4..b6c8d2486 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/build.ps1 index 5bf0e2c11..d5eb4d5cf 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,67 +1,177 @@ -$ErrorActionPreference = "Stop" - -function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) -{ - while($true) - { - try - { - Invoke-WebRequest $url -OutFile $downloadLocation - break - } - catch - { - $exceptionMessage = $_.Exception.Message - Write-Host "Failed to download '$url': $exceptionMessage" - if ($retries -gt 0) { - $retries-- - Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" - Start-Sleep -Seconds 10 +#!/usr/bin/env powershell +#requires -version 4 + +<# +.SYNOPSIS +Build this repository + +.DESCRIPTION +Downloads korebuild if required. Then builds the repository. + +.PARAMETER Path +The folder to build. Defaults to the folder containing this script. + +.PARAMETER Channel +The channel of KoreBuild to download. Overrides the value from the config file. + +.PARAMETER DotNetHome +The directory where .NET Core tools will be stored. + +.PARAMETER ToolsSource +The base url where build tools can be downloaded. Overrides the value from the config file. + +.PARAMETER Update +Updates KoreBuild to the latest version even if a lock file is present. + +.PARAMETER ConfigFile +The path to the configuration file that stores values. Defaults to version.xml. + +.PARAMETER MSBuildArgs +Arguments to be passed to MSBuild + +.NOTES +This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. +When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. + +The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. + +.EXAMPLE +Example config file: +```xml + + + + dev + https://aspnetcore.blob.core.windows.net/buildtools + + +``` +#> +[CmdletBinding(PositionalBinding = $false)] +param( + [string]$Path = $PSScriptRoot, + [Alias('c')] + [string]$Channel, + [Alias('d')] + [string]$DotNetHome, + [Alias('s')] + [string]$ToolsSource, + [Alias('u')] + [switch]$Update, + [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$MSBuildArgs +) + +Set-StrictMode -Version 2 +$ErrorActionPreference = 'Stop' + +# +# Functions +# + +function Get-KoreBuild { + + $lockFile = Join-Path $Path 'korebuild-lock.txt' + + if (!(Test-Path $lockFile) -or $Update) { + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + } + + $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 + if (!$version) { + Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" + } + $version = $version.TrimStart('version:').Trim() + $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + if (!(Test-Path $korebuildPath)) { + Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" + New-Item -ItemType Directory -Path $korebuildPath | Out-Null + $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" + + try { + $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" + Get-RemoteFile $remotePath $tmpfile + if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { + # Use built-in commands where possible as they are cross-plat compatible + Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath } - else - { - $exception = $_.Exception - throw $exception + else { + # Fallback to old approach for old installations of PowerShell + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) } } + catch { + Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore + throw + } + finally { + Remove-Item $tmpfile -ErrorAction Ignore + } } + + return $korebuildPath +} + +function Join-Paths([string]$path, [string[]]$childPaths) { + $childPaths | ForEach-Object { $path = Join-Path $path $_ } + return $path } -cd $PSScriptRoot +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { + if ($RemotePath -notlike 'http*') { + Copy-Item $RemotePath $LocalPath + return + } -$repoFolder = $PSScriptRoot -$env:REPO_FOLDER = $repoFolder + $retries = 10 + while ($retries -gt 0) { + $retries -= 1 + try { + Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + return + } + catch { + Write-Verbose "Request failed. $retries retries remaining" + } + } -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if ($env:KOREBUILD_ZIP) -{ - $koreBuildZip=$env:KOREBUILD_ZIP + Write-Error "Download failed: '$RemotePath'." } -$buildFolder = ".build" -$buildFile="$buildFolder\KoreBuild.ps1" +# +# Main +# -if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" +# Load configuration or set defaults - $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() - New-Item -Path "$tempFolder" -Type directory | Out-Null +if (Test-Path $ConfigFile) { + [xml] $config = Get-Content $ConfigFile + if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } + if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } +} - $localZipFile="$tempFolder\korebuild.zip" +if (!$DotNetHome) { + $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` + elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` + elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` + else { Join-Path $PSScriptRoot '.dotnet'} +} - DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 +if (!$Channel) { $Channel = 'dev' } +if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) +# Execute - New-Item -Path "$buildFolder" -Type directory | Out-Null - copy-item "$tempFolder\**\build\*" $buildFolder -Recurse +$korebuildPath = Get-KoreBuild +Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') - # Cleanup - if (Test-Path $tempFolder) { - Remove-Item -Recurse -Force $tempFolder - } +try { + Install-Tools $ToolsSource $DotNetHome + Invoke-RepositoryBuild $Path @MSBuildArgs +} +finally { + Remove-Module 'KoreBuild' -ErrorAction Ignore } - -&"$buildFile" @args diff --git a/build.sh b/build.sh index b0bcadb57..ab590e62f 100755 --- a/build.sh +++ b/build.sh @@ -1,46 +1,196 @@ #!/usr/bin/env bash -repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if [ ! -z $KOREBUILD_ZIP ]; then - koreBuildZip=$KOREBUILD_ZIP -fi +set -euo pipefail + +# +# variables +# -buildFolder=".build" -buildFile="$buildFolder/KoreBuild.sh" +RESET="\033[0m" +RED="\033[0;31m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +config_file="$DIR/version.xml" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' -if test ! -d $buildFolder; then - echo "Downloading KoreBuild from $koreBuildZip" +# +# Functions +# +__usage() { + echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - tempFolder="/tmp/KoreBuild-$(uuidgen)" - mkdir $tempFolder + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 + fi +} - localZipFile="$tempFolder/korebuild.zip" +get_korebuild() { + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f $lock_file ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + fi + local version="$(grep 'version:*' -m 1 $lock_file)" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - retries=6 - until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) - do - echo "Failed to download '$koreBuildZip'" - if [ "$retries" -le 0 ]; then - exit 1 + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file $remote_path $tmpfile; then + unzip -q -d "$korebuild_path" $tmpfile + fi + rm $tmpfile || true fi - retries=$((retries - 1)) - echo "Waiting 10 seconds before retrying. Retries left: $retries" - sleep 10s - done - unzip -q -d $tempFolder $localZipFile + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}$@${RESET}" 1>&2 +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp $remote_path $local_path + return 0 + fi - mkdir $buildFolder - cp -r $tempFolder/**/build/** $buildFolder + failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O $local_path $remote_path || failed=true + fi - chmod +x $buildFile + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + fi - # Cleanup - if test -d $tempFolder; then - rm -rf $tempFolder + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 fi +} + +__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} + +# +# main +# + +while [[ $# > 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel=${1:-} + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME=${1:-} + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 fi -$buildFile -r $repoFolder "$@" +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +if [ -f $config_file ]; then + comment=false + while __read_dom; do + if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi + if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi + if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi + if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi + done < $config_file +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +install_tools "$tools_source" "$DOTNET_HOME" +invoke_repository_build "$repo_path" $@ diff --git a/build/common.props b/build/common.props index f7497c8f4..ea940214e 100644 --- a/build/common.props +++ b/build/common.props @@ -1,6 +1,6 @@ - + Microsoft ASP.NET Core diff --git a/version.props b/version.props deleted file mode 100644 index cb77b4393..000000000 --- a/version.props +++ /dev/null @@ -1,7 +0,0 @@ - - - - 2.1.0 - preview1 - - \ No newline at end of file diff --git a/version.xml b/version.xml new file mode 100644 index 000000000..3c05022b7 --- /dev/null +++ b/version.xml @@ -0,0 +1,8 @@ + + + + dev + 2.1.0 + preview1 + + From a4458191c700437a00603116ad92633d1590319d Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 26 Jul 2017 10:29:04 -0700 Subject: [PATCH 063/248] Fix syntax warning when running build.sh on older versions of bash [ci skip] --- build.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/build.sh b/build.sh index ab590e62f..5568c6182 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ RESET="\033[0m" RED="\033[0;31m" MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" config_file="$DIR/version.xml" verbose=false update=false @@ -22,7 +22,7 @@ tools_source='' # Functions # __usage() { - echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" echo "" echo "Arguments:" echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." @@ -46,16 +46,17 @@ __usage() { } get_korebuild() { + local version local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f $lock_file ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" fi - local version="$(grep 'version:*' -m 1 $lock_file)" + version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" return 1 fi - version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" { @@ -64,10 +65,10 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file $remote_path $tmpfile; then - unzip -q -d "$korebuild_path" $tmpfile + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" fi - rm $tmpfile || true + rm "$tmpfile" || true fi source "$korebuild_path/KoreBuild.sh" @@ -81,7 +82,7 @@ get_korebuild() { } __error() { - echo -e "${RED}$@${RESET}" 1>&2 + echo -e "${RED}$*${RESET}" 1>&2 } __machine_has() { @@ -94,18 +95,18 @@ __get_remote_file() { local local_path=$2 if [[ "$remote_path" != 'http'* ]]; then - cp $remote_path $local_path + cp "$remote_path" "$local_path" return 0 fi failed=false if __machine_has wget; then - wget --tries 10 --quiet -O $local_path $remote_path || failed=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ]; then @@ -114,13 +115,13 @@ __get_remote_file() { fi } -__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} +__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} # # main # -while [[ $# > 0 ]]; do +while [[ $# -gt 0 ]]; do case $1 in -\?|-h|--help) __usage --no-exit @@ -128,7 +129,7 @@ while [[ $# > 0 ]]; do ;; -c|--channel|-Channel) shift - channel=${1:-} + channel="${1:-}" [ -z "$channel" ] && __usage ;; --config-file|-ConfigFile) @@ -138,7 +139,7 @@ while [[ $# > 0 ]]; do ;; -d|--dotnet-home|-DotNetHome) shift - DOTNET_HOME=${1:-} + DOTNET_HOME="${1:-}" [ -z "$DOTNET_HOME" ] && __usage ;; --path|-Path) @@ -178,14 +179,14 @@ if ! __machine_has curl && ! __machine_has wget; then exit 1 fi -if [ -f $config_file ]; then +if [ -f "$config_file" ]; then comment=false while __read_dom; do if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < $config_file + done < "$config_file" fi [ -z "$channel" ] && channel='dev' @@ -193,4 +194,4 @@ fi get_korebuild install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" $@ +invoke_repository_build "$repo_path" "$@" From 98496d7d6b55e079e78ef71cc9b4e4af5d8a63fe Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 2 Aug 2017 12:44:48 -0700 Subject: [PATCH 064/248] Update __get_remote_file logic --- build.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 5568c6182..8eace4c20 100755 --- a/build.sh +++ b/build.sh @@ -99,17 +99,16 @@ __get_remote_file() { return 0 fi - failed=false + local succeeded=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" && succeeded=true fi - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + if [ "$succeeded" = false ] && __machine_has curl; then + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" && succeeded=true fi - if [ "$failed" = true ]; then + if [ "$succeeded" = false ]; then __error "Download failed: $remote_path" 1>&2 return 1 fi From 4fec8c11c280dbb08a1bd3c76408c438d3c50c7b Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 2 Aug 2017 14:33:52 -0700 Subject: [PATCH 065/248] Ensure fallback to curl after failed wget --- build.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 8eace4c20..11cdbe550 100755 --- a/build.sh +++ b/build.sh @@ -99,16 +99,19 @@ __get_remote_file() { return 0 fi - local succeeded=false + local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" && succeeded=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true fi - if [ "$succeeded" = false ] && __machine_has curl; then - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" && succeeded=true + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi - if [ "$succeeded" = false ]; then + if [ "$failed" = true ]; then __error "Download failed: $remote_path" 1>&2 return 1 fi From d797543cfc587fbe812e66ddf910acbe5f86d009 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 3 Aug 2017 12:59:45 -0700 Subject: [PATCH 066/248] Update obsolete error (#1346) --- .../CookieAppBuilderExtensions.cs | 8 ++++---- .../FacebookAppBuilderExtensions.cs | 8 ++++---- .../GoogleAppBuilderExtensions.cs | 8 ++++---- .../JwtBearerAppBuilderExtensions.cs | 8 ++++---- .../MicrosoftAccountAppBuilderExtensions.cs | 8 ++++---- .../OAuthAppBuilderExtensions.cs | 8 ++++---- .../OpenIdConnectAppBuilderExtensions.cs | 8 ++++---- .../TwitterAppBuilderExtensions.cs | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs index bb5cdfff0..bdfd43c79 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class CookieAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseCookieAuthentication is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseCookieAuthentication is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseCookieAuthentication is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseCookieAuthentication is obsolete. Configure Cookie authentication with AddAuthentication().AddCookie in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseCookieAuthentication(this IApplicationBuilder app, CookieAuthenticationOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs index 1a9607eea..a94dc7bc4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class FacebookAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseFacebookAuthentication is obsolete. Configure Facebook authentication with AddAuthentication().AddFacebook in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseFacebookAuthentication is obsolete. Configure Facebook authentication with AddAuthentication().AddFacebook in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseFacebookAuthentication is obsolete. Configure Facebook authentication with AddAuthentication().AddFacebook in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseFacebookAuthentication is obsolete. Configure Facebook authentication with AddAuthentication().AddFacebook in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseFacebookAuthentication(this IApplicationBuilder app, FacebookOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs index ec7e8a7aa..4302d20db 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleAppBuilderExtensions.cs @@ -3,8 +3,6 @@ using System; using Microsoft.AspNetCore.Authentication.Google; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { @@ -14,21 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class GoogleAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseGoogleAuthentication is obsolete. Configure Google authentication with AddAuthentication().AddGoogle in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. + [Obsolete("UseGoogleAuthentication is obsolete. Configure Google authentication with AddAuthentication().AddGoogle in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseGoogleAuthentication is obsolete. Configure Google authentication with AddAuthentication().AddGoogle in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. + [Obsolete("UseGoogleAuthentication is obsolete. Configure Google authentication with AddAuthentication().AddGoogle in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseGoogleAuthentication(this IApplicationBuilder app, GoogleOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs index 9755c5cb7..0cfc97573 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class JwtBearerAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseJwtBearerAuthentication is obsolete. Configure JwtBearer authentication with AddAuthentication().AddJwtBearer in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseJwtBearerAuthentication is obsolete. Configure JwtBearer authentication with AddAuthentication().AddJwtBearer in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseJwtBearerAuthentication is obsolete. Configure JwtBearer authentication with AddAuthentication().AddJwtBearer in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseJwtBearerAuthentication is obsolete. Configure JwtBearer authentication with AddAuthentication().AddJwtBearer in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseJwtBearerAuthentication(this IApplicationBuilder app, JwtBearerOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs index 88306efbe..7fd71d7a9 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class MicrosoftAccountAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseMicrosoftAccountAuthentication is obsolete. Configure MicrosoftAccount authentication with AddAuthentication().AddMicrosoftAccount in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseMicrosoftAccountAuthentication is obsolete. Configure MicrosoftAccount authentication with AddAuthentication().AddMicrosoftAccount in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseMicrosoftAccountAuthentication is obsolete. Configure MicrosoftAccount authentication with AddAuthentication().AddMicrosoftAccount in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseMicrosoftAccountAuthentication is obsolete. Configure MicrosoftAccount authentication with AddAuthentication().AddMicrosoftAccount in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseMicrosoftAccountAuthentication(this IApplicationBuilder app, MicrosoftAccountOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs index ceec294ec..d55f311f7 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class OAuthAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseOAuthAuthentication is obsolete. Configure OAuth authentication with AddAuthentication().AddOAuth in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseOAuthAuthentication is obsolete. Configure OAuth authentication with AddAuthentication().AddOAuth in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseOAuthAuthentication is obsolete. Configure OAuth authentication with AddAuthentication().AddOAuth in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseOAuthAuthentication is obsolete. Configure OAuth authentication with AddAuthentication().AddOAuth in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseOAuthAuthentication(this IApplicationBuilder app, OAuthOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs index db5cfbbcc..0746ae3fd 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class OpenIdConnectAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseOpenIdConnectAuthentication is obsolete. Configure OpenIdConnect authentication with AddAuthentication().AddOpenIdConnect in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseOpenIdConnectAuthentication is obsolete. Configure OpenIdConnect authentication with AddAuthentication().AddOpenIdConnect in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseOpenIdConnectAuthentication is obsolete. Configure OpenIdConnect authentication with AddAuthentication().AddOpenIdConnect in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A that specifies options for the handler. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseOpenIdConnectAuthentication is obsolete. Configure OpenIdConnect authentication with AddAuthentication().AddOpenIdConnect in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseOpenIdConnectAuthentication(this IApplicationBuilder app, OpenIdConnectOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs index 2896365d6..36e1111da 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterAppBuilderExtensions.cs @@ -12,23 +12,23 @@ namespace Microsoft.AspNetCore.Builder public static class TwitterAppBuilderExtensions { /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseTwitterAuthentication is obsolete. Configure Twitter authentication with AddAuthentication().AddTwitter in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseTwitterAuthentication is obsolete. Configure Twitter authentication with AddAuthentication().AddTwitter in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); } /// - /// Obsolete, see https://go.microsoft.com/fwlink/?linkid=845470 + /// UseTwitterAuthentication is obsolete. Configure Twitter authentication with AddAuthentication().AddTwitter in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details. /// /// The to add the handler to. /// An action delegate to configure the provided . /// A reference to this instance after the operation has completed. - [Obsolete("See https://go.microsoft.com/fwlink/?linkid=845470", error: true)] + [Obsolete("UseTwitterAuthentication is obsolete. Configure Twitter authentication with AddAuthentication().AddTwitter in ConfigureServices. See https://go.microsoft.com/fwlink/?linkid=845470 for more details.", error: true)] public static IApplicationBuilder UseTwitterAuthentication(this IApplicationBuilder app, TwitterOptions options) { throw new NotSupportedException("This method is no longer supported, see https://go.microsoft.com/fwlink/?linkid=845470"); From 5d802a798847f61c8c32368f5690a48caefbca97 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 12 Jul 2017 08:54:58 -0700 Subject: [PATCH 067/248] Add sample for refresh tokens --- samples/OpenIdConnectSample/Startup.cs | 107 ++++++++++-- samples/SocialSample/Startup.cs | 231 +++++++++++++++++++++---- 2 files changed, 286 insertions(+), 52 deletions(-) diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 3325ea3c3..c05bc8b52 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; +using System.Net.Http; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; @@ -11,7 +13,9 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Newtonsoft.Json.Linq; namespace OpenIdConnectSample { @@ -53,6 +57,7 @@ public void ConfigureServices(IServiceCollection services) o.ClientSecret = Configuration["oidc:clientsecret"]; // for code flow o.Authority = Configuration["oidc:authority"]; o.ResponseType = OpenIdConnectResponseType.CodeIdToken; + o.SaveTokens = true; o.GetClaimsFromUserInfoEndpoint = true; o.Events = new OpenIdConnectEvents() { @@ -73,19 +78,21 @@ public void ConfigureServices(IServiceCollection services) }); } - public void Configure(IApplicationBuilder app) + public void Configure(IApplicationBuilder app, IOptionsMonitor optionsMonitor) { app.UseDeveloperExceptionPage(); app.UseAuthentication(); app.Run(async context => { + var response = context.Response; + if (context.Request.Path.Equals("/signedout")) { - await WriteHtmlAsync(context.Response, async res => + await WriteHtmlAsync(response, async res => { await res.WriteAsync($"

You have been signed out.

"); - await res.WriteAsync("Sign In"); + await res.WriteAsync("Home"); }); return; } @@ -93,10 +100,10 @@ await WriteHtmlAsync(context.Response, async res => if (context.Request.Path.Equals("/signout")) { await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - await WriteHtmlAsync(context.Response, async res => + await WriteHtmlAsync(response, async res => { - await context.Response.WriteAsync($"

Signed out {HtmlEncode(context.User.Identity.Name)}

"); - await context.Response.WriteAsync("Sign In"); + await res.WriteAsync($"

Signed out {HtmlEncode(context.User.Identity.Name)}

"); + await res.WriteAsync("Home"); }); return; } @@ -115,19 +122,22 @@ await WriteHtmlAsync(context.Response, async res => if (context.Request.Path.Equals("/Account/AccessDenied")) { await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - await WriteHtmlAsync(context.Response, async res => + await WriteHtmlAsync(response, async res => { - await context.Response.WriteAsync($"

Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'

"); - await context.Response.WriteAsync("Sign Out"); + await res.WriteAsync($"

Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'

"); + await res.WriteAsync("Sign Out"); + await res.WriteAsync("Home"); }); return; } // DefaultAuthenticateScheme causes User to be set - var user = context.User; + // var user = context.User; // This is what [Authorize] calls - // var user = await context.AuthenticateAsync(); + var userResult = await context.AuthenticateAsync(); + var user = userResult.Principal; + var props = userResult.Properties; // This is what [Authorize(ActiveAuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)] calls // var user = await context.AuthenticateAsync(OpenIdConnectDefaults.AuthenticationScheme); @@ -151,15 +161,76 @@ await WriteHtmlAsync(context.Response, async res => return; } - await WriteHtmlAsync(context.Response, async response => + if (context.Request.Path.Equals("/refresh")) + { + var refreshToken = props.GetTokenValue("refresh_token"); + + if (string.IsNullOrEmpty(refreshToken)) + { + await WriteHtmlAsync(response, async res => + { + await res.WriteAsync($"No refresh_token is available.
"); + await res.WriteAsync("Sign Out"); + }); + + return; + } + + var options = optionsMonitor.Get(OpenIdConnectDefaults.AuthenticationScheme); + var metadata = await options.ConfigurationManager.GetConfigurationAsync(context.RequestAborted); + + var pairs = new Dictionary() + { + { "client_id", options.ClientId }, + { "client_secret", options.ClientSecret }, + { "grant_type", "refresh_token" }, + { "refresh_token", refreshToken } + }; + var content = new FormUrlEncodedContent(pairs); + var tokenResponse = await options.Backchannel.PostAsync(metadata.TokenEndpoint, content, context.RequestAborted); + tokenResponse.EnsureSuccessStatusCode(); + + var payload = JObject.Parse(await tokenResponse.Content.ReadAsStringAsync()); + + // Persist the new acess token + props.UpdateTokenValue("access_token", payload.Value("access_token")); + props.UpdateTokenValue("refresh_token", payload.Value("refresh_token")); + if (int.TryParse(payload.Value("expires_in"), NumberStyles.Integer, CultureInfo.InvariantCulture, out var seconds)) + { + var expiresAt = DateTimeOffset.UtcNow + TimeSpan.FromSeconds(seconds); + props.UpdateTokenValue("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture)); + } + await context.SignInAsync(user, props); + + await WriteHtmlAsync(response, async res => + { + await res.WriteAsync($"

Refreshed.

"); + await res.WriteAsync("Refresh tokens"); + await res.WriteAsync("Home"); + + await res.WriteAsync("

Tokens:

"); + await WriteTableHeader(res, new string[] { "Token Type", "Value" }, props.GetTokens().Select(token => new string[] { token.Name, token.Value })); + + await res.WriteAsync("

Payload:

"); + await res.WriteAsync(HtmlEncoder.Default.Encode(payload.ToString()).Replace(",", ",
") + "
"); + }); + + return; + } + + await WriteHtmlAsync(response, async res => { - await response.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); - await response.WriteAsync("Restricted"); - await response.WriteAsync("Sign Out"); - await response.WriteAsync("Sign Out Remote"); + await res.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); + await res.WriteAsync("Refresh tokens"); + await res.WriteAsync("Restricted"); + await res.WriteAsync("Sign Out"); + await res.WriteAsync("Sign Out Remote"); + + await res.WriteAsync("

Claims:

"); + await WriteTableHeader(res, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value })); - await response.WriteAsync("

Claims:

"); - await WriteTableHeader(response, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value })); + await res.WriteAsync("

Tokens:

"); + await WriteTableHeader(res, new string[] { "Token Type", "Value" }, props.GetTokens().Select(token => new string[] { token.Name, token.Value })); }); }); } diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 8a59928c4..d69b25ee3 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; @@ -7,6 +9,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.Facebook; using Microsoft.AspNetCore.Authentication.Google; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; using Microsoft.AspNetCore.Authentication.OAuth; @@ -14,8 +17,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Extensions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; namespace SocialSample @@ -50,12 +55,7 @@ public void ConfigureServices(IServiceCollection services) throw new InvalidOperationException("User secrets must be configured for each authentication provider."); } - services.AddAuthentication(options => - { - options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; - options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; - }) + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(o => o.LoginPath = new PathString("/login")) // You must first create an app with Facebook and add its ID and Secret to your user-secrets. // https://developers.facebook.com/apps/ @@ -88,6 +88,8 @@ public void ConfigureServices(IServiceCollection services) { o.ClientId = Configuration["google:clientid"]; o.ClientSecret = Configuration["google:clientsecret"]; + o.AuthorizationEndpoint += "?prompt=consent"; // Hack so we always get a refresh token, it only comes on the first authorization response + o.AccessType = "offline"; o.SaveTokens = true; o.Events = new OAuthEvents() { @@ -145,6 +147,7 @@ public void ConfigureServices(IServiceCollection services) o.ClientId = Configuration["microsoftaccount:clientid"]; o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; o.SaveTokens = true; + o.Scope.Add("offline_access"); }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ @@ -215,16 +218,135 @@ public void Configure(IApplicationBuilder app) return; } - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync(""); - await context.Response.WriteAsync("Choose an authentication scheme:
"); + var response = context.Response; + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("Choose an authentication scheme:
"); var schemeProvider = context.RequestServices.GetRequiredService(); foreach (var provider in await schemeProvider.GetAllSchemesAsync()) { - // REVIEW: we lost access to display name (which is buried in the handler options) - await context.Response.WriteAsync("" + (provider.DisplayName ?? "(suppressed)") + "
"); + await response.WriteAsync("" + (provider.DisplayName ?? "(suppressed)") + "
"); + } + await response.WriteAsync(""); + }); + }); + + // Refresh the access token + app.Map("/refresh_token", signinApp => + { + signinApp.Run(async context => + { + var response = context.Response; + + // Setting DefaultAuthenticateScheme causes User to be set + // var user = context.User; + + // This is what [Authorize] calls + var userResult = await context.AuthenticateAsync(); + var user = userResult.Principal; + var authProperties = userResult.Properties; + + // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls + // var user = await context.AuthenticateAsync(MicrosoftAccountDefaults.AuthenticationScheme); + + // Deny anonymous request beyond this point. + if (!userResult.Succeeded || user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) + { + // This is what [Authorize] calls + // The cookie middleware will handle this and redirect to /login + await context.ChallengeAsync(); + + // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls + // await context.ChallengeAsync(MicrosoftAccountDefaults.AuthenticationScheme); + + return; + } + + var currentAuthType = user.Identities.First().AuthenticationType; + if (string.Equals(GoogleDefaults.AuthenticationScheme, currentAuthType) + || string.Equals(MicrosoftAccountDefaults.AuthenticationScheme, currentAuthType)) + { + var refreshToken = authProperties.GetTokenValue("refresh_token"); + + if (string.IsNullOrEmpty(refreshToken)) + { + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("No refresh_token is available.
"); + await response.WriteAsync("Home"); + await response.WriteAsync(""); + return; + } + + var options = await GetOAuthOptionsAsync(context, currentAuthType); + + var pairs = new Dictionary() + { + { "client_id", options.ClientId }, + { "client_secret", options.ClientSecret }, + { "grant_type", "refresh_token" }, + { "refresh_token", refreshToken } + }; + var content = new FormUrlEncodedContent(pairs); + var refreshResponse = await options.Backchannel.PostAsync(options.TokenEndpoint, content, context.RequestAborted); + refreshResponse.EnsureSuccessStatusCode(); + + var payload = JObject.Parse(await refreshResponse.Content.ReadAsStringAsync()); + + // Persist the new acess token + authProperties.UpdateTokenValue("access_token", payload.Value("access_token")); + refreshToken = payload.Value("refresh_token"); + if (!string.IsNullOrEmpty(refreshToken)) + { + authProperties.UpdateTokenValue("refresh_token", refreshToken); + } + if (int.TryParse(payload.Value("expires_in"), NumberStyles.Integer, CultureInfo.InvariantCulture, out var seconds)) + { + var expiresAt = DateTimeOffset.UtcNow + TimeSpan.FromSeconds(seconds); + authProperties.UpdateTokenValue("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture)); + } + await context.SignInAsync(user, authProperties); + + await PrintRefreshedTokensAsync(response, payload, authProperties); + + return; + } + // https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension + else if (string.Equals(FacebookDefaults.AuthenticationScheme, currentAuthType)) + { + var options = await GetOAuthOptionsAsync(context, currentAuthType); + + var accessToken = authProperties.GetTokenValue("access_token"); + + var query = new QueryBuilder() + { + { "grant_type", "fb_exchange_token" }, + { "client_id", options.ClientId }, + { "client_secret", options.ClientSecret }, + { "fb_exchange_token", accessToken }, + }.ToQueryString(); + + var refreshResponse = await options.Backchannel.GetStringAsync(options.TokenEndpoint + query); + var payload = JObject.Parse(refreshResponse); + + authProperties.UpdateTokenValue("access_token", payload.Value("access_token")); + if (int.TryParse(payload.Value("expires_in"), NumberStyles.Integer, CultureInfo.InvariantCulture, out var seconds)) + { + var expiresAt = DateTimeOffset.UtcNow + TimeSpan.FromSeconds(seconds); + authProperties.UpdateTokenValue("expires_at", expiresAt.ToString("o", CultureInfo.InvariantCulture)); + } + await context.SignInAsync(user, authProperties); + + await PrintRefreshedTokensAsync(response, payload, authProperties); + + return; } - await context.Response.WriteAsync(""); + + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("Refresh has not been implemented for this provider.
"); + await response.WriteAsync("Home"); + await response.WriteAsync(""); }); }); @@ -233,12 +355,13 @@ public void Configure(IApplicationBuilder app) { signoutApp.Run(async context => { - context.Response.ContentType = "text/html"; + var response = context.Response; + response.ContentType = "text/html"; await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - await context.Response.WriteAsync(""); - await context.Response.WriteAsync("You have been logged out. Goodbye " + context.User.Identity.Name + "
"); - await context.Response.WriteAsync("Home"); - await context.Response.WriteAsync(""); + await response.WriteAsync(""); + await response.WriteAsync("You have been logged out. Goodbye " + context.User.Identity.Name + "
"); + await response.WriteAsync("Home"); + await response.WriteAsync(""); }); }); @@ -247,11 +370,12 @@ public void Configure(IApplicationBuilder app) { errorApp.Run(async context => { - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync(""); - await context.Response.WriteAsync("An remote failure has occurred: " + context.Request.Query["FailureMessage"] + "
"); - await context.Response.WriteAsync("Home"); - await context.Response.WriteAsync(""); + var response = context.Response; + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("An remote failure has occurred: " + context.Request.Query["FailureMessage"] + "
"); + await response.WriteAsync("Home"); + await response.WriteAsync(""); }); }); @@ -271,7 +395,7 @@ public void Configure(IApplicationBuilder app) if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) { // This is what [Authorize] calls - // The cookie middleware will intercept this 401 and redirect to /login + // The cookie middleware will handle this and redirect to /login await context.ChallengeAsync(); // This is what [Authorize(ActiveAuthenticationSchemes = MicrosoftAccountDefaults.AuthenticationScheme)] calls @@ -281,24 +405,63 @@ public void Configure(IApplicationBuilder app) } // Display user information - context.Response.ContentType = "text/html"; - await context.Response.WriteAsync(""); - await context.Response.WriteAsync("Hello " + (context.User.Identity.Name ?? "anonymous") + "
"); + var response = context.Response; + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("Hello " + (context.User.Identity.Name ?? "anonymous") + "
"); foreach (var claim in context.User.Claims) { - await context.Response.WriteAsync(claim.Type + ": " + claim.Value + "
"); + await response.WriteAsync(claim.Type + ": " + claim.Value + "
"); } - await context.Response.WriteAsync("Tokens:
"); + await response.WriteAsync("Tokens:
"); - await context.Response.WriteAsync("Access Token: " + await context.GetTokenAsync("access_token") + "
"); - await context.Response.WriteAsync("Refresh Token: " + await context.GetTokenAsync("refresh_token") + "
"); - await context.Response.WriteAsync("Token Type: " + await context.GetTokenAsync("token_type") + "
"); - await context.Response.WriteAsync("expires_at: " + await context.GetTokenAsync("expires_at") + "
"); - await context.Response.WriteAsync("Logout
"); - await context.Response.WriteAsync(""); + await response.WriteAsync("Access Token: " + await context.GetTokenAsync("access_token") + "
"); + await response.WriteAsync("Refresh Token: " + await context.GetTokenAsync("refresh_token") + "
"); + await response.WriteAsync("Token Type: " + await context.GetTokenAsync("token_type") + "
"); + await response.WriteAsync("expires_at: " + await context.GetTokenAsync("expires_at") + "
"); + await response.WriteAsync("Logout
"); + await response.WriteAsync("Refresh Token
"); + await response.WriteAsync(""); }); } + + private async Task GetOAuthOptionsAsync(HttpContext context, string currentAuthType) + { + if (string.Equals(GoogleDefaults.AuthenticationScheme, currentAuthType)) + { + return context.RequestServices.GetRequiredService>().Get(currentAuthType); + } + else if (string.Equals(MicrosoftAccountDefaults.AuthenticationScheme, currentAuthType)) + { + return context.RequestServices.GetRequiredService>().Get(currentAuthType); + } + else if (string.Equals(FacebookDefaults.AuthenticationScheme, currentAuthType)) + { + return context.RequestServices.GetRequiredService>().Get(currentAuthType); + } + + throw new NotImplementedException(currentAuthType); + } + + private async Task PrintRefreshedTokensAsync(HttpResponse response, JObject payload, AuthenticationProperties authProperties) + { + response.ContentType = "text/html"; + await response.WriteAsync(""); + await response.WriteAsync("Refreshed.
"); + await response.WriteAsync(HtmlEncoder.Default.Encode(payload.ToString()).Replace(",", ",
") + "
"); + + await response.WriteAsync("
Tokens:
"); + + await response.WriteAsync("Access Token: " + authProperties.GetTokenValue("access_token") + "
"); + await response.WriteAsync("Refresh Token: " + authProperties.GetTokenValue("refresh_token") + "
"); + await response.WriteAsync("Token Type: " + authProperties.GetTokenValue("token_type") + "
"); + await response.WriteAsync("expires_at: " + authProperties.GetTokenValue("expires_at") + "
"); + + await response.WriteAsync("Home
"); + await response.WriteAsync("Refresh Token
"); + await response.WriteAsync(""); + } } } From c1250220508996a494d51627a8bd02b7792c012f Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 9 Aug 2017 15:29:34 -0700 Subject: [PATCH 068/248] #772 Fill in OIDC test gaps --- samples/SocialSample/Startup.cs | 2 +- .../OpenIdConnectChallengeTests.cs | 38 +++++++++++++------ .../OpenIdConnect/OpenIdConnectEventTests.cs | 14 +++---- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index d69b25ee3..36a53b38a 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -162,7 +162,7 @@ public void ConfigureServices(IServiceCollection services) }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ - .AddOAuth("GitHub", o => + .AddOAuth("GitHub", "Github", o => { o.ClientId = Configuration["github:clientid"]; o.ClientSecret = Configuration["github:clientsecret"]; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index d21a1f424..fb08ae278 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -5,11 +5,12 @@ using System.Linq; using System.Net; using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Primitives; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect @@ -19,7 +20,7 @@ public class OpenIdConnectChallengeTests private static readonly string ChallengeEndpoint = TestServerBuilder.TestHost + TestServerBuilder.Challenge; [Fact] - public async Task ChallengeIsIssuedCorrectly() + public async Task ChallengeRedirectIsIssuedCorrectly() { var settings = new TestSettings( opt => @@ -86,7 +87,7 @@ Example of a form post */ [Fact] - public async Task ChallengeIssueedCorrectlyForFormPost() + public async Task ChallengeFormPostIssuedCorrectly() { var settings = new TestSettings( opt => @@ -361,24 +362,37 @@ public async Task OnRedirectToIdentityProviderEventHandleResponse() Assert.Null(res.Headers.Location); } - [Fact] - public async Task ChallengeSetsNonceAndStateCookies() + [Theory] + [InlineData(OpenIdConnectRedirectBehavior.RedirectGet)] + [InlineData(OpenIdConnectRedirectBehavior.FormPost)] + public async Task ChallengeSetsNonceAndStateCookies(OpenIdConnectRedirectBehavior method) { var settings = new TestSettings(o => { + o.AuthenticationMethod = method; o.ClientId = "Test Id"; o.Authority = TestServerBuilder.DefaultAuthority; }); var server = settings.CreateTestServer(); var transaction = await server.SendAsync(ChallengeEndpoint); - var firstCookie = transaction.SetCookie.First(); - Assert.Contains(OpenIdConnectDefaults.CookieNoncePrefix, firstCookie); - Assert.Contains("expires", firstCookie); - - var secondCookie = transaction.SetCookie.Skip(1).First(); - Assert.StartsWith(".AspNetCore.Correlation.OpenIdConnect.", secondCookie); - Assert.Contains("expires", secondCookie); + var challengeCookies = SetCookieHeaderValue.ParseList(transaction.SetCookie); + var nonceCookie = challengeCookies.Where(cookie => cookie.Name.StartsWith(OpenIdConnectDefaults.CookieNoncePrefix, StringComparison.Ordinal)).Single(); + Assert.True(nonceCookie.Expires.HasValue); + Assert.True(nonceCookie.Expires > DateTime.UtcNow); + Assert.True(nonceCookie.HttpOnly); + Assert.Equal("/signin-oidc", nonceCookie.Path); + Assert.Equal("N", nonceCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.None, nonceCookie.SameSite); + + var correlationCookie = challengeCookies.Where(cookie => cookie.Name.StartsWith(".AspNetCore.Correlation.", StringComparison.Ordinal)).Single(); + Assert.True(correlationCookie.Expires.HasValue); + Assert.True(nonceCookie.Expires > DateTime.UtcNow); + Assert.True(correlationCookie.HttpOnly); + Assert.Equal("/signin-oidc", correlationCookie.Path); + Assert.False(StringSegment.IsNullOrEmpty(correlationCookie.Value)); + + Assert.Equal(2, challengeCookies.Count); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index 4ea69369e..ed20d2f5a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -76,7 +76,7 @@ public async Task OnMessageReceived_Skip_NoMoreEventsRun() } [Fact] - public async Task OnMessageReceived_Reject_NoMoreEventsRun() + public async Task OnMessageReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var remoteFailure = false; @@ -197,7 +197,7 @@ public async Task OnTokenValidated_Skip_NoMoreEventsRun() } [Fact] - public async Task OnTokenValidated_Reject_NoMoreEventsRun() + public async Task OnTokenValidated_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -385,7 +385,7 @@ public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() } [Fact] - public async Task OnAuthorizationCodeReceived_Reject_NoMoreEventsRun() + public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -596,7 +596,7 @@ public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() } [Fact] - public async Task OnTokenResponseReceived_Reject_NoMoreEventsRun() + public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -825,7 +825,7 @@ public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() } [Fact] - public async Task OnTokenValidatedBackchannel_Reject_NoMoreEventsRun() + public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() { var messageReceived = false; var codeReceived = false; @@ -1060,7 +1060,7 @@ public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() } [Fact] - public async Task OnUserInformationReceived_Reject_NoMoreEventsRun() + public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; @@ -1321,7 +1321,7 @@ public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() } [Fact] - public async Task OnAuthenticationFailed_Reject_NoMoreEventsRun() + public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; From 4eb1306692a7592210250e47a585fc47e40b7c2c Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Fri, 11 Aug 2017 10:24:18 -0700 Subject: [PATCH 069/248] Reacting to ResponseCookie Delete changes (#1362) https://github.com/aspnet/HttpAbstractions/commit/594f55947f4c1d0a9d3122e3f39bcfa81199b12a --- .../Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 49089234e..7c34f950a 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -273,7 +273,7 @@ public async Task CookiePolicyCanHijackDelete() Assert.NotNull(transaction.SetCookie); Assert.Equal(1, transaction.SetCookie.Count); - Assert.Equal("A=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax", transaction.SetCookie[0]); + Assert.Equal("A=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; secure; samesite=lax", transaction.SetCookie[0]); } [Fact] From 0c82d94a544caa7f39f1692c46d8d16a833daaa8 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 11 Aug 2017 11:50:25 -0700 Subject: [PATCH 070/248] #772 Signout FormPost test (#1358) --- .../OpenIdConnect/OpenIdConnectTests.cs | 36 +++++--- .../OpenIdConnect/TestSettings.cs | 90 ++++++++++++++----- 2 files changed, 91 insertions(+), 35 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index b7ac1f82d..32be26d33 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -182,27 +182,39 @@ public async Task EndSessionRequestDoesNotIncludeTelemetryParametersWhenDisabled } [Fact] - public async Task SignOutWithDefaultRedirectUri() + public async Task SignOutFormPostWithDefaultRedirectUri() { - var configuration = TestServerBuilder.CreateDefaultOpenIdConnectConfiguration(); - var server = TestServerBuilder.CreateServer(o => + var settings = new TestSettings(o => { + o.AuthenticationMethod = OpenIdConnectRedirectBehavior.FormPost; o.Authority = TestServerBuilder.DefaultAuthority; o.ClientId = "Test Id"; - o.Configuration = configuration; }); + var server = settings.CreateTestServer(); var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); - Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - Assert.True(transaction.Response.Headers.Location.AbsoluteUri.StartsWith(configuration.EndSessionEndpoint)); + Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - var query = transaction.Response.Headers.Location.Query.Substring(1).Split('&') - .Select(each => each.Split('=')) - .ToDictionary(pair => pair[0], pair => pair[1]); + settings.ValidateSignoutFormPost(transaction, + OpenIdConnectParameterNames.PostLogoutRedirectUri); + } - string redirectUri; - Assert.True(query.TryGetValue("post_logout_redirect_uri", out redirectUri)); - Assert.Equal(UrlEncoder.Default.Encode("https://example.com/signout-callback-oidc"), redirectUri, true); + [Fact] + public async Task SignOutRedirectWithDefaultRedirectUri() + { + var settings = new TestSettings(o => + { + o.AuthenticationMethod = OpenIdConnectRedirectBehavior.RedirectGet; + o.Authority = TestServerBuilder.DefaultAuthority; + o.ClientId = "Test Id"; + }); + var server = settings.CreateTestServer(); + + var transaction = await server.SendAsync(DefaultHost + TestServerBuilder.Signout); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + + settings.ValidateSignoutRedirect(transaction.Response.Headers.Location, + OpenIdConnectParameterNames.PostLogoutRedirectUri); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 9d9e5537f..bf9df4038 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -80,6 +80,44 @@ public IDictionary ValidateChallengeFormPost(string responseBody return formInputs; } + public IDictionary ValidateSignoutFormPost(TestTransaction transaction, params string[] parametersToValidate) + { + IDictionary formInputs = null; + var errors = new List(); + var xdoc = XDocument.Parse(transaction.ResponseText.Replace("doctype", "DOCTYPE")); + var forms = xdoc.Descendants("form"); + if (forms.Count() != 1) + { + errors.Add("Only one form element is expected in response body."); + } + else + { + formInputs = forms.Single() + .Elements("input") + .ToDictionary(elem => elem.Attribute("name").Value, + elem => elem.Attribute("value").Value); + + ValidateParameters(formInputs, parametersToValidate, errors, htmlEncoded: false); + } + + if (errors.Any()) + { + var buf = new StringBuilder(); + buf.AppendLine($"The signout form post is not valid."); + // buf.AppendLine(); + + foreach (var error in errors) + { + buf.AppendLine(error); + } + + Debug.WriteLine(buf.ToString()); + Assert.True(false, buf.ToString()); + } + + return formInputs; + } + public IDictionary ValidateChallengeRedirect(Uri redirectUri, params string[] parametersToValidate) => ValidateRedirectCore(redirectUri, OpenIdConnectRequestType.Authentication, parametersToValidate); @@ -156,6 +194,9 @@ private void ValidateParameters( case OpenIdConnectParameterNames.VersionTelemetry: ValidateVersionTelemetry(actualValues, errors, htmlEncoded); break; + case OpenIdConnectParameterNames.PostLogoutRedirectUri: + ValidatePostLogoutRedirectUri(actualValues, errors, htmlEncoded); + break; default: throw new InvalidOperationException($"Unknown parameter \"{paramToValidate}\"."); } @@ -186,42 +227,45 @@ private void ValidateExpectedAuthority(string absoluteUri, ICollection e } } - private void ValidateClientId(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.ClientId, _options.ClientId, actualQuery, errors, htmlEncoded); + private void ValidateClientId(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.ClientId, _options.ClientId, actualParams, errors, htmlEncoded); + + private void ValidateResponseType(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.ResponseType, _options.ResponseType, actualParams, errors, htmlEncoded); - private void ValidateResponseType(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.ResponseType, _options.ResponseType, actualQuery, errors, htmlEncoded); + private void ValidateResponseMode(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.ResponseMode, _options.ResponseMode, actualParams, errors, htmlEncoded); - private void ValidateResponseMode(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.ResponseMode, _options.ResponseMode, actualQuery, errors, htmlEncoded); + private void ValidateScope(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.Scope, string.Join(" ", _options.Scope), actualParams, errors, htmlEncoded); - private void ValidateScope(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.Scope, string.Join(" ", _options.Scope), actualQuery, errors, htmlEncoded); + private void ValidateRedirectUri(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.RedirectUri, TestServerBuilder.TestHost + _options.CallbackPath, actualParams, errors, htmlEncoded); - private void ValidateRedirectUri(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, TestServerBuilder.TestHost + _options.CallbackPath, actualQuery, errors, htmlEncoded); + private void ValidateResource(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.RedirectUri, _options.Resource, actualParams, errors, htmlEncoded); - private void ValidateResource(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.RedirectUri, _options.Resource, actualQuery, errors, htmlEncoded); + private void ValidateState(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); - private void ValidateState(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.State, ExpectedState, actualQuery, errors, htmlEncoded); + private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", actualParams, errors, htmlEncoded); - private void ValidateSkuTelemetry(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", actualQuery, errors, htmlEncoded); + private void ValidateVersionTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualParams, errors, htmlEncoded); - private void ValidateVersionTelemetry(IDictionary actualQuery, ICollection errors, bool htmlEncoded) => - ValidateQueryParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualQuery, errors, htmlEncoded); + private void ValidatePostLogoutRedirectUri(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.PostLogoutRedirectUri, "https://example.com/signout-callback-oidc", actualParams, errors, htmlEncoded); - private void ValidateQueryParameter( + private void ValidateParameter( string parameterName, string expectedValue, - IDictionary actualQuery, + IDictionary actualParams, ICollection errors, bool htmlEncoded) { string actualValue; - if (actualQuery.TryGetValue(parameterName, out actualValue)) + if (actualParams.TryGetValue(parameterName, out actualValue)) { if (htmlEncoded) { @@ -230,12 +274,12 @@ private void ValidateQueryParameter( if (actualValue != expectedValue) { - errors.Add($"Query parameter {parameterName}'s expected value is {expectedValue} but its actual value is {actualValue}"); + errors.Add($"Parameter {parameterName}'s expected value is '{expectedValue}' but its actual value is '{actualValue}'"); } } else { - errors.Add($"Query parameter {parameterName} is missing"); + errors.Add($"Parameter {parameterName} is missing"); } } } From 43db99a5686471641eed7913d71dab2dcf0d2464 Mon Sep 17 00:00:00 2001 From: Saravanan Date: Mon, 14 Aug 2017 22:59:02 +0530 Subject: [PATCH 071/248] =?UTF-8?q?Updated=20for=20the=20TwitterOptions=20?= =?UTF-8?q?Validation=20for=20the=20ConsumerKey=20and=20Con=E2=80=A6=20(#1?= =?UTF-8?q?337)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TwitterOptions.cs | 18 +++++++++++ .../TwitterTests.cs | 32 ++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 0190f21a6..86919d092 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -3,6 +3,7 @@ using System; using System.Security.Claims; +using System.Globalization; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Http; @@ -86,6 +87,23 @@ public CookieBuilder StateCookie set => _stateCookieBuilder = value ?? throw new ArgumentNullException(nameof(value)); } + /// + /// Added the validate method to ensure that the customer key and customer secret values are not not empty for the twitter authentication middleware + /// + public override void Validate() + { + base.Validate(); + if (string.IsNullOrEmpty(ConsumerKey)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(ConsumerKey)), nameof(ConsumerKey)); + } + + if (string.IsNullOrEmpty(ConsumerSecret)) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Exception_OptionMustBeProvided, nameof(ConsumerSecret)), nameof(ConsumerSecret)); + } + } + private class TwitterCookieBuilder : CookieBuilder { private readonly TwitterOptions _twitterOptions; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 1c387d889..746dfee6a 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -63,7 +63,7 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() } }; }, - context => + context => { // REVIEW: Gross context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); @@ -75,6 +75,36 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() Assert.Contains("custom=test", query); } + /// + /// Validates the Twitter Options to check if the Consumer Key is missing in the TwitterOptions and if so throws the ArgumentException + /// + /// + [Fact] + public async Task ThrowsIfClientIdMissing() + { + var server = CreateServer(o => + { + o.ConsumerSecret = "Test Consumer Secret"; + }); + + await Assert.ThrowsAsync("ConsumerKey", async () => await server.SendAsync("http://example.com/challenge")); + } + + /// + /// Validates the Twitter Options to check if the Consumer Secret is missing in the TwitterOptions and if so throws the ArgumentException + /// + /// + [Fact] + public async Task ThrowsIfClientSecretMissing() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + }); + + await Assert.ThrowsAsync("ConsumerSecret", async () => await server.SendAsync("http://example.com/challenge")); + } + [Fact] public async Task BadSignInWillThrow() { From b43ffc4acc6c38bc421678e9fe46da5585147c80 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Mon, 14 Aug 2017 13:06:32 -0500 Subject: [PATCH 072/248] Recommend CookieBuilder.HttpOnly instead of CookieBuilder.SameSite (#1366) --- .../CookieAuthenticationOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index ec67ecc18..420435daf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -196,7 +196,7 @@ public CookieBuilder Cookie /// to script on the page. /// ///
- [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.SameSite) + ".")] + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.HttpOnly) + ".")] public bool CookieHttpOnly { get => Cookie.HttpOnly; set => Cookie.HttpOnly = value; } /// From 488eb44467eb677eab62bdc49aa6255cc1be3119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Mon, 14 Aug 2017 20:07:19 +0200 Subject: [PATCH 073/248] Fix obsolete warning message (#1363) Fixes the messaged shown to developers when they are updating their applications to 2.0. Bad idea to set the domain with some random naming text. --- .../CookieAuthenticationOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 420435daf..0f2dbd312 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -161,7 +161,7 @@ public CookieBuilder Cookie /// system uses the cookie authentication handler multiple times. /// /// - [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Domain) + ".")] + [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Name) + ".")] public string CookieName { get => Cookie.Name; set => Cookie.Name = value; } /// From 5b29bced0d2f1cfc78843bcd9ec9a828c6fb5fef Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 22 Aug 2017 18:12:32 -0700 Subject: [PATCH 074/248] Upgrade to xunit 2.3.0-beta4 Includes changes to assertions as required by xunit.analyzers 0.6 --- build/dependencies.props | 5 +-- .../CookieTests.cs | 24 ++++++------- ...soft.AspNetCore.Authentication.Test.csproj | 1 + .../TicketSerializerTests.cs | 8 ++--- .../TokenExtensionTests.cs | 2 +- .../AuthorizationPolicyFacts.cs | 34 +++++++++---------- .../TicketInteropTests.cs | 2 +- 7 files changed, 39 insertions(+), 37 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a97cae9f6..0f73dd1b4 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -10,7 +10,8 @@ 2.0.0-* 3.0.1 2.0.0-* - 15.3.0-* - 2.3.0-beta2-* + 15.3.0 + 0.6.1 + 2.3.0-beta4-build3742 diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index c711fde49..d346c68d7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -54,8 +54,8 @@ public async Task AjaxLoginRedirectToReturnUrlTurnsInto200WithLocationHeader() var transaction = await SendAsync(server, "http://example.com/challenge?X-Requested-With=XMLHttpRequest"); Assert.Equal(HttpStatusCode.Unauthorized, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); - Assert.Equal(1, responded.Count()); - Assert.True(responded.Single().StartsWith("http://example.com/login")); + Assert.Single(responded); + Assert.StartsWith("http://example.com/login", responded.Single()); } [Fact] @@ -65,8 +65,8 @@ public async Task AjaxForbidTurnsInto403WithLocationHeader() var transaction = await SendAsync(server, "http://example.com/forbid?X-Requested-With=XMLHttpRequest"); Assert.Equal(HttpStatusCode.Forbidden, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); - Assert.Equal(1, responded.Count()); - Assert.True(responded.Single().StartsWith("http://example.com/denied")); + Assert.Single(responded); + Assert.StartsWith("http://example.com/denied", responded.Single()); } [Fact] @@ -76,8 +76,8 @@ public async Task AjaxLogoutRedirectToReturnUrlTurnsInto200WithLocationHeader() var transaction = await SendAsync(server, "http://example.com/signout?X-Requested-With=XMLHttpRequest&ReturnUrl=/"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); - Assert.Equal(1, responded.Count()); - Assert.True(responded.Single().StartsWith("/")); + Assert.Single(responded); + Assert.StartsWith("/", responded.Single()); } [Fact] @@ -87,8 +87,8 @@ public async Task AjaxChallengeRedirectTurnsInto200WithLocationHeader() var transaction = await SendAsync(server, "http://example.com/challenge?X-Requested-With=XMLHttpRequest&ReturnUrl=/"); Assert.Equal(HttpStatusCode.Unauthorized, transaction.Response.StatusCode); var responded = transaction.Response.Headers.GetValues("Location"); - Assert.Equal(1, responded.Count()); - Assert.True(responded.Single().StartsWith("http://example.com/Account/Login")); + Assert.Single(responded); + Assert.StartsWith("http://example.com/Account/Login", responded.Single()); } [Fact] @@ -439,7 +439,7 @@ public async Task CookieNotRenewedAfterSignOut() // signout wins over renew var transaction4 = await server.SendAsync("http://example.com/signout", transaction3.SetCookie[0]); - Assert.Equal(1, transaction4.SetCookie.Count()); + Assert.Single(transaction4.SetCookie); Assert.Contains(".AspNetCore.Cookies=; expires=", transaction4.SetCookie[0]); } @@ -717,7 +717,7 @@ public async Task CookieUsesPathBaseByDefault() new Uri("http://example.com/base")); var transaction1 = await SendAsync(server, "http://example.com/base/testpath"); - Assert.True(transaction1.SetCookie.Contains("path=/base")); + Assert.Contains("path=/base", transaction1.SetCookie); } [Fact] @@ -848,7 +848,7 @@ public async Task CanConfigureDefaultCookieInstance() var transaction = await server.SendAsync("http://example.com"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.True(transaction.SetCookie[0].StartsWith("One=")); + Assert.StartsWith("One=", transaction.SetCookie[0]); } [Fact] @@ -871,7 +871,7 @@ public async Task CanConfigureNamedCookieInstance() var transaction = await server.SendAsync("http://example.com"); Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); - Assert.True(transaction.SetCookie[0].StartsWith("One=")); + Assert.StartsWith("One=", transaction.SetCookie[0]); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 1529dc803..fc73325e0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -23,6 +23,7 @@ + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs index b37ae53d5..a1e58743b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TicketSerializerTests.cs @@ -28,7 +28,7 @@ public void CanRoundTripEmptyPrincipal() serializer.Write(writer, ticket); stream.Position = 0; var readTicket = serializer.Read(reader); - Assert.Equal(0, readTicket.Principal.Identities.Count()); + Assert.Empty(readTicket.Principal.Identities); Assert.Equal("bye", readTicket.Properties.RedirectUri); Assert.Equal("Hello", readTicket.AuthenticationScheme); } @@ -50,7 +50,7 @@ public void CanRoundTripBootstrapContext() serializer.Write(writer, ticket); stream.Position = 0; var readTicket = serializer.Read(reader); - Assert.Equal(1, readTicket.Principal.Identities.Count()); + Assert.Single(readTicket.Principal.Identities); Assert.Equal("misc", readTicket.Principal.Identity.AuthenticationType); Assert.Equal("bootstrap", readTicket.Principal.Identities.First().BootstrapContext); } @@ -73,7 +73,7 @@ public void CanRoundTripActorIdentity() serializer.Write(writer, ticket); stream.Position = 0; var readTicket = serializer.Read(reader); - Assert.Equal(1, readTicket.Principal.Identities.Count()); + Assert.Single(readTicket.Principal.Identities); Assert.Equal("misc", readTicket.Principal.Identity.AuthenticationType); var identity = (ClaimsIdentity) readTicket.Principal.Identity; @@ -108,7 +108,7 @@ public void CanRoundTripClaimProperties() serializer.Write(writer, ticket); stream.Position = 0; var readTicket = serializer.Read(reader); - Assert.Equal(1, readTicket.Principal.Identities.Count()); + Assert.Single(readTicket.Principal.Identities); Assert.Equal("misc", readTicket.Principal.Identity.AuthenticationType); var readClaim = readTicket.Principal.FindFirst("type"); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs index 05e5708de..4d4023bee 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TokenExtensionTests.cs @@ -48,7 +48,7 @@ public void SubsequentStoreTokenDeletesPreviousTokens() Assert.Null(props.GetTokenValue("One")); Assert.Null(props.GetTokenValue("Two")); Assert.Null(props.GetTokenValue("Three")); - Assert.Equal(1, props.GetTokens().Count()); + Assert.Single(props.GetTokens()); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs index 714b26c7e..3eefb7af7 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -40,12 +40,12 @@ public async Task CanCombineAuthorizeAttributes() // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); - Assert.True(combined.AuthenticationSchemes.Contains("dupe")); - Assert.True(combined.AuthenticationSchemes.Contains("roles")); + Assert.Contains("dupe", combined.AuthenticationSchemes); + Assert.Contains("roles", combined.AuthenticationSchemes); Assert.Equal(4, combined.Requirements.Count()); - Assert.True(combined.Requirements.Any(r => r is DenyAnonymousAuthorizationRequirement)); + Assert.Contains(combined.Requirements, r => r is DenyAnonymousAuthorizationRequirement); Assert.Equal(2, combined.Requirements.OfType().Count()); - Assert.Equal(1, combined.Requirements.OfType().Count()); + Assert.Single(combined.Requirements.OfType()); } [Fact] @@ -67,10 +67,10 @@ public async Task CanReplaceDefaultPolicy() // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); - Assert.True(combined.AuthenticationSchemes.Contains("dupe")); - Assert.True(combined.AuthenticationSchemes.Contains("default")); + Assert.Contains("dupe", combined.AuthenticationSchemes); + Assert.Contains("default", combined.AuthenticationSchemes); Assert.Equal(2, combined.Requirements.Count()); - Assert.False(combined.Requirements.Any(r => r is DenyAnonymousAuthorizationRequirement)); + Assert.DoesNotContain(combined.Requirements, r => r is DenyAnonymousAuthorizationRequirement); Assert.Equal(2, combined.Requirements.OfType().Count()); } @@ -88,11 +88,11 @@ public async Task CombineMustTrimRoles() var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert - Assert.True(combined.Requirements.Any(r => r is RolesAuthorizationRequirement)); + Assert.Contains(combined.Requirements, r => r is RolesAuthorizationRequirement); var rolesAuthorizationRequirement = combined.Requirements.OfType().First(); Assert.Equal(2, rolesAuthorizationRequirement.AllowedRoles.Count()); - Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r1"))); - Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r2"))); + Assert.Contains(rolesAuthorizationRequirement.AllowedRoles, r => r.Equals("r1")); + Assert.Contains(rolesAuthorizationRequirement.AllowedRoles, r => r.Equals("r2")); } [Fact] @@ -111,8 +111,8 @@ public async Task CombineMustTrimAuthenticationScheme() // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); - Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a1"))); - Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a2"))); + Assert.Contains(combined.AuthenticationSchemes, a => a.Equals("a1")); + Assert.Contains(combined.AuthenticationSchemes, a => a.Equals("a2")); } [Fact] @@ -131,8 +131,8 @@ public async Task CombineMustIgnoreEmptyAuthenticationScheme() // Assert Assert.Equal(2, combined.AuthenticationSchemes.Count()); - Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a1"))); - Assert.True(combined.AuthenticationSchemes.Any(a => a.Equals("a2"))); + Assert.Contains(combined.AuthenticationSchemes, a => a.Equals("a1")); + Assert.Contains(combined.AuthenticationSchemes, a => a.Equals("a2")); } [Fact] @@ -149,11 +149,11 @@ public async Task CombineMustIgnoreEmptyRoles() var combined = await AuthorizationPolicy.CombineAsync(provider, attributes); // Assert - Assert.True(combined.Requirements.Any(r => r is RolesAuthorizationRequirement)); + Assert.Contains(combined.Requirements, r => r is RolesAuthorizationRequirement); var rolesAuthorizationRequirement = combined.Requirements.OfType().First(); Assert.Equal(2, rolesAuthorizationRequirement.AllowedRoles.Count()); - Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r1"))); - Assert.True(rolesAuthorizationRequirement.AllowedRoles.Any(r => r.Equals("r2"))); + Assert.Contains(rolesAuthorizationRequirement.AllowedRoles, r => r.Equals("r1")); + Assert.Contains(rolesAuthorizationRequirement.AllowedRoles, r => r.Equals("r2")); } } } \ No newline at end of file diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs index b14ea0d74..769adc015 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -35,7 +35,7 @@ public void NewSerializerCanReadInteropTicket() var newTicket = newSerializer.Deserialize(bytes); Assert.NotNull(newTicket); - Assert.Equal(1, newTicket.Principal.Identities.Count()); + Assert.Single(newTicket.Principal.Identities); var newIdentity = newTicket.Principal.Identity as ClaimsIdentity; Assert.NotNull(newIdentity); Assert.Equal("scheme", newIdentity.AuthenticationType); From 414d596639d56633a789e039406eacecbe464f82 Mon Sep 17 00:00:00 2001 From: Brian Chavez Date: Sun, 27 Aug 2017 21:03:29 -0700 Subject: [PATCH 075/248] Spelling and grammar cleanup (#1391) --- .../Claims/ClaimAction.cs | 4 ++-- .../DefaultAuthorizationService.cs | 6 +++--- .../IAuthorizationService.cs | 2 +- .../Infrastructure/PassThroughAuthorizationHandler.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs index 965ca5fdb..78b63bb38 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimAction.cs @@ -31,10 +31,10 @@ public ClaimAction(string claimType, string valueType) public string ValueType { get; } /// - /// Exhamine the given userData json, determine if the requisite data is present, and optionally add it + /// Examine the given userData json, determine if the requisite data is present, and optionally add it /// as a new Claim on the ClaimsIdentity. /// - /// The source data to exhamine. This value may be null. + /// The source data to examine. This value may be null. /// The identity to add Claims to. /// The value to use for Claim.Issuer when creating a Claim. public abstract void Run(JObject userData, ClaimsIdentity identity, string issuer); diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 3380f64b1..9773ebbcc 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -30,7 +30,7 @@ public class DefaultAuthorizationService : IAuthorizationService /// The handlers used to fulfill s. /// The logger used to log messages, warnings and errors. /// The used to create the context to handle the authorization. - /// The used to determine if authorzation was successful. + /// The used to determine if authorization was successful. /// The used. public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, IAuthorizationHandlerProvider handlers, ILogger logger, IAuthorizationHandlerContextFactory contextFactory, IAuthorizationEvaluator evaluator, IOptions options) { @@ -74,7 +74,7 @@ public DefaultAuthorizationService(IAuthorizationPolicyProvider policyProvider, /// The resource to evaluate the requirements against. /// The requirements to evaluate. /// - /// A flag indicating whether authorization has succeded. + /// A flag indicating whether authorization has succeeded. /// This value is true when the user fulfills the policy otherwise false. /// public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) @@ -136,7 +136,7 @@ private static string GetClaimValue(IIdentity identity, string claimsType) /// The resource the policy should be checked with. /// The name of the policy to check against a specific context. /// - /// A flag indicating whether authorization has succeded. + /// A flag indicating whether authorization has succeeded. /// This value is true when the user fulfills the policy otherwise false. /// public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs index 32af74607..8976425ba 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationService.cs @@ -43,7 +43,7 @@ public interface IAuthorizationService /// /// A flag indicating whether authorization has succeeded. /// Returns a flag indicating whether the user, and optional resource has fulfilled the policy. - /// true when the the policy has been fulfilled; otherwise false. + /// true when the policy has been fulfilled; otherwise false. /// /// /// Resource is an optional parameter and may be null. Please ensure that you check it is not diff --git a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs index 60fd66b85..6f0b8293f 100644 --- a/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs +++ b/src/Microsoft.AspNetCore.Authorization/Infrastructure/PassThroughAuthorizationHandler.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNetCore.Authorization.Infrastructure { /// - /// Infrastructre class which allows an to + /// Infrastructure class which allows an to /// be its own . /// public class PassThroughAuthorizationHandler : IAuthorizationHandler From c8a99e580683b6d9d999d066d56cceeac301c091 Mon Sep 17 00:00:00 2001 From: Damir Ainullin Date: Mon, 28 Aug 2017 20:12:27 +0300 Subject: [PATCH 076/248] Removed redundant if checks (#1390) --- .../AuthenticationHandler.cs | 2 +- test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index d1d09f074..812ba2f1a 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -142,7 +142,7 @@ public async Task AuthenticateAsync() Logger.AuthenticationSchemeNotAuthenticated(Scheme.Name); } } - else if (result?.Failure != null) + else { Logger.AuthenticationSchemeNotAuthenticatedWithFailure(Scheme.Name, result.Failure.Message); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index d346c68d7..789f5ede9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -1325,11 +1325,11 @@ private static void Describe(HttpResponse res, AuthenticateResult result) res.StatusCode = 200; res.ContentType = "text/xml"; var xml = new XElement("xml"); - if (result != null && result?.Ticket?.Principal != null) + if (result?.Ticket?.Principal != null) { xml.Add(result.Ticket.Principal.Claims.Select(claim => new XElement("claim", new XAttribute("type", claim.Type), new XAttribute("value", claim.Value)))); } - if (result != null && result?.Ticket?.Properties != null) + if (result?.Ticket?.Properties != null) { xml.Add(result.Ticket.Properties.Items.Select(extra => new XElement("extra", new XAttribute("type", extra.Key), new XAttribute("value", extra.Value)))); } From bf685de16be9949d67e93cc058ef4393f005756b Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 24 Aug 2017 11:52:57 -0700 Subject: [PATCH 077/248] Using WebEncoders' Base64Url encode/decode functionality --- src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs b/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs index c0663295c..1f7ecc718 100644 --- a/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs +++ b/src/Microsoft.AspNetCore.Authentication/Data/TextEncoder.cs @@ -13,7 +13,7 @@ public static class Base64UrlTextEncoder /// Base64 encoded string modified with non-URL encodable characters public static string Encode(byte[] data) { - return WebUtilities.Base64UrlTextEncoder.Encode(data); + return WebUtilities.WebEncoders.Base64UrlEncode(data); } /// @@ -24,7 +24,7 @@ public static string Encode(byte[] data) /// The decoded data. public static byte[] Decode(string text) { - return WebUtilities.Base64UrlTextEncoder.Decode(text); + return WebUtilities.WebEncoders.Base64UrlDecode(text); } } } From 724be48ee90e0ed895f09a27b7219365b097197f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 29 Aug 2017 15:24:01 -0700 Subject: [PATCH 078/248] Use Directory.Build.props/targets --- appveyor.yml => .appveyor.yml | 0 build/common.props => Directory.Build.props | 13 ++++--------- Directory.Build.targets | 2 ++ Security.sln | 11 +++++++++-- samples/CookieSample/CookieSample.csproj | 4 +--- .../CookieSessionSample/CookieSessionSample.csproj | 4 +--- samples/JwtBearerSample/JwtBearerSample.csproj | 4 +--- .../OpenIdConnect.AzureAdSample.csproj | 2 -- .../OpenIdConnectSample/OpenIdConnectSample.csproj | 2 -- samples/SocialSample/SocialSample.csproj | 2 -- samples/SocialSample/Startup.cs | 10 +++++----- src/Directory.Build.props | 7 +++++++ ...crosoft.AspNetCore.Authentication.Cookies.csproj | 2 -- ...rosoft.AspNetCore.Authentication.Facebook.csproj | 2 -- ...icrosoft.AspNetCore.Authentication.Google.csproj | 2 -- ...osoft.AspNetCore.Authentication.JwtBearer.csproj | 3 +-- ...spNetCore.Authentication.MicrosoftAccount.csproj | 2 -- ...Microsoft.AspNetCore.Authentication.OAuth.csproj | 4 +--- ...t.AspNetCore.Authentication.OpenIdConnect.csproj | 3 +-- ...crosoft.AspNetCore.Authentication.Twitter.csproj | 2 -- .../Microsoft.AspNetCore.Authentication.csproj | 2 -- ...Microsoft.AspNetCore.Authorization.Policy.csproj | 4 +--- .../Microsoft.AspNetCore.Authorization.csproj | 4 +--- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 -- .../Microsoft.Owin.Security.Interop.csproj | 2 -- test/Directory.Build.props | 12 ++++++++++++ .../Microsoft.AspNetCore.Authentication.Test.csproj | 7 ------- .../Microsoft.AspNetCore.Authorization.Test.csproj | 6 ------ ...etCore.ChunkingCookieManager.Sources.Test.csproj | 5 ----- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 6 +----- .../Microsoft.Owin.Security.Interop.Test.csproj | 11 ++--------- 31 files changed, 50 insertions(+), 92 deletions(-) rename appveyor.yml => .appveyor.yml (100%) rename build/common.props => Directory.Build.props (59%) create mode 100644 Directory.Build.targets create mode 100644 src/Directory.Build.props create mode 100644 test/Directory.Build.props diff --git a/appveyor.yml b/.appveyor.yml similarity index 100% rename from appveyor.yml rename to .appveyor.yml diff --git a/build/common.props b/Directory.Build.props similarity index 59% rename from build/common.props rename to Directory.Build.props index ea940214e..e28500d6b 100644 --- a/build/common.props +++ b/Directory.Build.props @@ -1,20 +1,15 @@ - - - + + + Microsoft ASP.NET Core https://github.com/aspnet/Security git - $(MSBuildThisFileDirectory)Key.snk + $(MSBuildThisFileDirectory)build\Key.snk true true $(VersionSuffix)-$(BuildNumber) true - - - - - diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 000000000..f75adf7e4 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,2 @@ + + diff --git a/Security.sln b/Security.sln index 2e5ee56d0..811893c33 100644 --- a/Security.sln +++ b/Security.sln @@ -1,14 +1,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26621.2 +VisualStudioVersion = 15.0.26730.10 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" + ProjectSection(SolutionItems) = preProject + src\Directory.Build.props = src\Directory.Build.props + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F8C0AA27-F3FB-4286-8E4C-47EF86B539FF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookieSample", "samples\CookieSample\CookieSample.csproj", "{558C2C2A-AED8-49DE-BB60-D5F8AE06C714}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{7BF11F3A-60B6-4796-B504-579C67FFBA34}" + ProjectSection(SolutionItems) = preProject + test\Directory.Build.props = test\Directory.Build.props + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SocialSample", "samples\SocialSample\SocialSample.csproj", "{8C73D216-332D-41D8-BFD0-45BC4BC36552}" EndProject @@ -56,8 +62,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Chunki EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{86BD08B1-F978-4F58-9982-2A017807F01C}" ProjectSection(SolutionItems) = preProject - build\common.props = build\common.props build\dependencies.props = build\dependencies.props + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets build\Key.snk = build\Key.snk NuGet.config = NuGet.config build\repo.props = build\repo.props diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 64438de77..52e6efb49 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,6 +1,4 @@ - - - + net461;netcoreapp2.0 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index cb07f4385..5cb7e9c09 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,6 +1,4 @@ - - - + net461;netcoreapp2.0 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index fe2a5fa9d..6c9bd99dc 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,6 +1,4 @@ - - - + net461;netcoreapp2.0 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index cd8b6976f..9ad1abc42 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,7 +1,5 @@  - - net461;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index b3d875d47..301828b01 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,7 +1,5 @@  - - net461;netcoreapp2.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index d35796f75..02f214557 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,7 +1,5 @@  - - net461;netcoreapp2.0 aspnet5-SocialSample-20151210111056 diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 36a53b38a..a0b193b8e 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -415,7 +415,7 @@ public void Configure(IApplicationBuilder app) } await response.WriteAsync("Tokens:
"); - + await response.WriteAsync("Access Token: " + await context.GetTokenAsync("access_token") + "
"); await response.WriteAsync("Refresh Token: " + await context.GetTokenAsync("refresh_token") + "
"); await response.WriteAsync("Token Type: " + await context.GetTokenAsync("token_type") + "
"); @@ -426,19 +426,19 @@ public void Configure(IApplicationBuilder app) }); } - private async Task GetOAuthOptionsAsync(HttpContext context, string currentAuthType) + private Task GetOAuthOptionsAsync(HttpContext context, string currentAuthType) { if (string.Equals(GoogleDefaults.AuthenticationScheme, currentAuthType)) { - return context.RequestServices.GetRequiredService>().Get(currentAuthType); + return Task.FromResult(context.RequestServices.GetRequiredService>().Get(currentAuthType)); } else if (string.Equals(MicrosoftAccountDefaults.AuthenticationScheme, currentAuthType)) { - return context.RequestServices.GetRequiredService>().Get(currentAuthType); + return Task.FromResult(context.RequestServices.GetRequiredService>().Get(currentAuthType)); } else if (string.Equals(FacebookDefaults.AuthenticationScheme, currentAuthType)) { - return context.RequestServices.GetRequiredService>().Get(currentAuthType); + return Task.FromResult(context.RequestServices.GetRequiredService>().Get(currentAuthType)); } throw new NotImplementedException(currentAuthType); diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 000000000..d704a37df --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index 712aa8177..b188a58e0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to use cookie based authentication. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index a9ec57199..62aee1367 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index 805de682f..de8867f91 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index fe0bda164..5de668e1a 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -1,5 +1,4 @@ - - + ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 9437b5727..0eddc6f76 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index a15a75ee6..318c18e74 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -1,6 +1,4 @@ - - - + ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index ae8ffd8d5..413d5d025 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -1,5 +1,4 @@ - - + ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index d9c5cd0b3..f720d08f0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 8a1f97042..8f48bf685 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core common types used by the various authentication middleware components. netstandard2.0 diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index 83530a2be..17a027690 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core authorization policy helper classes. netstandard2.0 @@ -16,7 +14,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 15100fbbc..01e1dd314 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -1,6 +1,4 @@ - - - + ASP.NET Core authorization classes. diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 5dc2cd928..80fd59eb4 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core cookie policy classes to control the behavior of cookies. netstandard2.0 diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index 10a8be30f..71c07fa14 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -1,7 +1,5 @@  - - A compatibility layer for sharing authentication tickets between Microsoft.Owin.Security and Microsoft.AspNetCore.Authentication. net461 diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 000000000..b9ef98116 --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index fc73325e0..7f3e739f3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0;net461 netcoreapp2.0 @@ -21,11 +19,6 @@ - - - - - diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 6eb74aeeb..5192ee4fe 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0;net461 netcoreapp2.0 @@ -14,12 +12,8 @@ - - - - diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index b578f5dcf..d75c0a47d 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0;net461 netcoreapp2.0 @@ -13,9 +11,6 @@ - - - diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index f513de4b3..96db2b38f 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,6 +1,5 @@ - + - netcoreapp2.0;net461 netcoreapp2.0 @@ -14,9 +13,6 @@ - - - diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 14c0aa2f1..5e1e2eb92 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -1,7 +1,5 @@  - - net461 @@ -9,17 +7,12 @@ + + - - - - - - - From a53bf093a7d86b35e019c80515c92d7626982325 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 29 Aug 2017 15:26:04 -0700 Subject: [PATCH 079/248] Use PackageLineup to manage PackageReference versions --- Directory.Build.props | 1 - Directory.Build.targets | 14 +++++++++++++- NuGet.config | 1 - build/dependencies.props | 17 ----------------- build/repo.props | 6 ++++-- samples/CookieSample/CookieSample.csproj | 12 ++++++------ .../CookieSessionSample.csproj | 12 ++++++------ samples/JwtBearerSample/JwtBearerSample.csproj | 12 ++++++------ .../OpenIdConnect.AzureAdSample.csproj | 14 +++++++------- .../OpenIdConnectSample.csproj | 18 +++++++++--------- samples/SocialSample/SocialSample.csproj | 18 +++++++++--------- src/Directory.Build.props | 2 +- ....AspNetCore.Authentication.JwtBearer.csproj | 8 +++++++- ...soft.AspNetCore.Authentication.OAuth.csproj | 5 ++++- ...NetCore.Authentication.OpenIdConnect.csproj | 8 +++++++- .../Microsoft.AspNetCore.Authentication.csproj | 16 ++++++++-------- ...soft.AspNetCore.Authorization.Policy.csproj | 4 ++-- .../Microsoft.AspNetCore.Authorization.csproj | 4 ++-- .../Microsoft.AspNetCore.CookiePolicy.csproj | 4 ++-- .../Microsoft.Owin.Security.Interop.csproj | 4 ++-- test/Directory.Build.props | 12 ++++++------ ...osoft.AspNetCore.Authentication.Test.csproj | 2 +- ...rosoft.AspNetCore.Authorization.Test.csproj | 6 +++--- ...e.ChunkingCookieManager.Sources.Test.csproj | 2 +- ...crosoft.AspNetCore.CookiePolicy.Test.csproj | 4 ++-- ...Microsoft.Owin.Security.Interop.Test.csproj | 6 +++--- 26 files changed, 111 insertions(+), 101 deletions(-) delete mode 100644 build/dependencies.props diff --git a/Directory.Build.props b/Directory.Build.props index e28500d6b..2490e4244 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,4 @@  - diff --git a/Directory.Build.targets b/Directory.Build.targets index f75adf7e4..bc118fd90 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,2 +1,14 @@ - + + + + <_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh + <_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd + <_BootstrapperError> + Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'. + Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'. + + + + + diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de..20060c934 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,7 +3,6 @@ - diff --git a/build/dependencies.props b/build/dependencies.props deleted file mode 100644 index 0f73dd1b4..000000000 --- a/build/dependencies.props +++ /dev/null @@ -1,17 +0,0 @@ - - - 2.1.0-* - 4.4.0-* - 3.14.1 - 2.1.4 - 2.1.1-* - 10.0.1 - 2.0.0-* - 2.0.0-* - 3.0.1 - 2.0.0-* - 15.3.0 - 0.6.1 - 2.3.0-beta4-build3742 - - diff --git a/build/repo.props b/build/repo.props index d4bab3eeb..7866974bc 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,5 +1,7 @@ - + - + + + diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 52e6efb49..34af273c4 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 5cb7e9c09..6e6bd0e79 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 6c9bd99dc..2b3f9c3c9 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -10,12 +10,12 @@ - - - - - - + + + + + + diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 9ad1abc42..64d90423b 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -11,13 +11,13 @@ - - - - - - - + + + + + + + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 301828b01..bc54cbf3d 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -15,15 +15,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 02f214557..a1706f4d1 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -22,15 +22,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d704a37df..9d9a3de33 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 5de668e1a..8526fcd39 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -1,4 +1,5 @@  + ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. netstandard2.0 @@ -6,8 +7,13 @@ true aspnetcore;authentication;security + - + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 318c18e74..a7af0b7f3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -10,7 +10,10 @@ - + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index 413d5d025..a8f007748 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -1,4 +1,5 @@  + ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. netstandard2.0 @@ -6,8 +7,13 @@ true aspnetcore;authentication;security + - + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 8f48bf685..a156fa549 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -9,14 +9,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index 17a027690..087645ee0 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 01e1dd314..3b2ada85f 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -13,8 +13,8 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - - + + diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 80fd59eb4..c6021e012 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index 71c07fa14..67f8c9420 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index b9ef98116..724f34b0b 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,11 +2,11 @@ - - - - - - + + + + + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 7f3e739f3..ae8789e11 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 5192ee4fe..b133522f0 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index d75c0a47d..49bbbd91f 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -10,7 +10,7 @@ - + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index 96db2b38f..7d50d86a3 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 5e1e2eb92..779d8c141 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -10,9 +10,9 @@ - - - + + +
From 863846bb2a0bfd77a47ccb7726d57ab376020766 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 14 Sep 2017 10:59:59 -0700 Subject: [PATCH 080/248] Cleanup resx (#1424) --- .../Properties/Resources.Designer.cs | 6 ++-- .../Properties/Resources.Designer.cs | 12 +++---- .../Properties/Resources.Designer.cs | 12 +++---- .../Properties/Resources.Designer.cs | 18 ++++------ .../Properties/Resources.Designer.cs | 12 +++---- .../Properties/Resources.Designer.cs | 36 +++++++------------ .../Properties/Resources.Designer.cs | 12 +++---- .../Properties/Resources.Designer.cs | 24 +++++-------- .../Properties/Resources.Designer.cs | 18 ++++------ 9 files changed, 50 insertions(+), 100 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs index a3a2f2874..655da24a3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Properties/Resources.Designer.cs @@ -15,16 +15,14 @@ private static readonly ResourceManager _resourceManager ///
internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs index 690c5a280..03448b408 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/Properties/Resources.Designer.cs @@ -15,32 +15,28 @@ private static readonly ResourceManager _resourceManager ///
internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs index ef1d784f2..e95b8e061 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Properties/Resources.Designer.cs @@ -15,32 +15,28 @@ private static readonly ResourceManager _resourceManager /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs index 618d143ee..7ef5acecb 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Properties/Resources.Designer.cs @@ -15,48 +15,42 @@ private static readonly ResourceManager _resourceManager /// internal static string Exception_MissingId { - get { return GetString("Exception_MissingId"); } + get => GetString("Exception_MissingId"); } /// /// The user does not have an id. /// internal static string FormatException_MissingId() - { - return GetString("Exception_MissingId"); - } + => GetString("Exception_MissingId"); /// /// The '{0}' option must be provided. /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs index 00c7b848b..5a38ade0b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Properties/Resources.Designer.cs @@ -15,32 +15,28 @@ private static readonly ResourceManager _resourceManager /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs index 65a9273a0..753373ece 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Properties/Resources.Designer.cs @@ -15,96 +15,84 @@ private static readonly ResourceManager _resourceManager /// internal static string MessageStateIsNullOrEmpty { - get { return GetString("MessageStateIsNullOrEmpty"); } + get => GetString("MessageStateIsNullOrEmpty"); } /// /// OpenIdConnectAuthenticationHandler: message.State is null or empty. /// internal static string FormatMessageStateIsNullOrEmpty() - { - return GetString("MessageStateIsNullOrEmpty"); - } + => GetString("MessageStateIsNullOrEmpty"); /// /// Unable to unprotect the message.State. /// internal static string MessageStateIsInvalid { - get { return GetString("MessageStateIsInvalid"); } + get => GetString("MessageStateIsInvalid"); } /// /// Unable to unprotect the message.State. /// internal static string FormatMessageStateIsInvalid() - { - return GetString("MessageStateIsInvalid"); - } + => GetString("MessageStateIsInvalid"); /// /// Message contains error: '{0}', error_description: '{1}', error_uri: '{2}'. /// internal static string MessageContainsError { - get { return GetString("MessageContainsError"); } + get => GetString("MessageContainsError"); } /// /// Message contains error: '{0}', error_description: '{1}', error_uri: '{2}'. /// internal static string FormatMessageContainsError(object p0, object p1, object p2) - { - return string.Format(CultureInfo.CurrentCulture, GetString("MessageContainsError"), p0, p1, p2); - } + => string.Format(CultureInfo.CurrentCulture, GetString("MessageContainsError"), p0, p1, p2); /// /// The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{0}'. /// internal static string ValidatedSecurityTokenNotJwt { - get { return GetString("ValidatedSecurityTokenNotJwt"); } + get => GetString("ValidatedSecurityTokenNotJwt"); } /// /// The Validated Security Token must be of type JwtSecurityToken, but instead its type is: '{0}'. /// internal static string FormatValidatedSecurityTokenNotJwt(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("ValidatedSecurityTokenNotJwt"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("ValidatedSecurityTokenNotJwt"), p0); /// /// Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: '{0}'." /// internal static string UnableToValidateToken { - get { return GetString("UnableToValidateToken"); } + get => GetString("UnableToValidateToken"); } /// /// Unable to validate the 'id_token', no suitable ISecurityTokenValidator was found for: '{0}'." /// internal static string FormatUnableToValidateToken(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("UnableToValidateToken"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("UnableToValidateToken"), p0); /// /// Cannot process the message. Both id_token and code are missing. /// internal static string IdTokenCodeMissing { - get { return GetString("IdTokenCodeMissing"); } + get => GetString("IdTokenCodeMissing"); } /// /// Cannot process the message. Both id_token and code are missing. /// internal static string FormatIdTokenCodeMissing() - { - return GetString("IdTokenCodeMissing"); - } + => GetString("IdTokenCodeMissing"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs index d60c2fc73..2eabfff29 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Properties/Resources.Designer.cs @@ -15,32 +15,28 @@ private static readonly ResourceManager _resourceManager /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string Exception_ValidatorHandlerMismatch { - get { return GetString("Exception_ValidatorHandlerMismatch"); } + get => GetString("Exception_ValidatorHandlerMismatch"); } /// /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. /// internal static string FormatException_ValidatorHandlerMismatch() - { - return GetString("Exception_ValidatorHandlerMismatch"); - } + => GetString("Exception_ValidatorHandlerMismatch"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs index 11e2e4586..4f3f147e0 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs @@ -15,64 +15,56 @@ private static readonly ResourceManager _resourceManager /// internal static string Exception_DefaultDpapiRequiresAppNameKey { - get { return GetString("Exception_DefaultDpapiRequiresAppNameKey"); } + get => GetString("Exception_DefaultDpapiRequiresAppNameKey"); } /// /// The default data protection provider may only be used when the IApplicationBuilder.Properties contains an appropriate 'host.AppName' key. /// internal static string FormatException_DefaultDpapiRequiresAppNameKey() - { - return GetString("Exception_DefaultDpapiRequiresAppNameKey"); - } + => GetString("Exception_DefaultDpapiRequiresAppNameKey"); /// /// The state passed to UnhookAuthentication may only be the return value from HookAuthentication. /// internal static string Exception_UnhookAuthenticationStateType { - get { return GetString("Exception_UnhookAuthenticationStateType"); } + get => GetString("Exception_UnhookAuthenticationStateType"); } /// /// The state passed to UnhookAuthentication may only be the return value from HookAuthentication. /// internal static string FormatException_UnhookAuthenticationStateType() - { - return GetString("Exception_UnhookAuthenticationStateType"); - } + => GetString("Exception_UnhookAuthenticationStateType"); /// /// The AuthenticationTokenProvider's required synchronous events have not been registered. /// internal static string Exception_AuthenticationTokenDoesNotProvideSyncMethods { - get { return GetString("Exception_AuthenticationTokenDoesNotProvideSyncMethods"); } + get => GetString("Exception_AuthenticationTokenDoesNotProvideSyncMethods"); } /// /// The AuthenticationTokenProvider's required synchronous events have not been registered. /// internal static string FormatException_AuthenticationTokenDoesNotProvideSyncMethods() - { - return GetString("Exception_AuthenticationTokenDoesNotProvideSyncMethods"); - } + => GetString("Exception_AuthenticationTokenDoesNotProvideSyncMethods"); /// /// The '{0}' option must be provided. /// internal static string Exception_OptionMustBeProvided { - get { return GetString("Exception_OptionMustBeProvided"); } + get => GetString("Exception_OptionMustBeProvided"); } /// /// The '{0}' option must be provided. /// internal static string FormatException_OptionMustBeProvided(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs index 116001e65..c83fa9ea5 100644 --- a/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authorization/Properties/Resources.Designer.cs @@ -15,48 +15,42 @@ private static readonly ResourceManager _resourceManager /// internal static string Exception_AuthorizationPolicyEmpty { - get { return GetString("Exception_AuthorizationPolicyEmpty"); } + get => GetString("Exception_AuthorizationPolicyEmpty"); } /// /// AuthorizationPolicy must have at least one requirement. /// internal static string FormatException_AuthorizationPolicyEmpty() - { - return GetString("Exception_AuthorizationPolicyEmpty"); - } + => GetString("Exception_AuthorizationPolicyEmpty"); /// /// The AuthorizationPolicy named: '{0}' was not found. /// internal static string Exception_AuthorizationPolicyNotFound { - get { return GetString("Exception_AuthorizationPolicyNotFound"); } + get => GetString("Exception_AuthorizationPolicyNotFound"); } /// /// The AuthorizationPolicy named: '{0}' was not found. /// internal static string FormatException_AuthorizationPolicyNotFound(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Exception_AuthorizationPolicyNotFound"), p0); - } + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_AuthorizationPolicyNotFound"), p0); /// /// At least one role must be specified. /// internal static string Exception_RoleRequirementEmpty { - get { return GetString("Exception_RoleRequirementEmpty"); } + get => GetString("Exception_RoleRequirementEmpty"); } /// /// At least one role must be specified. /// internal static string FormatException_RoleRequirementEmpty() - { - return GetString("Exception_RoleRequirementEmpty"); - } + => GetString("Exception_RoleRequirementEmpty"); private static string GetString(string name, params string[] formatterNames) { From b9d9418f6d4fecd8e3b0c60538bb985c15e31fcc Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 15 Sep 2017 14:22:03 -0700 Subject: [PATCH 081/248] Block SignInScheme = self --- .../AuthenticationBuilder.cs | 8 +++- .../Properties/Resources.Designer.cs | 14 ++++++ .../Resources.resx | 3 ++ .../FacebookTests.cs | 48 +++++++++++++++++++ .../GoogleTests.cs | 15 +++++- .../MicrosoftAccountTests.cs | 13 +++++ .../OAuthTests.cs | 21 ++++++++ .../OpenIdConnectConfigurationTests.cs | 15 +++++- .../TwitterTests.cs | 13 +++++ 9 files changed, 145 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs index c29bdeae2..54b481885 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -84,7 +84,7 @@ public virtual AuthenticationBuilder AddRemoteScheme(string return AddScheme(authenticationScheme, displayName, configureOptions: configureOptions); } - // Used to ensure that there's always a default data protection provider + // Used to ensure that there's always a default sign in scheme that's not itself private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { private readonly AuthenticationOptions _authOptions; @@ -96,7 +96,11 @@ public EnsureSignInScheme(IOptions authOptions) public void PostConfigure(string name, TOptions options) { - options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme; + options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme ?? _authOptions.DefaultScheme; + if (string.Equals(options.SignInScheme, name, StringComparison.Ordinal)) + { + throw new InvalidOperationException(Resources.Exception_RemoteSignInSchemeCannotBeSelf); + } } } } diff --git a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs index 4f3f147e0..b1941a7dc 100644 --- a/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Authentication/Properties/Resources.Designer.cs @@ -66,6 +66,20 @@ internal static string Exception_OptionMustBeProvided internal static string FormatException_OptionMustBeProvided(object p0) => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); + /// + /// The SignInScheme for a remote authentication handler cannot be set to itself. If it was not explicitly set, the AuthenticationOptions.DefaultSignInScheme or DefaultScheme is used. + /// + internal static string Exception_RemoteSignInSchemeCannotBeSelf + { + get => GetString("Exception_RemoteSignInSchemeCannotBeSelf"); + } + + /// + /// The SignInScheme for a remote authentication handler cannot be set to itself. If it was not explicitly set, the AuthenticationOptions.DefaultSignInScheme or DefaultScheme is used. + /// + internal static string FormatException_RemoteSignInSchemeCannotBeSelf() + => GetString("Exception_RemoteSignInSchemeCannotBeSelf"); + private static string GetString(string name, params string[] formatterNames) { var value = _resourceManager.GetString(name); diff --git a/src/Microsoft.AspNetCore.Authentication/Resources.resx b/src/Microsoft.AspNetCore.Authentication/Resources.resx index 54d22bcc9..9e831dc74 100644 --- a/src/Microsoft.AspNetCore.Authentication/Resources.resx +++ b/src/Microsoft.AspNetCore.Authentication/Resources.resx @@ -129,4 +129,7 @@ The '{0}' option must be provided. + + The SignInScheme for a remote authentication handler cannot be set to itself. If it was not explicitly set, the AuthenticationOptions.DefaultSignInScheme or DefaultScheme is used. + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 75de0652e..81373403b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -24,6 +24,54 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { public class FacebookTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer( + app => { }, + services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = FacebookDefaults.AuthenticationScheme), + context => + { + // Gross + context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + return true; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultScheme() + { + var server = CreateServer( + app => { }, + services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(), + context => + { + // Gross + context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + return true; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultSignInScheme() + { + var server = CreateServer( + app => { }, + services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(), + context => + { + // Gross + context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + return true; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index f1038bb51..8f2cc52f9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -15,10 +15,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; using Newtonsoft.Json; using Xunit; @@ -26,6 +24,19 @@ namespace Microsoft.AspNetCore.Authentication.Google { public class GoogleTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.SignInScheme = GoogleDefaults.AuthenticationScheme; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 2e249a833..b2854e344 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -27,6 +27,19 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { public class MicrosoftAccountTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.SignInScheme = MicrosoftAccountDefaults.AuthenticationScheme; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index aeb313daa..30c33eb1d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -16,6 +16,27 @@ namespace Microsoft.AspNetCore.Authentication.OAuth { public class OAuthTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer( + app => { }, + services => services.AddAuthentication().AddOAuth("weeblie", o => + { + o.SignInScheme = "weeblie"; + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + }), + context => + { + // REVIEW: Gross. + context.ChallengeAsync("weeblie").GetAwaiter().GetResult(); + return true; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 74f00c8f9..d0d1c2609 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; -using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -46,6 +45,20 @@ public async Task MetadataAddressIsGeneratedFromAuthorityWhenMissing() Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } + [Fact] + public Task ThrowsWhenSignInSchemeIsSetToSelf() + { + return TestConfigurationException( + o => + { + o.SignInScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.Authority = TestServerBuilder.DefaultAuthority; + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + }, + ex => Assert.Contains("cannot be set to itself", ex.Message)); + } + [Fact] public Task ThrowsWhenClientIdIsMissing() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 746dfee6a..6c661af45 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -17,6 +17,19 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { public class TwitterTests { + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.SignInScheme = TwitterDefaults.AuthenticationScheme; + }); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + [Fact] public async Task VerifySchemeDefaults() { From eff1b42d6e4c90f6173ce5643a3f12b000206158 Mon Sep 17 00:00:00 2001 From: Anders Abel Date: Sat, 16 Sep 2017 19:41:52 +0200 Subject: [PATCH 082/248] Fix comment (#1436) Fix comment, it's setting sign in scheme (old left-over from copy-paste?) --- .../AuthenticationServiceCollectionExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index e1beea7b6..38fa47857 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -85,7 +85,7 @@ public static IServiceCollection AddRemoteScheme(this IServi return services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); } - // Used to ensure that there's always a default data protection provider + // Used to ensure that there's always a sign in scheme private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { private readonly AuthenticationOptions _authOptions; From 241880eadc0216918b1f879b403567ff6cb4d03c Mon Sep 17 00:00:00 2001 From: agoretsky Date: Tue, 19 Sep 2017 19:14:49 +0300 Subject: [PATCH 083/248] Minor improvements (#1403) * Fixed exception overwriting due to possible NullReferenceException * Removed unused local variables --- .../CookieAuthenticationHandler.cs | 5 ++--- .../RemoteAuthenticationHandler.cs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 996c334a7..754c91f1e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -132,7 +132,6 @@ private async Task ReadCookieTicket() } var currentUtc = Clock.UtcNow; - var issuedUtc = ticket.Properties.IssuedUtc; var expiresUtc = ticket.Properties.ExpiresUtc; if (expiresUtc != null && expiresUtc.Value < currentUtc) @@ -246,7 +245,7 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper _signInCalled = true; // Process the request cookie to initialize members like _sessionKey. - var result = await EnsureCookieTicket(); + await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); var signInContext = new CookieSigningInContext( @@ -328,7 +327,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) _signOutCalled = true; // Process the request cookie to initialize members like _sessionKey. - var ticket = await EnsureCookieTicket(); + await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); if (Options.SessionStore != null && _sessionKey != null) { diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index bcd598364..1134566d8 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -70,7 +70,7 @@ public virtual async Task HandleRequestAsync() new InvalidOperationException("Invalid return state, unable to redirect."); } - ticket = authResult.Ticket; + ticket = authResult?.Ticket; } catch (Exception ex) { From 1367a5d3858d4446c126940fe5c26267d0ac2512 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 14 Sep 2017 14:57:40 -0700 Subject: [PATCH 084/248] Make all handlers public --- .../FacebookHandler.cs | 2 +- src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs | 2 +- .../JwtBearerHandler.cs | 2 +- .../MicrosoftAccountHandler.cs | 2 +- .../TwitterHandler.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 9004fc09c..db664e2ee 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { - internal class FacebookHandler : OAuthHandler + public class FacebookHandler : OAuthHandler { public FacebookHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 7a2e1a2d1..155691a4b 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Authentication.Google { - internal class GoogleHandler : OAuthHandler + public class GoogleHandler : OAuthHandler { public GoogleHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 9cf73182b..f894a97d0 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { - internal class JwtBearerHandler : AuthenticationHandler + public class JwtBearerHandler : AuthenticationHandler { private OpenIdConnectConfiguration _configuration; diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index 8204bf07b..f4c06300c 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount { - internal class MicrosoftAccountHandler : OAuthHandler + public class MicrosoftAccountHandler : OAuthHandler { public MicrosoftAccountHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 1e1dd08d8..e8a961df3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { - internal class TwitterHandler : RemoteAuthenticationHandler + public class TwitterHandler : RemoteAuthenticationHandler { private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); private const string RequestTokenEndpoint = "https://api.twitter.com/oauth/request_token"; From 648bb1e8101beb6d0f2d8069a0b57e165318a52a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 19 Sep 2017 16:46:39 -0700 Subject: [PATCH 085/248] Obsolete old AddSchemes --- .../AuthenticationServiceCollectionExtensions.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index 38fa47857..b274eaace 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -46,7 +46,7 @@ public static AuthenticationBuilder AddAuthentication(this IServiceCollection se return builder; } - // REMOVE below once callers have been updated + [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureScheme, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler @@ -67,16 +67,19 @@ public static IServiceCollection AddScheme(this IServiceColl return services; } + [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler => services.AddScheme(authenticationScheme, displayName: null, configureScheme: null, configureOptions: configureOptions); + [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureOptions) where TOptions : AuthenticationSchemeOptions, new() where THandler : AuthenticationHandler => services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); + [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] public static IServiceCollection AddRemoteScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureOptions) where TOptions : RemoteAuthenticationOptions, new() where THandler : RemoteAuthenticationHandler From 31dd4ebd9c0c26fc9592aa08d7fb3804bf34011b Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Thu, 21 Sep 2017 17:58:29 -0700 Subject: [PATCH 086/248] Increase Minimum Version of Visual Studio to 15.3.0 --- Security.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Security.sln b/Security.sln index 811893c33..f88d8576b 100644 --- a/Security.sln +++ b/Security.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.10 -MinimumVisualStudioVersion = 10.0.40219.1 +MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" ProjectSection(SolutionItems) = preProject src\Directory.Build.props = src\Directory.Build.props From 13fdbac48fabd723aed7819669d7f9c5bb8e3da2 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 21 Sep 2017 12:28:24 -0700 Subject: [PATCH 087/248] #942 Add the SignedOutCallbackRedirect event for OIDC --- .../Events/OpenIdConnectEvents.cs | 7 + .../LoggingExtensions.cs | 20 + .../OpenIdConnectHandler.cs | 44 +- .../RemoteAuthenticationHandler.cs | 4 + .../OpenIdConnect/OpenIdConnectEventTests.cs | 1151 ++++++++--------- 5 files changed, 643 insertions(+), 583 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs index d8467be8d..2a48d250b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Events/OpenIdConnectEvents.cs @@ -38,6 +38,11 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents /// public Func OnRedirectToIdentityProviderForSignOut { get; set; } = context => Task.CompletedTask; + /// + /// Invoked before redirecting to the at the end of a remote sign-out flow. + /// + public Func OnSignedOutCallbackRedirect { get; set; } = context => Task.CompletedTask; + /// /// Invoked when a request is received on the RemoteSignOutPath. /// @@ -68,6 +73,8 @@ public class OpenIdConnectEvents : RemoteAuthenticationEvents public virtual Task RedirectToIdentityProviderForSignOut(RedirectContext context) => OnRedirectToIdentityProviderForSignOut(context); + public virtual Task SignedOutCallbackRedirect(RemoteSignOutContext context) => OnSignedOutCallbackRedirect(context); + public virtual Task RemoteSignOut(RemoteSignOutContext context) => OnRemoteSignOut(context); public virtual Task TokenResponseReceived(TokenResponseReceivedContext context) => OnTokenResponseReceived(context); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs index 458cfd73e..224af87b6 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/LoggingExtensions.cs @@ -9,6 +9,8 @@ internal static class LoggingExtensions { private static Action _redirectToIdentityProviderForSignOutHandledResponse; private static Action _redirectToIdentityProviderHandledResponse; + private static Action _signoutCallbackRedirectHandledResponse; + private static Action _signoutCallbackRedirectSkipped; private static Action _updatingConfiguration; private static Action _receivedIdToken; private static Action _redeemingCodeForTokens; @@ -248,6 +250,14 @@ static LoggingExtensions() eventId: 49, logLevel: LogLevel.Information, formatString: "AuthenticationScheme: {AuthenticationScheme} signed out."); + _signoutCallbackRedirectHandledResponse = LoggerMessage.Define( + eventId: 50, + logLevel: LogLevel.Debug, + formatString: "RedirectToSignedOutRedirectUri.HandledResponse"); + _signoutCallbackRedirectSkipped = LoggerMessage.Define( + eventId: 51, + logLevel: LogLevel.Debug, + formatString: "RedirectToSignedOutRedirectUri.Skipped"); } public static void UpdatingConfiguration(this ILogger logger) @@ -345,6 +355,16 @@ public static void RedirectToIdentityProviderHandledResponse(this ILogger logger _redirectToIdentityProviderHandledResponse(logger, null); } + public static void SignoutCallbackRedirectHandledResponse(this ILogger logger) + { + _signoutCallbackRedirectHandledResponse(logger, null); + } + + public static void SignoutCallbackRedirectSkipped(this ILogger logger) + { + _signoutCallbackRedirectSkipped(logger, null); + } + public static void UserInformationReceivedHandledResponse(this ILogger logger) { _userInformationReceivedHandledResponse(logger, null); diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 65e1e1951..bf365ceca 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -122,6 +122,10 @@ protected virtual async Task HandleRemoteSignOutAsync() Logger.RemoteSignOutSkipped(); return false; } + if (remoteSignOutContext.Result.Failure != null) + { + throw new InvalidOperationException("An error was returned from the RemoteSignOut event.", remoteSignOutContext.Result.Failure); + } } if (message == null) @@ -273,18 +277,46 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) /// Response to the callback from OpenId provider after session ended. /// /// A task executing the callback procedure - protected virtual Task HandleSignOutCallbackAsync() + protected async virtual Task HandleSignOutCallbackAsync() { - if (Request.Query.TryGetValue(OpenIdConnectParameterNames.State, out StringValues protectedState)) + var message = new OpenIdConnectMessage(Request.Query.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + AuthenticationProperties properties = null; + if (!string.IsNullOrEmpty(message.State)) + { + properties = Options.StateDataFormat.Unprotect(message.State); + } + + var signOut = new RemoteSignOutContext(Context, Scheme, Options, message) { - var properties = Options.StateDataFormat.Unprotect(protectedState); - if (!string.IsNullOrEmpty(properties?.RedirectUri)) + Properties = properties, + }; + + await Events.SignedOutCallbackRedirect(signOut); + if (signOut.Result != null) + { + if (signOut.Result.Handled) { - Response.Redirect(properties.RedirectUri); + Logger.SignoutCallbackRedirectHandledResponse(); + return true; + } + if (signOut.Result.Skipped) + { + Logger.SignoutCallbackRedirectSkipped(); + return false; + } + if (signOut.Result.Failure != null) + { + throw new InvalidOperationException("An error was returned from the SignedOutCallbackRedirect event.", signOut.Result.Failure); } } - return Task.FromResult(true); + properties = signOut.Properties; + if (!string.IsNullOrEmpty(properties?.RedirectUri)) + { + Response.Redirect(properties.RedirectUri); + } + + return true; } /// diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 1134566d8..4051ee666 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -93,6 +93,10 @@ public virtual async Task HandleRequestAsync() { return false; } + else if (errorContext.Result.Failure != null) + { + throw new InvalidOperationException("An error was returned from the RemoteFailure event.", errorContext.Result.Failure); + } } throw exception; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index ed20d2f5a..f3fc26187 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -16,11 +16,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Primitives; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect @@ -37,32 +38,22 @@ public class OpenIdConnectEventTests private readonly Func FailureNotImpl = context => { throw new NotImplementedException("Failure", context.Failure); }; private readonly Func RedirectNotImpl = context => { throw new NotImplementedException("Redirect"); }; private readonly Func RemoteSignOutNotImpl = context => { throw new NotImplementedException("Remote"); }; + private readonly Func SignedOutCallbackNotImpl = context => { throw new NotImplementedException("SingedOut"); }; private readonly RequestDelegate AppNotImpl = context => { throw new NotImplementedException("App"); }; [Fact] public async Task OnMessageReceived_Skip_NoMoreEventsRun() { var messageReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnTokenValidated = TokenNotImpl, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - OnRemoteFailure = FailureNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -80,30 +71,20 @@ public async Task OnMessageReceived_Fail_NoMoreEventsRun() { var messageReceived = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnTokenValidated = TokenNotImpl, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -124,27 +105,16 @@ public async Task OnMessageReceived_Fail_NoMoreEventsRun() public async Task OnMessageReceived_Handled_NoMoreEventsRun() { var messageReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnTokenValidated = TokenNotImpl, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", ""); @@ -159,30 +129,20 @@ public async Task OnTokenValidated_Skip_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -202,34 +162,25 @@ public async Task OnTokenValidated_Fail_NoMoreEventsRun() var messageReceived = false; var tokenValidated = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -252,32 +203,22 @@ public async Task OnTokenValidated_HandledWithoutTicket_NoMoreEventsRun() { var messageReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.HandleResponse(); context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); @@ -295,36 +236,27 @@ public async Task OnTokenValidated_HandledWithTicket_SkipToTicketReceived() var messageReceived = false; var tokenValidated = false; var ticketReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Success(); return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); @@ -342,34 +274,25 @@ public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() var messageReceived = false; var tokenValidated = false; var codeReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -391,38 +314,30 @@ public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() var tokenValidated = false; var codeReceived = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -447,36 +362,27 @@ public async Task OnAuthorizationCodeReceived_HandledWithoutTicket_NoMoreEventsR var messageReceived = false; var tokenValidated = false; var codeReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; context.HandleResponse(); context.Principal = null; context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -495,40 +401,32 @@ public async Task OnAuthorizationCodeReceived_HandledWithTicket_SkipToTicketRece var tokenValidated = false; var codeReceived = false; var ticketReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; context.Success(); return Task.FromResult(0); - }, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -548,38 +446,30 @@ public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() var tokenValidated = false; var codeReceived = false; var tokenResponseReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -603,42 +493,35 @@ public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() var codeReceived = false; var tokenResponseReceived = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -665,40 +548,32 @@ public async Task OnTokenResponseReceived_HandledWithoutTicket_NoMoreEventsRun() var tokenValidated = false; var codeReceived = false; var tokenResponseReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -719,44 +594,37 @@ public async Task OnTokenResponseReceived_HandledWithTicket_SkipToTicketReceived var codeReceived = false; var ticketReceived = false; var tokenResponseReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; context.Success(); return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -777,38 +645,30 @@ public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() var codeReceived = false; var tokenResponseReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -832,42 +692,35 @@ public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() var tokenResponseReceived = false; var tokenValidated = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -894,40 +747,32 @@ public async Task OnTokenValidatedBackchannel_HandledWithoutTicket_NoMoreEventsR var codeReceived = false; var tokenResponseReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); @@ -948,44 +793,37 @@ public async Task OnTokenValidatedBackchannel_HandledWithTicket_SkipToTicketRece var ticketReceived = false; var tokenResponseReceived = false; var tokenValidated = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; context.Success(); return Task.FromResult(0); - }, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); @@ -1007,42 +845,35 @@ public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() var codeReceived = false; var tokenResponseReceived = false; var userInfoReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1068,46 +899,40 @@ public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() var tokenResponseReceived = false; var userInfoReceived = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1136,44 +961,37 @@ public async Task OnUserInformationReceived_HandledWithoutTicket_NoMoreEventsRun var codeReceived = false; var tokenResponseReceived = false; var userInfoReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; context.Principal = null; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1196,49 +1014,43 @@ public async Task OnUserInformationReceived_HandledWithTicket_SkipToTicketReceiv var ticketReceived = false; var tokenResponseReceived = false; var userInfoReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; // context.Ticket = null; context.Success(); return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1262,47 +1074,41 @@ public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() var tokenResponseReceived = false; var userInfoReceived = false; var authFailed = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); context.SkipHandler(); return Task.FromResult(0); - }, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1330,51 +1136,46 @@ public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() var userInfoReceived = false; var authFailed = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); context.Fail("Authentication was aborted from user code."); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; return Task.FromResult(0); - }, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1405,34 +1206,34 @@ public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() var tokenResponseReceived = false; var userInfoReceived = false; var authFailed = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); @@ -1440,14 +1241,8 @@ public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1472,34 +1267,34 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( var tokenResponseReceived = false; var userInfoReceived = false; var authFailed = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); @@ -1515,20 +1310,15 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); context.Success(); return Task.FromResult(0); - }, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticketReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1554,52 +1344,47 @@ public async Task OnRemoteFailure_Skip_NoMoreEventsRun() var userInfoReceived = false; var authFailed = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); context.SkipHandler(); return Task.FromResult(0); - }, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1628,53 +1413,48 @@ public async Task OnRemoteFailure_Handled_NoMoreEventsRun() var userInfoReceived = false; var authFailed = false; var remoteFailure = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; throw new NotImplementedException("TestException"); - }, - OnAuthenticationFailed = context => + }; + events.OnAuthenticationFailed = context => { authFailed = true; Assert.Equal("TestException", context.Exception.Message); return Task.FromResult(0); - }, - OnRemoteFailure = context => + }; + events.OnRemoteFailure = context => { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - OnTicketReceived = TicketNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1699,46 +1479,40 @@ public async Task OnTicketReceived_Skip_NoMoreEventsRun() var tokenResponseReceived = false; var userInfoReceived = false; var ticektReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticektReceived = true; context.SkipHandler(); return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), context => { return context.Response.WriteAsync(context.Request.Path); @@ -1765,47 +1539,41 @@ public async Task OnTicketReceived_Handled_NoMoreEventsRun() var tokenResponseReceived = false; var userInfoReceived = false; var ticektReceived = false; - var server = CreateServer(new OpenIdConnectEvents() + var server = CreateServer(CreateNotImpEvents(events => { - OnMessageReceived = context => + events.OnMessageReceived = context => { messageReceived = true; return Task.FromResult(0); - }, - OnTokenValidated = context => + }; + events.OnTokenValidated = context => { tokenValidated = true; return Task.FromResult(0); - }, - OnAuthorizationCodeReceived = context => + }; + events.OnAuthorizationCodeReceived = context => { codeReceived = true; return Task.FromResult(0); - }, - OnTokenResponseReceived = context => + }; + events.OnTokenResponseReceived = context => { tokenResponseReceived = true; return Task.FromResult(0); - }, - OnUserInformationReceived = context => + }; + events.OnUserInformationReceived = context => { userInfoReceived = true; return Task.FromResult(0); - }, - OnAuthenticationFailed = FailedNotImpl, - OnRemoteFailure = FailureNotImpl, - OnTicketReceived = context => + }; + events.OnTicketReceived = context => { ticektReceived = true; context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); - }, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - }, + }; + }), AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); @@ -1820,23 +1588,250 @@ public async Task OnTicketReceived_Handled_NoMoreEventsRun() Assert.True(ticektReceived); } + [Fact] + public async Task OnRedirectToIdentityProviderForSignOut_Invoked() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRedirectToIdentityProviderForSignOut = context => + { + forSignOut = true; + return Task.CompletedTask; + }; + }), + context => + { + return context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); + }); + + var client = server.CreateClient(); + var response = await client.GetAsync("/"); + + Assert.Equal(HttpStatusCode.Found, response.StatusCode); + Assert.Equal("http://testhost/end", response.Headers.Location.GetLeftPart(UriPartial.Path)); + Assert.True(forSignOut); + } + + [Fact] + public async Task OnRedirectToIdentityProviderForSignOut_Handled_RedirectNotInvoked() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRedirectToIdentityProviderForSignOut = context => + { + forSignOut = true; + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + }), + context => + { + return context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); + }); + + var client = server.CreateClient(); + var response = await client.GetAsync("/"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Null(response.Headers.Location); + Assert.True(forSignOut); + } + + [Fact] + public async Task OnRemoteSignOut_Invoked() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRemoteSignOut = context => + { + forSignOut = true; + return Task.CompletedTask; + }; + }), + AppNotImpl); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-oidc"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.True(forSignOut); + Assert.True(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); + Assert.True(SetCookieHeaderValue.TryParseStrictList(values.ToList(), out var parsedValues)); + Assert.Equal(1, parsedValues.Count); + Assert.True(StringSegment.IsNullOrEmpty(parsedValues.Single().Value)); + } + + [Fact] + public async Task OnRemoteSignOut_Handled_NoSignout() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRemoteSignOut = context => + { + forSignOut = true; + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + }), + AppNotImpl); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-oidc"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.True(forSignOut); + Assert.False(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); + } + + [Fact] + public async Task OnRemoteSignOut_Skip_NoSignout() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnRemoteSignOut = context => + { + forSignOut = true; + context.SkipHandler(); + return Task.CompletedTask; + }; + }), + context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.CompletedTask; + }); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-oidc"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.True(forSignOut); + Assert.False(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); + } + + [Fact] + public async Task OnRedirectToSignedOutRedirectUri_Invoked() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnSignedOutCallbackRedirect = context => + { + forSignOut = true; + return Task.CompletedTask; + }; + }), + AppNotImpl); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); + + Assert.Equal(HttpStatusCode.Found, response.StatusCode); + Assert.Equal("http://testhost/redirect", response.Headers.Location.AbsoluteUri); + Assert.True(forSignOut); + } + + [Fact] + public async Task OnRedirectToSignedOutRedirectUri_Handled_NoRedirect() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnSignedOutCallbackRedirect = context => + { + forSignOut = true; + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + }), + AppNotImpl); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Null(response.Headers.Location); + Assert.True(forSignOut); + } + + [Fact] + public async Task OnRedirectToSignedOutRedirectUri_Skipped_NoRedirect() + { + var forSignOut = false; + var server = CreateServer(CreateNotImpEvents(events => + { + events.OnSignedOutCallbackRedirect = context => + { + forSignOut = true; + context.SkipHandler(); + return Task.CompletedTask; + }; + }), + context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.CompletedTask; + }); + + var client = server.CreateClient(); + var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Null(response.Headers.Location); + Assert.True(forSignOut); + } + + private OpenIdConnectEvents CreateNotImpEvents(Action configureEvents) + { + var events = new OpenIdConnectEvents() + { + OnMessageReceived = MessageNotImpl, + OnTokenValidated = TokenNotImpl, + OnAuthorizationCodeReceived = CodeNotImpl, + OnTokenResponseReceived = TokenResponseNotImpl, + OnUserInformationReceived = UserNotImpl, + OnAuthenticationFailed = FailedNotImpl, + OnTicketReceived = TicketNotImpl, + OnRemoteFailure = FailureNotImpl, + + OnRedirectToIdentityProvider = RedirectNotImpl, + OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, + OnRemoteSignOut = RemoteSignOutNotImpl, + OnSignedOutCallbackRedirect = SignedOutCallbackNotImpl, + }; + configureEvents(events); + return events; + } + private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appCode) { var builder = new WebHostBuilder() .ConfigureServices(services => { - services.AddAuthentication() + services.AddAuthentication(auth => + { + auth.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + auth.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; + }) .AddCookie() .AddOpenIdConnect(o => { o.Events = events; - o.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; o.ClientId = "ClientId"; o.GetClaimsFromUserInfoEndpoint = true; o.Configuration = new OpenIdConnectConfiguration() { TokenEndpoint = "http://testhost/tokens", UserInfoEndpoint = "http://testhost/user", + EndSessionEndpoint = "http://testhost/end" }; o.StateDataFormat = new TestStateDataFormat(); o.SecurityTokenValidator = new TestTokenValidator(); @@ -1868,7 +1863,7 @@ private class TestStateDataFormat : ISecureDataFormat public string Protect(AuthenticationProperties data) { - throw new NotImplementedException(); + return "protected_state"; } public string Protect(AuthenticationProperties data, string purpose) @@ -1879,11 +1874,13 @@ public string Protect(AuthenticationProperties data, string purpose) public AuthenticationProperties Unprotect(string protectedText) { Assert.Equal("protected_state", protectedText); - return new AuthenticationProperties(new Dictionary() + var properties = new AuthenticationProperties(new Dictionary() { { ".xsrf", "corrilationId" }, { OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, "redirect_uri" } }); + properties.RedirectUri = "http://testhost/redirect"; + return properties; } public AuthenticationProperties Unprotect(string protectedText, string purpose) From 5abcfe7e3d78f777d45503b50de5cea17cf9aa5e Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 22 Sep 2017 17:10:59 -0700 Subject: [PATCH 088/248] Update API check baselines to 2.0 --- .../baseline.netcore.json | 1348 ++++---- .../breakingchanges.netcore.json | 47 - .../baseline.netcore.json | 399 +-- .../breakingchanges.netcore.json | 19 - .../baseline.netcore.json | 261 +- .../breakingchanges.netcore.json | 40 - .../baseline.netcore.json | 374 +-- .../breakingchanges.netcore.json | 43 - .../baseline.netcore.json | 219 +- .../breakingchanges.netcore.json | 19 - .../baseline.netcore.json | 1481 ++++++--- .../breakingchanges.netcore.json | 35 - .../baseline.netcore.json | 1549 +++++---- .../breakingchanges.netcore.json | 68 - .../baseline.netcore.json | 394 +-- .../breakingchanges.netcore.json | 45 - .../baseline.netcore.json | 2960 ++++++++--------- .../breakingchanges.netcore.json | 116 - .../baseline.netcore.json | 211 ++ .../baseline.netcore.json | 386 ++- .../baseline.netcore.json | 26 +- .../baseline.netframework.json | 5 +- 22 files changed, 5377 insertions(+), 4668 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json delete mode 100644 src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json index 56e48d3fe..1f1115460 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", + "Name": "Microsoft.Extensions.DependencyInjection.CookieExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -12,14 +12,14 @@ "Members": [ { "Kind": "Method", - "Name": "UseCookieAuthentication", + "Name": "AddCookie", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, "Extension": true, "Visibility": "Public", @@ -27,281 +27,396 @@ }, { "Kind": "Method", - "Name": "UseCookieAuthentication", + "Name": "AddCookie", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Name": "authenticationScheme", + "Type": "System.String" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, "Extension": true, "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "ImplementedInterfaces": [ - "Microsoft.Extensions.Options.IOptions" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_CookieName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_CookieName", + "Name": "AddCookie", "Parameters": [ { - "Name": "value", - "Type": "System.String" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_CookieDomain", - "Parameters": [], - "ReturnType": "System.String", + "Name": "AddCookie", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_CookieDomain", + "Name": "AddCookie", "Parameters": [ { - "Name": "value", + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_CookiePath", - "Parameters": [], - "ReturnType": "System.String", + "Name": "UseCookieAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_CookiePath", + "Name": "UseCookieAuthentication", "Parameters": [ { - "Name": "value", - "Type": "System.String" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { - "Kind": "Method", - "Name": "get_CookieHttpOnly", + "Kind": "Field", + "Name": "CookiePrefix", "Parameters": [], - "ReturnType": "System.Boolean", + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_CookieHttpOnly", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "LoginPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_CookieSecure", + "Kind": "Field", + "Name": "LogoutPath", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_CookieSecure", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "AccessDeniedPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_DataProtectionProvider", + "Kind": "Field", + "Name": "ReturnUrlParameter", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_DataProtectionProvider", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, "Visibility": "Public", - "GenericParameter": [] - }, + "GenericParameter": [], + "Constant": true, + "Literal": "\"Cookies\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler" + ], + "Members": [ { "Kind": "Method", - "Name": "get_ExpireTimeSpan", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ExpireTimeSpan", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "System.TimeSpan" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents" } ], "ReturnType": "System.Void", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_SlidingExpiration", + "Name": "InitializeHandlerAsync", "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SlidingExpiration", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_LoginPath", + "Name": "HandleAuthenticateAsync", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_LoginPath", + "Name": "FinishResponseAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignInAsync", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_LogoutPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_LogoutPath", + "Name": "HandleForbiddenAsync", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_AccessDeniedPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_AccessDeniedPath", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" } ], - "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_ReturnUrlParameter", + "Name": "get_Cookie", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ReturnUrlParameter", + "Name": "set_Cookie", "Parameters": [ { "Name": "value", - "Type": "System.String" + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" } ], "ReturnType": "System.Void", @@ -310,19 +425,19 @@ }, { "Kind": "Method", - "Name": "get_Events", + "Name": "get_DataProtectionProvider", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Events", + "Name": "set_DataProtectionProvider", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" } ], "ReturnType": "System.Void", @@ -331,19 +446,19 @@ }, { "Kind": "Method", - "Name": "get_TicketDataFormat", + "Name": "get_SlidingExpiration", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_TicketDataFormat", + "Name": "set_SlidingExpiration", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + "Type": "System.Boolean" } ], "ReturnType": "System.Void", @@ -352,19 +467,19 @@ }, { "Kind": "Method", - "Name": "get_SystemClock", + "Name": "get_LoginPath", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SystemClock", + "Name": "set_LoginPath", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + "Type": "Microsoft.AspNetCore.Http.PathString" } ], "ReturnType": "System.Void", @@ -373,19 +488,19 @@ }, { "Kind": "Method", - "Name": "get_CookieManager", + "Name": "get_LogoutPath", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_CookieManager", + "Name": "set_LogoutPath", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" + "Type": "Microsoft.AspNetCore.Http.PathString" } ], "ReturnType": "System.Void", @@ -394,58 +509,40 @@ }, { "Kind": "Method", - "Name": "get_SessionStore", + "Name": "get_AccessDeniedPath", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SessionStore", + "Name": "set_AccessDeniedPath", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore" + "Type": "Microsoft.AspNetCore.Http.PathString" } ], "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" - ], - "Members": [ { "Kind": "Method", - "Name": "get_ChunkSize", + "Name": "get_ReturnUrlParameter", "Parameters": [], - "ReturnType": "System.Nullable", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ChunkSize", + "Name": "set_ReturnUrlParameter", "Parameters": [ { "Name": "value", - "Type": "System.Nullable" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -454,19 +551,19 @@ }, { "Kind": "Method", - "Name": "get_ThrowForPartialCookies", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.Boolean", + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ThrowForPartialCookies", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "System.Boolean" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents" } ], "ReturnType": "System.Void", @@ -475,367 +572,197 @@ }, { "Kind": "Method", - "Name": "GetRequestCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Name": "get_TicketDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AppendResponseCookie", + "Name": "set_TicketDataFormat", "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, { "Name": "value", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" } ], "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "DeleteCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "CookiePrefix", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "LoginPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "LogoutPath", + "Name": "get_CookieManager", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "AccessDeniedPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Static": true, - "ReadOnly": true, + "Kind": "Method", + "Name": "set_CookieManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" + } + ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "ReturnUrlParameter", + "Kind": "Method", + "Name": "get_SessionStore", "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Cookies\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ { "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", + "Name": "set_SessionStore", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "urlEncoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore" } ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "GetRequestCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - } - ], - "ReturnType": "System.String", + "Name": "get_ExpireTimeSpan", + "Parameters": [], + "ReturnType": "System.TimeSpan", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AppendResponseCookie", + "Name": "set_ExpireTimeSpan", "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, { "Name": "value", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" + "Type": "System.TimeSpan" } ], "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "DeleteCookie", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "key", - "Type": "System.String" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Http.CookieOptions" - } - ], - "ReturnType": "System.Void", + "Name": "get_CookieName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "StoreAsync", + "Name": "set_CookieName", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "value", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RenewAsync", + "Name": "get_CookieDomain", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieDomain", "Parameters": [ { - "Name": "key", + "Name": "value", "Type": "System.String" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RetrieveAsync", + "Name": "get_CookiePath", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookiePath", "Parameters": [ { - "Name": "key", + "Name": "value", "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RemoveAsync", + "Name": "get_CookieHttpOnly", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CookieHttpOnly", "Parameters": [ { - "Name": "key", - "Type": "System.String" + "Name": "value", + "Type": "System.Boolean" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "get_Options", + "Name": "get_CookieSecure", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions", + "ReturnType": "Microsoft.AspNetCore.Http.CookieSecurePolicy", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_CookieSecure", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieSecurePolicy" } ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -846,9 +773,7 @@ "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents" - ], + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -938,7 +863,7 @@ "Kind": "Method", "Name": "get_OnRedirectToLogin", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -948,7 +873,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -959,7 +884,7 @@ "Kind": "Method", "Name": "get_OnRedirectToAccessDenied", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -969,7 +894,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -980,7 +905,7 @@ "Kind": "Method", "Name": "get_OnRedirectToLogout", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -990,7 +915,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -1001,7 +926,7 @@ "Kind": "Method", "Name": "get_OnRedirectToReturnUrl", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -1011,7 +936,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -1029,7 +954,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1044,7 +968,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1059,7 +982,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1074,7 +996,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1084,12 +1005,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1099,12 +1019,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1114,12 +1033,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1129,12 +1047,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1148,100 +1065,13 @@ ], "GenericParameters": [] }, - { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RedirectUri", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "redirectUri", - "Type": "System.String" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, { "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "BaseType": "Microsoft.AspNetCore.Authentication.PrincipalContext", "ImplementedInterfaces": [], "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Constructor", "Name": ".ctor", @@ -1251,12 +1081,8 @@ "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" - }, - { - "Name": "authenticationScheme", - "Type": "System.String" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "Name": "principal", @@ -1264,7 +1090,11 @@ }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" } ], "Visibility": "Public", @@ -1277,59 +1107,9 @@ "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "BaseType": "Microsoft.AspNetCore.Authentication.PrincipalContext", "ImplementedInterfaces": [], "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "get_CookieOptions", @@ -1360,12 +1140,12 @@ "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { - "Name": "authenticationScheme", - "Type": "System.String" + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" }, { "Name": "principal", @@ -1373,7 +1153,7 @@ }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "cookieOptions", @@ -1390,7 +1170,7 @@ "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ { @@ -1414,27 +1194,6 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Constructor", "Name": ".ctor", @@ -1443,13 +1202,17 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "cookieOptions", @@ -1465,26 +1228,10 @@ { "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext", "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PrincipalContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", "Name": "get_ShouldRenew", @@ -1536,12 +1283,16 @@ "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.CookieAuthenticationOptions" + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], "Visibility": "Public", @@ -1551,7 +1302,7 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", "Visibility": "Public", "Kind": "Interface", "Abstract": true, @@ -1559,47 +1310,97 @@ "Members": [ { "Kind": "Method", - "Name": "ValidatePrincipal", + "Name": "GetRequestCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.String", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SigningIn", + "Name": "AppendResponseCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SignedIn", + "Name": "DeleteCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ITicketStore", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "StoreAsync", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "System.Threading.Tasks.Task", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToLogout", + "Name": "RenewAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Name": "key", + "Type": "System.String" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], "ReturnType": "System.Threading.Tasks.Task", @@ -1607,55 +1408,216 @@ }, { "Kind": "Method", - "Name": "RedirectToLogin", + "Name": "RetrieveAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Name": "key", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoveAsync", + "Parameters": [ + { + "Name": "key", + "Type": "System.String" } ], "ReturnType": "System.Threading.Tasks.Task", "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.PostConfigureCookieAuthenticationOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_ChunkSize", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToReturnUrl", + "Name": "set_ChunkSize", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ThrowForPartialCookies", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ThrowForPartialCookies", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetRequestCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToAccessDenied", + "Name": "AppendResponseCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "value", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SigningOut", + "Name": "DeleteCookie", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "key", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Http.CookieOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Cookies.ICookieManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "DefaultChunkSize", + "Parameters": [], + "ReturnType": "System.Int32", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "4050" } ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json deleted file mode 100644 index 91781d2dd..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json +++ /dev/null @@ -1,47 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents : Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.CookieAuthenticationOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions, Microsoft.Extensions.Options.IOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.Cookies.ICookieAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.CookieAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseCookieAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.CookieAuthenticationOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieRedirectContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSignedInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningInContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieSigningOutContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieValidatePrincipalContext : Microsoft.AspNetCore.Authentication.Cookies.BaseCookieContext", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json index 1e070fc7f..82a48a6bf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json @@ -1,61 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Facebook\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", + "Name": "Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -65,308 +12,171 @@ "Members": [ { "Kind": "Method", - "Name": "GetId", + "Name": "AddFacebook", "Parameters": [ { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" } ], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetAgeRangeMin", + "Name": "AddFacebook", "Parameters": [ { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetAgeRangeMax", - "Parameters": [ + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetBirthday", + "Name": "AddFacebook", "Parameters": [ { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetFirstName", - "Parameters": [ + "Name": "authenticationScheme", + "Type": "System.String" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetGender", + "Name": "AddFacebook", "Parameters": [ { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLastName", - "Parameters": [ + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetLink", - "Parameters": [ + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { - "Kind": "Method", - "Name": "GetLocation", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetLocale", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetMiddleName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetTimeZone", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], "ReturnType": "System.String", "Static": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [], + "Constant": true, + "Literal": "\"Facebook\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "CreateHandler", + "Name": "Validate", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ReturnType": "System.Void", "Virtual": true, "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseFacebookAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "UseFacebookAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.FacebookOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.FacebookOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ { "Kind": "Method", "Name": "get_AppId", @@ -447,7 +257,52 @@ } ], "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseFacebookAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseFacebookAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json deleted file mode 100644 index f64e6b834..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/breakingchanges.netcore.json +++ /dev/null @@ -1,19 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.FacebookOptions : Microsoft.AspNetCore.Builder.OAuthOptions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Facebook.FacebookHelper", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.FacebookAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseFacebookAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.FacebookOptions options)", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json index 647633afa..61aae649d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.GoogleExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,51 +11,94 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddGoogle", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddGoogle", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddGoogle", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddGoogle", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Google\"" + "GenericParameter": [] } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -64,75 +107,68 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetFamilyName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetProfile", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], "ReturnType": "System.String", "Static": true, "Visibility": "Public", - "GenericParameter": [] - }, + "GenericParameter": [], + "Constant": true, + "Literal": "\"Google\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", "Name": "GetEmail", @@ -151,51 +187,37 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "CreateHandler", + "Name": "get_AccessType", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", + "ReturnType": "System.String", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_AccessType", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "value", + "Type": "System.String" } ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -236,7 +258,7 @@ }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.GoogleOptions" + "Type": "Microsoft.AspNetCore.Authentication.Google.GoogleOptions" } ], "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", @@ -247,45 +269,6 @@ } ], "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.GoogleOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AccessType", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AccessType", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json deleted file mode 100644 index db3d1fcf0..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Google/breakingchanges.netcore.json +++ /dev/null @@ -1,40 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Google.GoogleMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.GoogleOptions : Microsoft.AspNetCore.Builder.OAuthOptions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.GoogleAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseGoogleAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.GoogleOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetFamilyName(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetGivenName(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetId(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetName(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.Google.GoogleHelper", - "MemberId": "public static System.String GetProfile(Newtonsoft.Json.Linq.JObject user)", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json index 37e18e53e..997cf7bdf 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.JwtBearerExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,104 +11,86 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddJwtBearer", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Bearer\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AddJwtBearer", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "configureOptions", + "Type": "System.Action" } ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Exception", - "Parameters": [], - "ReturnType": "System.Exception", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Exception", + "Name": "AddJwtBearer", "Parameters": [ { - "Name": "value", - "Type": "System.Exception" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AddJwtBearer", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -116,33 +98,45 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "Name": "Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "Abstract": true, + "Static": true, + "Sealed": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.JwtBearerOptions", + "Name": "UseJwtBearerAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "UseJwtBearerAuthentication", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -150,58 +144,51 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_Exception", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "MessageReceived", + "Name": "set_Exception", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext" + "Name": "value", + "Type": "System.Exception" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "TokenValidated", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Challenge", - "Parameters": [ + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", "GenericParameter": [] } ], @@ -211,17 +198,9 @@ "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "get_AuthenticateFailure", @@ -306,6 +285,22 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Handled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -314,13 +309,17 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -333,9 +332,7 @@ "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" - ], + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -432,7 +429,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -447,7 +443,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -462,7 +457,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -477,7 +471,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -495,7 +488,7 @@ "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", "ImplementedInterfaces": [], "Members": [ { @@ -527,9 +520,13 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], "Visibility": "Public", @@ -542,7 +539,7 @@ "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", "ImplementedInterfaces": [], "Members": [ { @@ -574,9 +571,13 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" } ], "Visibility": "Public", @@ -586,7 +587,7 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerDefaults", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -595,47 +596,24 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "UseJwtBearerAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseJwtBearerAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.JwtBearerOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", "Static": true, - "Extension": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [], + "Constant": true, + "Literal": "\"Bearer\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.JwtBearerOptions", + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "ImplementedInterfaces": [], "Members": [ { @@ -747,7 +725,7 @@ "Kind": "Method", "Name": "get_Events", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", + "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -757,7 +735,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents" + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents" } ], "ReturnType": "System.Void", @@ -869,27 +847,6 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "get_SystemClock", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SystemClock", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "get_SecurityTokenValidators", @@ -970,7 +927,44 @@ } ], "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json deleted file mode 100644 index 223ff401b..000000000 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json +++ /dev/null @@ -1,43 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents : Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.JwtBearerOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.JwtBearer.IJwtBearerEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.JwtBearerAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJwtBearerAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.JwtBearerOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerChallengeContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.MessageReceivedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.TokenValidatedContext : Microsoft.AspNetCore.Authentication.JwtBearer.BaseJwtBearerContext", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json index 06b3cd0d5..5791297b2 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,51 +11,94 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthorizationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "TokenEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddMicrosoftAccount", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Microsoft\"" + "GenericParameter": [] } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountDefaults", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -64,124 +107,70 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "GetId", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetDisplayName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthorizationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetGivenName", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "TokenEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetSurname", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "UserInformationEndpoint", + "Parameters": [], "ReturnType": "System.String", "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "GetEmail", - "Parameters": [ - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], "ReturnType": "System.String", "Static": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [], + "Constant": true, + "Literal": "\"Microsoft\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "ImplementedInterfaces": [], "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, - { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -222,7 +211,7 @@ }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions" + "Type": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions" } ], "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", @@ -233,24 +222,6 @@ } ], "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.MicrosoftAccountOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json deleted file mode 100644 index 66f2a77b4..000000000 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/breakingchanges.netcore.json +++ /dev/null @@ -1,19 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountMiddleware : Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.MicrosoftAccountOptions : Microsoft.AspNetCore.Builder.OAuthOptions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHelper", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.MicrosoftAccountAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseMicrosoftAccountAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.MicrosoftAccountOptions options)", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json index d485aedb1..ffda3cbaf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json @@ -1,6 +1,724 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.OAuthExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddOAuth", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddOAuth", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddOAuth", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler" + ] + } + ] + }, + { + "Kind": "Method", + "Name": "AddOAuth", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler" + ] + } + ] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.OAuthPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "T0" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseOAuthAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseOAuthAuthentication", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ClaimActionCollectionMapExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "MapJsonKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapJsonKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapJsonSubKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + }, + { + "Name": "subKey", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapJsonSubKey", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + }, + { + "Name": "subKey", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapCustomJson", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "resolver", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapCustomJson", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "resolver", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteClaim", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimType", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_User", + "Parameters": [], + "ReturnType": "Newtonsoft.Json.Linq.JObject", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenResponse", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AccessToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshToken", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExpiresIn", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Identity", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RunClaimActions", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RunClaimActions", + "Parameters": [ + { + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + }, + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" + }, + { + "Name": "backchannel", + "Type": "System.Net.Http.HttpClient" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + }, + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnCreatingTicket", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnCreatingTicket", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToAuthorizationEndpoint", + "Parameters": [], + "ReturnType": "System.Func, System.Threading.Tasks.Task>", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func, System.Threading.Tasks.Task>" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreatingTicket", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToAuthorizationEndpoint", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", "Visibility": "Public", @@ -16,11 +734,42 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "HandleRemoteAuthenticateAsync", "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, "Override": true, "Visibility": "Protected", @@ -54,7 +803,7 @@ }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "tokens", @@ -68,14 +817,14 @@ }, { "Kind": "Method", - "Name": "HandleUnauthorizedAsync", + "Name": "HandleChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, "Override": true, "Visibility": "Protected", @@ -87,7 +836,7 @@ "Parameters": [ { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "redirectUri", @@ -113,63 +862,11 @@ "Name": ".ctor", "Parameters": [ { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.OAuthOptions" - ] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" }, { - "Name": "loggerFactory", + "Name": "logger", "Type": "Microsoft.Extensions.Logging.ILoggerFactory" }, { @@ -177,12 +874,8 @@ "Type": "System.Text.Encodings.Web.UrlEncoder" }, { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" - }, - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" } ], "Visibility": "Public", @@ -195,60 +888,43 @@ "ParameterPosition": 0, "New": true, "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.OAuthOptions" + "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions" ] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthOptions", "Visibility": "Public", "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "Success", - "Parameters": [ - { - "Name": "response", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Static": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Failed", - "Parameters": [ - { - "Name": "error", - "Type": "System.Exception" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", - "Static": true, + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Response", + "Name": "get_ClientId", "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Response", + "Name": "set_ClientId", "Parameters": [ { "Name": "value", - "Type": "Newtonsoft.Json.Linq.JObject" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -257,7 +933,7 @@ }, { "Kind": "Method", - "Name": "get_AccessToken", + "Name": "get_ClientSecret", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -265,7 +941,7 @@ }, { "Kind": "Method", - "Name": "set_AccessToken", + "Name": "set_ClientSecret", "Parameters": [ { "Name": "value", @@ -278,7 +954,7 @@ }, { "Kind": "Method", - "Name": "get_TokenType", + "Name": "get_AuthorizationEndpoint", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -286,7 +962,7 @@ }, { "Kind": "Method", - "Name": "set_TokenType", + "Name": "set_AuthorizationEndpoint", "Parameters": [ { "Name": "value", @@ -299,7 +975,7 @@ }, { "Kind": "Method", - "Name": "get_RefreshToken", + "Name": "get_TokenEndpoint", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -307,7 +983,7 @@ }, { "Kind": "Method", - "Name": "set_RefreshToken", + "Name": "set_TokenEndpoint", "Parameters": [ { "Name": "value", @@ -320,7 +996,7 @@ }, { "Kind": "Method", - "Name": "get_ExpiresIn", + "Name": "get_UserInformationEndpoint", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -328,7 +1004,7 @@ }, { "Kind": "Method", - "Name": "set_ExpiresIn", + "Name": "set_UserInformationEndpoint", "Parameters": [ { "Name": "value", @@ -341,150 +1017,121 @@ }, { "Kind": "Method", - "Name": "get_Error", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.Exception", + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Error", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "System.Exception" + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents" } ], "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", - "Visibility": "Public", - "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_User", + "Name": "get_ClaimActions", "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_TokenResponse", + "Name": "get_Scope", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "ReturnType": "System.Collections.Generic.ICollection", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_AccessToken", + "Name": "get_StateDataFormat", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_TokenType", - "Parameters": [], - "ReturnType": "System.String", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_RefreshToken", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [], - "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_ExpiresIn", - "Parameters": [], - "ReturnType": "System.Nullable", + "Name": "Success", + "Parameters": [ + { + "Name": "response", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", + "Name": "Failed", + "Parameters": [ + { + "Name": "error", + "Type": "System.Exception" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Ticket", + "Name": "get_Response", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "ReturnType": "Newtonsoft.Json.Linq.JObject", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Ticket", + "Name": "set_Response", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Type": "Newtonsoft.Json.Linq.JObject" } ], "ReturnType": "System.Void", @@ -493,99 +1140,40 @@ }, { "Kind": "Method", - "Name": "get_Identity", + "Name": "get_AccessToken", "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsIdentity", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_AccessToken", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + "Name": "value", + "Type": "System.String" } ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - }, - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" - }, - { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" - }, - { - "Name": "tokens", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" - }, - { - "Name": "user", - "Type": "Newtonsoft.Json.Linq.JObject" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" - ], - "Members": [ { "Kind": "Method", - "Name": "get_OnCreatingTicket", + "Name": "get_TokenType", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnCreatingTicket", + "Name": "set_TokenType", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -594,19 +1182,19 @@ }, { "Kind": "Method", - "Name": "get_OnRedirectToAuthorizationEndpoint", + "Name": "get_RefreshToken", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnRedirectToAuthorizationEndpoint", + "Name": "set_RefreshToken", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -615,38 +1203,43 @@ }, { "Kind": "Method", - "Name": "CreatingTicket", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "Name": "get_ExpiresIn", + "Parameters": [], + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", + "Name": "set_ExpiresIn", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext" + "Name": "value", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "get_Error", "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Error", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] } @@ -654,23 +1247,23 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext", + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "Abstract": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Options", + "Name": "get_ClaimType", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OAuthOptions", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_RedirectUri", + "Name": "get_ValueType", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -678,79 +1271,40 @@ }, { "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", + "Name": "Run", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" }, { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" }, { - "Name": "redirectUri", + "Name": "issuer", "Type": "System.String" } ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseOAuthAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, + "ReturnType": "System.Void", + "Virtual": true, + "Abstract": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "UseOAuthAuthentication", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "claimType", + "Type": "System.String" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OAuthOptions" + "Name": "valueType", + "Type": "System.String" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -758,26 +1312,27 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.OAuthOptions", + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "ImplementedInterfaces": [], + "ImplementedInterfaces": [ + "System.Collections.Generic.IEnumerable" + ], "Members": [ { "Kind": "Method", - "Name": "get_ClientId", + "Name": "Clear", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ClientId", + "Name": "Remove", "Parameters": [ { - "Name": "value", + "Name": "claimType", "Type": "System.String" } ], @@ -787,19 +1342,11 @@ }, { "Kind": "Method", - "Name": "get_ClientSecret", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClientSecret", + "Name": "Add", "Parameters": [ { - "Name": "value", - "Type": "System.String" + "Name": "action", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction" } ], "ReturnType": "System.Void", @@ -808,148 +1355,256 @@ }, { "Kind": "Method", - "Name": "get_AuthorizationEndpoint", + "Name": "GetEnumerator", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "System.Collections.Generic.IEnumerator", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "System.Collections.Generic.IEnumerable", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_AuthorizationEndpoint", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.CustomJsonClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_TokenEndpoint", + "Name": "get_Resolver", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "System.Func", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_TokenEndpoint", + "Name": "Run", "Parameters": [ { - "Name": "value", + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", "Type": "System.String" } ], "ReturnType": "System.Void", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_UserInformationEndpoint", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "resolver", + "Type": "System.Func" + } + ], "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.DeleteClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "set_UserInformationEndpoint", + "Name": "Run", "Parameters": [ { - "Name": "value", + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", "Type": "System.String" } ], "ReturnType": "System.Void", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Events", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents" + "Name": "claimType", + "Type": "System.String" } ], - "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonKeyClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_Scope", + "Name": "get_JsonKey", "Parameters": [], - "ReturnType": "System.Collections.Generic.ICollection", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_StateDataFormat", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Name": "Run", + "Parameters": [ + { + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_StateDataFormat", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" } ], - "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonSubKeyClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonKeyClaimAction", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_SystemClock", + "Name": "get_SubKey", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SystemClock", + "Name": "Run", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" } ], "ReturnType": "System.Void", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "jsonKey", + "Type": "System.String" + }, + { + "Name": "subKey", + "Type": "System.String" + } + ], "Visibility": "Public", "GenericParameter": [] } ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json deleted file mode 100644 index 3124d7fe7..000000000 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/breakingchanges.netcore.json +++ /dev/null @@ -1,35 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthCreatingTicketContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.OAuthOptions", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware where T0 : Microsoft.AspNetCore.Builder.OAuthOptions, new()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.OAuthOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.OAuth.IOAuthEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.OAuthAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOAuthAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OAuthOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OAuth.OAuthRedirectToAuthorizationContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json index 64cb79487..9623b214e 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.OpenIdConnectExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,200 +11,132 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthenticationPropertiesKey", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "Caption", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddOpenIdConnect", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "CookieNoncePrefix", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddOpenIdConnect", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "RedirectUriForCodePropertiesKey", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddOpenIdConnect", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Field", - "Name": "UserstatePropertiesKey", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddOpenIdConnect", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, - "ReadOnly": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"OpenIdConnect\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler", + "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Abstract": true, + "Static": true, + "Sealed": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HtmlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteSignOutAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", - "Parameters": [ - { - "Name": "signout", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleUnauthorizedAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "RedeemAuthorizationCodeAsync", + "Name": "UseOpenIdConnectAuthentication", "Parameters": [ { - "Name": "tokenEndpointRequest", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetUserInformationAsync", - "Parameters": [ - { - "Name": "message", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" - }, - { - "Name": "jwt", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", + "Name": "UseOpenIdConnectAuthentication", "Parameters": [ { - "Name": "backchannel", - "Type": "System.Net.Http.HttpClient" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" }, { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" } ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -212,75 +144,61 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.ClaimActionCollectionUniqueExtensions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Abstract": true, + "Static": true, + "Sealed": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Backchannel", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpClient", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_HtmlEncoder", - "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", + "Name": "MapUniqueJsonKey", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" }, { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" - }, - { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + "Name": "claimType", + "Type": "System.String" }, { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" - }, + "Name": "jsonKey", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapUniqueJsonKey", + "Parameters": [ { - "Name": "services", - "Type": "System.IServiceProvider" + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" }, { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "claimType", + "Type": "System.String" }, { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "jsonKey", + "Type": "System.String" }, { - "Name": "htmlEncoder", - "Type": "System.Text.Encodings.Web.HtmlEncoder" + "Name": "valueType", + "Type": "System.String" } ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -288,36 +206,33 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext", "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "RedirectGet", + "Kind": "Method", + "Name": "get_ProtocolMessage", "Parameters": [], - "GenericParameter": [], - "Literal": "0" + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "Visibility": "Public", + "GenericParameter": [] }, { - "Kind": "Field", - "Name": "FormPost", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Exception", @@ -347,9 +262,13 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" } ], "Visibility": "Public", @@ -362,24 +281,24 @@ "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Properties", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Properties", + "Name": "set_ProtocolMessage", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], "ReturnType": "System.Void", @@ -511,9 +430,17 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -523,35 +450,48 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Options", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_ProtocolMessage", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Token", "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ProtocolMessage", + "Name": "set_Token", "Parameters": [ { "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -566,9 +506,17 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -578,147 +526,174 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_OnAuthenticationFailed", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AuthorizationCodeReceived", + "Name": "set_OnAuthenticationFailed", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "MessageReceived", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_OnAuthorizationCodeReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToIdentityProvider", + "Name": "set_OnAuthorizationCodeReceived", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToIdentityProviderForSignOut", + "Name": "get_OnMessageReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnMessageReceived", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RemoteSignOut", + "Name": "get_OnRedirectToIdentityProvider", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProvider", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TokenResponseReceived", + "Name": "get_OnRedirectToIdentityProviderForSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProviderForSignOut", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TokenValidated", + "Name": "get_OnRemoteSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteSignOut", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "UserInformationReceived", + "Name": "get_OnTokenResponseReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTokenResponseReceived", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "get_Token", + "Name": "get_OnTokenValidated", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "System.Func", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Token", + "Name": "set_OnTokenValidated", "Parameters": [ { "Name": "value", - "Type": "System.String" + "Type": "System.Func" } ], "ReturnType": "System.Void", @@ -727,19 +702,19 @@ }, { "Kind": "Method", - "Name": "get_Properties", + "Name": "get_OnUserInformationReceived", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "System.Func", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Properties", + "Name": "set_OnUserInformationReceived", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "System.Func" } ], "ReturnType": "System.Void", @@ -747,153 +722,163 @@ "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AuthenticationFailed", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" } ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_OnAuthenticationFailed", - "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnAuthenticationFailed", + "Name": "AuthorizationCodeReceived", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_OnAuthorizationCodeReceived", - "Parameters": [], - "ReturnType": "System.Func", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnAuthorizationCodeReceived", + "Name": "RedirectToIdentityProvider", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" } ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_OnMessageReceived", - "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnMessageReceived", + "Name": "RedirectToIdentityProviderForSignOut", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_OnRedirectToIdentityProvider", - "Parameters": [], - "ReturnType": "System.Func", + "Name": "RemoteSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnRedirectToIdentityProvider", + "Name": "TokenResponseReceived", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_OnRedirectToIdentityProviderForSignOut", - "Parameters": [], - "ReturnType": "System.Func", + "Name": "TokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnRedirectToIdentityProviderForSignOut", + "Name": "UserInformationReceived", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_OnRemoteSignOut", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnRemoteSignOut", + "Name": "set_ProtocolMessage", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], "ReturnType": "System.Void", @@ -902,61 +887,124 @@ }, { "Kind": "Method", - "Name": "get_OnTokenResponseReceived", + "Name": "get_Handled", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnTokenResponseReceived", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_OnTokenValidated", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnTokenValidated", + "Name": "set_ProtocolMessage", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_OnUserInformationReceived", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnUserInformationReceived", + "Name": "set_ProtocolMessage", "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], "ReturnType": "System.Void", @@ -965,194 +1013,147 @@ }, { "Kind": "Method", - "Name": "AuthenticationFailed", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AuthorizationCodeReceived", + "Name": "set_TokenEndpointResponse", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext" + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "MessageReceived", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "RedirectToIdentityProvider", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToIdentityProviderForSignOut", + "Name": "set_ProtocolMessage", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext" + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "RemoteSignOut", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + { + "Kind": "Method", + "Name": "get_SecurityToken", + "Parameters": [], + "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TokenResponseReceived", + "Name": "set_SecurityToken", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext" + "Name": "value", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TokenValidated", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "Name": "get_TokenEndpointResponse", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "UserInformationReceived", + "Name": "set_TokenEndpointResponse", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext" + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ { "Kind": "Method", - "Name": "get_Properties", + "Name": "get_Nonce", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_Nonce", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "value", + "Type": "System.String" } ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Constructor", "Name": ".ctor", @@ -1161,13 +1162,21 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" }, { - "Name": "message", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -1177,35 +1186,48 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Properties", + "Name": "get_ProtocolMessage", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_TokenEndpointResponse", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_User", "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "ReturnType": "Newtonsoft.Json.Linq.JObject", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_TokenEndpointResponse", + "Name": "set_User", "Parameters": [ { "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Type": "Newtonsoft.Json.Linq.JObject" } ], "ReturnType": "System.Void", @@ -1220,13 +1242,21 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "Visibility": "Public", @@ -1236,202 +1266,268 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", + "Abstract": true, + "Static": true, + "Sealed": true, "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "get_Properties", + "Kind": "Field", + "Name": "AuthenticationPropertiesKey", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_SecurityToken", + "Kind": "Field", + "Name": "CookieNoncePrefix", "Parameters": [], - "ReturnType": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken", + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "set_SecurityToken", - "Parameters": [ - { - "Name": "value", - "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" - } - ], - "ReturnType": "System.Void", + "Kind": "Field", + "Name": "RedirectUriForCodePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_TokenEndpointResponse", + "Kind": "Field", + "Name": "UserstatePropertiesKey", "Parameters": [], - "ReturnType": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage", + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"OpenIdConnect\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" + ], + "Members": [ { "Kind": "Method", - "Name": "set_TokenEndpointResponse", + "Name": "get_Backchannel", + "Parameters": [], + "ReturnType": "System.Net.Http.HttpClient", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HtmlEncoder", + "Parameters": [], + "ReturnType": "System.Text.Encodings.Web.HtmlEncoder", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents" } ], "ReturnType": "System.Void", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Nonce", + "Name": "CreateEventsAsync", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Nonce", + "Name": "HandleRemoteSignOutAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignOutAsync", "Parameters": [ { - "Name": "value", - "Type": "System.String" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "HandleSignOutCallbackAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "get_User", + "Name": "HandleRemoteAuthenticateAsync", "Parameters": [], - "ReturnType": "Newtonsoft.Json.Linq.JObject", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_User", + "Name": "RedeemAuthorizationCodeAsync", "Parameters": [ { - "Name": "value", - "Type": "Newtonsoft.Json.Linq.JObject" + "Name": "tokenEndpointRequest", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "GetUserInformationAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectMessage" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseOpenIdConnectAuthentication", - "Parameters": [ + "Name": "jwt", + "Type": "System.IdentityModel.Tokens.Jwt.JwtSecurityToken" + }, { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "UseOpenIdConnectAuthentication", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions" + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "htmlEncoder", + "Type": "System.Text.Encodings.Web.HtmlEncoder" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" } ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -1439,12 +1535,22 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.OpenIdConnectOptions", + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Authority", @@ -1571,6 +1677,14 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ClaimActions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_RequireHttpsMetadata", @@ -1617,7 +1731,7 @@ "Kind": "Method", "Name": "get_Events", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", + "ReturnType": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -1627,7 +1741,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents" + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents" } ], "ReturnType": "System.Void", @@ -1657,7 +1771,28 @@ }, { "Kind": "Method", - "Name": "get_PostLogoutRedirectUri", + "Name": "get_SignedOutCallbackPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignedOutCallbackPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignedOutRedirectUri", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -1665,7 +1800,7 @@ }, { "Kind": "Method", - "Name": "set_PostLogoutRedirectUri", + "Name": "set_SignedOutRedirectUri", "Parameters": [ { "Name": "value", @@ -1835,7 +1970,7 @@ "Kind": "Method", "Name": "get_StateDataFormat", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, @@ -1845,7 +1980,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" } ], "ReturnType": "System.Void", @@ -1959,19 +2094,40 @@ }, { "Kind": "Method", - "Name": "get_SystemClock", + "Name": "get_DisableTelemetry", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SystemClock", + "Name": "set_DisableTelemetry", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_NonceCookie", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_NonceCookie", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" } ], "ReturnType": "System.Void", @@ -1984,13 +2140,121 @@ "Parameters": [], "Visibility": "Public", "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", "Parameters": [ { - "Name": "authenticationScheme", + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectRedirectBehavior", + "Visibility": "Public", + "Kind": "Enumeration", + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "RedirectGet", + "Parameters": [], + "GenericParameter": [], + "Literal": "0" + }, + { + "Kind": "Field", + "Name": "FormPost", + "Parameters": [], + "GenericParameter": [], + "Literal": "1" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.Claims.UniqueJsonKeyClaimAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.JsonKeyClaimAction", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Run", + "Parameters": [ + { + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "claimType", + "Type": "System.String" + }, + { + "Name": "valueType", + "Type": "System.String" + }, + { + "Name": "jsonKey", "Type": "System.String" } ], @@ -2000,6 +2264,5 @@ ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json deleted file mode 100644 index 931a7b079..000000000 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/breakingchanges.netcore.json +++ /dev/null @@ -1,68 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.OpenIdConnectOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.OpenIdConnect.IOpenIdConnectEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.OpenIdConnectAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseOpenIdConnectAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.OpenIdConnectOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthenticationFailedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.AuthorizationCodeReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.MessageReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RedirectContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenResponseReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.TokenValidatedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.OpenIdConnect.UserInformationReceivedContext : Microsoft.AspNetCore.Authentication.OpenIdConnect.BaseOpenIdConnectContext", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", - "MemberId": "public static readonly System.String Caption", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json index c35232a31..b577f07eb 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterDefaults", + "Name": "Microsoft.Extensions.DependencyInjection.TwitterExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -11,99 +11,86 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Field", - "Name": "AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", + "Kind": "Method", + "Name": "AddTwitter", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Static": true, + "Extension": true, "Visibility": "Public", - "GenericParameter": [], - "Constant": true, - "Literal": "\"Twitter\"" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Override": true, - "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AddTwitter", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "dataProtectionProvider", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" - }, + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddTwitter", + "Parameters": [ { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "sharedOptions", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "authenticationScheme", + "Type": "System.String" }, { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Name": "configureOptions", + "Type": "System.Action" } ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.TwitterOptions", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AddTwitter", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] } @@ -111,36 +98,46 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "Name": "Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", "Visibility": "Public", - "Kind": "Interface", + "Kind": "Class", "Abstract": true, - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "CreatingTicket", + "Name": "UseTwitterAuthentication", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RedirectToAuthorizationEndpoint", + "Name": "UseTwitterAuthentication", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", "GenericParameter": [] } ], @@ -150,7 +147,7 @@ "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", + "BaseType": "Microsoft.AspNetCore.Authentication.ResultContext", "ImplementedInterfaces": [], "Members": [ { @@ -193,48 +190,6 @@ "Visibility": "Public", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Principal", - "Parameters": [ - { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Properties", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Constructor", "Name": ".ctor", @@ -243,9 +198,21 @@ "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, { "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" }, { "Name": "userId", @@ -279,9 +246,7 @@ "Visibility": "Public", "Kind": "Class", "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" - ], + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -308,7 +273,7 @@ "Kind": "Method", "Name": "get_OnRedirectToAuthorizationEndpoint", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Func, System.Threading.Tasks.Task>", "Visibility": "Public", "GenericParameter": [] }, @@ -318,7 +283,7 @@ "Parameters": [ { "Name": "value", - "Type": "System.Func" + "Type": "System.Func, System.Threading.Tasks.Task>" } ], "ReturnType": "System.Void", @@ -336,7 +301,6 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -346,12 +310,11 @@ "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext" + "Type": "Microsoft.AspNetCore.Authentication.RedirectContext" } ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -365,56 +328,6 @@ ], "GenericParameters": [] }, - { - "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_RedirectUri", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "redirectUri", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, { "Name": "Microsoft.AspNetCore.Authentication.Twitter.AccessToken", "Visibility": "Public", @@ -547,7 +460,7 @@ "Kind": "Method", "Name": "get_Properties", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", "Visibility": "Public", "GenericParameter": [] }, @@ -557,7 +470,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Void", @@ -655,7 +568,7 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterDefaults", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -664,47 +577,34 @@ "ImplementedInterfaces": [], "Members": [ { - "Kind": "Method", - "Name": "UseTwitterAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", "Static": true, - "Extension": true, + "ReadOnly": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "UseTwitterAuthentication", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.TwitterOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", "Static": true, - "Extension": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [], + "Constant": true, + "Literal": "\"Twitter\"" } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Builder.TwitterOptions", + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", "ImplementedInterfaces": [], "Members": [ { @@ -770,6 +670,14 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ClaimActions", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_StateDataFormat", @@ -795,7 +703,7 @@ "Kind": "Method", "Name": "get_Events", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents", "Visibility": "Public", "GenericParameter": [] }, @@ -805,7 +713,7 @@ "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents" + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents" } ], "ReturnType": "System.Void", @@ -814,19 +722,19 @@ }, { "Kind": "Method", - "Name": "get_SystemClock", + "Name": "get_StateCookie", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_SystemClock", + "Name": "set_StateCookie", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" } ], "ReturnType": "System.Void", @@ -842,7 +750,49 @@ } ], "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json deleted file mode 100644 index 6b8440911..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/breakingchanges.netcore.json +++ /dev/null @@ -1,45 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents : Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents, Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterMiddleware : Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.TwitterOptions : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.Twitter.ITwitterEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "MemberId": "public Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties get_Properties()", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.RequestToken", - "MemberId": "public System.Void set_Properties(Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties value)", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.TwitterAppBuilderExtensions", - "MemberId": "public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseTwitterAuthentication(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.TwitterOptions options)", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterCreatingTicketContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Twitter.TwitterRedirectToAuthorizationEndpointContext : Microsoft.AspNetCore.Authentication.Twitter.BaseTwitterContext", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json index 1f69da5a8..6db7d2c81 100644 --- a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json @@ -1,488 +1,140 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.AspNetCore.Builder.AuthenticationOptions", + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", "Visibility": "Public", "Kind": "Class", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AuthenticationScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AuthenticationScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AutomaticAuthenticate", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AutomaticAuthenticate", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AutomaticChallenge", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AutomaticChallenge", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ClaimsIssuer", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ClaimsIssuer", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Description", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Description", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "transform", - "Type": "System.Func>" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseClaimsTransformation", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Transformer", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_Transformer", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Builder.AuthenticationOptions", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_BackchannelTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelTimeout", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_BackchannelHttpHandler", - "Parameters": [], - "ReturnType": "System.Net.Http.HttpMessageHandler", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_BackchannelHttpHandler", - "Parameters": [ - { - "Name": "value", - "Type": "System.Net.Http.HttpMessageHandler" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_CallbackPath", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.PathString", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_CallbackPath", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.PathString" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignInScheme", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignInScheme", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_DisplayName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_DisplayName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_RemoteAuthenticationTimeout", - "Parameters": [], - "ReturnType": "System.TimeSpan", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_RemoteAuthenticationTimeout", - "Parameters": [ - { - "Name": "value", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SaveTokens", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SaveTokens", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_Succeeded", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Ticket", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Failure", - "Parameters": [], - "ReturnType": "System.Exception", - "Visibility": "Public", - "GenericParameter": [] - }, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_Skipped", + "Name": "get_Services", "Parameters": [], - "ReturnType": "System.Boolean", + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Success", + "Name": "AddScheme", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] }, { "Kind": "Method", - "Name": "Skip", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, + "Name": "AddScheme", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] }, { "Kind": "Method", - "Name": "Fail", + "Name": "AddRemoteScheme", "Parameters": [ { - "Name": "failure", - "Type": "System.Exception" + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler" + ] + } + ] }, { - "Kind": "Method", - "Name": "Fail", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "failureMessage", - "Type": "System.String" + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Static": true, "Visibility": "Public", "GenericParameter": [] } @@ -495,70 +147,23 @@ "Kind": "Class", "Abstract": true, "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + "Microsoft.AspNetCore.Authentication.IAuthenticationHandler" ], "Members": [ { "Kind": "Method", - "Name": "get_SignInAccepted", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignInAccepted", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SignOutAccepted", + "Name": "get_Scheme", "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SignOutAccepted", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationScheme", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_ChallengeCalled", + "Name": "get_Options", "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_ChallengeCalled", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Protected", + "ReturnType": "T0", + "Visibility": "Public", "GenericParameter": [] }, { @@ -587,7 +192,7 @@ }, { "Kind": "Method", - "Name": "get_OriginalPathBase", + "Name": "get_OriginalPath", "Parameters": [], "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Protected", @@ -595,7 +200,7 @@ }, { "Kind": "Method", - "Name": "get_OriginalPath", + "Name": "get_OriginalPathBase", "Parameters": [], "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Protected", @@ -619,38 +224,57 @@ }, { "Kind": "Method", - "Name": "get_PriorHandler", + "Name": "get_Clock", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", + "ReturnType": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OptionsMonitor", + "Parameters": [], + "ReturnType": "Microsoft.Extensions.Options.IOptionsMonitor", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_PriorHandler", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "System.Object", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + "Type": "System.Object" } ], "ReturnType": "System.Void", - "Visibility": "Public", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_CurrentUri", + "Name": "get_ClaimsIssuer", "Parameters": [], "ReturnType": "System.String", + "Virtual": true, "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Options", + "Name": "get_CurrentUri", "Parameters": [], - "ReturnType": "T0", + "ReturnType": "System.String", "Visibility": "Protected", "GenericParameter": [] }, @@ -659,42 +283,24 @@ "Name": "InitializeAsync", "Parameters": [ { - "Name": "options", - "Type": "T0" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "Name": "context", "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "logger", - "Type": "Microsoft.Extensions.Logging.ILogger" - }, - { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" } ], "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "BuildRedirectUri", - "Parameters": [ - { - "Name": "targetPath", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "FinishResponseAsync", + "Name": "InitializeEventsAsync", "Parameters": [], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, @@ -703,59 +309,43 @@ }, { "Kind": "Method", - "Name": "HandleRequestAsync", + "Name": "CreateEventsAsync", "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetDescriptions", - "Parameters": [ - { - "Name": "describeContext", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" - } - ], - "ReturnType": "System.Void", - "Sealed": true, + "Name": "InitializeHandlerAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ShouldHandleScheme", + "Name": "BuildRedirectUri", "Parameters": [ { - "Name": "authenticationScheme", + "Name": "targetPath", "Type": "System.String" - }, - { - "Name": "handleAutomatic", - "Type": "System.Boolean" } ], - "ReturnType": "System.Boolean", - "Visibility": "Public", + "ReturnType": "System.String", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", "Name": "AuthenticateAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, @@ -767,6 +357,14 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "HandleAuthenticateOnceSafeAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "HandleAuthenticateAsync", @@ -779,27 +377,25 @@ }, { "Kind": "Method", - "Name": "SignInAsync", + "Name": "HandleForbiddenAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleSignInAsync", + "Name": "HandleChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Threading.Tasks.Task", @@ -809,106 +405,149 @@ }, { "Kind": "Method", - "Name": "SignOutAsync", + "Name": "ChallengeAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Threading.Tasks.Task", "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleSignOutAsync", + "Name": "ForbidAsync", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, "Virtual": true, - "Visibility": "Protected", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationHandler", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "HandleForbiddenAsync", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, "Visibility": "Protected", "GenericParameter": [] + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Schemes", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider", + "Visibility": "Public", + "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleUnauthorizedAsync", + "Name": "set_Schemes", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ChallengeAsync", + "Name": "Invoke", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" } ], "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], - "Visibility": "Protected", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "schemes", + "Type": "Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider" + } + ], + "Visibility": "Public", "GenericParameter": [] } ], - "GenericParameters": [ - { - "ParameterName": "TOptions", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" - ] - } - ] + "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "Visibility": "Public", "Kind": "Class", - "Abstract": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_AuthenticationScheme", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ClaimsIssuer", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -916,7 +555,7 @@ }, { "Kind": "Method", - "Name": "set_AuthenticationScheme", + "Name": "set_ClaimsIssuer", "Parameters": [ { "Name": "value", @@ -929,19 +568,19 @@ }, { "Kind": "Method", - "Name": "get_Options", + "Name": "get_Events", "Parameters": [], - "ReturnType": "T0", + "ReturnType": "System.Object", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Options", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "T0" + "Type": "System.Object" } ], "ReturnType": "System.Void", @@ -950,19 +589,19 @@ }, { "Kind": "Method", - "Name": "get_Logger", + "Name": "get_EventsType", "Parameters": [], - "ReturnType": "Microsoft.Extensions.Logging.ILogger", + "ReturnType": "System.Type", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Logger", + "Name": "set_EventsType", "Parameters": [ { "Name": "value", - "Type": "Microsoft.Extensions.Logging.ILogger" + "Type": "System.Type" } ], "ReturnType": "System.Void", @@ -970,132 +609,232 @@ "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_UrlEncoder", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [], - "ReturnType": "System.Text.Encodings.Web.UrlEncoder", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "set_UrlEncoder", + "Name": "Serialize", "Parameters": [ { - "Name": "value", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "model", + "Type": "T0" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Byte[]", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Invoke", + "Name": "Deserialize", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "data", + "Type": "System.Byte[]" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", + "ReturnType": "T0", "GenericParameter": [] - }, + } + ], + "GenericParameters": [ + { + "ParameterName": "TModel", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "CreateHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + } + ], + "ReturnType": "System.String", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "Protect", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + "Name": "data", + "Type": "T0" }, { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - }, + "Name": "purpose", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ { - "Name": "loggerFactory", - "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + "Name": "protectedText", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" }, { - "Name": "encoder", - "Type": "System.Text.Encodings.Web.UrlEncoder" + "Name": "purpose", + "Type": "System.String" } ], - "Visibility": "Protected", + "ReturnType": "T0", "GenericParameter": [] } ], "GenericParameters": [ { - "ParameterName": "TOptions", + "ParameterName": "TData", "ParameterPosition": 0, - "New": true, - "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.AuthenticationOptions" - ] + "BaseTypeOrInterfaces": [] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Name": "Microsoft.AspNetCore.Authentication.PropertiesDataFormat", "Visibility": "Public", "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IDataSerializer" + ], "Members": [ { "Kind": "Method", - "Name": "get_AuthenticationScheme", + "Name": "get_Default", "Parameters": [], - "ReturnType": "System.String", + "ReturnType": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Name": "Serialize", + "Parameters": [ + { + "Name": "model", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Properties", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", + "Name": "Deserialize", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "Write", "Parameters": [ { - "Name": "principal", - "Type": "System.Security.Claims.ClaimsPrincipal" + "Name": "writer", + "Type": "System.IO.BinaryWriter" }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Read", + "Parameters": [ { - "Name": "authenticationScheme", - "Type": "System.String" + "Name": "reader", + "Type": "System.IO.BinaryReader" } ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -1103,105 +842,164 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationToken", + "Name": "Microsoft.AspNetCore.Authentication.SecureDataFormat", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [], + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + ], "Members": [ { "Kind": "Method", - "Name": "get_Name", - "Parameters": [], + "Name": "Protect", + "Parameters": [ + { + "Name": "data", + "Type": "T0" + } + ], "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Name", + "Name": "Protect", "Parameters": [ { - "Name": "value", + "Name": "data", + "Type": "T0" + }, + { + "Name": "purpose", "Type": "System.String" } ], - "ReturnType": "System.Void", + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Value", - "Parameters": [], - "ReturnType": "System.String", + "Name": "Unprotect", + "Parameters": [ + { + "Name": "protectedText", + "Type": "System.String" + } + ], + "ReturnType": "T0", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Value", + "Name": "Unprotect", "Parameters": [ { - "Name": "value", + "Name": "protectedText", + "Type": "System.String" + }, + { + "Name": "purpose", "Type": "System.String" } ], - "ReturnType": "System.Void", + "ReturnType": "T0", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], + "Parameters": [ + { + "Name": "serializer", + "Type": "Microsoft.AspNetCore.Authentication.IDataSerializer" + }, + { + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + } + ], "Visibility": "Public", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TData", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [] + } + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", + "Name": "Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder", "Visibility": "Public", "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Context", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Principal", - "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Name": "Encode", + "Parameters": [ + { + "Name": "data", + "Type": "System.Byte[]" + } + ], + "ReturnType": "System.String", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Principal", + "Name": "Decode", "Parameters": [ { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" + "Name": "text", + "Type": "System.String" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Byte[]", + "Static": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.TicketDataFormat", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Constructor", "Name": ".ctor", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "protector", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" } ], "Visibility": "Public", @@ -1211,153 +1009,156 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler", + "Name": "Microsoft.AspNetCore.Authentication.TicketSerializer", "Visibility": "Public", "Kind": "Class", "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + "Microsoft.AspNetCore.Authentication.IDataSerializer" ], "Members": [ { "Kind": "Method", - "Name": "get_PriorHandler", + "Name": "get_Default", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "ReturnType": "Microsoft.AspNetCore.Authentication.TicketSerializer", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_PriorHandler", + "Name": "Serialize", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler" + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Void", + "ReturnType": "System.Byte[]", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "AuthenticateAsync", + "Name": "Deserialize", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext" + "Name": "data", + "Type": "System.Byte[]" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ChallengeAsync", + "Name": "Write", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, + "ReturnType": "System.Void", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetDescriptions", + "Name": "WriteIdentity", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext" + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" } ], "ReturnType": "System.Void", - "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SignInAsync", + "Name": "WriteClaim", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + "Name": "writer", + "Type": "System.IO.BinaryWriter" + }, + { + "Name": "claim", + "Type": "System.Security.Claims.Claim" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, + "ReturnType": "System.Void", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SignOutAsync", + "Name": "Read", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + "Name": "reader", + "Type": "System.IO.BinaryReader" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RegisterAuthenticationHandler", + "Name": "ReadIdentity", "Parameters": [ { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" + "Name": "reader", + "Type": "System.IO.BinaryReader" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Security.Claims.ClaimsIdentity", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "UnregisterAuthenticationHandler", + "Name": "ReadClaim", "Parameters": [ { - "Name": "auth", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature" + "Name": "reader", + "Type": "System.IO.BinaryReader" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" } ], - "ReturnType": "System.Void", - "Visibility": "Public", + "ReturnType": "System.Security.Claims.Claim", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [ - { - "Name": "transform", - "Type": "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - }, - { - "Name": "httpContext", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -1365,42 +1166,49 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", + "Name": "Microsoft.AspNetCore.Authentication.BaseContext", "Visibility": "Public", "Kind": "Class", + "Abstract": true, "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "get_Scheme", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationScheme", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Options", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", + "ReturnType": "T0", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Options", - "Parameters": [ - { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.ClaimsTransformationOptions" - } - ], - "ReturnType": "System.Void", + "Name": "get_HttpContext", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_Request", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Response", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", "Visibility": "Public", "GenericParameter": [] }, @@ -1409,212 +1217,197 @@ "Name": ".ctor", "Parameters": [ { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" }, { "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Type": "T0" } ], - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.ClaimsTransformer", + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestContext", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IClaimsTransformer" - ], + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_OnTransform", + "Name": "get_Result", "Parameters": [], - "ReturnType": "System.Func>", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnTransform", + "Name": "set_Result", "Parameters": [ { "Name": "value", - "Type": "System.Func>" + "Type": "Microsoft.AspNetCore.Authentication.HandleRequestResult" } ], "ReturnType": "System.Void", - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TransformAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "SkipHandler", "Parameters": [], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + }, { - "Kind": "Method", - "Name": "TransformAsync", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.ClaimsTransformationContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" } ], - "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Protected", "GenericParameter": [] } ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + "GenericParameters": [ { - "Kind": "Method", - "Name": "get_UtcNow", - "Parameters": [], - "ReturnType": "System.DateTimeOffset", - "GenericParameter": [] + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] } - ], - "GenericParameters": [] + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Name": "Microsoft.AspNetCore.Authentication.PrincipalContext", "Visibility": "Public", "Kind": "Class", "Abstract": true, - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "HandleRequestAsync", + "Name": "get_Principal", "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Security.Claims.ClaimsPrincipal", "Virtual": true, - "Override": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleRemoteCallbackAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleRemoteAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Abstract": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleAuthenticateAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "HandleSignOutAsync", + "Name": "set_Principal", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext" + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", "Virtual": true, - "Override": true, - "Visibility": "Protected", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "HandleSignInAsync", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.SignInContext" + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, "Visibility": "Protected", "GenericParameter": [] - }, + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PropertiesContext", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "HandleForbiddenAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", "Virtual": true, - "Override": true, - "Visibility": "Protected", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GenerateCorrelationId", + "Name": "set_Properties", "Parameters": [ { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], "ReturnType": "System.Void", @@ -1623,23 +1416,26 @@ "GenericParameter": [] }, { - "Kind": "Method", - "Name": "ValidateCorrelationId", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" + }, { "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Boolean", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], "Visibility": "Protected", "GenericParameter": [] } @@ -1649,20 +1445,21 @@ "ParameterName": "TOptions", "ParameterPosition": 0, "BaseTypeOrInterfaces": [ - "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" ] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", + "Name": "Microsoft.AspNetCore.Authentication.RedirectContext", "Visibility": "Public", "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_SignInScheme", + "Name": "get_RedirectUri", "Parameters": [], "ReturnType": "System.String", "Visibility": "Public", @@ -1670,7 +1467,7 @@ }, { "Kind": "Method", - "Name": "set_SignInScheme", + "Name": "set_RedirectUri", "Parameters": [ { "Name": "value", @@ -1684,277 +1481,243 @@ { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], "Visibility": "Public", "GenericParameter": [] } ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SystemClock", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.ISystemClock" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_UtcNow", - "Parameters": [], - "ReturnType": "System.DateTimeOffset", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISystemClock", - "Visibility": "Public", - "GenericParameter": [] - }, + "GenericParameters": [ { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] + "ParameterName": "TOptions", + "ParameterPosition": 0, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] } - ], - "GenericParameters": [] + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "Visibility": "Public", "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.HandleRequestContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "StoreTokens", + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Principal", "Parameters": [ { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokens", - "Type": "System.Collections.Generic.IEnumerable" + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" } ], "ReturnType": "System.Void", - "Static": true, - "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetTokenValue", - "Parameters": [ - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Static": true, - "Extension": true, + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetTokens", + "Name": "set_Properties", "Parameters": [ { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Collections.Generic.IEnumerable", - "Static": true, - "Extension": true, + "ReturnType": "System.Void", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetTokenAsync", - "Parameters": [ - { - "Name": "manager", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" - }, - { - "Name": "tokenName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, + "Name": "Success", + "Parameters": [], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "GetTokenAsync", + "Name": "Fail", "Parameters": [ { - "Name": "manager", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationManager" - }, - { - "Name": "signInScheme", - "Type": "System.String" - }, - { - "Name": "tokenName", - "Type": "System.String" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Static": true, - "Extension": true, + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "Serialize", + "Name": "Fail", "Parameters": [ { - "Name": "model", - "Type": "T0" + "Name": "failureMessage", + "Type": "System.String" } ], - "ReturnType": "System.Byte[]", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Deserialize", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "data", - "Type": "System.Byte[]" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "T0", + "Visibility": "Protected", "GenericParameter": [] } ], "GenericParameters": [ { - "ParameterName": "TModel", + "ParameterName": "TOptions", "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, + "Kind": "Class", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "Protect", + "Name": "get_OnRemoteFailure", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteFailure", "Parameters": [ { - "Name": "data", - "Type": "T0" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.String", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Protect", + "Name": "get_OnTicketReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnTicketReceived", "Parameters": [ { - "Name": "data", - "Type": "T0" - }, - { - "Name": "purpose", - "Type": "System.String" + "Name": "value", + "Type": "System.Func" } ], - "ReturnType": "System.String", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Unprotect", + "Name": "RemoteFailure", "Parameters": [ { - "Name": "protectedText", - "Type": "System.String" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.RemoteFailureContext" } ], - "ReturnType": "T0", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Unprotect", + "Name": "TicketReceived", "Parameters": [ { - "Name": "protectedText", - "Type": "System.String" - }, - { - "Name": "purpose", - "Type": "System.String" + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" } ], - "ReturnType": "T0", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [ - { - "ParameterName": "TData", - "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] - } - ] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.PropertiesDataFormat", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], + "Parameters": [], "Visibility": "Public", "GenericParameter": [] } @@ -1962,171 +1725,157 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", + "Name": "Microsoft.AspNetCore.Authentication.RemoteFailureContext", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" - ], + "BaseType": "Microsoft.AspNetCore.Authentication.HandleRequestContext", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Default", + "Name": "get_Failure", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.PropertiesSerializer", - "Static": true, + "ReturnType": "System.Exception", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Serialize", + "Name": "set_Failure", "Parameters": [ { - "Name": "model", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "value", + "Type": "System.Exception" } ], - "ReturnType": "System.Byte[]", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Deserialize", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "data", - "Type": "System.Byte[]" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + }, + { + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ResultContext", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "properties", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" - } - ], - "ReturnType": "System.Void", - "Virtual": true, + "Name": "get_Principal", + "Parameters": [], + "ReturnType": "System.Security.Claims.ClaimsPrincipal", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Read", + "Name": "set_Principal", "Parameters": [ { - "Name": "reader", - "Type": "System.IO.BinaryReader" + "Name": "value", + "Type": "System.Security.Claims.ClaimsPrincipal" } ], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", - "Virtual": true, + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "get_Properties", "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.SecureDataFormat", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.ISecureDataFormat" - ], - "Members": [ + }, { "Kind": "Method", - "Name": "Protect", + "Name": "set_Properties", "Parameters": [ { - "Name": "data", - "Type": "T0" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Protect", - "Parameters": [ - { - "Name": "data", - "Type": "T0" - }, - { - "Name": "purpose", - "Type": "System.String" - } - ], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Name": "get_Result", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Unprotect", + "Name": "Success", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "NoResult", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", "Parameters": [ { - "Name": "protectedText", - "Type": "System.String" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "T0", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Unprotect", + "Name": "Fail", "Parameters": [ { - "Name": "protectedText", - "Type": "System.String" - }, - { - "Name": "purpose", + "Name": "failureMessage", "Type": "System.String" } ], - "ReturnType": "T0", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, @@ -2135,60 +1884,81 @@ "Name": ".ctor", "Parameters": [ { - "Name": "serializer", - "Type": "Microsoft.AspNetCore.Authentication.IDataSerializer" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" }, { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "T0" } ], - "Visibility": "Public", + "Visibility": "Protected", "GenericParameter": [] } ], "GenericParameters": [ { - "ParameterName": "TData", + "ParameterName": "TOptions", "ParameterPosition": 0, - "BaseTypeOrInterfaces": [] + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] } ] }, { - "Name": "Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder", + "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", "Visibility": "Public", "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "Encode", + "Name": "get_ReturnUri", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ReturnUri", "Parameters": [ { - "Name": "data", - "Type": "System.Byte[]" + "Name": "value", + "Type": "System.String" } ], - "ReturnType": "System.String", - "Static": true, + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Decode", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "text", - "Type": "System.String" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + }, + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Byte[]", - "Static": true, "Visibility": "Public", "GenericParameter": [] } @@ -2196,170 +1966,149 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.TicketDataFormat", + "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.SecureDataFormat", + "Kind": "Interface", + "Abstract": true, "ImplementedInterfaces": [], "Members": [ { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "protector", - "Type": "Microsoft.AspNetCore.DataProtection.IDataProtector" - } - ], - "Visibility": "Public", + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", "GenericParameter": [] } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.TicketSerializer", + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", "Visibility": "Public", "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IDataSerializer" + "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler" ], "Members": [ { "Kind": "Method", - "Name": "get_Default", + "Name": "get_SignInScheme", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.TicketSerializer", - "Static": true, - "Visibility": "Public", + "ReturnType": "System.String", + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Serialize", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" } ], - "ReturnType": "System.Byte[]", + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Deserialize", - "Parameters": [ - { - "Name": "data", - "Type": "System.Byte[]" - } - ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "Name": "ShouldHandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IDataSerializer", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Write", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" - } - ], - "ReturnType": "System.Void", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "WriteIdentity", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" - } - ], - "ReturnType": "System.Void", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, + "Abstract": true, "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "WriteClaim", - "Parameters": [ - { - "Name": "writer", - "Type": "System.IO.BinaryWriter" - }, - { - "Name": "claim", - "Type": "System.Security.Claims.Claim" - } - ], - "ReturnType": "System.Void", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, + "Override": true, "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Read", + "Name": "HandleForbiddenAsync", "Parameters": [ { - "Name": "reader", - "Type": "System.IO.BinaryReader" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ReadIdentity", + "Name": "GenerateCorrelationId", "Parameters": [ { - "Name": "reader", - "Type": "System.IO.BinaryReader" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Security.Claims.ClaimsIdentity", + "ReturnType": "System.Void", "Virtual": true, "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "ReadClaim", + "Name": "ValidateCorrelationId", "Parameters": [ { - "Name": "reader", - "Type": "System.IO.BinaryReader" - }, - { - "Name": "identity", - "Type": "System.Security.Claims.ClaimsIdentity" + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "System.Security.Claims.Claim", + "ReturnType": "System.Boolean", "Virtual": true, "Visibility": "Protected", "GenericParameter": [] @@ -2367,81 +2116,113 @@ { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Protected", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + ] + } + ] }, { - "Name": "Microsoft.AspNetCore.Authentication.BaseContext", + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", "Visibility": "Public", "Kind": "Class", - "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_HttpContext", + "Name": "Validate", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpContext", + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Request", + "Name": "get_BackchannelTimeout", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpRequest", + "ReturnType": "System.TimeSpan", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Response", + "Name": "set_BackchannelTimeout", + "Parameters": [ + { + "Name": "value", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_BackchannelHttpHandler", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.HttpResponse", + "ReturnType": "System.Net.Http.HttpMessageHandler", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_BackchannelHttpHandler", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "value", + "Type": "System.Net.Http.HttpMessageHandler" } ], - "Visibility": "Protected", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseContext", - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "get_State", + "Name": "get_Backchannel", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.EventResultState", + "ReturnType": "System.Net.Http.HttpClient", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_State", + "Name": "set_Backchannel", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.EventResultState" + "Type": "System.Net.Http.HttpClient" } ], "ReturnType": "System.Void", @@ -2450,51 +2231,61 @@ }, { "Kind": "Method", - "Name": "get_HandledResponse", + "Name": "get_DataProtectionProvider", "Parameters": [], - "ReturnType": "System.Boolean", + "ReturnType": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", + "Name": "set_DataProtectionProvider", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "HandleResponse", + "Name": "get_CallbackPath", "Parameters": [], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Http.PathString", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SkipToNextMiddleware", - "Parameters": [], + "Name": "set_CallbackPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], "ReturnType": "System.Void", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Ticket", + "Name": "get_SignInScheme", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationTicket", + "ReturnType": "System.String", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Ticket", + "Name": "set_SignInScheme", "Parameters": [ { "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Type": "System.String" } ], "ReturnType": "System.Void", @@ -2503,86 +2294,40 @@ }, { "Kind": "Method", - "Name": "CheckEventResult", - "Parameters": [ - { - "Name": "result", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Direction": "Out" - } - ], - "ReturnType": "System.Boolean", + "Name": "get_RemoteAuthenticationTimeout", + "Parameters": [], + "ReturnType": "System.TimeSpan", "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "set_RemoteAuthenticationTimeout", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "value", + "Type": "System.TimeSpan" } ], - "Visibility": "Protected", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.EventResultState", - "Visibility": "Public", - "Kind": "Enumeration", - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "Continue", - "Parameters": [], - "GenericParameter": [], - "Literal": "0" - }, - { - "Kind": "Field", - "Name": "Skipped", - "Parameters": [], - "GenericParameter": [], - "Literal": "1" }, - { - "Kind": "Field", - "Name": "HandledResponse", - "Parameters": [], - "GenericParameter": [], - "Literal": "2" - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.FailureContext", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", - "ImplementedInterfaces": [], - "Members": [ { "Kind": "Method", - "Name": "get_Failure", + "Name": "get_Events", "Parameters": [], - "ReturnType": "System.Exception", + "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Failure", + "Name": "set_Events", "Parameters": [ { "Name": "value", - "Type": "System.Exception" + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" } ], "ReturnType": "System.Void", @@ -2590,135 +2335,166 @@ "GenericParameter": [] }, { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "failure", - "Type": "System.Exception" - } - ], + "Kind": "Method", + "Name": "get_SaveTokens", + "Parameters": [], + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ + }, { "Kind": "Method", - "Name": "RemoteFailure", + "Name": "set_SaveTokens", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" + "Name": "value", + "Type": "System.Boolean" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TicketReceived", + "Name": "get_CorrelationCookie", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CorrelationCookie", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", "GenericParameter": [] } ], "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", "Visibility": "Public", "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents" - ], + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_OnRemoteFailure", - "Parameters": [], - "ReturnType": "System.Func", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_OnRemoteFailure", - "Parameters": [ - { - "Name": "value", - "Type": "System.Func" - } - ], - "ReturnType": "System.Void", + "Name": "get_Handled", + "Parameters": [], + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_OnTicketReceived", + "Name": "get_Skipped", "Parameters": [], - "ReturnType": "System.Func", + "ReturnType": "System.Boolean", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_OnTicketReceived", + "Name": "Success", "Parameters": [ { - "Name": "value", - "Type": "System.Func" + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "RemoteFailure", + "Name": "Fail", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.FailureContext" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "TicketReceived", + "Name": "Fail", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Authentication.TicketReceivedContext" + "Name": "failureMessage", + "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Handle", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SystemClock", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.ISystemClock" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "Sealed": true, "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.ISystemClock", "Visibility": "Public", "GenericParameter": [] }, @@ -2733,165 +2509,313 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.TicketReceivedContext", + "Name": "Microsoft.AspNetCore.Authentication.Internal.RequestPathBaseCookieBuilder", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.BaseControlContext", + "BaseType": "Microsoft.AspNetCore.Http.CookieBuilder", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_Principal", + "Name": "get_AdditionalPath", "Parameters": [], - "ReturnType": "System.Security.Claims.ClaimsPrincipal", - "Visibility": "Public", + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Principal", + "Name": "Build", "Parameters": [ { - "Name": "value", - "Type": "System.Security.Claims.ClaimsPrincipal" + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "expiresFrom", + "Type": "System.DateTimeOffset" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", + "Virtual": true, + "Override": true, "Visibility": "Public", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "get_Properties", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties", "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Builder.AuthAppBuilderExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "set_Properties", + "Name": "UseAuthentication", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties" + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ { "Kind": "Method", - "Name": "get_Options", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", + "Name": "AddAuthentication", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Options", + "Name": "AddAuthentication", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "defaultScheme", + "Type": "System.String" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_ReturnUri", - "Parameters": [], - "ReturnType": "System.String", + "Name": "AddAuthentication", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ReturnUri", + "Name": "AddScheme", "Parameters": [ { - "Name": "value", + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", "Type": "System.String" + }, + { + "Name": "configureScheme", + "Type": "System.Action" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], - "ReturnType": "System.Void", + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] }, { - "Kind": "Constructor", - "Name": ".ctor", + "Kind": "Method", + "Name": "AddScheme", "Parameters": [ { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" }, { - "Name": "options", - "Type": "Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions" + "Name": "authenticationScheme", + "Type": "System.String" }, { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "configureOptions", + "Type": "System.Action" } ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] + }, { "Kind": "Method", - "Name": "AddAuthentication", + "Name": "AddScheme", "Parameters": [ { "Name": "services", "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" } ], "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", "Static": true, "Extension": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationHandler" + ] + } + ] }, { "Kind": "Method", - "Name": "AddAuthentication", + "Name": "AddRemoteScheme", "Parameters": [ { "Name": "services", "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, { "Name": "configureOptions", - "Type": "System.Action" + "Type": "System.Action" } ], "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", "Static": true, "Extension": true, "Visibility": "Public", - "GenericParameter": [] + "GenericParameter": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions" + ] + }, + { + "ParameterName": "THandler", + "ParameterPosition": 1, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler" + ] + } + ] } ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json deleted file mode 100644 index 81dc1133e..000000000 --- a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json +++ /dev/null @@ -1,116 +0,0 @@ - [ - { - "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.AuthenticationHandler : Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.AuthenticationMiddleware where T0 : Microsoft.AspNetCore.Builder.AuthenticationOptions, new()", - "Kind": "Removal" - }, - { - "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler where T0 : Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public abstract class Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticateResult", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticationTicket", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.AuthenticationToken", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationHandler : Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformationMiddleware", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.ClaimsTransformer : Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.PropertiesDataFormat : Microsoft.AspNetCore.Authentication.SecureDataFormat", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.PropertiesSerializer : Microsoft.AspNetCore.Authentication.IDataSerializer", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents : Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.SharedAuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.ClaimsTransformationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Builder.RemoteAuthenticationOptions : Microsoft.AspNetCore.Builder.AuthenticationOptions", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.IClaimsTransformer", - "Kind": "Removal" - }, - { - "TypeId": "public interface Microsoft.AspNetCore.Authentication.IRemoteAuthenticationEvents", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.AspNetCore.Builder.ClaimsTransformationAppBuilderExtensions", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", - "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configureOptions)", - "Kind": "Removal" - }, - { - "TypeId": "public abstract class Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.BaseControlContext : Microsoft.AspNetCore.Authentication.BaseContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.FailureContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "Kind": "Removal" - }, - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.TicketReceivedContext : Microsoft.AspNetCore.Authentication.BaseControlContext", - "Kind": "Removal" - }, - { - "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", - "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddAuthentication(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)", - "Kind": "Removal" - }, - { - "TypeId": "public enum Microsoft.AspNetCore.Authentication.EventResultState", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json new file mode 100644 index 000000000..0bad3ed62 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json @@ -0,0 +1,211 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AuthenticateAsync", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + }, + { + "Name": "authenticationResult", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Challenged", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Forbidden", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Succeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Challenge", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Forbid", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Success", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.Policy.PolicyAuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.Policy.PolicyEvaluator", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator" + ], + "Members": [ + { + "Kind": "Method", + "Name": "AuthenticateAsync", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthorizeAsync", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" + }, + { + "Name": "authenticationResult", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticateResult" + }, + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "authorization", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationService" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.PolicyServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddAuthorizationPolicyEvaluator", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json index 8ae585270..6108db6d2 100644 --- a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.AuthorizationServiceCollectionExtensions", @@ -66,6 +66,54 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationFailure", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_FailCalled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_FailedRequirements", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IEnumerable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ExplicitFail", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationFailure", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Failed", + "Parameters": [ + { + "Name": "failed", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationFailure", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.AuthorizationHandler", "Visibility": "Public", @@ -208,6 +256,7 @@ "Name": "get_Requirements", "Parameters": [], "ReturnType": "System.Collections.Generic.IEnumerable", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -216,6 +265,7 @@ "Name": "get_User", "Parameters": [], "ReturnType": "System.Security.Claims.ClaimsPrincipal", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -224,6 +274,7 @@ "Name": "get_Resource", "Parameters": [], "ReturnType": "System.Object", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -232,6 +283,7 @@ "Name": "get_PendingRequirements", "Parameters": [], "ReturnType": "System.Collections.Generic.IEnumerable", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -240,6 +292,7 @@ "Name": "get_HasFailed", "Parameters": [], "ReturnType": "System.Boolean", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -248,6 +301,7 @@ "Name": "get_HasSucceeded", "Parameters": [], "ReturnType": "System.Boolean", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -256,6 +310,7 @@ "Name": "Fail", "Parameters": [], "ReturnType": "System.Void", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -269,6 +324,7 @@ } ], "ReturnType": "System.Void", + "Virtual": true, "Visibility": "Public", "GenericParameter": [] }, @@ -301,6 +357,27 @@ "Kind": "Class", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "get_InvokeHandlersAfterFailure", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_InvokeHandlersAfterFailure", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_DefaultPolicy", @@ -714,6 +791,63 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Succeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Failure", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationFailure", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Success", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Failed", + "Parameters": [ + { + "Name": "failure", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationFailure" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Failed", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.AuthorizationServiceExtensions", "Visibility": "Public", @@ -744,7 +878,7 @@ "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationRequirement" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Static": true, "Extension": true, "Visibility": "Public", @@ -771,7 +905,7 @@ "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Static": true, "Extension": true, "Visibility": "Public", @@ -794,7 +928,7 @@ "Type": "Microsoft.AspNetCore.Authorization.AuthorizationPolicy" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Static": true, "Extension": true, "Visibility": "Public", @@ -817,7 +951,7 @@ "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Static": true, "Extension": true, "Visibility": "Public", @@ -891,7 +1025,7 @@ }, { "Kind": "Method", - "Name": "get_ActiveAuthenticationSchemes", + "Name": "get_AuthenticationSchemes", "Parameters": [], "ReturnType": "System.String", "Sealed": true, @@ -902,7 +1036,7 @@ }, { "Kind": "Method", - "Name": "set_ActiveAuthenticationSchemes", + "Name": "set_AuthenticationSchemes", "Parameters": [ { "Name": "value", @@ -916,6 +1050,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ActiveAuthenticationSchemes", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ActiveAuthenticationSchemes", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -938,6 +1093,120 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationEvaluator", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationEvaluator" + ], + "Members": [ + { + "Kind": "Method", + "Name": "Evaluate", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationEvaluator", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationHandlerContextFactory", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerContextFactory" + ], + "Members": [ + { + "Kind": "Method", + "Name": "CreateContext", + "Parameters": [ + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerContextFactory", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationHandlerProvider", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "GetHandlersAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task>", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "handlers", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.DefaultAuthorizationPolicyProvider", "Visibility": "Public", @@ -1012,7 +1281,7 @@ "Type": "System.Collections.Generic.IEnumerable" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Sealed": true, "Virtual": true, "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", @@ -1036,7 +1305,7 @@ "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "Sealed": true, "Virtual": true, "ImplementedInterface": "Microsoft.AspNetCore.Authorization.IAuthorizationService", @@ -1053,11 +1322,23 @@ }, { "Name": "handlers", - "Type": "System.Collections.Generic.IEnumerable" + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerProvider" }, { "Name": "logger", "Type": "Microsoft.Extensions.Logging.ILogger" + }, + { + "Name": "contextFactory", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerContextFactory" + }, + { + "Name": "evaluator", + "Type": "Microsoft.AspNetCore.Authorization.IAuthorizationEvaluator" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" } ], "Visibility": "Public", @@ -1075,6 +1356,28 @@ "Members": [], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationEvaluator", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Evaluate", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationResult", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandler", "Visibility": "Public", @@ -1097,6 +1400,58 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerContextFactory", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateContext", + "Parameters": [ + { + "Name": "requirements", + "Type": "System.Collections.Generic.IEnumerable" + }, + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "resource", + "Type": "System.Object" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationHandlerProvider", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetHandlersAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authorization.AuthorizationHandlerContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task>", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider", "Visibility": "Public", @@ -1159,7 +1514,7 @@ "Type": "System.Collections.Generic.IEnumerable" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "GenericParameter": [] }, { @@ -1179,7 +1534,7 @@ "Type": "System.String" } ], - "ReturnType": "System.Threading.Tasks.Task", + "ReturnType": "System.Threading.Tasks.Task", "GenericParameter": [] } ], @@ -1232,14 +1587,14 @@ }, { "Kind": "Method", - "Name": "get_ActiveAuthenticationSchemes", + "Name": "get_AuthenticationSchemes", "Parameters": [], "ReturnType": "System.String", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_ActiveAuthenticationSchemes", + "Name": "set_AuthenticationSchemes", "Parameters": [ { "Name": "value", @@ -1588,6 +1943,5 @@ ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json index 8eef347eb..97da7ea5c 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", @@ -53,6 +53,27 @@ "Kind": "Class", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "get_MinimumSameSitePolicy", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.SameSiteMode", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MinimumSameSitePolicy", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.SameSiteMode" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_HttpOnly", @@ -387,6 +408,5 @@ ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json index 1fc242ec5..a55bf8f33 100644 --- a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json +++ b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", @@ -368,6 +368,5 @@ ], "GenericParameters": [] } - ], - "SourceFilters": [] + ] } \ No newline at end of file From 144ee21696e838c1f96676573ffe30e8f2ba8bd6 Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 6 Jul 2017 12:36:34 -0700 Subject: [PATCH 089/248] #1188 Add AuthenticationProperties to HandleRequestResult and RemoteFailureContext --- samples/SocialSample/Startup.cs | 59 +++++-- .../OAuthHandler.cs | 38 ++--- .../OpenIdConnectHandler.cs | 43 +++-- .../TwitterHandler.cs | 9 +- .../Events/RemoteFailureContext.cs | 5 + ...cationResult.cs => HandleRequestResult.cs} | 24 ++- .../RemoteAuthenticationHandler.cs | 19 ++- .../GoogleTests.cs | 36 +++- .../OAuthTests.cs | 156 ++++++++++-------- .../OpenIdConnect/OpenIdConnectEventTests.cs | 18 +- .../TwitterTests.cs | 113 ++++++++----- 11 files changed, 344 insertions(+), 176 deletions(-) rename src/Microsoft.AspNetCore.Authentication/{RemoteAuthenticationResult.cs => HandleRequestResult.cs} (72%) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index a0b193b8e..35896e84b 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -67,6 +67,10 @@ public void ConfigureServices(IServiceCollection services) o.Fields.Add("name"); o.Fields.Add("email"); o.SaveTokens = true; + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project @@ -81,6 +85,10 @@ public void ConfigureServices(IServiceCollection services) o.Scope.Add("profile"); o.Scope.Add("email"); o.SaveTokens = true; + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project @@ -93,12 +101,7 @@ public void ConfigureServices(IServiceCollection services) o.SaveTokens = true; o.Events = new OAuthEvents() { - OnRemoteFailure = ctx => - { - ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); - ctx.HandleResponse(); - return Task.FromResult(0); - } + OnRemoteFailure = HandleOnRemoteFailure }; o.ClaimActions.MapJsonSubKey("urn:google:image", "image", "url"); o.ClaimActions.Remove(ClaimTypes.GivenName); @@ -116,12 +119,7 @@ public void ConfigureServices(IServiceCollection services) o.ClaimActions.MapJsonKey("urn:twitter:profilepicture", "profile_image_url", ClaimTypes.Uri); o.Events = new TwitterEvents() { - OnRemoteFailure = ctx => - { - ctx.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(ctx.Failure.Message)); - ctx.HandleResponse(); - return Task.FromResult(0); - } + OnRemoteFailure = HandleOnRemoteFailure }; }) /* Azure AD app model v2 has restrictions that prevent the use of plain HTTP for redirect URLs. @@ -139,6 +137,10 @@ public void ConfigureServices(IServiceCollection services) o.TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint; o.Scope.Add("https://graph.microsoft.com/user.read"); o.SaveTokens = true; + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets. // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/ @@ -148,6 +150,10 @@ public void ConfigureServices(IServiceCollection services) o.ClientSecret = Configuration["microsoftaccount:clientsecret"]; o.SaveTokens = true; o.Scope.Add("offline_access"); + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ @@ -159,6 +165,10 @@ public void ConfigureServices(IServiceCollection services) o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize"; o.TokenEndpoint = "https://github.com/login/oauth/access_token"; o.SaveTokens = true; + o.Events = new OAuthEvents() + { + OnRemoteFailure = HandleOnRemoteFailure + }; }) // You must first create an app with GitHub and add its ID and Secret to your user-secrets. // https://github.com/settings/applications/ @@ -180,6 +190,7 @@ public void ConfigureServices(IServiceCollection services) o.ClaimActions.MapJsonKey("urn:github:url", "url"); o.Events = new OAuthEvents { + OnRemoteFailure = HandleOnRemoteFailure, OnCreatingTicket = async context => { // Get the GitHub user @@ -198,6 +209,30 @@ public void ConfigureServices(IServiceCollection services) }); } + private async Task HandleOnRemoteFailure(RemoteFailureContext context) + { + context.Response.StatusCode = 500; + context.Response.ContentType = "text/html"; + await context.Response.WriteAsync(""); + await context.Response.WriteAsync("A remote failure has occurred: " + UrlEncoder.Default.Encode(context.Failure.Message) + "
"); + + if (context.Properties != null) + { + await context.Response.WriteAsync("Properties:
"); + foreach (var pair in context.Properties.Items) + { + await context.Response.WriteAsync($"-{ UrlEncoder.Default.Encode(pair.Key)}={ UrlEncoder.Default.Encode(pair.Value)}
"); + } + } + + await context.Response.WriteAsync("Home"); + await context.Response.WriteAsync(""); + + // context.Response.Redirect("/error?FailureMessage=" + UrlEncoder.Default.Encode(context.Failure.Message)); + + context.HandleResponse(); + } + public void Configure(IApplicationBuilder app) { app.UseDeveloperExceptionPage(); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 007d7dbef..80680a7cf 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -44,9 +44,22 @@ public OAuthHandler(IOptionsMonitor options, ILoggerFactory logger, Ur protected override async Task HandleRemoteAuthenticateAsync() { - AuthenticationProperties properties = null; var query = Request.Query; + var state = query["state"]; + var properties = Options.StateDataFormat.Unprotect(state); + + if (properties == null) + { + return HandleRequestResult.Fail("The oauth state was missing or invalid."); + } + + // OAuth2 10.12 CSRF + if (!ValidateCorrelationId(properties)) + { + return HandleRequestResult.Fail("Correlation failed.", properties); + } + var error = query["error"]; if (!StringValues.IsNullOrEmpty(error)) { @@ -63,39 +76,26 @@ protected override async Task HandleRemoteAuthenticateAsync failureMessage.Append(";Uri=").Append(errorUri); } - return HandleRequestResult.Fail(failureMessage.ToString()); + return HandleRequestResult.Fail(failureMessage.ToString(), properties); } var code = query["code"]; - var state = query["state"]; - - properties = Options.StateDataFormat.Unprotect(state); - if (properties == null) - { - return HandleRequestResult.Fail("The oauth state was missing or invalid."); - } - - // OAuth2 10.12 CSRF - if (!ValidateCorrelationId(properties)) - { - return HandleRequestResult.Fail("Correlation failed."); - } if (StringValues.IsNullOrEmpty(code)) { - return HandleRequestResult.Fail("Code was not found."); + return HandleRequestResult.Fail("Code was not found.", properties); } var tokens = await ExchangeCodeAsync(code, BuildRedirectUri(Options.CallbackPath)); if (tokens.Error != null) { - return HandleRequestResult.Fail(tokens.Error); + return HandleRequestResult.Fail(tokens.Error, properties); } if (string.IsNullOrEmpty(tokens.AccessToken)) { - return HandleRequestResult.Fail("Failed to retrieve access token."); + return HandleRequestResult.Fail("Failed to retrieve access token.", properties); } var identity = new ClaimsIdentity(ClaimsIssuer); @@ -141,7 +141,7 @@ protected override async Task HandleRemoteAuthenticateAsync } else { - return HandleRequestResult.Fail("Failed to retrieve user information from remote server."); + return HandleRequestResult.Fail("Failed to retrieve user information from remote server.", properties); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index bf365ceca..7f65afdce 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -491,13 +491,10 @@ protected override async Task HandleRemoteAuthenticateAsync return HandleRequestResult.Fail("No message."); } + AuthenticationProperties properties = null; try { - AuthenticationProperties properties = null; - if (!string.IsNullOrEmpty(authorizationResponse.State)) - { - properties = Options.StateDataFormat.Unprotect(authorizationResponse.State); - } + properties = ReadPropertiesAndClearState(authorizationResponse); var messageReceivedContext = await RunMessageReceivedEventAsync(authorizationResponse, properties); if (messageReceivedContext.Result != null) @@ -521,8 +518,7 @@ protected override async Task HandleRemoteAuthenticateAsync return HandleRequestResult.Fail(Resources.MessageStateIsNullOrEmpty); } - // if state exists and we failed to 'unprotect' this is not a message we should process. - properties = Options.StateDataFormat.Unprotect(authorizationResponse.State); + properties = ReadPropertiesAndClearState(authorizationResponse); } if (properties == null) @@ -533,21 +529,20 @@ protected override async Task HandleRemoteAuthenticateAsync // Not for us? return HandleRequestResult.SkipHandler(); } + + // if state exists and we failed to 'unprotect' this is not a message we should process. return HandleRequestResult.Fail(Resources.MessageStateIsInvalid); } - properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out string userstate); - authorizationResponse.State = userstate; - if (!ValidateCorrelationId(properties)) { - return HandleRequestResult.Fail("Correlation failed."); + return HandleRequestResult.Fail("Correlation failed.", properties); } // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(authorizationResponse.Error)) { - return HandleRequestResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null)); + return HandleRequestResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null), properties); } if (_configuration == null && Options.ConfigurationManager != null) @@ -635,8 +630,7 @@ protected override async Task HandleRemoteAuthenticateAsync // At least a cursory validation is required on the new IdToken, even if we've already validated the one from the authorization response. // And we'll want to validate the new JWT in ValidateTokenResponse. - JwtSecurityToken tokenEndpointJwt; - var tokenEndpointUser = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out tokenEndpointJwt); + var tokenEndpointUser = ValidateToken(tokenEndpointResponse.IdToken, properties, validationParameters, out var tokenEndpointJwt); // Avoid reading & deleting the nonce cookie, running the event, etc, if it was already done as part of the authorization response validation. if (user == null) @@ -722,8 +716,25 @@ protected override async Task HandleRemoteAuthenticateAsync return authenticationFailedContext.Result; } - return HandleRequestResult.Fail(exception); + return HandleRequestResult.Fail(exception, properties); + } + } + + private AuthenticationProperties ReadPropertiesAndClearState(OpenIdConnectMessage message) + { + AuthenticationProperties properties = null; + if (!string.IsNullOrEmpty(message.State)) + { + properties = Options.StateDataFormat.Unprotect(message.State); + + if (properties != null) + { + // If properties can be decoded from state, clear the message state. + properties.Items.TryGetValue(OpenIdConnectDefaults.UserstatePropertiesKey, out var userstate); + message.State = userstate; + } } + return properties; } private void PopulateSessionProperties(OpenIdConnectMessage message, AuthenticationProperties properties) @@ -830,7 +841,7 @@ protected virtual async Task GetUserInformationAsync( } else { - return HandleRequestResult.Fail("Unknown response type: " + contentType.MediaType); + return HandleRequestResult.Fail("Unknown response type: " + contentType.MediaType, properties); } var userInformationReceivedContext = await RunUserInformationReceivedEventAsync(principal, properties, message, user); diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index e8a961df3..acfd765d9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -46,7 +46,6 @@ public TwitterHandler(IOptionsMonitor options, ILoggerFactory lo protected override async Task HandleRemoteAuthenticateAsync() { - AuthenticationProperties properties = null; var query = Request.Query; var protectedRequestToken = Request.Cookies[Options.StateCookie.Name]; @@ -57,25 +56,25 @@ protected override async Task HandleRemoteAuthenticateAsync return HandleRequestResult.Fail("Invalid state cookie."); } - properties = requestToken.Properties; + var properties = requestToken.Properties; // REVIEW: see which of these are really errors var returnedToken = query["oauth_token"]; if (StringValues.IsNullOrEmpty(returnedToken)) { - return HandleRequestResult.Fail("Missing oauth_token"); + return HandleRequestResult.Fail("Missing oauth_token", properties); } if (!string.Equals(returnedToken, requestToken.Token, StringComparison.Ordinal)) { - return HandleRequestResult.Fail("Unmatched token"); + return HandleRequestResult.Fail("Unmatched token", properties); } var oauthVerifier = query["oauth_verifier"]; if (StringValues.IsNullOrEmpty(oauthVerifier)) { - return HandleRequestResult.Fail("Missing or blank oauth_verifier"); + return HandleRequestResult.Fail("Missing or blank oauth_verifier", properties); } var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs index becdfb543..6b3598f40 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteFailureContext.cs @@ -25,5 +25,10 @@ public RemoteFailureContext( /// User friendly error message for the error. ///
public Exception Failure { get; set; } + + /// + /// Additional state values for the authentication session. + /// + public AuthenticationProperties Properties { get; set; } } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs similarity index 72% rename from src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs rename to src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs index 8bcd2be01..3f6c2d917 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs @@ -49,13 +49,31 @@ public class HandleRequestResult : AuthenticateResult /// /// Indicates that there was a failure during authentication. /// - /// The failure message. + /// The failure exception. + /// Additional state values for the authentication session. /// The result. - public static new HandleRequestResult Fail(string failureMessage) + public static new HandleRequestResult Fail(Exception failure, AuthenticationProperties properties) { - return new HandleRequestResult() { Failure = new Exception(failureMessage) }; + return new HandleRequestResult() { Failure = failure, Properties = properties }; } + /// + /// Indicates that there was a failure during authentication. + /// + /// The failure message. + /// The result. + public static new HandleRequestResult Fail(string failureMessage) + => Fail(new Exception(failureMessage)); + + /// + /// Indicates that there was a failure during authentication. + /// + /// The failure message. + /// Additional state values for the authentication session. + /// The result. + public static new HandleRequestResult Fail(string failureMessage, AuthenticationProperties properties) + => Fail(new Exception(failureMessage), properties); + /// /// Discontinue all processing for this request and return to the client. /// The caller is responsible for generating the full response. diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 4051ee666..bea4895d6 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -49,6 +49,7 @@ public virtual async Task HandleRequestAsync() AuthenticationTicket ticket = null; Exception exception = null; + AuthenticationProperties properties = null; try { var authResult = await HandleRemoteAuthenticateAsync(); @@ -66,8 +67,8 @@ public virtual async Task HandleRequestAsync() } else if (!authResult.Succeeded) { - exception = authResult.Failure ?? - new InvalidOperationException("Invalid return state, unable to redirect."); + exception = authResult.Failure ?? new InvalidOperationException("Invalid return state, unable to redirect."); + properties = authResult.Properties; } ticket = authResult?.Ticket; @@ -80,7 +81,10 @@ public virtual async Task HandleRequestAsync() if (exception != null) { Logger.RemoteAuthenticationError(exception.Message); - var errorContext = new RemoteFailureContext(Context, Scheme, Options, exception); + var errorContext = new RemoteFailureContext(Context, Scheme, Options, exception) + { + Properties = properties + }; await Events.RemoteFailure(errorContext); if (errorContext.Result != null) @@ -95,11 +99,14 @@ public virtual async Task HandleRequestAsync() } else if (errorContext.Result.Failure != null) { - throw new InvalidOperationException("An error was returned from the RemoteFailure event.", errorContext.Result.Failure); + throw new Exception("An error was returned from the RemoteFailure event.", errorContext.Result.Failure); } } - throw exception; + if (errorContext.Failure != null) + { + throw new Exception("An error was encountered while handling the remote login.", errorContext.Failure); + } } // We have a ticket if we get here @@ -107,7 +114,7 @@ public virtual async Task HandleRequestAsync() { ReturnUri = ticket.Properties.RedirectUri }; - // REVIEW: is this safe or good? + ticket.Properties.RedirectUri = null; // Mark which provider produced this identity so we can cross-check later in HandleAuthenticateAsync diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 8f2cc52f9..51bc67cc3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -253,6 +253,7 @@ public async Task ReplyPathWithErrorFails(bool redirect) { o.ClientId = "Test Id"; o.ClientSecret = "Test Secret"; + o.StateDataFormat = new TestStateDataFormat(); o.Events = redirect ? new OAuthEvents() { OnRemoteFailure = ctx => @@ -263,7 +264,8 @@ public async Task ReplyPathWithErrorFails(bool redirect) } } : new OAuthEvents(); }); - var sendTask = server.SendAsync("https://example.com/signin-google?error=OMG&error_description=SoBad&error_uri=foobar"); + var sendTask = server.SendAsync("https://example.com/signin-google?error=OMG&error_description=SoBad&error_uri=foobar&state=protected_state", + ".AspNetCore.Correlation.Google.corrilationId=N"); if (redirect) { var transaction = await sendTask; @@ -1075,5 +1077,37 @@ private static TestServer CreateServer(Action configureOptions, F }); return new TestServer(builder); } + + private class TestStateDataFormat : ISecureDataFormat + { + private AuthenticationProperties Data { get; set; } + + public string Protect(AuthenticationProperties data) + { + return "protected_state"; + } + + public string Protect(AuthenticationProperties data, string purpose) + { + throw new NotImplementedException(); + } + + public AuthenticationProperties Unprotect(string protectedText) + { + Assert.Equal("protected_state", protectedText); + var properties = new AuthenticationProperties(new Dictionary() + { + { ".xsrf", "corrilationId" }, + { "testkey", "testvalue" } + }); + properties.RedirectUri = "http://testhost/redirect"; + return properties; + } + + public AuthenticationProperties Unprotect(string protectedText, string purpose) + { + throw new NotImplementedException(); + } + } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 30c33eb1d..81d2360ec 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; @@ -10,6 +11,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.OAuth @@ -20,20 +22,13 @@ public class OAuthTests public async Task VerifySignInSchemeCannotBeSetToSelf() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "weeblie"; o.ClientId = "whatever"; o.ClientSecret = "whatever"; - }), - context => - { - // REVIEW: Gross. - context.ChallengeAsync("weeblie").GetAwaiter().GetResult(); - return true; - }); - var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + })); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/")); Assert.Contains("cannot be set to itself", error.Message); } @@ -54,7 +49,6 @@ public async Task VerifySchemeDefaults() public async Task ThrowsIfClientIdMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; @@ -62,22 +56,14 @@ public async Task ThrowsIfClientIdMissing() o.ClientSecret = "whatever"; o.TokenEndpoint = "/"; o.AuthorizationEndpoint = "/"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("ClientId", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("ClientId", () => server.SendAsync("http://example.com/")); } [Fact] public async Task ThrowsIfClientSecretMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.SignInScheme = "whatever"; @@ -85,22 +71,14 @@ public async Task ThrowsIfClientSecretMissing() o.CallbackPath = "/"; o.TokenEndpoint = "/"; o.AuthorizationEndpoint = "/"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("ClientSecret", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("ClientSecret", () => server.SendAsync("http://example.com/")); } [Fact] public async Task ThrowsIfCallbackPathMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; @@ -108,22 +86,14 @@ public async Task ThrowsIfCallbackPathMissing() o.TokenEndpoint = "/"; o.AuthorizationEndpoint = "/"; o.SignInScheme = "eh"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("CallbackPath", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("CallbackPath", () => server.SendAsync("http://example.com/")); } [Fact] public async Task ThrowsIfTokenEndpointMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; @@ -131,22 +101,14 @@ public async Task ThrowsIfTokenEndpointMissing() o.CallbackPath = "/"; o.AuthorizationEndpoint = "/"; o.SignInScheme = "eh"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("TokenEndpoint", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("TokenEndpoint", () => server.SendAsync("http://example.com/")); } [Fact] public async Task ThrowsIfAuthorizationEndpointMissing() { var server = CreateServer( - app => { }, services => services.AddAuthentication().AddOAuth("weeblie", o => { o.ClientId = "Whatever;"; @@ -154,22 +116,14 @@ public async Task ThrowsIfAuthorizationEndpointMissing() o.CallbackPath = "/"; o.TokenEndpoint = "/"; o.SignInScheme = "eh"; - }), - context => - { - // REVIEW: Gross. - Assert.Throws("AuthorizationEndpoint", () => context.ChallengeAsync("weeblie").GetAwaiter().GetResult()); - return true; - }); - var transaction = await server.SendAsync("http://example.com/challenge"); - Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); + })); + await Assert.ThrowsAsync("AuthorizationEndpoint", () => server.SendAsync("http://example.com/")); } [Fact] public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallBackPath() { var server = CreateServer( - app => { }, s => s.AddAuthentication().AddOAuth( "Weblie", opt => @@ -181,9 +135,9 @@ public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallB opt.TokenEndpoint = "https://example.com/provider/token"; opt.CallbackPath = "/oauth-callback"; }), - ctx => + async ctx => { - ctx.ChallengeAsync("Weblie").ConfigureAwait(false).GetAwaiter().GetResult(); + await ctx.ChallengeAsync("Weblie"); return true; }); @@ -201,7 +155,6 @@ public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallB public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOverriden() { var server = CreateServer( - app => { }, s => s.AddAuthentication().AddOAuth( "Weblie", opt => @@ -214,9 +167,9 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv opt.CallbackPath = "/oauth-callback"; opt.CorrelationCookie.Path = "/"; }), - ctx => + async ctx => { - ctx.ChallengeAsync("Weblie").ConfigureAwait(false).GetAwaiter().GetResult(); + await ctx.ChallengeAsync("Weblie"); return true; }); @@ -230,15 +183,50 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv Assert.Contains("path=/", correlation); } - private static TestServer CreateServer(Action configure, Action configureServices, Func handler) + [Fact] + public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + opt.ClientId = "Test Id"; + opt.ClientSecret = "secret"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.AuthorizationEndpoint = "https://example.com/provider/login"; + opt.TokenEndpoint = "https://example.com/provider/token"; + opt.CallbackPath = "/oauth-callback"; + opt.StateDataFormat = new TestStateDataFormat(); + opt.Events = new OAuthEvents() + { + OnRemoteFailure = context => + { + Assert.Contains("declined", context.Failure.Message); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.Response.StatusCode = StatusCodes.Status406NotAcceptable; + context.HandleResponse(); + return Task.CompletedTask; + } + }; + })); + + var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=declined&state=protected_state", + ".AspNetCore.Correlation.Weblie.corrilationId=N"); + + Assert.Equal(HttpStatusCode.NotAcceptable, transaction.Response.StatusCode); + Assert.Null(transaction.Response.Headers.Location); + } + + private static TestServer CreateServer(Action configureServices, Func> handler = null) { var builder = new WebHostBuilder() .Configure(app => { - configure?.Invoke(app); + app.UseAuthentication(); app.Use(async (context, next) => { - if (handler == null || !handler(context)) + if (handler == null || ! await handler(context)) { await next(); } @@ -247,5 +235,37 @@ private static TestServer CreateServer(Action configure, Ac .ConfigureServices(configureServices); return new TestServer(builder); } + + private class TestStateDataFormat : ISecureDataFormat + { + private AuthenticationProperties Data { get; set; } + + public string Protect(AuthenticationProperties data) + { + return "protected_state"; + } + + public string Protect(AuthenticationProperties data, string purpose) + { + throw new NotImplementedException(); + } + + public AuthenticationProperties Unprotect(string protectedText) + { + Assert.Equal("protected_state", protectedText); + var properties = new AuthenticationProperties(new Dictionary() + { + { ".xsrf", "corrilationId" }, + { "testkey", "testvalue" } + }); + properties.RedirectUri = "http://testhost/redirect"; + return properties; + } + + public AuthenticationProperties Unprotect(string protectedText, string purpose) + { + throw new NotImplementedException(); + } + } } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index f3fc26187..87bdc3f3c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -95,7 +95,7 @@ public async Task OnMessageReceived_Fail_NoMoreEventsRun() return PostAsync(server, "signin-oidc", ""); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(remoteFailure); @@ -191,7 +191,7 @@ public async Task OnTokenValidated_Fail_NoMoreEventsRun() return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -348,7 +348,7 @@ public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -532,7 +532,7 @@ public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -731,7 +731,7 @@ public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() return PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(codeReceived); @@ -943,7 +943,7 @@ public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -1186,7 +1186,7 @@ public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() return PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); }); - Assert.Equal("Authentication was aborted from user code.", exception.Message); + Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); Assert.True(messageReceived); Assert.True(tokenValidated); @@ -1450,6 +1450,7 @@ public async Task OnRemoteFailure_Handled_NoMoreEventsRun() { remoteFailure = true; Assert.Equal("TestException", context.Failure.Message); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); context.HandleResponse(); context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.FromResult(0); @@ -1877,7 +1878,8 @@ public AuthenticationProperties Unprotect(string protectedText) var properties = new AuthenticationProperties(new Dictionary() { { ".xsrf", "corrilationId" }, - { OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, "redirect_uri" } + { OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, "redirect_uri" }, + { "testkey", "testvalue" } }); properties.RedirectUri = "http://testhost/redirect"; return properties; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 6c661af45..735cb3314 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. using System; +using System.Linq; using System.Net; using System.Net.Http; using System.Security.Claims; @@ -11,6 +12,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter @@ -60,26 +62,12 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() }; o.BackchannelHttpHandler = new TestHttpMessageHandler { - Sender = req => - { - if (req.RequestUri.AbsoluteUri == "https://api.twitter.com/oauth/request_token") - { - return new HttpResponseMessage(HttpStatusCode.OK) - { - Content = - new StringContent("oauth_callback_confirmed=true&oauth_token=test_oauth_token&oauth_token_secret=test_oauth_token_secret", - Encoding.UTF8, - "application/x-www-form-urlencoded") - }; - } - return null; - } + Sender = BackchannelRequestToken }; }, - context => + async context => { - // REVIEW: Gross - context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); + await context.ChallengeAsync("Twitter"); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -168,7 +156,6 @@ public async Task ForbidThrows() Assert.Equal(HttpStatusCode.OK, transaction.Response.StatusCode); } - [Fact] public async Task ChallengeWillTriggerRedirection() { @@ -178,35 +165,70 @@ public async Task ChallengeWillTriggerRedirection() o.ConsumerSecret = "Test Consumer Secret"; o.BackchannelHttpHandler = new TestHttpMessageHandler { - Sender = req => + Sender = BackchannelRequestToken + }; + }, + async context => + { + await context.ChallengeAsync("Twitter"); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + var location = transaction.Response.Headers.Location.AbsoluteUri; + Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); + } + + [Fact] + public async Task BadCallbackCallsRemoteAuthFailedWithState() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.BackchannelHttpHandler = new TestHttpMessageHandler + { + Sender = BackchannelRequestToken + }; + o.Events = new TwitterEvents() + { + OnRemoteFailure = context => { - if (req.RequestUri.AbsoluteUri == "https://api.twitter.com/oauth/request_token") - { - return new HttpResponseMessage(HttpStatusCode.OK) - { - Content = - new StringContent("oauth_callback_confirmed=true&oauth_token=test_oauth_token&oauth_token_secret=test_oauth_token_secret", - Encoding.UTF8, - "application/x-www-form-urlencoded") - }; - } - return null; + Assert.NotNull(context.Failure); + Assert.NotNull(context.Properties); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.Response.StatusCode = StatusCodes.Status406NotAcceptable; + context.HandleResponse(); + return Task.CompletedTask; } }; }, - context => - { - // REVIEW: gross - context.ChallengeAsync("Twitter").GetAwaiter().GetResult(); - return true; - }); + async context => + { + var properties = new AuthenticationProperties(); + properties.Items["testkey"] = "testvalue"; + await context.ChallengeAsync("Twitter", properties); + return true; + }); var transaction = await server.SendAsync("http://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); + Assert.True(transaction.Response.Headers.TryGetValues(HeaderNames.SetCookie, out var setCookie)); + Assert.True(SetCookieHeaderValue.TryParseList(setCookie.ToList(), out var setCookieValues)); + Assert.Single(setCookieValues); + var setCookieValue = setCookieValues.Single(); + var cookie = new CookieHeaderValue(setCookieValue.Name, setCookieValue.Value); + + var request = new HttpRequestMessage(HttpMethod.Get, "/signin-twitter"); + request.Headers.Add(HeaderNames.Cookie, cookie.ToString()); + var client = server.CreateClient(); + var response = await client.SendAsync(request); + + Assert.Equal(HttpStatusCode.NotAcceptable, response.StatusCode); } - private static TestServer CreateServer(Action options, Func handler = null) + private static TestServer CreateServer(Action options, Func> handler = null) { var builder = new WebHostBuilder() .Configure(app => @@ -228,7 +250,7 @@ private static TestServer CreateServer(Action options, Func(() => context.ForbidAsync("Twitter")); } - else if (handler == null || !handler(context)) + else if (handler == null || ! await handler(context)) { await next(); } @@ -247,5 +269,20 @@ private static TestServer CreateServer(Action options, Func Date: Thu, 28 Sep 2017 22:03:52 +0100 Subject: [PATCH 090/248] Added ability to set prompt parameter in OpenIdConnectOptions (#1401) --- .../OpenIdConnectHandler.cs | 1 + .../OpenIdConnectOptions.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 7f65afdce..0b2419e2a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -349,6 +349,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop RedirectUri = BuildRedirectUri(Options.CallbackPath), Resource = Options.Resource, ResponseType = Options.ResponseType, + Prompt = Options.Prompt, Scope = string.Join(" ", Options.Scope) }; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a8545e35a..e589a2bc8 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -209,6 +209,11 @@ public override void Validate() /// public string ResponseType { get; set; } = OpenIdConnectResponseType.IdToken; + /// + /// Gets or sets the 'prompt'. + /// + public string Prompt { get; set; } + /// /// Gets the list of permissions to request. /// From 0959c941b40086b131b1e01d304fc23bb887fdc8 Mon Sep 17 00:00:00 2001 From: Josh Coulter Date: Mon, 2 Oct 2017 13:25:46 -0500 Subject: [PATCH 091/248] Cleaned up OAuth handler's exception messages (#1462) --- .../FacebookHandler.cs | 2 +- src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs | 2 +- .../MicrosoftAccountHandler.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index db664e2ee..0f83c1719 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -37,7 +37,7 @@ protected override async Task CreateTicketAsync(ClaimsIden var response = await Backchannel.GetAsync(endpoint, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"Failed to retrieve Facebook user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Facebook Graph API is enabled."); + throw new HttpRequestException($"An error occurred when retrieving Facebook user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Facebook Graph API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 155691a4b..091896f7c 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -34,7 +34,7 @@ protected override async Task CreateTicketAsync( var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"An error occurred when retrieving user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Google+ API is enabled."); + throw new HttpRequestException($"An error occurred when retrieving Google user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Google+ API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs index f4c06300c..bba547277 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountHandler.cs @@ -27,7 +27,7 @@ protected override async Task CreateTicketAsync(ClaimsIden var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { - throw new HttpRequestException($"Failed to retrived Microsoft user information ({response.StatusCode}) Please check if the authentication information is correct and the corresponding Microsoft Account API is enabled."); + throw new HttpRequestException($"An error occurred when retrieving Microsoft user information ({response.StatusCode}). Please check if the authentication information is correct and the corresponding Microsoft Account API is enabled."); } var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); From 54e4f6834e6fa0f1cf2cc8c2599674ffe017c890 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 5 Oct 2017 15:35:51 -0700 Subject: [PATCH 092/248] Minor test code changes to resolve xUnit2013 build error --- .../CookieChunkingTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs index 143e1d254..69ead8fa6 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -17,7 +17,7 @@ public void AppendLargeCookie_Appended() string testString = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; new ChunkingCookieManager() { ChunkSize = null }.AppendResponseCookie(context, "TestCookie", testString, new CookieOptions()); var values = context.Response.Headers["Set-Cookie"]; - Assert.Equal(1, values.Count); + Assert.Single(values); Assert.Equal("TestCookie=" + testString + "; path=/; samesite=lax", values[0]); } From 3e7d1a7fd466623a90e6130b765f63501f6f8762 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 6 Oct 2017 16:09:26 -0700 Subject: [PATCH 093/248] React to updated IdentityModel version --- .../OpenIdConnect/TestSettings.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index bf9df4038..458f746c4 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -249,7 +249,13 @@ private void ValidateState(IDictionary actualParams, ICollection ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => - ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET", actualParams, errors, htmlEncoded); +#if NETCOREAPP2_0 + ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NETSTANDARD1_4", actualParams, errors, htmlEncoded); +#elif NET461 + ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET451", actualParams, errors, htmlEncoded); +#else +#error Invalid target framework. +#endif private void ValidateVersionTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => ValidateParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualParams, errors, htmlEncoded); From e34a5f8fb8e97b32077e8587261590c3910ad181 Mon Sep 17 00:00:00 2001 From: OpenIDAuthority Date: Wed, 16 Aug 2017 21:13:23 -0700 Subject: [PATCH 094/248] Add MaxAge to OpenIdConnectOptions - max_age parameter added to the authentication request if MaxAge is not null - throws exception if MaxAge is set to a negative value - Fractions of seconds are ignored - See http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest for expected behavior Addresses #1233 --- .../OpenIdConnectHandler.cs | 8 ++++ .../OpenIdConnectOptions.cs | 12 ++++++ .../OpenIdConnectChallengeTests.cs | 41 +++++++++++++++++++ .../OpenIdConnectConfigurationTests.cs | 15 +++++++ .../OpenIdConnect/TestSettings.cs | 19 +++++++++ 5 files changed, 95 insertions(+) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 0b2419e2a..0f60a558a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -353,6 +353,14 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop Scope = string.Join(" ", Options.Scope) }; + // Add the 'max_age' parameter to the authentication request if MaxAge is not null. + // See http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest + if (Options.MaxAge != null) + { + message.MaxAge = Convert.ToInt64(Math.Floor(((TimeSpan)Options.MaxAge).TotalSeconds)) + .ToString(CultureInfo.InvariantCulture); + } + // Omitting the response_mode parameter when it already corresponds to the default // response_mode used for the specified response_type is recommended by the specifications. // See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#ResponseModes diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index e589a2bc8..f6d914731 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -84,6 +84,11 @@ public override void Validate() { base.Validate(); + if (MaxAge != null && MaxAge.Value < TimeSpan.Zero) + { + throw new InvalidOperationException("MaxAge must not be a negative TimeSpan."); + } + if (string.IsNullOrEmpty(ClientId)) { throw new ArgumentException("Options.ClientId must be provided", nameof(ClientId)); @@ -159,6 +164,13 @@ public override void Validate() set => base.Events = value; } + /// + /// Gets or sets the 'max_age'. If set the 'max_age' parameter will be sent with the authentication request. If the identity + /// provider has not actively authenticated the user within the length of time specified, the user will be prompted to + /// re-authenticate. By default no max_age is specified. + /// + public TimeSpan? MaxAge { get; set; } = null; + /// /// Gets or sets the that is used to ensure that the 'id_token' received /// is valid per: http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index fb08ae278..4ff5aa9ad 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -409,5 +409,46 @@ public async Task Challenge_WithEmptyConfig_Fails() var exception = await Assert.ThrowsAsync(() => server.SendAsync(ChallengeEndpoint)); Assert.Equal("Cannot redirect to the authorization endpoint, the configuration may be missing or invalid.", exception.Message); } + + [Fact] + public async Task Challenge_WithDefaultMaxAge_HasExpectedMaxAgeParam() + { + var settings = new TestSettings( + opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + }); + + var server = settings.CreateTestServer(); + var transaction = await server.SendAsync(ChallengeEndpoint); + + var res = transaction.Response; + + settings.ValidateChallengeRedirect( + res.Headers.Location, + OpenIdConnectParameterNames.MaxAge); + } + + [Fact] + public async Task Challenge_WithSpecificMaxAge_HasExpectedMaxAgeParam() + { + var settings = new TestSettings( + opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.MaxAge = TimeSpan.FromMinutes(20); + }); + + var server = settings.CreateTestServer(); + var transaction = await server.SendAsync(ChallengeEndpoint); + + var res = transaction.Response; + + settings.ValidateChallengeRedirect( + res.Headers.Location, + OpenIdConnectParameterNames.MaxAge); + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index d0d1c2609..871ef9d08 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -115,6 +115,21 @@ public Task ThrowsWhenMetadataAddressIsNotHttps() ); } + [Fact] + public Task ThrowsWhenMaxAgeIsNegative() + { + return TestConfigurationException( + o => + { + o.SignInScheme = "TestScheme"; + o.ClientId = "Test Id"; + o.Authority = TestServerBuilder.DefaultAuthority; + o.MaxAge = TimeSpan.FromSeconds(-1); + }, + ex => Assert.Equal("MaxAge must not be a negative TimeSpan.", ex.Message) + ); + } + private TestServer BuildTestServer(Action options) { var builder = new WebHostBuilder() diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 458f746c4..5b4ea2348 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -4,12 +4,14 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.Linq; using System.Reflection; using System.Text; using System.Text.Encodings.Web; using System.Xml.Linq; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.TestHost; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; @@ -197,6 +199,9 @@ private void ValidateParameters( case OpenIdConnectParameterNames.PostLogoutRedirectUri: ValidatePostLogoutRedirectUri(actualValues, errors, htmlEncoded); break; + case OpenIdConnectParameterNames.MaxAge: + ValidateMaxAge(actualValues, errors, htmlEncoded); + break; default: throw new InvalidOperationException($"Unknown parameter \"{paramToValidate}\"."); } @@ -263,6 +268,20 @@ private void ValidateVersionTelemetry(IDictionary actualParams, private void ValidatePostLogoutRedirectUri(IDictionary actualParams, ICollection errors, bool htmlEncoded) => ValidateParameter(OpenIdConnectParameterNames.PostLogoutRedirectUri, "https://example.com/signout-callback-oidc", actualParams, errors, htmlEncoded); + private void ValidateMaxAge(IDictionary actualQuery, ICollection errors, bool htmlEncoded) + { + if(_options.MaxAge != null) + { + string expectedMaxAge = Convert.ToInt64(Math.Floor(((TimeSpan)_options.MaxAge).TotalSeconds)) + .ToString(CultureInfo.InvariantCulture); + ValidateParameter(OpenIdConnectParameterNames.MaxAge, expectedMaxAge, actualQuery, errors, htmlEncoded); + } + else if(actualQuery.ContainsKey(OpenIdConnectParameterNames.MaxAge)) + { + errors.Add($"Parameter {OpenIdConnectParameterNames.MaxAge} is present but it should be absent"); + } + } + private void ValidateParameter( string parameterName, string expectedValue, From 0904af8ff3c4f76f0d65bbec5a17ac40ac6a1f5b Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 9 Oct 2017 09:53:21 -0700 Subject: [PATCH 095/248] PR style cleanup --- .../OpenIdConnectHandler.cs | 4 ++-- .../OpenIdConnectOptions.cs | 6 +++--- .../OpenIdConnect/OpenIdConnectChallengeTests.cs | 8 ++++---- .../OpenIdConnect/OpenIdConnectConfigurationTests.cs | 4 ++-- .../OpenIdConnect/TestSettings.cs | 8 +++----- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 0f60a558a..330d064c0 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -355,9 +355,9 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // Add the 'max_age' parameter to the authentication request if MaxAge is not null. // See http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest - if (Options.MaxAge != null) + if (Options.MaxAge.HasValue) { - message.MaxAge = Convert.ToInt64(Math.Floor(((TimeSpan)Options.MaxAge).TotalSeconds)) + message.MaxAge = Convert.ToInt64(Math.Floor((Options.MaxAge.Value).TotalSeconds)) .ToString(CultureInfo.InvariantCulture); } diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index f6d914731..a40d37435 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -84,9 +84,9 @@ public override void Validate() { base.Validate(); - if (MaxAge != null && MaxAge.Value < TimeSpan.Zero) + if (MaxAge.HasValue && MaxAge.Value < TimeSpan.Zero) { - throw new InvalidOperationException("MaxAge must not be a negative TimeSpan."); + throw new ArgumentOutOfRangeException(nameof(MaxAge), MaxAge.Value, "The value must not be a negative TimeSpan."); } if (string.IsNullOrEmpty(ClientId)) @@ -169,7 +169,7 @@ public override void Validate() /// provider has not actively authenticated the user within the length of time specified, the user will be prompted to /// re-authenticate. By default no max_age is specified. /// - public TimeSpan? MaxAge { get; set; } = null; + public TimeSpan? MaxAge { get; set; } /// /// Gets or sets the that is used to ensure that the 'id_token' received diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index 4ff5aa9ad..7ab81c9dd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -414,8 +414,8 @@ public async Task Challenge_WithEmptyConfig_Fails() public async Task Challenge_WithDefaultMaxAge_HasExpectedMaxAgeParam() { var settings = new TestSettings( - opt => - { + opt => + { opt.ClientId = "Test Id"; opt.Authority = TestServerBuilder.DefaultAuthority; }); @@ -434,8 +434,8 @@ public async Task Challenge_WithDefaultMaxAge_HasExpectedMaxAgeParam() public async Task Challenge_WithSpecificMaxAge_HasExpectedMaxAgeParam() { var settings = new TestSettings( - opt => - { + opt => + { opt.ClientId = "Test Id"; opt.Authority = TestServerBuilder.DefaultAuthority; opt.MaxAge = TimeSpan.FromMinutes(20); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 871ef9d08..69ba75829 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -118,7 +118,7 @@ public Task ThrowsWhenMetadataAddressIsNotHttps() [Fact] public Task ThrowsWhenMaxAgeIsNegative() { - return TestConfigurationException( + return TestConfigurationException( o => { o.SignInScheme = "TestScheme"; @@ -126,7 +126,7 @@ public Task ThrowsWhenMaxAgeIsNegative() o.Authority = TestServerBuilder.DefaultAuthority; o.MaxAge = TimeSpan.FromSeconds(-1); }, - ex => Assert.Equal("MaxAge must not be a negative TimeSpan.", ex.Message) + ex => Assert.StartsWith("The value must not be a negative TimeSpan.", ex.Message) ); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 5b4ea2348..f174342ae 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -4,14 +4,12 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Globalization; using System.Linq; using System.Reflection; using System.Text; using System.Text.Encodings.Web; using System.Xml.Linq; using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.TestHost; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Xunit; @@ -270,10 +268,10 @@ private void ValidatePostLogoutRedirectUri(IDictionary actualPar private void ValidateMaxAge(IDictionary actualQuery, ICollection errors, bool htmlEncoded) { - if(_options.MaxAge != null) + if(_options.MaxAge.HasValue) { - string expectedMaxAge = Convert.ToInt64(Math.Floor(((TimeSpan)_options.MaxAge).TotalSeconds)) - .ToString(CultureInfo.InvariantCulture); + Assert.Equal(TimeSpan.FromMinutes(20), _options.MaxAge.Value); + string expectedMaxAge = "1200"; ValidateParameter(OpenIdConnectParameterNames.MaxAge, expectedMaxAge, actualQuery, errors, htmlEncoded); } else if(actualQuery.ContainsKey(OpenIdConnectParameterNames.MaxAge)) From e0ad6ed6b9abbb73e3ca68c6abdf2a0126defec1 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 20 Sep 2017 13:23:33 -0700 Subject: [PATCH 096/248] Update bootstrappers --- .appveyor.yml | 4 +- build.cmd | 2 +- build.sh | 197 +------------------------------------- run.cmd | 2 + build.ps1 => run.ps1 | 56 +++++++---- run.sh | 223 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 266 insertions(+), 218 deletions(-) create mode 100644 run.cmd rename build.ps1 => run.ps1 (73%) create mode 100755 run.sh diff --git a/.appveyor.yml b/.appveyor.yml index 4f85bae46..c7b6e3431 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true branches: only: @@ -8,7 +8,7 @@ branches: - /^(.*\/)?ci-.*$/ - /^rel\/.*/ build_script: - - ps: .\build.ps1 + - ps: .\run.ps1 default-build clone_depth: 1 environment: global: diff --git a/build.cmd b/build.cmd index b6c8d2486..c0050bda1 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh index 11cdbe550..98a4b2276 100755 --- a/build.sh +++ b/build.sh @@ -1,199 +1,8 @@ #!/usr/bin/env bash set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -config_file="$DIR/version.xml" -verbose=false -update=false -repo_path="$DIR" -channel='' -tools_source='' - -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo "" - echo "Description:" - echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}$*${RESET}" 1>&2 -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} - -# -# main -# - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -if [ -f "$config_file" ]; then - comment=false - while __read_dom; do - if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi - if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi - if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi - if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < "$config_file" -fi - -[ -z "$channel" ] && channel='dev' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' -get_korebuild -install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" "$@" +# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) +chmod +x "$DIR/run.sh"; sync +"$DIR/run.sh" default-build "$@" diff --git a/run.cmd b/run.cmd new file mode 100644 index 000000000..d52d5c7e6 --- /dev/null +++ b/run.cmd @@ -0,0 +1,2 @@ +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/run.ps1 similarity index 73% rename from build.ps1 rename to run.ps1 index d5eb4d5cf..49c289985 100644 --- a/build.ps1 +++ b/run.ps1 @@ -3,10 +3,13 @@ <# .SYNOPSIS -Build this repository +Executes KoreBuild commands. .DESCRIPTION -Downloads korebuild if required. Then builds the repository. +Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. + +.PARAMETER Command +The KoreBuild command to run. .PARAMETER Path The folder to build. Defaults to the folder containing this script. @@ -24,31 +27,32 @@ The base url where build tools can be downloaded. Overrides the value from the c Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to version.xml. +The path to the configuration file that stores values. Defaults to korebuild.json. -.PARAMETER MSBuildArgs -Arguments to be passed to MSBuild +.PARAMETER Arguments +Arguments to be passed to the command .NOTES This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. -The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. +The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set +in the file are overridden by command line parameters. .EXAMPLE Example config file: -```xml - - - - dev - https://aspnetcore.blob.core.windows.net/buildtools - - +```json +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev", + "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" +} ``` #> [CmdletBinding(PositionalBinding = $false)] param( + [Parameter(Mandatory=$true, Position = 0)] + [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] [string]$Channel, @@ -58,9 +62,9 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [string]$ConfigFile, [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$MSBuildArgs + [string[]]$Arguments ) Set-StrictMode -Version 2 @@ -147,10 +151,20 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { # Load configuration or set defaults +$Path = Resolve-Path $Path +if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } + if (Test-Path $ConfigFile) { - [xml] $config = Get-Content $ConfigFile - if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } - if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } + try { + $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json + if ($config) { + if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } + if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} + } + } catch { + Write-Warning "$ConfigFile could not be read. Its settings will be ignored." + Write-Warning $Error[0] + } } if (!$DotNetHome) { @@ -169,8 +183,8 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Install-Tools $ToolsSource $DotNetHome - Invoke-RepositoryBuild $Path @MSBuildArgs + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Invoke-KoreBuildCommand $Command @Arguments } finally { Remove-Module 'KoreBuild' -ErrorAction Ignore diff --git a/run.sh b/run.sh new file mode 100755 index 000000000..c278423ac --- /dev/null +++ b/run.sh @@ -0,0 +1,223 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# +# variables +# + +RESET="\033[0m" +RED="\033[0;31m" +YELLOW="\033[0;33m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' + +# +# Functions +# +__usage() { + echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " command The command to be run." + echo " ... Arguments passed to the command. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." + + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 + fi +} + +get_korebuild() { + local version + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + fi + version="$(grep 'version:*' -m 1 "$lock_file")" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" + fi + rm "$tmpfile" || true + fi + + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}error: $*${RESET}" 1>&2 +} + +__warn() { + echo -e "${YELLOW}warning: $*${RESET}" +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp "$remote_path" "$local_path" + return 0 + fi + + local failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true + fi + + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + fi + + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 + fi +} + +# +# main +# + +command="${1:-}" +shift + +while [[ $# -gt 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel="${1:-}" + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + if [ ! -f "$config_file" ]; then + __error "Invalid value for --config-file. $config_file does not exist." + exit 1 + fi + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME="${1:-}" + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 +fi + +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" +if [ -f "$config_file" ]; then + if __machine_has jq ; then + if jq '.' "$config_file" >/dev/null ; then + config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" + config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + elif __machine_has python ; then + if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then + config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" + config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + else + __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' + fi + + [ ! -z "${config_channel:-}" ] && channel="$config_channel" + [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +invoke_korebuild_command "$command" "$@" From 02cd997e3258a4e928a2cf1cf28f7ccae66ec635 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 10 Oct 2017 13:51:07 -0700 Subject: [PATCH 097/248] Add Validate(scheme) and use for RemoteSignInScheme not self validation --- .../AuthenticationBuilder.cs | 4 ---- .../AuthenticationHandler.cs | 2 +- .../AuthenticationSchemeOptions.cs | 11 ++++++++--- .../RemoteAuthenticationOptions.cs | 13 +++++++++++++ .../FacebookTests.cs | 16 +++++++++++++--- .../OAuthTests.cs | 3 +++ 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs index 54b481885..3bce55ea1 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -97,10 +97,6 @@ public EnsureSignInScheme(IOptions authOptions) public void PostConfigure(string name, TOptions options) { options.SignInScheme = options.SignInScheme ?? _authOptions.DefaultSignInScheme ?? _authOptions.DefaultScheme; - if (string.Equals(options.SignInScheme, name, StringComparison.Ordinal)) - { - throw new InvalidOperationException(Resources.Exception_RemoteSignInSchemeCannotBeSelf); - } } } } diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 812ba2f1a..9728e5ff0 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -87,7 +87,7 @@ public async Task InitializeAsync(AuthenticationScheme scheme, HttpContext conte Context = context; Options = OptionsMonitor.Get(Scheme.Name) ?? new TOptions(); - Options.Validate(); + Options.Validate(Scheme.Name); await InitializeEventsAsync(); await InitializeHandlerAsync(); diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs index 0e86b3a9f..18d4c9788 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -13,9 +13,14 @@ public class AuthenticationSchemeOptions /// /// Check that the options are valid. Should throw an exception if things are not ok. /// - public virtual void Validate() - { - } + public virtual void Validate() { } + + /// + /// Checks that the options are valid for a specific scheme + /// + /// The scheme being validated. + public virtual void Validate(string scheme) + => Validate(); /// /// Gets or sets the issuer that should be used for any claims that are created diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 3b34cf43e..daba1890f 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -32,6 +32,19 @@ public RemoteAuthenticationOptions() }; } + /// + /// Checks that the options are valid for a specific scheme + /// + /// The scheme being validated. + public override void Validate(string scheme) + { + base.Validate(scheme); + if (string.Equals(scheme, SignInScheme, StringComparison.Ordinal)) + { + throw new InvalidOperationException(Resources.Exception_RemoteSignInSchemeCannotBeSelf); + } + } + /// /// Check that the options are valid. Should throw an exception if things are not ok. /// diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 81373403b..2314b6b3c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -29,7 +29,11 @@ public async Task VerifySignInSchemeCannotBeSetToSelf() { var server = CreateServer( app => { }, - services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = FacebookDefaults.AuthenticationScheme), + services => services.AddAuthentication().AddFacebook(o => { + o.AppId = "whatever"; + o.AppSecret = "whatever"; + o.SignInScheme = FacebookDefaults.AuthenticationScheme; + }), context => { // Gross @@ -45,7 +49,10 @@ public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultScheme() { var server = CreateServer( app => { }, - services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(), + services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => { + o.AppId = "whatever"; + o.AppSecret = "whatever"; + }), context => { // Gross @@ -61,7 +68,10 @@ public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultSignInScheme() { var server = CreateServer( app => { }, - services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(), + services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => { + o.AppId = "whatever"; + o.AppSecret = "whatever"; + }), context => { // Gross diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 81d2360ec..65d865b94 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -27,6 +27,9 @@ public async Task VerifySignInSchemeCannotBeSetToSelf() o.SignInScheme = "weeblie"; o.ClientId = "whatever"; o.ClientSecret = "whatever"; + o.CallbackPath = "/whatever"; + o.AuthorizationEndpoint = "/whatever"; + o.TokenEndpoint = "/whatever"; })); var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/")); Assert.Contains("cannot be set to itself", error.Message); From bd07f8b683ce793490d108b2310fa6112953d172 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 11 Oct 2017 12:40:15 -0700 Subject: [PATCH 098/248] #1353 use a compliant Expires header value for expiration. --- .../CookieAuthenticationHandler.cs | 4 ++-- .../OpenIdConnectHandler.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 754c91f1e..5d0afba46 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -20,7 +20,7 @@ public class CookieAuthenticationHandler : IAuthenticationSignOutHandler { private const string HeaderValueNoCache = "no-cache"; - private const string HeaderValueMinusOne = "-1"; + private const string HeaderValueEpocDate = "Thu, 01 Jan 1970 00:00:00 GMT"; private const string SessionIdClaim = "Microsoft.AspNetCore.Authentication.Cookies-SessionId"; private bool _shouldRefresh; @@ -359,7 +359,7 @@ private async Task ApplyHeaders(bool shouldRedirectToReturnUrl, AuthenticationPr { Response.Headers[HeaderNames.CacheControl] = HeaderValueNoCache; Response.Headers[HeaderNames.Pragma] = HeaderValueNoCache; - Response.Headers[HeaderNames.Expires] = HeaderValueMinusOne; + Response.Headers[HeaderNames.Expires] = HeaderValueEpocDate; if (shouldRedirectToReturnUrl && Response.StatusCode == 200) { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 330d064c0..7981cafd1 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -32,6 +32,7 @@ public class OpenIdConnectHandler : RemoteAuthenticationHandler"; private const string HtmlFormFormat = @" @@ -261,7 +262,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) // Emit Cache-Control=no-cache to prevent client caching. Response.Headers[HeaderNames.CacheControl] = "no-cache"; Response.Headers[HeaderNames.Pragma] = "no-cache"; - Response.Headers[HeaderNames.Expires] = "-1"; + Response.Headers[HeaderNames.Expires] = HeaderValueEpocDate; await Response.Body.WriteAsync(buffer, 0, buffer.Length); } @@ -442,7 +443,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // Emit Cache-Control=no-cache to prevent client caching. Response.Headers[HeaderNames.CacheControl] = "no-cache"; Response.Headers[HeaderNames.Pragma] = "no-cache"; - Response.Headers[HeaderNames.Expires] = "-1"; + Response.Headers[HeaderNames.Expires] = HeaderValueEpocDate; await Response.Body.WriteAsync(buffer, 0, buffer.Length); return; From 824539f47ac7f57a824092b04795e25198e1438f Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 11 Oct 2017 16:10:24 -0700 Subject: [PATCH 099/248] #1349 Don't throw for partial cookies --- .../ChunkingCookieManager.cs | 1 - src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs | 1 - .../CookieChunkingTests.cs | 3 ++- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs index 9b602383c..7217e70d4 100644 --- a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -44,7 +44,6 @@ public ChunkingCookieManager() // See http://browsercookielimits.x64.me/. // Leave at least 40 in case CookiePolicy tries to add 'secure', 'samesite=strict' and/or 'httponly'. ChunkSize = DefaultChunkSize; - ThrowForPartialCookies = true; } /// diff --git a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs index b323258d9..1ae4f00cd 100644 --- a/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs +++ b/src/Microsoft.Owin.Security.Interop/ChunkingCookieManager.cs @@ -25,7 +25,6 @@ public ChunkingCookieManager() // See http://browsercookielimits.x64.me/. // Leave at least 20 in case CookiePolicy tries to add 'secure' and/or 'httponly'. ChunkSize = 4070; - ThrowForPartialCookies = true; } /// diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs index 69ead8fa6..e645745b3 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/CookieChunkingTests.cs @@ -81,7 +81,8 @@ public void GetLargeChunkedCookieWithMissingChunk_ThrowingEnabled_Throws() "TestCookieC7=STUVWXYZ" }; - Assert.Throws(() => new ChunkingCookieManager().GetRequestCookie(context, "TestCookie")); + Assert.Throws(() => new ChunkingCookieManager() { ThrowForPartialCookies = true } + .GetRequestCookie(context, "TestCookie")); } [Fact] From a2a86ffc782d94ac3e54b66d3889b2d4259b3989 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Oct 2017 12:52:41 -0700 Subject: [PATCH 100/248] Add RepositoryRoot --- Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2490e4244..61b629ccc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,11 @@ - + Microsoft ASP.NET Core https://github.com/aspnet/Security git + $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true true From 794e9c79fd15ccd550737c6ee41dc96722a303f2 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 19 Oct 2017 12:38:15 -0700 Subject: [PATCH 101/248] Update cookie doc comments --- .../CookieAuthenticationOptions.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 0f2dbd312..04c71ed1e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -80,11 +80,10 @@ public CookieBuilder Cookie public bool SlidingExpiration { get; set; } /// - /// The LoginPath property informs the handler that it should change an outgoing 401 Unauthorized status - /// code into a 302 redirection onto the given login path. The current url which generated the 401 is added - /// to the LoginPath as a query string parameter named by the ReturnUrlParameter. Once a request to the - /// LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect the browser back - /// to the url which caused the original unauthorized status code. + /// The LoginPath property is used by the handler for the redirection target when handling ChallengeAsync. + /// The current url which is added to the LoginPath as a query string parameter named by the ReturnUrlParameter. + /// Once a request to the LoginPath grants a new SignIn identity, the ReturnUrlParameter value is used to redirect + /// the browser back to the original url. /// public PathString LoginPath { get; set; } @@ -94,16 +93,14 @@ public CookieBuilder Cookie public PathString LogoutPath { get; set; } /// - /// The AccessDeniedPath property informs the handler that it should change an outgoing 403 Forbidden status - /// code into a 302 redirection onto the given path. + /// The AccessDeniedPath property is used by the handler for the redirection target when handling ForbidAsync. /// public PathString AccessDeniedPath { get; set; } /// /// The ReturnUrlParameter determines the name of the query string parameter which is appended by the handler - /// when a 401 Unauthorized status code is changed to a 302 redirect onto the login path. This is also the query - /// string parameter looked for when a request arrives on the login path or logout path, in order to return to the - /// original url after the action is performed. + /// when during a Challenge. This is also the query string parameter looked for when a request arrives on the + /// login path or logout path, in order to return to the original url after the action is performed. /// public string ReturnUrlParameter { get; set; } From 88cb3df0ebdd524a8c56e74b740296941947fdff Mon Sep 17 00:00:00 2001 From: tstojecki Date: Tue, 31 Oct 2017 17:27:07 +0100 Subject: [PATCH 102/248] Added support for multiple values (arrays) in default claim action (#1501) * Added support for multiple values (arrays) in default claim action * Added tests to claim action update to support array values --- .../Claims/JsonKeyClaimAction.cs | 17 +++++- .../ClaimActionTests.cs | 55 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs index e628904de..ccd1a965d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/JsonKeyClaimAction.cs @@ -32,7 +32,22 @@ public JsonKeyClaimAction(string claimType, string valueType, string jsonKey) /// public override void Run(JObject userData, ClaimsIdentity identity, string issuer) { - var value = userData?.Value(JsonKey); + var value = userData?[JsonKey]; + if (value is JValue) + { + AddClaim(value?.ToString(), identity, issuer); + } + else if (value is JArray) + { + foreach (var v in value) + { + AddClaim(v?.ToString(), identity, issuer); + } + } + } + + private void AddClaim(string value, ClaimsIdentity identity, string issuer) + { if (!string.IsNullOrEmpty(value)) { identity.AddClaim(new Claim(ClaimType, value, ValueType, issuer)); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs new file mode 100644 index 000000000..541e1edf2 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs @@ -0,0 +1,55 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Linq; +using System.Security.Claims; +using Microsoft.AspNetCore.Testing.xunit; +using Xunit; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication +{ + public class ClaimActionTests + { + [Fact] + public void CanMapSingleValueUserDataToClaim() + { + var userData = new JObject + { + ["name"] = "test" + }; + + var identity = new ClaimsIdentity(); + + var action = new JsonKeyClaimAction("name", "name", "name"); + action.Run(userData, identity, "iss"); + + Assert.Equal("name", identity.FindFirst("name").Type); + Assert.Equal("test", identity.FindFirst("name").Value); + } + + [Fact] + public void CanMapArrayValueUserDataToClaims() + { + var userData = new JObject + { + ["role"] = new JArray { "role1", "role2" } + }; + + var identity = new ClaimsIdentity(); + + var action = new JsonKeyClaimAction("role", "role", "role"); + action.Run(userData, identity, "iss"); + + var roleClaims = identity.FindAll("role").ToList(); + Assert.Equal(2, roleClaims.Count); + Assert.Equal("role", roleClaims[0].Type); + Assert.Equal("role1", roleClaims[0].Value); + Assert.Equal("role", roleClaims[1].Type); + Assert.Equal("role2", roleClaims[1].Value); + } + } +} From 00c92101575c7c035efe4a23a4d9eeda43afd41d Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 26 Oct 2017 11:56:16 -0700 Subject: [PATCH 103/248] Refactor OIDC event tests --- .../OpenIdConnect/OpenIdConnectEventTests.cs | 2006 ++++++----------- 1 file changed, 701 insertions(+), 1305 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index 87bdc3f3c..7530b00c3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -28,67 +28,44 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { public class OpenIdConnectEventTests { - private readonly Func MessageNotImpl = context => { throw new NotImplementedException("Message"); }; - private readonly Func TokenNotImpl = context => { throw new NotImplementedException("Token"); }; - private readonly Func CodeNotImpl = context => { throw new NotImplementedException("Code"); }; - private readonly Func TokenResponseNotImpl = context => { throw new NotImplementedException("TokenResponse"); }; - private readonly Func UserNotImpl = context => { throw new NotImplementedException("User"); }; - private readonly Func FailedNotImpl = context => { throw new NotImplementedException("Failed", context.Exception); }; - private readonly Func TicketNotImpl = context => { throw new NotImplementedException("Ticket"); }; - private readonly Func FailureNotImpl = context => { throw new NotImplementedException("Failure", context.Failure); }; - private readonly Func RedirectNotImpl = context => { throw new NotImplementedException("Redirect"); }; - private readonly Func RemoteSignOutNotImpl = context => { throw new NotImplementedException("Remote"); }; - private readonly Func SignedOutCallbackNotImpl = context => { throw new NotImplementedException("SingedOut"); }; + private readonly RequestDelegate AppWritePath = context => context.Response.WriteAsync(context.Request.Path); private readonly RequestDelegate AppNotImpl = context => { throw new NotImplementedException("App"); }; [Fact] public async Task OnMessageReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + }; + events.OnMessageReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", ""); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); + events.ValidateExpectations(); } [Fact] public async Task OnMessageReceived_Fail_NoMoreEventsRun() { - var messageReceived = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectRemoteFailure = true, + }; + events.OnMessageReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -96,95 +73,68 @@ public async Task OnMessageReceived_Fail_NoMoreEventsRun() }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnMessageReceived_Handled_NoMoreEventsRun() { - var messageReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + }; + events.OnMessageReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", ""); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidated_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + }; + events.OnTokenValidated = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidated_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectRemoteFailure = true, + }; + events.OnTokenValidated = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -192,156 +142,108 @@ public async Task OnTokenValidated_Fail_NoMoreEventsRun() }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidated_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.HandleResponse(); - context.Principal = null; - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + }; + events.OnTokenValidated = context => + { + context.HandleResponse(); + context.Principal = null; + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); + events.ValidateExpectations(); } - // TODO: Do any other events depend on the presence of the ticket? It's strange we have to double handle this event. [Fact] public async Task OnTokenValidated_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var ticketReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectTicketReceived = true, + }; + events.OnTokenValidated = context => + { + context.HandleResponse(); + context.Principal = null; + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + events.OnTokenValidated = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnAuthorizationCodeReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + }; + events.OnAuthorizationCodeReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); + events.ValidateExpectations(); } [Fact] public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectRemoteFailure = true, + }; + events.OnAuthorizationCodeReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -349,183 +251,105 @@ public async Task OnAuthorizationCodeReceived_Fail_NoMoreEventsRun() }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnAuthorizationCodeReceived_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - context.HandleResponse(); - context.Principal = null; - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + }; + events.OnAuthorizationCodeReceived = context => + { + context.HandleResponse(); + context.Principal = null; + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); + events.ValidateExpectations(); } [Fact] public async Task OnAuthorizationCodeReceived_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var ticketReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTicketReceived = true, + }; + events.OnAuthorizationCodeReceived = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenResponseReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + }; + events.OnTokenResponseReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + var events = new ExpectedOidcEvents() { - return context.Response.WriteAsync(context.Request.Path); - }); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectRemoteFailure = true, + }; + events.OnTokenResponseReceived = context => + { + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -533,198 +357,107 @@ public async Task OnTokenResponseReceived_Fail_NoMoreEventsRun() }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnTokenResponseReceived_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - context.Principal = null; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + }; + events.OnTokenResponseReceived = context => + { + context.Principal = null; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenResponseReceived_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var ticketReceived = false; - var tokenResponseReceived = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectTicketReceived = true, + }; + events.OnTokenResponseReceived = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidatedBackchannel_Skip_NoMoreEventsRun() { - var messageReceived = false; - var codeReceived = false; - var tokenResponseReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + }; + events.OnTokenValidated = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(tokenValidated); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() { - var messageReceived = false; - var codeReceived = false; - var tokenResponseReceived = false; - var tokenValidated = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + var events = new ExpectedOidcEvents() { - return context.Response.WriteAsync(context.Request.Path); - }); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectRemoteFailure = true, + }; + events.OnTokenValidated = context => + { + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -732,211 +465,109 @@ public async Task OnTokenValidatedBackchannel_Fail_NoMoreEventsRun() }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(tokenValidated); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidatedBackchannel_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var codeReceived = false; - var tokenResponseReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Principal = null; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + }; + events.OnTokenValidated = context => + { + context.Principal = null; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(tokenValidated); + events.ValidateExpectations(); } [Fact] public async Task OnTokenValidatedBackchannel_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var codeReceived = false; - var ticketReceived = false; - var tokenResponseReceived = false; - var tokenValidated = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectTicketReceived = true, + }; + events.OnTokenValidated = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(tokenValidated); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnUserInformationReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + var events = new ExpectedOidcEvents() { - return context.Response.WriteAsync(context.Request.Path); - }); + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + }; + events.OnUserInformationReceived = context => + { + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); + events.ValidateExpectations(); } [Fact] public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectRemoteFailure = true, + }; + events.OnUserInformationReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -944,242 +575,123 @@ public async Task OnUserInformationReceived_Fail_NoMoreEventsRun() }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnUserInformationReceived_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - context.Principal = null; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + }; + events.OnUserInformationReceived = context => + { + context.Principal = null; + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); + events.ValidateExpectations(); } [Fact] public async Task OnUserInformationReceived_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var ticketReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - // context.Ticket = null; - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectTicketReceived = true, + }; + events.OnUserInformationReceived = context => + { + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnAuthenticationFailed_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + }; + events.OnUserInformationReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); + events.ValidateExpectations(); } [Fact] public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - context.Fail("Authentication was aborted from user code."); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - return Task.FromResult(0); - }; - }), - context => + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + ExpectRemoteFailure = true, + }; + events.OnUserInformationReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + context.Fail("Authentication was aborted from user code."); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var exception = await Assert.ThrowsAsync(delegate { @@ -1187,420 +699,222 @@ public async Task OnAuthenticationFailed_Fail_NoMoreEventsRun() }); Assert.Equal("Authentication was aborted from user code.", exception.InnerException.Message); - - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnAuthenticationFailed_HandledWithoutTicket_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - Assert.Null(context.Principal); - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + }; + events.OnUserInformationReceived = context => + { + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + Assert.Null(context.Principal); + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); + events.ValidateExpectations(); } [Fact] public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var ticketReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - Assert.Null(context.Principal); + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + ExpectTicketReceived = true, + }; + events.OnUserInformationReceived = context => + { + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + Assert.Null(context.Principal); - var claims = new[] - { - new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), - new Claim(ClaimTypes.Email, "bob@contoso.com"), - new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") - }; - - context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); - context.Success(); - return Task.FromResult(0); - }; - events.OnTicketReceived = context => + var claims = new[] { - ticketReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); + new Claim(ClaimTypes.NameIdentifier, "Bob le Magnifique"), + new Claim(ClaimTypes.Email, "bob@contoso.com"), + new Claim(ClaimsIdentity.DefaultNameClaimType, "bob") }; - }), - AppNotImpl); + + context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); + context.Success(); + return Task.FromResult(0); + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); - Assert.True(ticketReceived); + events.ValidateExpectations(); } [Fact] public async Task OnRemoteFailure_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - Assert.Equal("TestException", context.Failure.Message); - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + ExpectRemoteFailure = true, + }; + events.OnUserInformationReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + throw new NotImplementedException("TestException"); + }; + events.OnAuthenticationFailed = context => + { + Assert.Equal("TestException", context.Exception.Message); + return Task.FromResult(0); + }; + events.OnRemoteFailure = context => + { + Assert.Equal("TestException", context.Failure.Message); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnRemoteFailure_Handled_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var authFailed = false; - var remoteFailure = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - throw new NotImplementedException("TestException"); - }; - events.OnAuthenticationFailed = context => - { - authFailed = true; - Assert.Equal("TestException", context.Exception.Message); - return Task.FromResult(0); - }; - events.OnRemoteFailure = context => - { - remoteFailure = true; - Assert.Equal("TestException", context.Failure.Message); - Assert.Equal("testvalue", context.Properties.Items["testkey"]); - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectAuthenticationFailed = true, + ExpectRemoteFailure = true, + }; + events.OnUserInformationReceived = context => + { + throw new NotImplementedException("TestException"); + }; + events.OnRemoteFailure = context => + { + Assert.Equal("TestException", context.Failure.Message); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(authFailed); - Assert.True(remoteFailure); + events.ValidateExpectations(); } [Fact] public async Task OnTicketReceived_Skip_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var ticektReceived = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticektReceived = true; - context.SkipHandler(); - return Task.FromResult(0); - }; - }), - context => + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectTicketReceived = true, + }; + events.OnTicketReceived = context => { - return context.Response.WriteAsync(context.Request.Path); - }); + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(ticektReceived); + events.ValidateExpectations(); } [Fact] public async Task OnTicketReceived_Handled_NoMoreEventsRun() { - var messageReceived = false; - var tokenValidated = false; - var codeReceived = false; - var tokenResponseReceived = false; - var userInfoReceived = false; - var ticektReceived = false; - var server = CreateServer(CreateNotImpEvents(events => - { - events.OnMessageReceived = context => - { - messageReceived = true; - return Task.FromResult(0); - }; - events.OnTokenValidated = context => - { - tokenValidated = true; - return Task.FromResult(0); - }; - events.OnAuthorizationCodeReceived = context => - { - codeReceived = true; - return Task.FromResult(0); - }; - events.OnTokenResponseReceived = context => - { - tokenResponseReceived = true; - return Task.FromResult(0); - }; - events.OnUserInformationReceived = context => - { - userInfoReceived = true; - return Task.FromResult(0); - }; - events.OnTicketReceived = context => - { - ticektReceived = true; - context.HandleResponse(); - context.Response.StatusCode = StatusCodes.Status202Accepted; - return Task.FromResult(0); - }; - }), - AppNotImpl); + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectTokenValidated = true, + ExpectAuthorizationCodeReceived = true, + ExpectTokenResponseReceived = true, + ExpectUserInfoReceived = true, + ExpectTicketReceived = true, + }; + events.OnTicketReceived = context => + { + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); var response = await PostAsync(server, "signin-oidc", "id_token=my_id_token&state=protected_state&code=my_code"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Equal("", await response.Content.ReadAsStringAsync()); - Assert.True(messageReceived); - Assert.True(tokenValidated); - Assert.True(codeReceived); - Assert.True(tokenResponseReceived); - Assert.True(userInfoReceived); - Assert.True(ticektReceived); + events.ValidateExpectations(); } [Fact] public async Task OnRedirectToIdentityProviderForSignOut_Invoked() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRedirectToIdentityProviderForSignOut = context => - { - forSignOut = true; - return Task.CompletedTask; - }; - }), + ExpectRedirectForSignOut = true, + }; + var server = CreateServer(events, context => { return context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); @@ -1611,23 +925,23 @@ public async Task OnRedirectToIdentityProviderForSignOut_Invoked() Assert.Equal(HttpStatusCode.Found, response.StatusCode); Assert.Equal("http://testhost/end", response.Headers.Location.GetLeftPart(UriPartial.Path)); - Assert.True(forSignOut); + events.ValidateExpectations(); } [Fact] public async Task OnRedirectToIdentityProviderForSignOut_Handled_RedirectNotInvoked() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRedirectToIdentityProviderForSignOut = context => - { - forSignOut = true; - context.Response.StatusCode = StatusCodes.Status202Accepted; - context.HandleResponse(); - return Task.CompletedTask; - }; - }), + ExpectRedirectForSignOut = true, + }; + events.OnRedirectToIdentityProviderForSignOut = context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + var server = CreateServer(events, context => { return context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); @@ -1638,28 +952,23 @@ public async Task OnRedirectToIdentityProviderForSignOut_Handled_RedirectNotInvo Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Null(response.Headers.Location); - Assert.True(forSignOut); + events.ValidateExpectations(); } [Fact] public async Task OnRemoteSignOut_Invoked() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRemoteSignOut = context => - { - forSignOut = true; - return Task.CompletedTask; - }; - }), - AppNotImpl); + ExpectRemoteSignOut = true, + }; + var server = CreateServer(events, AppNotImpl); var client = server.CreateClient(); var response = await client.GetAsync("/signout-oidc"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.True(forSignOut); + events.ValidateExpectations(); Assert.True(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); Assert.True(SetCookieHeaderValue.TryParseStrictList(values.ToList(), out var parsedValues)); Assert.Equal(1, parsedValues.Count); @@ -1669,41 +978,39 @@ public async Task OnRemoteSignOut_Invoked() [Fact] public async Task OnRemoteSignOut_Handled_NoSignout() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRemoteSignOut = context => - { - forSignOut = true; - context.Response.StatusCode = StatusCodes.Status202Accepted; - context.HandleResponse(); - return Task.CompletedTask; - }; - }), - AppNotImpl); + ExpectRemoteSignOut = true, + }; + events.OnRemoteSignOut = context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + var server = CreateServer(events, AppNotImpl); var client = server.CreateClient(); var response = await client.GetAsync("/signout-oidc"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); - Assert.True(forSignOut); + events.ValidateExpectations(); Assert.False(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); } [Fact] public async Task OnRemoteSignOut_Skip_NoSignout() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnRemoteSignOut = context => - { - forSignOut = true; - context.SkipHandler(); - return Task.CompletedTask; - }; - }), - context => + ExpectRemoteSignOut = true, + }; + events.OnRemoteSignOut = context => + { + context.SkipHandler(); + return Task.CompletedTask; + }; + var server = CreateServer(events, context => { context.Response.StatusCode = StatusCodes.Status202Accepted; return Task.CompletedTask; @@ -1713,69 +1020,63 @@ public async Task OnRemoteSignOut_Skip_NoSignout() var response = await client.GetAsync("/signout-oidc"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); - Assert.True(forSignOut); + events.ValidateExpectations(); Assert.False(response.Headers.TryGetValues(HeaderNames.SetCookie, out var values)); } [Fact] public async Task OnRedirectToSignedOutRedirectUri_Invoked() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnSignedOutCallbackRedirect = context => - { - forSignOut = true; - return Task.CompletedTask; - }; - }), - AppNotImpl); + ExpectRedirectToSignedOut = true, + }; + var server = CreateServer(events, AppNotImpl); var client = server.CreateClient(); var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); Assert.Equal(HttpStatusCode.Found, response.StatusCode); Assert.Equal("http://testhost/redirect", response.Headers.Location.AbsoluteUri); - Assert.True(forSignOut); + events.ValidateExpectations(); } [Fact] public async Task OnRedirectToSignedOutRedirectUri_Handled_NoRedirect() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnSignedOutCallbackRedirect = context => - { - forSignOut = true; - context.Response.StatusCode = StatusCodes.Status202Accepted; - context.HandleResponse(); - return Task.CompletedTask; - }; - }), - AppNotImpl); + ExpectRedirectToSignedOut = true, + }; + events.OnSignedOutCallbackRedirect = context => + { + context.Response.StatusCode = StatusCodes.Status202Accepted; + context.HandleResponse(); + return Task.CompletedTask; + }; + var server = CreateServer(events, AppNotImpl); var client = server.CreateClient(); var response = await client.GetAsync("/signout-callback-oidc?state=protected_state"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Null(response.Headers.Location); - Assert.True(forSignOut); + events.ValidateExpectations(); } [Fact] public async Task OnRedirectToSignedOutRedirectUri_Skipped_NoRedirect() { - var forSignOut = false; - var server = CreateServer(CreateNotImpEvents(events => + var events = new ExpectedOidcEvents() { - events.OnSignedOutCallbackRedirect = context => - { - forSignOut = true; - context.SkipHandler(); - return Task.CompletedTask; - }; - }), + ExpectRedirectToSignedOut = true, + }; + events.OnSignedOutCallbackRedirect = context => + { + context.SkipHandler(); + return Task.CompletedTask; + }; + var server = CreateServer(events, context => { context.Response.StatusCode = StatusCodes.Status202Accepted; @@ -1787,29 +1088,124 @@ public async Task OnRedirectToSignedOutRedirectUri_Skipped_NoRedirect() Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.Null(response.Headers.Location); - Assert.True(forSignOut); + events.ValidateExpectations(); } - private OpenIdConnectEvents CreateNotImpEvents(Action configureEvents) + private class ExpectedOidcEvents : OpenIdConnectEvents { - var events = new OpenIdConnectEvents() - { - OnMessageReceived = MessageNotImpl, - OnTokenValidated = TokenNotImpl, - OnAuthorizationCodeReceived = CodeNotImpl, - OnTokenResponseReceived = TokenResponseNotImpl, - OnUserInformationReceived = UserNotImpl, - OnAuthenticationFailed = FailedNotImpl, - OnTicketReceived = TicketNotImpl, - OnRemoteFailure = FailureNotImpl, - - OnRedirectToIdentityProvider = RedirectNotImpl, - OnRedirectToIdentityProviderForSignOut = RedirectNotImpl, - OnRemoteSignOut = RemoteSignOutNotImpl, - OnSignedOutCallbackRedirect = SignedOutCallbackNotImpl, - }; - configureEvents(events); - return events; + public bool ExpectMessageReceived { get; set; } + public bool InvokedMessageReceived { get; set; } + + public bool ExpectTokenValidated { get; set; } + public bool InvokedTokenValidated { get; set; } + + public bool ExpectRemoteFailure { get; set; } + public bool InvokedRemoteFailure { get; set; } + + public bool ExpectTicketReceived { get; set; } + public bool InvokedTicketReceived { get; set; } + + public bool ExpectAuthorizationCodeReceived { get; set; } + public bool InvokedAuthorizationCodeReceived { get; set; } + + public bool ExpectTokenResponseReceived { get; set; } + public bool InvokedTokenResponseReceived { get; set; } + + public bool ExpectUserInfoReceived { get; set; } + public bool InvokedUserInfoReceived { get; set; } + + public bool ExpectAuthenticationFailed { get; set; } + public bool InvokeAuthenticationFailed { get; set; } + + public bool ExpectRedirectForSignOut { get; set; } + public bool InvokedRedirectForSignOut { get; set; } + + public bool ExpectRemoteSignOut { get; set; } + public bool InvokedRemoteSignOut { get; set; } + + public bool ExpectRedirectToSignedOut { get; set; } + public bool InvokedRedirectToSignedOut { get; set; } + + public override Task MessageReceived(MessageReceivedContext context) + { + InvokedMessageReceived = true; + return base.MessageReceived(context); + } + + public override Task TokenValidated(TokenValidatedContext context) + { + InvokedTokenValidated = true; + return base.TokenValidated(context); + } + + public override Task AuthorizationCodeReceived(AuthorizationCodeReceivedContext context) + { + InvokedAuthorizationCodeReceived = true; + return base.AuthorizationCodeReceived(context); + } + + public override Task TokenResponseReceived(TokenResponseReceivedContext context) + { + InvokedTokenResponseReceived = true; + return base.TokenResponseReceived(context); + } + + public override Task UserInformationReceived(UserInformationReceivedContext context) + { + InvokedUserInfoReceived = true; + return base.UserInformationReceived(context); + } + + public override Task AuthenticationFailed(AuthenticationFailedContext context) + { + InvokeAuthenticationFailed = true; + return base.AuthenticationFailed(context); + } + + public override Task TicketReceived(TicketReceivedContext context) + { + InvokedTicketReceived = true; + return base.TicketReceived(context); + } + + public override Task RemoteFailure(RemoteFailureContext context) + { + InvokedRemoteFailure = true; + return base.RemoteFailure(context); + } + + public override Task RedirectToIdentityProviderForSignOut(RedirectContext context) + { + InvokedRedirectForSignOut = true; + return base.RedirectToIdentityProviderForSignOut(context); + } + + public override Task RemoteSignOut(RemoteSignOutContext context) + { + InvokedRemoteSignOut = true; + return base.RemoteSignOut(context); + } + + public override Task SignedOutCallbackRedirect(RemoteSignOutContext context) + { + InvokedRedirectToSignedOut = true; + return base.SignedOutCallbackRedirect(context); + } + + public void ValidateExpectations() + { + Assert.Equal(ExpectMessageReceived, InvokedMessageReceived); + Assert.Equal(ExpectTokenValidated, InvokedTokenValidated); + Assert.Equal(ExpectAuthorizationCodeReceived, InvokedAuthorizationCodeReceived); + Assert.Equal(ExpectTokenResponseReceived, InvokedTokenResponseReceived); + Assert.Equal(ExpectUserInfoReceived, InvokedUserInfoReceived); + Assert.Equal(ExpectAuthenticationFailed, InvokeAuthenticationFailed); + Assert.Equal(ExpectTicketReceived, InvokedTicketReceived); + Assert.Equal(ExpectRemoteFailure, InvokedRemoteFailure); + Assert.Equal(ExpectRedirectForSignOut, InvokedRedirectForSignOut); + Assert.Equal(ExpectRemoteSignOut, InvokedRemoteSignOut); + Assert.Equal(ExpectRedirectToSignedOut, InvokedRedirectToSignedOut); + } } private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appCode) From bd8ecd02684d490ece96c484e1092386f3515dec Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Nov 2017 16:37:42 -0700 Subject: [PATCH 104/248] Pin tool and package versions to make builds more repeatable Part of aspnet/Universe#575 --- .gitignore | 1 - Directory.Build.props | 6 +-- Directory.Build.targets | 17 ++----- NuGet.config | 1 + build/dependencies.props | 46 +++++++++++++++++++ build/repo.props | 8 +++- korebuild-lock.txt | 2 + korebuild.json | 4 ++ samples/CookieSample/CookieSample.csproj | 12 ++--- .../CookieSessionSample.csproj | 12 ++--- .../JwtBearerSample/JwtBearerSample.csproj | 12 ++--- .../OpenIdConnect.AzureAdSample.csproj | 14 +++--- .../OpenIdConnectSample.csproj | 18 ++++---- samples/SocialSample/SocialSample.csproj | 18 ++++---- src/Directory.Build.props | 2 +- ...AspNetCore.Authentication.JwtBearer.csproj | 2 +- ...oft.AspNetCore.Authentication.OAuth.csproj | 2 +- ...etCore.Authentication.OpenIdConnect.csproj | 2 +- ...Microsoft.AspNetCore.Authentication.csproj | 16 +++---- ...oft.AspNetCore.Authorization.Policy.csproj | 4 +- .../Microsoft.AspNetCore.Authorization.csproj | 4 +- .../Microsoft.AspNetCore.CookiePolicy.csproj | 4 +- .../Microsoft.Owin.Security.Interop.csproj | 4 +- test/Directory.Build.props | 12 ++--- ...soft.AspNetCore.Authentication.Test.csproj | 2 +- ...osoft.AspNetCore.Authorization.Test.csproj | 6 +-- ....ChunkingCookieManager.Sources.Test.csproj | 2 +- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 4 +- ...icrosoft.Owin.Security.Interop.Test.csproj | 6 +-- version.props | 10 ++++ version.xml | 8 ---- 31 files changed, 155 insertions(+), 106 deletions(-) create mode 100644 build/dependencies.props create mode 100644 korebuild-lock.txt create mode 100644 korebuild.json create mode 100644 version.props delete mode 100644 version.xml diff --git a/.gitignore b/.gitignore index bac5b7505..d5717b3f3 100644 --- a/.gitignore +++ b/.gitignore @@ -30,4 +30,3 @@ project.lock.json /.vs/ .vscode/ global.json -korebuild-lock.txt diff --git a/Directory.Build.props b/Directory.Build.props index 61b629ccc..d277ef862 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,6 @@ - - + + + Microsoft ASP.NET Core @@ -9,7 +10,6 @@ $(MSBuildThisFileDirectory)build\Key.snk true true - $(VersionSuffix)-$(BuildNumber) true diff --git a/Directory.Build.targets b/Directory.Build.targets index bc118fd90..e83ff95e3 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,14 +1,5 @@ - - - - <_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh - <_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd - <_BootstrapperError> - Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'. - Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'. - - - - - + + + $(MicrosoftNETCoreApp20PackageVersion) + diff --git a/NuGet.config b/NuGet.config index 20060c934..4e8a1f6de 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,6 +3,7 @@ + diff --git a/build/dependencies.props b/build/dependencies.props new file mode 100644 index 000000000..13ed63da1 --- /dev/null +++ b/build/dependencies.props @@ -0,0 +1,46 @@ + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + + 2.1.0-preview1-15550 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 2.1.0-preview1-27498 + 3.14.1 + 5.2.0-preview1-408290725 + 2.0.0 + 15.3.0 + 3.0.1 + 3.0.1 + 3.0.1 + 10.0.1 + 0.7.0 + 2.3.0 + 2.3.0 + + + diff --git a/build/repo.props b/build/repo.props index 7866974bc..598c7f5a3 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,7 +1,11 @@  - - + + + + Internal.AspNetCore.Universe.Lineup + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json + diff --git a/korebuild-lock.txt b/korebuild-lock.txt new file mode 100644 index 000000000..36d805603 --- /dev/null +++ b/korebuild-lock.txt @@ -0,0 +1,2 @@ +version:2.1.0-preview1-15550 +commithash:0dd080d0d87b4d1966ec0af9961dc8bacc04f84f diff --git a/korebuild.json b/korebuild.json new file mode 100644 index 000000000..bd5d51a51 --- /dev/null +++ b/korebuild.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev" +} diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 34af273c4..d8ebc437e 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 6e6bd0e79..d48038176 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 2b3f9c3c9..2880ac963 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -10,12 +10,12 @@ - - - - - - + + + + + + diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 64d90423b..1e0a0f5e3 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -11,13 +11,13 @@ - - - - - - - + + + + + + + diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index bc54cbf3d..84fb99c7b 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -15,15 +15,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index a1706f4d1..7a8de5763 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -22,15 +22,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9d9a3de33..1e0980f66 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index 8526fcd39..e5bae5a3d 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index a7af0b7f3..5c8a5e3a9 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index a8f007748..b7f4c1704 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index a156fa549..7e3ce4eb3 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -9,14 +9,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index 087645ee0..16e4aa262 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index 3b2ada85f..ac4aa6c32 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -13,8 +13,8 @@ Microsoft.AspNetCore.Authorization.AuthorizeAttribute - - + + diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index c6021e012..1a42b04dd 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj index 67f8c9420..a12bc6563 100644 --- a/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj +++ b/src/Microsoft.Owin.Security.Interop/Microsoft.Owin.Security.Interop.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 724f34b0b..19544e342 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,11 +2,11 @@ - - - - - - + + + + + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index ae8789e11..2a43b216d 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index b133522f0..2b2cc69ba 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 49bbbd91f..e6f0b2293 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -10,7 +10,7 @@ - + diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index 7d50d86a3..951dac0c5 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index 779d8c141..f369f1f01 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -10,9 +10,9 @@ - - - + + + diff --git a/version.props b/version.props new file mode 100644 index 000000000..5c4a7c32d --- /dev/null +++ b/version.props @@ -0,0 +1,10 @@ + + + 2.1.0 + preview1 + $(VersionPrefix) + $(VersionPrefix)-$(VersionSuffix)-final + t000 + $(VersionSuffix)-$(BuildNumber) + + diff --git a/version.xml b/version.xml deleted file mode 100644 index 3c05022b7..000000000 --- a/version.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - dev - 2.1.0 - preview1 - - From 1927f65e976a6d81d5ed1fe734833aca578cd166 Mon Sep 17 00:00:00 2001 From: Dominick Baier Date: Fri, 3 Nov 2017 16:55:42 +0100 Subject: [PATCH 105/248] Change LogLevel from Information to Debug (see #1517) --- src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs index 46223d647..8cba6c0d5 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -39,7 +39,7 @@ static LoggingExtensions() formatString: "{AuthenticationScheme} was not authenticated. Failure message: {FailureMessage}"); _authSchemeAuthenticated = LoggerMessage.Define( eventId: 8, - logLevel: LogLevel.Information, + logLevel: LogLevel.Debug, formatString: "AuthenticationScheme: {AuthenticationScheme} was successfully authenticated."); _authSchemeNotAuthenticated = LoggerMessage.Define( eventId: 9, From 72e1cb1385c982e6dba90c839d1a1455e2813e6c Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 6 Nov 2017 14:16:57 -0800 Subject: [PATCH 106/248] Add VirtualSchemes --- .../AuthenticationBuilder.cs | 41 +- .../AuthenticationHandler.cs | 18 +- .../VirtualAuthenticationHandler.cs | 71 +++ .../VirtualSchemeOptions.cs | 33 ++ .../GoogleTests.cs | 22 +- .../VirtualHandlerTests.cs | 525 ++++++++++++++++++ 6 files changed, 674 insertions(+), 36 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs index 3bce55ea1..7bf8fe96e 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -25,18 +25,10 @@ public AuthenticationBuilder(IServiceCollection services) /// public virtual IServiceCollection Services { get; } - /// - /// Adds a which can be used by . - /// - /// The type to configure the handler."/>. - /// The used to handle this scheme. - /// The name of this scheme. - /// The display name of this scheme. - /// Used to configure the scheme options. - /// The builder. - public virtual AuthenticationBuilder AddScheme(string authenticationScheme, string displayName, Action configureOptions) - where TOptions : AuthenticationSchemeOptions, new() - where THandler : AuthenticationHandler + + private AuthenticationBuilder AddSchemeHelper(string authenticationScheme, string displayName, Action configureOptions) + where TOptions : class, new() + where THandler : class, IAuthenticationHandler { Services.Configure(o => { @@ -53,6 +45,20 @@ public virtual AuthenticationBuilder AddScheme(string authen return this; } + /// + /// Adds a which can be used by . + /// + /// The type to configure the handler."/>. + /// The used to handle this scheme. + /// The name of this scheme. + /// The display name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddScheme(string authenticationScheme, string displayName, Action configureOptions) + where TOptions : AuthenticationSchemeOptions, new() + where THandler : AuthenticationHandler + => AddSchemeHelper(authenticationScheme, displayName, configureOptions); + /// /// Adds a which can be used by . /// @@ -84,6 +90,17 @@ public virtual AuthenticationBuilder AddRemoteScheme(string return AddScheme(authenticationScheme, displayName, configureOptions: configureOptions); } + /// + /// Adds a based authentication handler which can be used to + /// redirect to other authentication schemes. + /// + /// The name of this scheme. + /// The display name of this scheme. + /// Used to configure the scheme options. + /// The builder. + public virtual AuthenticationBuilder AddVirtualScheme(string authenticationScheme, string displayName, Action configureOptions) + => AddSchemeHelper(authenticationScheme, displayName, configureOptions); + // Used to ensure that there's always a default sign in scheme that's not itself private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 9728e5ff0..ef4292100 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -22,12 +22,12 @@ namespace Microsoft.AspNetCore.Authentication protected HttpRequest Request { - get { return Context.Request; } + get => Context.Request; } protected HttpResponse Response { - get { return Context.Response; } + get => Context.Response; } protected PathString OriginalPath => Context.Features.Get()?.OriginalPath ?? Request.Path; @@ -52,10 +52,7 @@ protected HttpResponse Response protected string CurrentUri { - get - { - return Request.Scheme + "://" + Request.Host + Request.PathBase + Request.Path + Request.QueryString; - } + get => Request.Scheme + "://" + Request.Host + Request.PathBase + Request.Path + Request.QueryString; } protected AuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) @@ -116,15 +113,10 @@ protected virtual async Task InitializeEventsAsync() /// Called after options/events have been initialized for the handler to finish initializing itself. /// /// A task - protected virtual Task InitializeHandlerAsync() - { - return Task.CompletedTask; - } + protected virtual Task InitializeHandlerAsync() => Task.CompletedTask; protected string BuildRedirectUri(string targetPath) - { - return Request.Scheme + "://" + Request.Host + OriginalPathBase + targetPath; - } + => Request.Scheme + "://" + Request.Host + OriginalPathBase + targetPath; public async Task AuthenticateAsync() { diff --git a/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs new file mode 100644 index 000000000..4a023bec2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs @@ -0,0 +1,71 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Forwards calls to another authentication scheme. + /// + public class VirtualAuthenticationHandler : IAuthenticationHandler, IAuthenticationSignInHandler + { + protected IOptionsMonitor OptionsMonitor { get; } + public AuthenticationScheme Scheme { get; private set; } + public VirtualSchemeOptions Options { get; private set; } + protected HttpContext Context { get; private set; } + + public VirtualAuthenticationHandler(IOptionsMonitor options) + { + OptionsMonitor = options; + } + + /// + /// Initialize the handler, resolve the options and validate them. + /// + /// + /// + /// A Task. + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + if (scheme == null) + { + throw new ArgumentNullException(nameof(scheme)); + } + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + Scheme = scheme; + Context = context; + + Options = OptionsMonitor.Get(Scheme.Name) ?? new VirtualSchemeOptions(); + Options.Validate(); + + return Task.CompletedTask; + } + + protected virtual string ResolveTarget(string scheme) + => scheme ?? Options.DefaultSelector?.Invoke(Context) ?? Options.Default; + + public virtual Task AuthenticateAsync() + => Context.AuthenticateAsync(ResolveTarget(Options.Authenticate)); + + public virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + => Context.SignInAsync(ResolveTarget(Options.SignIn), user, properties); + + public virtual Task SignOutAsync(AuthenticationProperties properties) + => Context.SignOutAsync(ResolveTarget(Options.SignOut), properties); + + public virtual Task ChallengeAsync(AuthenticationProperties properties) + => Context.ChallengeAsync(ResolveTarget(Options.Challenge), properties); + + public virtual Task ForbidAsync(AuthenticationProperties properties) + => Context.ForbidAsync(ResolveTarget(Options.Forbid), properties); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs new file mode 100644 index 000000000..38d819bf5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs @@ -0,0 +1,33 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Used to redirect authentication methods to another scheme + /// + public class VirtualSchemeOptions + { + public string Default { get; set; } + + public string Authenticate { get; set; } + public string Challenge { get; set; } + public string Forbid { get; set; } + public string SignIn { get; set; } + public string SignOut { get; set; } + + /// + /// Used to select a default scheme to target based on the request. + /// + public Func DefaultSelector { get; set; } + + + /// + /// Check that the options are valid. Should throw an exception if things are not ok. + /// + public virtual void Validate() { } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 51bc67cc3..944a4827c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -990,7 +990,7 @@ private static TestServer CreateServer(Action configureOptions, F var res = context.Response; if (req.Path == new PathString("/challenge")) { - await context.ChallengeAsync("Google"); + await context.ChallengeAsync(); } else if (req.Path == new PathString("/challengeFacebook")) { @@ -1061,19 +1061,19 @@ private static TestServer CreateServer(Action configureOptions, F .ConfigureServices(services => { services.AddTransient(); - services.AddAuthentication(o => - { - o.DefaultScheme = TestExtensions.CookieAuthenticationScheme; - o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme; - }); - services.AddAuthentication() + services.AddAuthentication("Auth") + .AddVirtualScheme("Auth", "Auth", o => + { + o.Default = TestExtensions.CookieAuthenticationScheme; + o.Challenge = GoogleDefaults.AuthenticationScheme; + }) .AddCookie(TestExtensions.CookieAuthenticationScheme) .AddGoogle(configureOptions) .AddFacebook(o => - { - o.AppId = "Test AppId"; - o.AppSecret = "Test AppSecrent"; - }); + { + o.AppId = "Test AppId"; + o.AppSecret = "Test AppSecrent"; + }); }); return new TestServer(builder); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs new file mode 100644 index 000000000..a43478c94 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs @@ -0,0 +1,525 @@ +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication +{ + public class VirtualHandlerTests + { + [Fact] + public async Task CanDispatch() + { + var server = CreateServer(services => + { + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + o.AddScheme("auth3", "auth3"); + }) + .AddVirtualScheme("policy1", "policy1", p => + { + p.Default = "auth1"; + }) + .AddVirtualScheme("policy2", "policy2", p => + { + p.Authenticate = "auth2"; + }); + }); + + var transaction = await server.SendAsync("http://example.com/auth/policy1"); + Assert.Equal("auth1", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth1")); + + transaction = await server.SendAsync("http://example.com/auth/auth1"); + Assert.Equal("auth1", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth1")); + + transaction = await server.SendAsync("http://example.com/auth/auth2"); + Assert.Equal("auth2", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth2")); + + transaction = await server.SendAsync("http://example.com/auth/auth3"); + Assert.Equal("auth3", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth3")); + + transaction = await server.SendAsync("http://example.com/auth/policy2"); + Assert.Equal("auth2", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth2")); + } + + [Fact] + public async Task DefaultTargetSelectorWinsOverDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => { + p.Default = "auth2"; + p.DefaultSelector = ctx => "auth1"; + }); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(1, handler1.ChallengeCount); + Assert.Equal(0, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(1, handler1.SignInCount); + Assert.Equal(0, handler2.SignInCount); + } + + [Fact] + public async Task NullDefaultTargetSelectorFallsBacktoDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => { + p.Default = "auth1"; + p.DefaultSelector = ctx => null; + }); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(1, handler1.ChallengeCount); + Assert.Equal(0, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(1, handler1.SignInCount); + Assert.Equal(0, handler2.SignInCount); + } + + [Fact] + public async Task SpecificTargetAlwaysWinsOverDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => { + p.Default = "auth2"; + p.DefaultSelector = ctx => "auth2"; + p.Authenticate = "auth1"; + p.SignIn = "auth1"; + p.SignOut = "auth1"; + p.Forbid = "auth1"; + p.Challenge = "auth1"; + }); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(1, handler1.ChallengeCount); + Assert.Equal(0, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(1, handler1.SignInCount); + Assert.Equal(0, handler2.SignInCount); + } + + [Fact] + public async Task VirtualSchemeTargetsForwardWithDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => p.Default = "auth1"); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(1, handler1.ChallengeCount); + Assert.Equal(0, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(1, handler1.SignInCount); + Assert.Equal(0, handler2.SignInCount); + } + + [Fact] + public async Task VirtualSchemeTargetsOverrideDefaultTarget() + { + var services = new ServiceCollection().AddOptions(); + + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + }) + .AddVirtualScheme("forward", "forward", p => + { + p.Default = "auth1"; + p.Challenge = "auth2"; + p.SignIn = "auth2"; + }); + + var handler1 = new TestHandler(); + services.AddSingleton(handler1); + var handler2 = new TestHandler2(); + services.AddSingleton(handler2); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, handler1.AuthenticateCount); + Assert.Equal(0, handler1.ForbidCount); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(0, handler1.SignOutCount); + Assert.Equal(0, handler2.AuthenticateCount); + Assert.Equal(0, handler2.ForbidCount); + Assert.Equal(0, handler2.ChallengeCount); + Assert.Equal(0, handler2.SignInCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.AuthenticateAsync("forward"); + Assert.Equal(1, handler1.AuthenticateCount); + Assert.Equal(0, handler2.AuthenticateCount); + + await context.ForbidAsync("forward"); + Assert.Equal(1, handler1.ForbidCount); + Assert.Equal(0, handler2.ForbidCount); + + await context.ChallengeAsync("forward"); + Assert.Equal(0, handler1.ChallengeCount); + Assert.Equal(1, handler2.ChallengeCount); + + await context.SignOutAsync("forward"); + Assert.Equal(1, handler1.SignOutCount); + Assert.Equal(0, handler2.SignOutCount); + + await context.SignInAsync("forward", new ClaimsPrincipal()); + Assert.Equal(0, handler1.SignInCount); + Assert.Equal(1, handler2.SignInCount); + } + + [Fact] + public async Task CanDynamicTargetBasedOnQueryString() + { + var server = CreateServer(services => + { + services.AddAuthentication(o => + { + o.AddScheme("auth1", "auth1"); + o.AddScheme("auth2", "auth2"); + o.AddScheme("auth3", "auth3"); + }) + .AddVirtualScheme("dynamic", "dynamic", p => + { + p.DefaultSelector = c => c.Request.QueryString.Value.Substring(1); + }); + }); + + var transaction = await server.SendAsync("http://example.com/auth/dynamic?auth1"); + Assert.Equal("auth1", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth1")); + transaction = await server.SendAsync("http://example.com/auth/dynamic?auth2"); + Assert.Equal("auth2", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth2")); + transaction = await server.SendAsync("http://example.com/auth/dynamic?auth3"); + Assert.Equal("auth3", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth3")); + } + + [Fact] + public async Task TargetsDefaultSchemeByDefault() + { + var server = CreateServer(services => + { + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("default", "default"); + }) + .AddVirtualScheme("virtual", "virtual", p => { }); + }); + + var transaction = await server.SendAsync("http://example.com/auth/virtual"); + Assert.Equal("default", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "default")); + } + + [Fact] + public async Task TargetsDefaultSchemeThrowsWithNoDefault() + { + var server = CreateServer(services => + { + services.AddAuthentication(o => + { + o.AddScheme("default", "default"); + }) + .AddVirtualScheme("virtual", "virtual", p => { }); + }); + + var error = await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/virtual")); + Assert.Contains("No authenticationScheme was specified", error.Message); + } + + private class TestHandler : IAuthenticationSignInHandler + { + public AuthenticationScheme Scheme { get; set; } + public int SignInCount { get; set; } + public int SignOutCount { get; set; } + public int ForbidCount { get; set; } + public int ChallengeCount { get; set; } + public int AuthenticateCount { get; set; } + + public Task AuthenticateAsync() + { + AuthenticateCount++; + var principal = new ClaimsPrincipal(); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + principal.AddIdentity(id); + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); + } + + public Task ChallengeAsync(AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + public Task ForbidAsync(AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + Scheme = scheme; + return Task.CompletedTask; + } + + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + SignInCount++; + return Task.CompletedTask; + } + + public Task SignOutAsync(AuthenticationProperties properties) + { + SignOutCount++; + return Task.CompletedTask; + } + } + + private class TestHandler2 : IAuthenticationSignInHandler + { + public AuthenticationScheme Scheme { get; set; } + public int SignInCount { get; set; } + public int SignOutCount { get; set; } + public int ForbidCount { get; set; } + public int ChallengeCount { get; set; } + public int AuthenticateCount { get; set; } + + public Task AuthenticateAsync() + { + AuthenticateCount++; + var principal = new ClaimsPrincipal(); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + principal.AddIdentity(id); + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); + } + + public Task ChallengeAsync(AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + public Task ForbidAsync(AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + Scheme = scheme; + return Task.CompletedTask; + } + + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + SignInCount++; + return Task.CompletedTask; + } + + public Task SignOutAsync(AuthenticationProperties properties) + { + SignOutCount++; + return Task.CompletedTask; + } + } + + private static TestServer CreateServer(Action configure = null, string defaultScheme = null) + { + var builder = new WebHostBuilder() + .Configure(app => + { + app.UseAuthentication(); + app.Use(async (context, next) => + { + var req = context.Request; + var res = context.Response; + if (req.Path.StartsWithSegments(new PathString("/auth"), out var remainder)) + { + var name = (remainder.Value.Length > 0) ? remainder.Value.Substring(1) : null; + var result = await context.AuthenticateAsync(name); + res.Describe(result?.Ticket?.Principal); + } + else + { + await next(); + } + }); + }) + .ConfigureServices(services => + { + configure?.Invoke(services); + }); + return new TestServer(builder); + } + } +} From 148aef110e647d02224a2b2a180917539a8beaa0 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 7 Nov 2017 17:30:50 -0800 Subject: [PATCH 107/248] Remove redundant ProjectReference's in Auth.Test.csproj cref dotnet/sdk#1716 --- .../Microsoft.AspNetCore.Authentication.Test.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 2a43b216d..b49206567 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -12,8 +12,6 @@ - - From 5e51cb5c691eda23e965a57ac5d83c8497ff40d6 Mon Sep 17 00:00:00 2001 From: Mikael Frosthage Date: Fri, 10 Nov 2017 17:46:12 +0100 Subject: [PATCH 108/248] Fixed summary tag on comment (#1535) --- .../OpenIdConnect/OpenIdConnectTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs index 32be26d33..da52e0e4c 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectTests.cs @@ -27,7 +27,7 @@ public class OpenIdConnectTests /// /// Tests RedirectForSignOutContext replaces the OpenIdConnectMesssage correctly. - /// summary> + /// /// Task [Fact] public async Task SignOutSettingMessage() From f8711a2da3fdf6b250d528136c6e9d8ecf78062b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 13 Nov 2017 17:24:59 -0800 Subject: [PATCH 109/248] Update samples and tests to target netcoreapp2.1 --- Directory.Build.props | 4 ++++ korebuild-lock.txt | 4 ++-- samples/CookieSample/CookieSample.csproj | 2 +- samples/CookieSessionSample/CookieSessionSample.csproj | 2 +- samples/JwtBearerSample/JwtBearerSample.csproj | 2 +- .../OpenIdConnect.AzureAdSample.csproj | 2 +- samples/OpenIdConnectSample/OpenIdConnectSample.csproj | 2 +- samples/SocialSample/SocialSample.csproj | 2 +- test/Directory.Build.props | 7 +++++++ .../Microsoft.AspNetCore.Authentication.Test.csproj | 3 +-- .../OpenIdConnect/TestSettings.cs | 2 +- .../Microsoft.AspNetCore.Authorization.Test.csproj | 3 +-- ...ft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj | 3 +-- .../Microsoft.AspNetCore.CookiePolicy.Test.csproj | 3 +-- 14 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index d277ef862..e6771f7a8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,8 @@  + + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 36d805603..95f461301 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15550 -commithash:0dd080d0d87b4d1966ec0af9961dc8bacc04f84f +version:2.1.0-preview1-15567 +commithash:903e3104807b1bb8cddd28bdef205b1e2dc021d1 diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index d8ebc437e..193137b86 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index d48038176..6241edd66 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 2880ac963..84b436581 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 aspnet5-JwtBearerSample-20151210102827 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 1e0a0f5e3..b14b9590f 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 84fb99c7b..23e87d4f2 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index 7a8de5763..a423ae21a 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + net461;netcoreapp2.1 aspnet5-SocialSample-20151210111056 diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 19544e342..b842a4831 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,6 +1,13 @@  + + netcoreapp2.1 + $(DeveloperBuildTestTfms) + $(StandardTestTfms);netcoreapp2.0 + $(StandardTestTfms);net461 + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index b49206567..57fed96c0 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index f174342ae..509b85e64 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -252,7 +252,7 @@ private void ValidateState(IDictionary actualParams, ICollection ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => -#if NETCOREAPP2_0 +#if NETCOREAPP2_0 || NETCOREAPP2_1 ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NETSTANDARD1_4", actualParams, errors, htmlEncoded); #elif NET461 ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET451", actualParams, errors, htmlEncoded); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 2b2cc69ba..d4379c3aa 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index e6f0b2293..20cd400ce 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index 951dac0c5..d7a42f3ef 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) From 34083584a6593b636ed507c1b8e50570197ec2ad Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 17 Nov 2017 13:00:26 -0800 Subject: [PATCH 110/248] Use MicrosoftNETCoreApp21PackageVersion to determine the runtime framework in netcoreapp2.1 --- Directory.Build.targets | 1 + build/dependencies.props | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index e83ff95e3..894b1d0cf 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,5 +1,6 @@  $(MicrosoftNETCoreApp20PackageVersion) + $(MicrosoftNETCoreApp21PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index 13ed63da1..7ef0a7cf7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -33,6 +33,7 @@ 3.14.1 5.2.0-preview1-408290725 2.0.0 + 2.1.0-preview1-25907-02 15.3.0 3.0.1 3.0.1 From 28aae41993ee31b66cff28c6b8590941560c57b3 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 20 Nov 2017 12:18:35 -0800 Subject: [PATCH 111/248] Use MSBuild to set NuGet feeds instead of NuGet.config --- Directory.Build.props | 1 + NuGet.config | 4 +--- build/sources.props | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 build/sources.props diff --git a/Directory.Build.props b/Directory.Build.props index e6771f7a8..adbda10ef 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,6 +5,7 @@ + Microsoft ASP.NET Core diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de..e32bddfd5 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,8 +2,6 @@ - - - + diff --git a/build/sources.props b/build/sources.props new file mode 100644 index 000000000..c03f3ddb6 --- /dev/null +++ b/build/sources.props @@ -0,0 +1,16 @@ + + + + + $(DotNetRestoreSources) + + $(RestoreSources); + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; + + + $(RestoreSources); + https://api.nuget.org/v3/index.json; + + + From a9482d1d03fc22f62e42cf31b8adb32c5550835e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Nov 2017 15:48:55 -0800 Subject: [PATCH 112/248] Replace aspnetcore-ci-dev feed with aspnetcore-dev --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- build/repo.props | 2 +- build/sources.props | 2 +- korebuild-lock.txt | 4 +-- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7ef0a7cf7..e02aaa262 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,37 +1,37 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15550 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 - 2.1.0-preview1-27498 + 2.1.0-preview1-15576 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 3.14.1 - 5.2.0-preview1-408290725 + 5.2.0-preview2-41113220915 2.0.0 2.1.0-preview1-25907-02 15.3.0 diff --git a/build/repo.props b/build/repo.props index 598c7f5a3..62f47b7a5 100644 --- a/build/repo.props +++ b/build/repo.props @@ -6,6 +6,6 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index c03f3ddb6..9feff29d0 100644 --- a/build/sources.props +++ b/build/sources.props @@ -5,7 +5,7 @@ $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 95f461301..1a99066b7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15567 -commithash:903e3104807b1bb8cddd28bdef205b1e2dc021d1 +version:2.1.0-preview1-15576 +commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 From e2f6ad6169e229c60cd8d3b6221bb43f66bcabea Mon Sep 17 00:00:00 2001 From: Muqeet Khan Date: Wed, 22 Nov 2017 13:04:54 -0600 Subject: [PATCH 113/248] Updated logging extension to remove the period on ValidationFailed _tokenValidationFailed format string includes the JWT token followed by a period, which if a dev troubleshooting copies incorrectly to the EOL will make the JWT invalid. Current: Failed to validate the token eyJhbGc.......HCwFmw. Proposed: Failed to validate the token eyJhbGc.......HCwFmw --- .../LoggingExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs index 008190f51..38a75feca 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs @@ -16,7 +16,7 @@ static LoggingExtensions() _tokenValidationFailed = LoggerMessage.Define( eventId: 1, logLevel: LogLevel.Information, - formatString: "Failed to validate the token {Token}."); + formatString: "Failed to validate the token {Token}"); _tokenValidationSucceeded = LoggerMessage.Define( eventId: 2, logLevel: LogLevel.Information, From e69d9e20635abcc8ae46970f819397b717b2527a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 29 Nov 2017 14:09:30 -0800 Subject: [PATCH 114/248] Specify runtime versions to install --- build/repo.props | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build/repo.props b/build/repo.props index 62f47b7a5..541470c9f 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,11 +1,17 @@  + + - Internal.AspNetCore.Universe.Lineup https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + + + + + From c5307f9a7a809b2c640785ac7f271287f807524e Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 1 Dec 2017 10:27:12 -0800 Subject: [PATCH 115/248] Update bootstrappers --- run.ps1 | 17 +++++++++++------ run.sh | 30 +++++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/run.ps1 b/run.ps1 index 49c289985..27dcf848f 100644 --- a/run.ps1 +++ b/run.ps1 @@ -29,6 +29,9 @@ Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile The path to the configuration file that stores values. Defaults to korebuild.json. +.PARAMETER ToolsSourceSuffix +The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. + .PARAMETER Arguments Arguments to be passed to the command @@ -51,7 +54,7 @@ Example config file: #> [CmdletBinding(PositionalBinding = $false)] param( - [Parameter(Mandatory=$true, Position = 0)] + [Parameter(Mandatory = $true, Position = 0)] [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] @@ -63,6 +66,7 @@ param( [Alias('u')] [switch]$Update, [string]$ConfigFile, + [string]$ToolsSourceSuffix, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -79,7 +83,7 @@ function Get-KoreBuild { $lockFile = Join-Path $Path 'korebuild-lock.txt' if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix } $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 @@ -96,7 +100,7 @@ function Get-KoreBuild { try { $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile + Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { # Use built-in commands where possible as they are cross-plat compatible Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath @@ -124,7 +128,7 @@ function Join-Paths([string]$path, [string[]]$childPaths) { return $path } -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { if ($RemotePath -notlike 'http*') { Copy-Item $RemotePath $LocalPath return @@ -134,7 +138,7 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { while ($retries -gt 0) { $retries -= 1 try { - Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath return } catch { @@ -161,7 +165,8 @@ if (Test-Path $ConfigFile) { if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} } - } catch { + } + catch { Write-Warning "$ConfigFile could not be read. Its settings will be ignored." Write-Warning $Error[0] } diff --git a/run.sh b/run.sh index c278423ac..834961fc3 100755 --- a/run.sh +++ b/run.sh @@ -17,6 +17,7 @@ update=false repo_path="$DIR" channel='' tools_source='' +tools_source_suffix='' # # Functions @@ -29,13 +30,14 @@ __usage() { echo " ... Arguments passed to the command. Variable number of arguments allowed." echo "" echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." echo "" echo "Description:" echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." @@ -50,7 +52,7 @@ get_korebuild() { local version local lock_file="$repo_path/korebuild-lock.txt" if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" fi version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then @@ -66,7 +68,7 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then + if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then unzip -q -d "$korebuild_path" "$tmpfile" fi rm "$tmpfile" || true @@ -98,6 +100,7 @@ __machine_has() { __get_remote_file() { local remote_path=$1 local local_path=$2 + local remote_path_suffix=$3 if [[ "$remote_path" != 'http'* ]]; then cp "$remote_path" "$local_path" @@ -106,14 +109,14 @@ __get_remote_file() { local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true else failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true fi if [ "$failed" = true ]; then @@ -164,6 +167,11 @@ while [[ $# -gt 0 ]]; do tools_source="${1:-}" [ -z "$tools_source" ] && __usage ;; + --tools-source-suffix|-ToolsSourceSuffix) + shift + tools_source_suffix="${1:-}" + [ -z "$tools_source_suffix" ] && __usage + ;; -u|--update|-Update) update=true ;; From 4edc900dd89a0ad0a2244634764ac23696909f94 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 10 Dec 2017 13:47:31 -0800 Subject: [PATCH 116/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 62 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index e02aaa262..450a5804b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,45 +3,45 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15576 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 + 2.1.0-preview1-15618 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 3.14.1 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-25907-02 + 2.1.0-preview1-25915-01 15.3.0 3.0.1 3.0.1 3.0.1 10.0.1 - 0.7.0 - 2.3.0 - 2.3.0 + 0.8.0 + 2.3.1 + 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1a99066b7..e7cce9300 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15576 -commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 +version:2.1.0-preview1-15618 +commithash:00ce1383114015fe89b221146036e59e6bc11219 From bd3c202fcd707fdb7ac583d466463007bd9137df Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 13 Dec 2017 21:42:05 +0000 Subject: [PATCH 117/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 450a5804b..d98007d0c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,37 +3,37 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15618 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 + 2.1.0-preview1-15626 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 3.14.1 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-25915-01 + 2.1.0-preview1-26008-01 15.3.0 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e7cce9300..8d52a6128 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15618 -commithash:00ce1383114015fe89b221146036e59e6bc11219 +version:2.1.0-preview1-15626 +commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 From 45ab9485d3116432d1235ba0f466ff5d69e21620 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 18 Dec 2017 17:56:00 -0800 Subject: [PATCH 118/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d98007d0c..9eca47a75 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,36 +4,36 @@ 2.1.0-preview1-15626 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 3.14.1 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26008-01 + 2.1.0-preview1-26016-05 15.3.0 3.0.1 3.0.1 From f8b4f4c620e2faaeec262d302df143068c8d0b33 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 17 Nov 2017 15:08:30 -0800 Subject: [PATCH 119/248] Add consent to CookiePolicy #1561 --- Security.sln | 21 +- .../CookiePolicySample.csproj | 18 + samples/CookiePolicySample/Program.cs | 26 + .../Properties/launchSettings.json | 27 + samples/CookiePolicySample/Startup.cs | 118 ++++ .../ChunkingCookieManager.cs | 2 + .../CookieAuthenticationOptions.cs | 1 + .../OpenIdConnectOptions.cs | 1 + .../TwitterOptions.cs | 1 + .../RemoteAuthenticationOptions.cs | 1 + .../AppendCookieContext.cs | 3 + .../CookiePolicyMiddleware.cs | 151 +---- .../CookiePolicyOptions.cs | 12 + .../DeleteCookieContext.cs | 3 + .../ResponseCookiesWrapper.cs | 220 +++++++ .../CookieConsentTests.cs | 561 ++++++++++++++++++ 16 files changed, 1021 insertions(+), 145 deletions(-) create mode 100644 samples/CookiePolicySample/CookiePolicySample.csproj create mode 100644 samples/CookiePolicySample/Program.cs create mode 100644 samples/CookiePolicySample/Properties/launchSettings.json create mode 100644 samples/CookiePolicySample/Startup.cs create mode 100644 src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs create mode 100644 test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs diff --git a/Security.sln b/Security.sln index f88d8576b..543b3be26 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.10 +VisualStudioVersion = 15.0.27004.2002 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" ProjectSection(SolutionItems) = preProject @@ -72,6 +72,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization.Policy", "src\Microsoft.AspNetCore.Authorization.Policy\Microsoft.AspNetCore.Authorization.Policy.csproj", "{58194599-F07D-47A3-9DF2-E21A22C5EF9E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookiePolicySample", "samples\CookiePolicySample\CookiePolicySample.csproj", "{24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -462,6 +464,22 @@ Global {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x64.Build.0 = Release|Any CPU {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.ActiveCfg = Release|Any CPU {58194599-F07D-47A3-9DF2-E21A22C5EF9E}.Release|x86.Build.0 = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|x64.ActiveCfg = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|x64.Build.0 = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|x86.ActiveCfg = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Debug|x86.Build.0 = Debug|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|Any CPU.Build.0 = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x64.ActiveCfg = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x64.Build.0 = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x86.ActiveCfg = Release|Any CPU + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -491,6 +509,7 @@ Global {3A7AD414-EBDE-4F92-B307-4E8F19B6117E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {ABF8089E-43D0-4010-84A7-7A9DCFE49357} diff --git a/samples/CookiePolicySample/CookiePolicySample.csproj b/samples/CookiePolicySample/CookiePolicySample.csproj new file mode 100644 index 000000000..fb2e7d917 --- /dev/null +++ b/samples/CookiePolicySample/CookiePolicySample.csproj @@ -0,0 +1,18 @@ + + + + net461;netcoreapp2.1 + + + + + + + + + + + + + + diff --git a/samples/CookiePolicySample/Program.cs b/samples/CookiePolicySample/Program.cs new file mode 100644 index 000000000..12fc8ff28 --- /dev/null +++ b/samples/CookiePolicySample/Program.cs @@ -0,0 +1,26 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; + +namespace CookiePolicySample +{ + public static class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/samples/CookiePolicySample/Properties/launchSettings.json b/samples/CookiePolicySample/Properties/launchSettings.json new file mode 100644 index 000000000..38ca6fc37 --- /dev/null +++ b/samples/CookiePolicySample/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:1788/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "CookieSample": { + "commandName": "Project", + "launchBrowser": true, + "applicationUrl": "http://localhost:12345", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/samples/CookiePolicySample/Startup.cs b/samples/CookiePolicySample/Startup.cs new file mode 100644 index 000000000..7ce9c2d2d --- /dev/null +++ b/samples/CookiePolicySample/Startup.cs @@ -0,0 +1,118 @@ +using System; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; + +namespace CookiePolicySample +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) + .AddCookie(); + services.Configure(options => + { + options.CheckConsentNeeded = context => context.Request.PathBase.Equals("/NeedsConsent"); + + options.OnAppendCookie = context => { }; + }); + } + + public void Configure(IApplicationBuilder app) + { + app.UseCookiePolicy(); + app.UseAuthentication(); + + app.Map("/NeedsConsent", NestedApp); + app.Map("/NeedsNoConsent", NestedApp); + NestedApp(app); + } + + private void NestedApp(IApplicationBuilder app) + { + app.Run(async context => + { + var path = context.Request.Path; + switch (path) + { + case "/Login": + var user = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "bob") }, + CookieAuthenticationDefaults.AuthenticationScheme)); + await context.SignInAsync(user); + break; + case "/Logout": + await context.SignOutAsync(); + break; + case "/CreateTempCookie": + context.Response.Cookies.Append("Temp", "1"); + break; + case "/RemoveTempCookie": + context.Response.Cookies.Delete("Temp"); + break; + case "/GrantConsent": + context.Features.Get().GrantConsent(); + break; + case "/WithdrawConsent": + context.Features.Get().WithdrawConsent(); + break; + } + + // TODO: Debug log when cookie is suppressed + + await HomePage(context); + }); + } + + private async Task HomePage(HttpContext context) + { + var response = context.Response; + var cookies = context.Request.Cookies; + response.ContentType = "text/html"; + await response.WriteAsync("\r\n"); + + await response.WriteAsync($"Home
\r\n"); + await response.WriteAsync($"Login
\r\n"); + await response.WriteAsync($"Logout
\r\n"); + await response.WriteAsync($"Create Temp Cookie
\r\n"); + await response.WriteAsync($"Remove Temp Cookie
\r\n"); + await response.WriteAsync($"Grant Consent
\r\n"); + await response.WriteAsync($"Withdraw Consent
\r\n"); + await response.WriteAsync("
\r\n"); + await response.WriteAsync($"Needs Consent
\r\n"); + await response.WriteAsync($"Needs No Consent
\r\n"); + await response.WriteAsync("
\r\n"); + + var feature = context.Features.Get(); + await response.WriteAsync($"Consent:
\r\n"); + await response.WriteAsync($" - IsNeeded: {feature.IsConsentNeeded}
\r\n"); + await response.WriteAsync($" - Has: {feature.HasConsent}
\r\n"); + await response.WriteAsync($" - Can Track: {feature.CanTrack}
\r\n"); + await response.WriteAsync("
\r\n"); + + await response.WriteAsync($"{cookies.Count} Request Cookies:
\r\n"); + foreach (var cookie in cookies) + { + await response.WriteAsync($" - {cookie.Key} = {cookie.Value}
\r\n"); + } + await response.WriteAsync("
\r\n"); + + var responseCookies = response.Headers[HeaderNames.SetCookie]; + await response.WriteAsync($"{responseCookies.Count} Response Cookies:
\r\n"); + foreach (var cookie in responseCookies) + { + await response.WriteAsync($" - {cookie}
\r\n"); + } + + await response.WriteAsync(""); + } + } +} diff --git a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs index 7217e70d4..42cc4e2f0 100644 --- a/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs +++ b/shared/Microsoft.AspNetCore.ChunkingCookieManager.Sources/ChunkingCookieManager.cs @@ -285,6 +285,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) Path = options.Path, Domain = options.Domain, SameSite = options.SameSite, + IsEssential = options.IsEssential, Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), }); @@ -299,6 +300,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) Path = options.Path, Domain = options.Domain, SameSite = options.SameSite, + IsEssential = options.IsEssential, Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), }); } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 04c71ed1e..35017f9c4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -21,6 +21,7 @@ public class CookieAuthenticationOptions : AuthenticationSchemeOptions SameSite = SameSiteMode.Lax, HttpOnly = true, SecurePolicy = CookieSecurePolicy.SameAsRequest, + IsEssential = true, }; /// diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs index a40d37435..cbf6e8eab 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectOptions.cs @@ -74,6 +74,7 @@ public OpenIdConnectOptions() HttpOnly = true, SameSite = SameSiteMode.None, SecurePolicy = CookieSecurePolicy.SameAsRequest, + IsEssential = true, }; } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 86919d092..03396807e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -35,6 +35,7 @@ public TwitterOptions() SecurePolicy = CookieSecurePolicy.SameAsRequest, HttpOnly = true, SameSite = SameSiteMode.Lax, + IsEssential = true, }; } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index daba1890f..1bd3b210e 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -29,6 +29,7 @@ public RemoteAuthenticationOptions() HttpOnly = true, SameSite = SameSiteMode.None, SecurePolicy = CookieSecurePolicy.SameAsRequest, + IsEssential = true, }; } diff --git a/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs b/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs index 1b13251f7..bbb4899c0 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/AppendCookieContext.cs @@ -19,5 +19,8 @@ public AppendCookieContext(HttpContext context, CookieOptions options, string na public CookieOptions CookieOptions { get; } public string CookieName { get; set; } public string CookieValue { get; set; } + public bool IsConsentNeeded { get; internal set; } + public bool HasConsent { get; internal set; } + public bool IssueCookie { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index 92adac967..b99fed2c3 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; @@ -27,157 +26,21 @@ public CookiePolicyMiddleware( public Task Invoke(HttpContext context) { var feature = context.Features.Get() ?? new ResponseCookiesFeature(context.Features); - context.Features.Set(new CookiesWrapperFeature(context, Options, feature)); + var wrapper = new ResponseCookiesWrapper(context, Options, feature); + context.Features.Set(new CookiesWrapperFeature(wrapper)); + context.Features.Set(wrapper); + return _next(context); } private class CookiesWrapperFeature : IResponseCookiesFeature { - public CookiesWrapperFeature(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature) - { - Wrapper = new CookiesWrapper(context, options, feature); - } - - public IResponseCookies Wrapper { get; } - - public IResponseCookies Cookies - { - get - { - return Wrapper; - } - } - } - - private class CookiesWrapper : IResponseCookies - { - public CookiesWrapper(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature) + public CookiesWrapperFeature(ResponseCookiesWrapper wrapper) { - Context = context; - Feature = feature; - Policy = options; + Cookies = wrapper; } - public HttpContext Context { get; } - - public IResponseCookiesFeature Feature { get; } - - public IResponseCookies Cookies - { - get - { - return Feature.Cookies; - } - } - - public CookiePolicyOptions Policy { get; } - - private bool PolicyRequiresCookieOptions() - { - return Policy.MinimumSameSitePolicy != SameSiteMode.None || Policy.HttpOnly != HttpOnlyPolicy.None || Policy.Secure != CookieSecurePolicy.None; - } - - public void Append(string key, string value) - { - if (PolicyRequiresCookieOptions() || Policy.OnAppendCookie != null) - { - Append(key, value, new CookieOptions()); - } - else - { - Cookies.Append(key, value); - } - } - - public void Append(string key, string value, CookieOptions options) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - ApplyPolicy(options); - if (Policy.OnAppendCookie != null) - { - var context = new AppendCookieContext(Context, options, key, value); - Policy.OnAppendCookie(context); - key = context.CookieName; - value = context.CookieValue; - } - Cookies.Append(key, value, options); - } - - public void Delete(string key) - { - if (PolicyRequiresCookieOptions() || Policy.OnDeleteCookie != null) - { - Delete(key, new CookieOptions()); - } - else - { - Cookies.Delete(key); - } - } - - public void Delete(string key, CookieOptions options) - { - if (options == null) - { - throw new ArgumentNullException(nameof(options)); - } - - ApplyPolicy(options); - if (Policy.OnDeleteCookie != null) - { - var context = new DeleteCookieContext(Context, options, key); - Policy.OnDeleteCookie(context); - key = context.CookieName; - } - Cookies.Delete(key, options); - } - - private void ApplyPolicy(CookieOptions options) - { - switch (Policy.Secure) - { - case CookieSecurePolicy.Always: - options.Secure = true; - break; - case CookieSecurePolicy.SameAsRequest: - options.Secure = Context.Request.IsHttps; - break; - case CookieSecurePolicy.None: - break; - default: - throw new InvalidOperationException(); - } - switch (Policy.MinimumSameSitePolicy) - { - case SameSiteMode.None: - break; - case SameSiteMode.Lax: - if (options.SameSite == SameSiteMode.None) - { - options.SameSite = SameSiteMode.Lax; - } - break; - case SameSiteMode.Strict: - options.SameSite = SameSiteMode.Strict; - break; - default: - throw new InvalidOperationException($"Unrecognized {nameof(SameSiteMode)} value {Policy.MinimumSameSitePolicy.ToString()}"); - } - switch (Policy.HttpOnly) - { - case HttpOnlyPolicy.Always: - options.HttpOnly = true; - break; - case HttpOnlyPolicy.None: - break; - default: - throw new InvalidOperationException($"Unrecognized {nameof(HttpOnlyPolicy)} value {Policy.HttpOnly.ToString()}"); - } - } + public IResponseCookies Cookies { get; } } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index 1e474bfe2..cc2deaa3a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -27,6 +27,18 @@ public class CookiePolicyOptions /// public CookieSecurePolicy Secure { get; set; } = CookieSecurePolicy.None; + public CookieBuilder ConsentCookie { get; set; } = new CookieBuilder() + { + Name = ".AspNet.Consent", + Expiration = TimeSpan.FromDays(90), + IsEssential = true, + }; + + /// + /// Checks if consent policies should be evaluated on this request. The default is false. + /// + public Func CheckConsentNeeded { get; set; } + /// /// Called when a cookie is appended. /// diff --git a/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs b/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs index f0693bf71..fd79ea8d4 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/DeleteCookieContext.cs @@ -17,5 +17,8 @@ public DeleteCookieContext(HttpContext context, CookieOptions options, string na public HttpContext Context { get; } public CookieOptions CookieOptions { get; } public string CookieName { get; set; } + public bool IsConsentNeeded { get; internal set; } + public bool HasConsent { get; internal set; } + public bool IssueCookie { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs new file mode 100644 index 000000000..fa68a3cbe --- /dev/null +++ b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs @@ -0,0 +1,220 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; + +namespace Microsoft.AspNetCore.CookiePolicy +{ + internal class ResponseCookiesWrapper : IResponseCookies, ITrackingConsentFeature + { + private const string ConsentValue = "yes"; + + private bool? _isConsentNeeded; + private bool? _hasConsent; + + public ResponseCookiesWrapper(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature) + { + Context = context; + Feature = feature; + Options = options; + } + + private HttpContext Context { get; } + + private IResponseCookiesFeature Feature { get; } + + private IResponseCookies Cookies => Feature.Cookies; + + private CookiePolicyOptions Options { get; } + + public bool IsConsentNeeded + { + get + { + if (!_isConsentNeeded.HasValue) + { + _isConsentNeeded = Options.CheckConsentNeeded == null ? false + : Options.CheckConsentNeeded(Context); + } + + return _isConsentNeeded.Value; + } + } + + public bool HasConsent + { + get + { + if (!_hasConsent.HasValue) + { + var cookie = Context.Request.Cookies[Options.ConsentCookie.Name]; + _hasConsent = string.Equals(cookie, ConsentValue, StringComparison.Ordinal); + } + + return _hasConsent.Value; + } + } + + public bool CanTrack => !IsConsentNeeded || HasConsent; + + public void GrantConsent() + { + if (!HasConsent && !Context.Response.HasStarted) + { + var cookieOptions = Options.ConsentCookie.Build(Context); + // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. + Append(Options.ConsentCookie.Name, ConsentValue, cookieOptions); + } + _hasConsent = true; + } + + public void WithdrawConsent() + { + if (HasConsent && !Context.Response.HasStarted) + { + var cookieOptions = Options.ConsentCookie.Build(Context); + // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. + Delete(Options.ConsentCookie.Name, cookieOptions); + } + _hasConsent = false; + } + + private bool CheckPolicyRequired() + { + return !CanTrack + || Options.MinimumSameSitePolicy != SameSiteMode.None + || Options.HttpOnly != HttpOnlyPolicy.None + || Options.Secure != CookieSecurePolicy.None; + } + + public void Append(string key, string value) + { + if (CheckPolicyRequired() || Options.OnAppendCookie != null) + { + Append(key, value, new CookieOptions()); + } + else + { + Cookies.Append(key, value); + } + } + + public void Append(string key, string value, CookieOptions options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + var issueCookie = CanTrack || options.IsEssential; + ApplyPolicy(options); + if (Options.OnAppendCookie != null) + { + var context = new AppendCookieContext(Context, options, key, value) + { + IsConsentNeeded = IsConsentNeeded, + HasConsent = HasConsent, + IssueCookie = issueCookie, + }; + Options.OnAppendCookie(context); + + key = context.CookieName; + value = context.CookieValue; + issueCookie = context.IssueCookie; + } + + if (issueCookie) + { + Cookies.Append(key, value, options); + } + } + + public void Delete(string key) + { + if (CheckPolicyRequired() || Options.OnDeleteCookie != null) + { + Delete(key, new CookieOptions()); + } + else + { + Cookies.Delete(key); + } + } + + public void Delete(string key, CookieOptions options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + // Assume you can always delete cookies unless directly overridden in the user event. + var issueCookie = true; + ApplyPolicy(options); + if (Options.OnDeleteCookie != null) + { + var context = new DeleteCookieContext(Context, options, key) + { + IsConsentNeeded = IsConsentNeeded, + HasConsent = HasConsent, + IssueCookie = issueCookie, + }; + Options.OnDeleteCookie(context); + + key = context.CookieName; + issueCookie = context.IssueCookie; + } + + if (issueCookie) + { + Cookies.Delete(key, options); + } + } + + private void ApplyPolicy(CookieOptions options) + { + switch (Options.Secure) + { + case CookieSecurePolicy.Always: + options.Secure = true; + break; + case CookieSecurePolicy.SameAsRequest: + options.Secure = Context.Request.IsHttps; + break; + case CookieSecurePolicy.None: + break; + default: + throw new InvalidOperationException(); + } + switch (Options.MinimumSameSitePolicy) + { + case SameSiteMode.None: + break; + case SameSiteMode.Lax: + if (options.SameSite == SameSiteMode.None) + { + options.SameSite = SameSiteMode.Lax; + } + break; + case SameSiteMode.Strict: + options.SameSite = SameSiteMode.Strict; + break; + default: + throw new InvalidOperationException($"Unrecognized {nameof(SameSiteMode)} value {Options.MinimumSameSitePolicy.ToString()}"); + } + switch (Options.HttpOnly) + { + case HttpOnlyPolicy.Always: + options.HttpOnly = true; + break; + case HttpOnlyPolicy.None: + break; + default: + throw new InvalidOperationException($"Unrecognized {nameof(HttpOnlyPolicy)} value {Options.HttpOnly.ToString()}"); + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs new file mode 100644 index 000000000..4e62d54a2 --- /dev/null +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -0,0 +1,561 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; +using Xunit; + +namespace Microsoft.AspNetCore.CookiePolicy.Test +{ + public class CookieConsentTests + { + [Fact] + public async Task ConsentChecksOffByDefault() + { + var httpContext = await RunTestAsync(options => { }, requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.False(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task ConsentEnabledForTemplateScenario() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task NonEssentialCookiesWithOptionsExcluded() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value", new CookieOptions() { IsEssential = false }); + return Task.CompletedTask; + }); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task NonEssentialCookiesCanBeAllowedViaOnAppendCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.OnAppendCookie = context => + { + Assert.True(context.IsConsentNeeded); + Assert.False(context.HasConsent); + Assert.False(context.IssueCookie); + context.IssueCookie = true; + }; + }, + requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value", new CookieOptions() { IsEssential = false }); + return Task.CompletedTask; + }); + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task NeedsConsentDoesNotPreventEssentialCookies() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value", new CookieOptions() { IsEssential = true }); + return Task.CompletedTask; + }); + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task EssentialCookiesCanBeExcludedByOnAppendCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.OnAppendCookie = context => + { + Assert.True(context.IsConsentNeeded); + Assert.True(context.HasConsent); + Assert.True(context.IssueCookie); + context.IssueCookie = false; + }; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value", new CookieOptions() { IsEssential = true }); + return Task.CompletedTask; + }); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task HasConsentReadsRequestCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task HasConsentIgnoresInvalidRequestCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=IAmATeapot"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task GrantConsentSetsCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(2, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent", consentCookie.Name); + Assert.Equal("yes", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + var testCookie = cookies[1]; + Assert.Equal("Test", testCookie.Name); + Assert.Equal("Value", testCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, testCookie.SameSite); + Assert.Null(testCookie.Expires); + } + + [Fact] + public async Task GrantConsentAppliesPolicyToConsentCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.MinimumSameSitePolicy = Http.SameSiteMode.Strict; + options.OnAppendCookie = context => + { + Assert.Equal(".AspNet.Consent", context.CookieName); + Assert.Equal("yes", context.CookieValue); + Assert.Equal(Http.SameSiteMode.Strict, context.CookieOptions.SameSite); + context.CookieName += "1"; + context.CookieValue += "1"; + }; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent1", consentCookie.Name); + Assert.Equal("yes1", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Strict, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + } + + [Fact] + public async Task GrantConsentWhenAlreadyHasItDoesNotSetCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + + Assert.Equal("Test=Value; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task GrantConsentAfterResponseStartsSetsHasConsentButDoesNotSetCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + async context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + await context.Response.WriteAsync("Started."); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + Assert.Throws(() => context.Response.Cookies.Append("Test", "Value")); + + await context.Response.WriteAsync("Granted."); + }); + + var reader = new StreamReader(httpContext.Response.Body); + Assert.Equal("Started.Granted.", await reader.ReadToEndAsync()); + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task WithdrawConsentWhenNotHasConsentNoOps() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.WithdrawConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + context.Response.Cookies.Append("Test", "Value"); + return Task.CompletedTask; + }); + + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task WithdrawConsentDeletesCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value1"); + + feature.WithdrawConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + context.Response.Cookies.Append("Test", "Value2"); + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(2, cookies.Count); + var testCookie = cookies[0]; + Assert.Equal("Test", testCookie.Name); + Assert.Equal("Value1", testCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, testCookie.SameSite); + Assert.Null(testCookie.Expires); + var consentCookie = cookies[1]; + Assert.Equal(".AspNet.Consent", consentCookie.Name); + Assert.Equal("", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + } + + [Fact] + public async Task WithdrawConsentAppliesPolicyToDeleteCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.MinimumSameSitePolicy = Http.SameSiteMode.Strict; + options.OnDeleteCookie = context => + { + Assert.Equal(".AspNet.Consent", context.CookieName); + context.CookieName += "1"; + }; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + feature.WithdrawConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent1", consentCookie.Name); + Assert.Equal("", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Strict, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + } + + [Fact] + public async Task WithdrawConsentAfterResponseHasStartedDoesNotDeleteCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => + { + requestContext.Request.Headers[HeaderNames.Cookie] = ".AspNet.Consent=yes"; + }, + async context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + context.Response.Cookies.Append("Test", "Value1"); + + await context.Response.WriteAsync("Started."); + + feature.WithdrawConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + // Doesn't throw the normal InvalidOperationException because the cookie is never written + context.Response.Cookies.Append("Test", "Value2"); + + await context.Response.WriteAsync("Withdrawn."); + }); + + var reader = new StreamReader(httpContext.Response.Body); + Assert.Equal("Started.Withdrawn.", await reader.ReadToEndAsync()); + Assert.Equal("Test=Value1; path=/; samesite=lax", httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + [Fact] + public async Task DeleteCookieDoesNotRequireConsent() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Delete("Test"); + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var testCookie = cookies[0]; + Assert.Equal("Test", testCookie.Name); + Assert.Equal("", testCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, testCookie.SameSite); + Assert.NotNull(testCookie.Expires); + } + + [Fact] + public async Task OnDeleteCookieCanSuppressCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.OnDeleteCookie = context => + { + Assert.True(context.IsConsentNeeded); + Assert.False(context.HasConsent); + Assert.True(context.IssueCookie); + context.IssueCookie = false; + }; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + context.Response.Cookies.Delete("Test"); + return Task.CompletedTask; + }); + + Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); + } + + private Task RunTestAsync(Action configureOptions, Action configureRequest, RequestDelegate handleRequest) + { + var builder = new WebHostBuilder() + .ConfigureServices(services => + { + services.Configure(configureOptions); + }) + .Configure(app => + { + app.UseCookiePolicy(); + app.Run(handleRequest); + }); + var server = new TestServer(builder); + return server.SendAsync(configureRequest); + } + } +} \ No newline at end of file From 13e2a16b319b94918e626659ead4322737f58a8d Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 28 Dec 2017 11:52:47 -0800 Subject: [PATCH 120/248] Update dependencies for CookiePolicy --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 9eca47a75..f145edd9c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,33 +4,33 @@
2.1.0-preview1-15626 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 3.14.1 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 2.1.0-preview1-27918 + 3.14.2 5.2.0-preview2-41113220915 2.0.0 2.1.0-preview1-26016-05 From c67cc03b778afa28a3dafbfa7695650c4d9a70ff Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 31 Dec 2017 21:58:42 +0000 Subject: [PATCH 121/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index f145edd9c..3540fc231 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15626 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 - 2.1.0-preview1-27918 + 2.1.0-preview1-15651 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 3.14.2 5.2.0-preview2-41113220915 2.0.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 8d52a6128..7c2e97aa7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15626 -commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 +version:2.1.0-preview1-15651 +commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 From e13ceb690bfe2a534fa11720d75fd87b4e07d6b0 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 29 Dec 2017 15:59:34 -0800 Subject: [PATCH 122/248] Detect remote denails for Twitter accounts --- .../TwitterHandler.cs | 6 ++++++ .../TwitterTests.cs | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index acfd765d9..670e76f7e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -60,6 +60,12 @@ protected override async Task HandleRemoteAuthenticateAsync // REVIEW: see which of these are really errors + var denied = query["denied"]; + if (!StringValues.IsNullOrEmpty(denied)) + { + return HandleRequestResult.Fail("The user denied permissions.", properties); + } + var returnedToken = query["oauth_token"]; if (StringValues.IsNullOrEmpty(returnedToken)) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 735cb3314..2a63757b9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -195,6 +195,7 @@ public async Task BadCallbackCallsRemoteAuthFailedWithState() OnRemoteFailure = context => { Assert.NotNull(context.Failure); + Assert.Equal("The user denied permissions.", context.Failure.Message); Assert.NotNull(context.Properties); Assert.Equal("testvalue", context.Properties.Items["testkey"]); context.Response.StatusCode = StatusCodes.Status406NotAcceptable; @@ -220,7 +221,7 @@ public async Task BadCallbackCallsRemoteAuthFailedWithState() var setCookieValue = setCookieValues.Single(); var cookie = new CookieHeaderValue(setCookieValue.Name, setCookieValue.Value); - var request = new HttpRequestMessage(HttpMethod.Get, "/signin-twitter"); + var request = new HttpRequestMessage(HttpMethod.Get, "/signin-twitter?denied=ABCDEFG"); request.Headers.Add(HeaderNames.Cookie, cookie.ToString()); var client = server.CreateClient(); var response = await client.SendAsync(request); From da066d50e062b850b92606e4ee8673586ad0df07 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 4 Jan 2018 02:05:41 +0000 Subject: [PATCH 123/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3540fc231..cdb400f90 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 2.1.0-preview1-15651 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 3.14.2 5.2.0-preview2-41113220915 2.0.0 From 1f855f7b062a6870607a233b32a23cb65c2bee1c Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 5 Jan 2018 12:34:39 -0800 Subject: [PATCH 124/248] Implement ITrackingConsentFeature.CreateConsentCookie() #1590 --- Security.sln | 1 + .../ResponseCookiesWrapper.cs | 37 +++++++- .../CookieConsentTests.cs | 85 +++++++++++++++++++ 3 files changed, 119 insertions(+), 4 deletions(-) diff --git a/Security.sln b/Security.sln index 543b3be26..f598f34eb 100644 --- a/Security.sln +++ b/Security.sln @@ -68,6 +68,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build\Key.snk = build\Key.snk NuGet.config = NuGet.config build\repo.props = build\repo.props + build\sources.props = build\sources.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authorization.Policy", "src\Microsoft.AspNetCore.Authorization.Policy\Microsoft.AspNetCore.Authorization.Policy.csproj", "{58194599-F07D-47A3-9DF2-E21A22C5EF9E}" diff --git a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs index fa68a3cbe..e05cc9466 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs @@ -82,6 +82,30 @@ public void WithdrawConsent() _hasConsent = false; } + // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. + public string CreateConsentCookie() + { + var key = Options.ConsentCookie.Name; + var value = ConsentValue; + var options = Options.ConsentCookie.Build(Context); + ApplyAppendPolicy(ref key, ref value, options); + + var setCookieHeaderValue = new Net.Http.Headers.SetCookieHeaderValue( + Uri.EscapeDataString(key), + Uri.EscapeDataString(value)) + { + Domain = options.Domain, + Path = options.Path, + Expires = options.Expires, + MaxAge = options.MaxAge, + Secure = options.Secure, + SameSite = (Net.Http.Headers.SameSiteMode)options.SameSite, + HttpOnly = options.HttpOnly + }; + + return setCookieHeaderValue.ToString(); + } + private bool CheckPolicyRequired() { return !CanTrack @@ -109,6 +133,14 @@ public void Append(string key, string value, CookieOptions options) throw new ArgumentNullException(nameof(options)); } + if (ApplyAppendPolicy(ref key, ref value, options)) + { + Cookies.Append(key, value, options); + } + } + + private bool ApplyAppendPolicy(ref string key, ref string value, CookieOptions options) + { var issueCookie = CanTrack || options.IsEssential; ApplyPolicy(options); if (Options.OnAppendCookie != null) @@ -126,10 +158,7 @@ public void Append(string key, string value, CookieOptions options) issueCookie = context.IssueCookie; } - if (issueCookie) - { - Cookies.Append(key, value, options); - } + return issueCookie; } public void Delete(string key) diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs index 4e62d54a2..3cd018e57 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -542,6 +542,91 @@ public async Task OnDeleteCookieCanSuppressCookie() Assert.Empty(httpContext.Response.Headers[HeaderNames.SetCookie]); } + [Fact] + public async Task CreateConsentCookieMatchesGrantConsentCookie() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + var cookie = feature.CreateConsentCookie(); + context.Response.Headers["ManualCookie"] = cookie; + + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent", consentCookie.Name); + Assert.Equal("yes", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + + Assert.Equal(httpContext.Response.Headers[HeaderNames.SetCookie], httpContext.Response.Headers["ManualCookie"]); + } + + [Fact] + public async Task CreateConsentCookieAppliesPolicy() + { + var httpContext = await RunTestAsync(options => + { + options.CheckConsentNeeded = context => true; + options.MinimumSameSitePolicy = Http.SameSiteMode.Strict; + options.OnAppendCookie = context => + { + Assert.Equal(".AspNet.Consent", context.CookieName); + Assert.Equal("yes", context.CookieValue); + Assert.Equal(Http.SameSiteMode.Strict, context.CookieOptions.SameSite); + context.CookieName += "1"; + context.CookieValue += "1"; + }; + }, + requestContext => { }, + context => + { + var feature = context.Features.Get(); + Assert.True(feature.IsConsentNeeded); + Assert.False(feature.HasConsent); + Assert.False(feature.CanTrack); + + feature.GrantConsent(); + + Assert.True(feature.IsConsentNeeded); + Assert.True(feature.HasConsent); + Assert.True(feature.CanTrack); + + var cookie = feature.CreateConsentCookie(); + context.Response.Headers["ManualCookie"] = cookie; + + return Task.CompletedTask; + }); + + var cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers[HeaderNames.SetCookie]); + Assert.Equal(1, cookies.Count); + var consentCookie = cookies[0]; + Assert.Equal(".AspNet.Consent1", consentCookie.Name); + Assert.Equal("yes1", consentCookie.Value); + Assert.Equal(Net.Http.Headers.SameSiteMode.Strict, consentCookie.SameSite); + Assert.NotNull(consentCookie.Expires); + + Assert.Equal(httpContext.Response.Headers[HeaderNames.SetCookie], httpContext.Response.Headers["ManualCookie"]); + } + private Task RunTestAsync(Action configureOptions, Action configureRequest, RequestDelegate handleRequest) { var builder = new WebHostBuilder() From 226b24060f72a7d63e6a6f8f3eaeb4dc5a909fe5 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 8 Jan 2018 09:11:13 -0800 Subject: [PATCH 125/248] Update deps --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index cdb400f90..bf30832e1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,36 +4,36 @@ 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 + 2.1.0-preview1-28009 3.14.2 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26016-05 + 2.1.0-preview1-26102-01 15.3.0 3.0.1 3.0.1 From dde7671c06da64e4a7a290c37ed86e9a9bdd0dd7 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 8 Jan 2018 09:23:06 -0800 Subject: [PATCH 126/248] OIDC: Use IdentityModel redirect form generator #1448 --- .../OpenIdConnectHandler.cs | 44 +------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 7981cafd1..4f722323d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -16,7 +16,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Primitives; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Tokens; using Microsoft.Net.Http.Headers; @@ -30,23 +29,8 @@ namespace Microsoft.AspNetCore.Authentication.OpenIdConnect public class OpenIdConnectHandler : RemoteAuthenticationHandler, IAuthenticationSignOutHandler { private const string NonceProperty = "N"; - private const string UriSchemeDelimiter = "://"; private const string HeaderValueEpocDate = "Thu, 01 Jan 1970 00:00:00 GMT"; - private const string InputTagFormat = @""; - private const string HtmlFormFormat = @" - - - Please wait while you're being redirected to the identity provider - - -
- {1} - -
- - -"; private static readonly RandomNumberGenerator CryptoRandom = RandomNumberGenerator.Create(); @@ -241,19 +225,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) } else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) { - var inputs = new StringBuilder(); - foreach (var parameter in message.Parameters) - { - var name = HtmlEncoder.Encode(parameter.Key); - var value = HtmlEncoder.Encode(parameter.Value); - - var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value); - inputs.AppendLine(input); - } - - var issuer = HtmlEncoder.Encode(message.IssuerAddress); - - var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs); + var content = message.BuildFormPost(); var buffer = Encoding.UTF8.GetBytes(content); Response.ContentLength = buffer.Length; @@ -422,19 +394,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop } else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) { - var inputs = new StringBuilder(); - foreach (var parameter in message.Parameters) - { - var name = HtmlEncoder.Encode(parameter.Key); - var value = HtmlEncoder.Encode(parameter.Value); - - var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value); - inputs.AppendLine(input); - } - - var issuer = HtmlEncoder.Encode(message.IssuerAddress); - - var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs); + var content = message.BuildFormPost(); var buffer = Encoding.UTF8.GetBytes(content); Response.ContentLength = buffer.Length; From ba1eb281d135400436c52c17edc71307bc038ec0 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 16 Jan 2018 11:40:05 -0800 Subject: [PATCH 127/248] Stop logging username/token Fixes https://github.com/aspnet/Security/issues/1259 --- .../JwtBearerHandler.cs | 2 +- .../LoggingExtensions.cs | 20 +++++--------- .../DefaultAuthorizationService.cs | 26 ++----------------- .../LoggingExtensions.cs | 24 +++++++---------- 4 files changed, 20 insertions(+), 52 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index f894a97d0..6d5c7f5f5 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -110,7 +110,7 @@ protected override async Task HandleAuthenticateAsync() } catch (Exception ex) { - Logger.TokenValidationFailed(token, ex); + Logger.TokenValidationFailed(ex); // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the event. if (Options.RefreshOnIssuerKeyNotFound && Options.ConfigurationManager != null diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs index 38a75feca..5c6ca088a 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/LoggingExtensions.cs @@ -7,16 +7,16 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static Action _tokenValidationFailed; + private static Action _tokenValidationFailed; private static Action _tokenValidationSucceeded; private static Action _errorProcessingMessage; static LoggingExtensions() { - _tokenValidationFailed = LoggerMessage.Define( + _tokenValidationFailed = LoggerMessage.Define( eventId: 1, logLevel: LogLevel.Information, - formatString: "Failed to validate the token {Token}"); + formatString: "Failed to validate the token."); _tokenValidationSucceeded = LoggerMessage.Define( eventId: 2, logLevel: LogLevel.Information, @@ -27,19 +27,13 @@ static LoggingExtensions() formatString: "Exception occurred while processing message."); } - public static void TokenValidationFailed(this ILogger logger, string token, Exception ex) - { - _tokenValidationFailed(logger, token, ex); - } + public static void TokenValidationFailed(this ILogger logger, Exception ex) + => _tokenValidationFailed(logger, ex); public static void TokenValidationSucceeded(this ILogger logger) - { - _tokenValidationSucceeded(logger, null); - } + => _tokenValidationSucceeded(logger, null); public static void ErrorProcessingMessage(this ILogger logger, Exception ex) - { - _errorProcessingMessage(logger, ex); - } + => _errorProcessingMessage(logger, ex); } } diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs index 9773ebbcc..bc5d571c4 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationService.cs @@ -98,37 +98,15 @@ public async Task AuthorizeAsync(ClaimsPrincipal user, obje var result = _evaluator.Evaluate(authContext); if (result.Succeeded) { - _logger.UserAuthorizationSucceeded(GetUserNameForLogging(user)); + _logger.UserAuthorizationSucceeded(); } else { - _logger.UserAuthorizationFailed(GetUserNameForLogging(user)); + _logger.UserAuthorizationFailed(); } return result; } - private string GetUserNameForLogging(ClaimsPrincipal user) - { - var identity = user?.Identity; - if (identity != null) - { - var name = identity.Name; - if (name != null) - { - return name; - } - return GetClaimValue(identity, "sub") - ?? GetClaimValue(identity, ClaimTypes.Name) - ?? GetClaimValue(identity, ClaimTypes.NameIdentifier); - } - return null; - } - - private static string GetClaimValue(IIdentity identity, string claimsType) - { - return (identity as ClaimsIdentity)?.FindFirst(claimsType)?.Value; - } - /// /// Checks if a user meets a specific authorization policy. /// diff --git a/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs index 1d524dd74..386df85e0 100644 --- a/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authorization/LoggingExtensions.cs @@ -7,29 +7,25 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static Action _userAuthorizationFailed; - private static Action _userAuthorizationSucceeded; + private static Action _userAuthorizationFailed; + private static Action _userAuthorizationSucceeded; static LoggingExtensions() { - _userAuthorizationSucceeded = LoggerMessage.Define( + _userAuthorizationSucceeded = LoggerMessage.Define( eventId: 1, logLevel: LogLevel.Information, - formatString: "Authorization was successful for user: {UserName}."); - _userAuthorizationFailed = LoggerMessage.Define( + formatString: "Authorization was successful."); + _userAuthorizationFailed = LoggerMessage.Define( eventId: 2, logLevel: LogLevel.Information, - formatString: "Authorization failed for user: {UserName}."); + formatString: "Authorization failed."); } - public static void UserAuthorizationSucceeded(this ILogger logger, string userName) - { - _userAuthorizationSucceeded(logger, userName, null); - } + public static void UserAuthorizationSucceeded(this ILogger logger) + => _userAuthorizationSucceeded(logger, null); - public static void UserAuthorizationFailed(this ILogger logger, string userName) - { - _userAuthorizationFailed(logger, userName, null); - } + public static void UserAuthorizationFailed(this ILogger logger) + => _userAuthorizationFailed(logger, null); } } From c534335cb0b10b45708e2be2f94a94a86d6148a2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 23 Jan 2018 15:32:49 -0800 Subject: [PATCH 128/248] Branching for 2.1.0-preview1 --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- build/repo.props | 4 +-- build/sources.props | 4 +-- korebuild-lock.txt | 4 +-- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index bf30832e1..1aaf7a18a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,37 +3,37 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
- 2.1.0-preview1-15651 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 + 2.1.0-preview1-15679 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 3.14.2 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26102-01 + 2.1.0-preview1-26115-03 15.3.0 3.0.1 3.0.1 diff --git a/build/repo.props b/build/repo.props index 541470c9f..2ab5a2ae3 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -7,7 +7,7 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9feff29d0..5d6639333 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,11 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7c2e97aa7..a474bc0e3 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15651 -commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 +version:2.1.0-preview1-15679 +commithash:5347461137cb45a77ddcc0b55b2478092de43338 From a940b6e3564c911dfdf96c850d78e9c785ade88e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 24 Jan 2018 15:00:29 -0800 Subject: [PATCH 129/248] Updating version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 5c4a7c32d..370d5abab 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview1 + preview2 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From ab8328abcaceb4569bd8c3c1b3177a88f19a3489 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 25 Jan 2018 15:55:46 -0800 Subject: [PATCH 130/248] Raise the CookiePolicy consent cookie lifetime to one year #1589 --- src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs | 2 +- .../CookieConsentTests.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs index cc2deaa3a..32d047297 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyOptions.cs @@ -30,7 +30,7 @@ public class CookiePolicyOptions public CookieBuilder ConsentCookie { get; set; } = new CookieBuilder() { Name = ".AspNet.Consent", - Expiration = TimeSpan.FromDays(90), + Expiration = TimeSpan.FromDays(365), IsEssential = true, }; diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs index 3cd018e57..4e35c165f 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -221,6 +221,8 @@ public async Task GrantConsentSetsCookie() var consentCookie = cookies[0]; Assert.Equal(".AspNet.Consent", consentCookie.Name); Assert.Equal("yes", consentCookie.Value); + Assert.True(consentCookie.Expires.HasValue); + Assert.True(consentCookie.Expires.Value > DateTimeOffset.Now + TimeSpan.FromDays(364)); Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); Assert.NotNull(consentCookie.Expires); var testCookie = cookies[1]; From 272aa16322f25f6c054598bdc06e7518ed0212fa Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 26 Jan 2018 11:46:35 -0800 Subject: [PATCH 131/248] Update JwtBearer sample error handling #1613 --- samples/JwtBearerSample/Startup.cs | 44 ++++++++++-------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/samples/JwtBearerSample/Startup.cs b/samples/JwtBearerSample/Startup.cs index 6f2c5e2ec..8c4a63cad 100644 --- a/samples/JwtBearerSample/Startup.cs +++ b/samples/JwtBearerSample/Startup.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.ExceptionServices; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; @@ -43,33 +44,13 @@ public Startup(IHostingEnvironment env) // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { - // This can be removed after https://github.com/aspnet/IISIntegration/issues/371 - services.AddAuthentication(options => - { - options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; - options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; - }).AddJwtBearer(o => - { - // You also need to update /wwwroot/app/scripts/app.js - o.Authority = Configuration["jwt:authority"]; - o.Audience = Configuration["jwt:audience"]; - o.Events = new JwtBearerEvents() + services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(o => { - OnAuthenticationFailed = c => - { - c.NoResult(); - - c.Response.StatusCode = 500; - c.Response.ContentType = "text/plain"; - if (Environment.IsDevelopment()) - { - // Debug only, in production do not share exceptions with the remote host. - return c.Response.WriteAsync(c.Exception.ToString()); - } - return c.Response.WriteAsync("An error occurred processing your authentication."); - } - }; - }); + // You also need to update /wwwroot/app/scripts/app.js + o.Authority = Configuration["oidc:authority"]; + o.Audience = Configuration["oidc:clientid"]; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -86,13 +67,16 @@ public void Configure(IApplicationBuilder app) app.Use(async (context, next) => { // Use this if there are multiple authentication schemes - // var user = await context.Authentication.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme); - - var user = context.User; // We can do this because of there's only a single authentication scheme - if (user?.Identity?.IsAuthenticated ?? false) + var authResult = await context.AuthenticateAsync(JwtBearerDefaults.AuthenticationScheme); + if (authResult.Succeeded && authResult.Principal.Identity.IsAuthenticated) { await next(); } + else if (authResult.Failure != null) + { + // Rethrow, let the exception page handle it. + ExceptionDispatchInfo.Capture(authResult.Failure).Throw(); + } else { await context.ChallengeAsync(); From c729063c31d60753bc3bf08a91768a5de32e1f3d Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Tue, 30 Jan 2018 15:27:52 -0800 Subject: [PATCH 132/248] Fix flaky cookie policy tests #1629 --- .../CookieConsentTests.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs index 4e35c165f..fffb8cc88 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookieConsentTests.cs @@ -579,7 +579,13 @@ public async Task CreateConsentCookieMatchesGrantConsentCookie() Assert.Equal(Net.Http.Headers.SameSiteMode.Lax, consentCookie.SameSite); Assert.NotNull(consentCookie.Expires); - Assert.Equal(httpContext.Response.Headers[HeaderNames.SetCookie], httpContext.Response.Headers["ManualCookie"]); + cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers["ManualCookie"]); + Assert.Equal(1, cookies.Count); + var manualCookie = cookies[0]; + Assert.Equal(consentCookie.Name, manualCookie.Name); + Assert.Equal(consentCookie.Value, manualCookie.Value); + Assert.Equal(consentCookie.SameSite, manualCookie.SameSite); + Assert.NotNull(manualCookie.Expires); // Expires may not exactly match to the second. } [Fact] @@ -626,7 +632,13 @@ public async Task CreateConsentCookieAppliesPolicy() Assert.Equal(Net.Http.Headers.SameSiteMode.Strict, consentCookie.SameSite); Assert.NotNull(consentCookie.Expires); - Assert.Equal(httpContext.Response.Headers[HeaderNames.SetCookie], httpContext.Response.Headers["ManualCookie"]); + cookies = SetCookieHeaderValue.ParseList(httpContext.Response.Headers["ManualCookie"]); + Assert.Equal(1, cookies.Count); + var manualCookie = cookies[0]; + Assert.Equal(consentCookie.Name, manualCookie.Name); + Assert.Equal(consentCookie.Value, manualCookie.Value); + Assert.Equal(consentCookie.SameSite, manualCookie.SameSite); + Assert.NotNull(manualCookie.Expires); // Expires may not exactly match to the second. } private Task RunTestAsync(Action configureOptions, Action configureRequest, RequestDelegate handleRequest) From 088dc56f3daad861abbdd1ad665a85b99d65e848 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 31 Jan 2018 15:01:13 -0800 Subject: [PATCH 133/248] Update dependencies.props to 2.1.0-preview-28193, build tools to 2.1.0-preview1-1010 [ci skip] Scripted changes: - updated travis and appveyor.yml files to only build dev, ci, and release branches - updated dependencies.props - updated korebuild-lock.txt - updated korebuild.json to release/2.1 channel --- .appveyor.yml | 16 +++++------- .travis.yml | 24 ++++++++--------- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- korebuild.json | 4 +-- 5 files changed, 51 insertions(+), 53 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index c7b6e3431..4eea96ab6 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,19 +1,17 @@ init: - - git config --global core.autocrlf true +- git config --global core.autocrlf true branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ build_script: - - ps: .\run.ps1 default-build +- ps: .\run.ps1 default-build clone_depth: 1 environment: global: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: off -deploy: off +test: 'off' +deploy: 'off' os: Visual Studio 2017 diff --git a/.travis.yml b/.travis.yml index 6c59666f3..64bdbb444 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,25 +3,25 @@ sudo: false dist: trusty env: global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 mono: none os: - - linux - - osx +- linux +- osx osx_image: xcode8.2 addons: apt: packages: - - libunwind8 + - libunwind8 branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi +- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s + /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib + /usr/local/lib/; fi script: - - ./build.sh +- ./build.sh diff --git a/build/dependencies.props b/build/dependencies.props index 1aaf7a18a..bd1daf187 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,37 +3,37 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15679 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 + 2.1.0-preview1-1010 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 3.14.2 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26115-03 + 2.1.0-preview1-26122-01 15.3.0 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a474bc0e3..851bfbf20 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15679 -commithash:5347461137cb45a77ddcc0b55b2478092de43338 +version:2.1.0-preview1-1010 +commithash:75ca924dfbd673c38841025b04c4dcd93b84f56d diff --git a/korebuild.json b/korebuild.json index bd5d51a51..678d8bb94 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From c1171cd3ff0de71e6ce3e100059fa0115ebb8ee1 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 1 Feb 2018 04:30:48 +0000 Subject: [PATCH 134/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index bf30832e1..c5a4ece3c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,37 +3,37 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15651 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 - 2.1.0-preview1-28009 + 2.1.0-preview2-15692 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 3.14.2 5.2.0-preview2-41113220915 2.0.0 - 2.1.0-preview1-26102-01 + 2.1.0-preview2-26130-04 15.3.0 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7c2e97aa7..232cb858c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15651 -commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 +version:2.1.0-preview2-15692 +commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 From c0b8be58ba0ccdb3a4cd38825c30536f60ab99ce Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 1 Feb 2018 14:40:56 -0800 Subject: [PATCH 135/248] Add scheme forwarding (authN policies) (#1625) --- .../CookieAuthenticationHandler.cs | 14 + .../OpenIdConnectHandler.cs | 7 + .../AuthenticationHandler.cs | 30 ++ .../AuthenticationSchemeOptions.cs | 53 +++ .../CookieTests.cs | 412 ++++++++++++++++- .../FacebookTests.cs | 397 ++++++++++++++++ .../GoogleTests.cs | 409 ++++++++++++++++- .../JwtBearerTests.cs | 399 ++++++++++++++++- .../MicrosoftAccountTests.cs | 395 ++++++++++++++++ .../OAuthTests.cs | 422 +++++++++++++++++- .../OpenIdConnectConfigurationTests.cs | 418 +++++++++++++++++ .../TestHandlers.cs | 115 +++++ .../TwitterTests.cs | 396 ++++++++++++++++ 13 files changed, 3441 insertions(+), 26 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 5d0afba46..9a2fbfbc7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -240,6 +240,13 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper throw new ArgumentNullException(nameof(user)); } + var target = ResolveTarget(Options.ForwardSignIn); + if (target != null) + { + await Context.SignInAsync(target, user, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); _signInCalled = true; @@ -322,6 +329,13 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper public async virtual Task SignOutAsync(AuthenticationProperties properties) { + var target = ResolveTarget(Options.ForwardSignOut); + if (target != null) + { + await Context.SignOutAsync(target, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); _signOutCalled = true; diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 4f722323d..ce7494fb4 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -155,6 +155,13 @@ protected virtual async Task HandleRemoteSignOutAsync() /// A task executing the sign out procedure public async virtual Task SignOutAsync(AuthenticationProperties properties) { + var target = ResolveTarget(Options.ForwardSignOut); + if (target != null) + { + await Context.SignOutAsync(target, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); Logger.EnteringOpenIdAuthenticationHandlerHandleSignOutAsync(GetType().FullName); diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index ef4292100..4399ce5f7 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -118,8 +118,24 @@ protected virtual async Task InitializeEventsAsync() protected string BuildRedirectUri(string targetPath) => Request.Scheme + "://" + Request.Host + OriginalPathBase + targetPath; + protected virtual string ResolveTarget(string scheme) + { + var target = scheme ?? Options.ForwardDefaultSelector?.Invoke(Context) ?? Options.ForwardDefault; + + // Prevent self targetting + return string.Equals(target, Scheme.Name, StringComparison.Ordinal) + ? null + : target; + } + public async Task AuthenticateAsync() { + var target = ResolveTarget(Options.ForwardAuthenticate); + if (target != null) + { + return await Context.AuthenticateAsync(target); + } + // Calling Authenticate more than once should always return the original value. var result = await HandleAuthenticateOnceAsync(); if (result?.Failure == null) @@ -200,6 +216,13 @@ protected virtual Task HandleChallengeAsync(AuthenticationProperties properties) public async Task ChallengeAsync(AuthenticationProperties properties) { + var target = ResolveTarget(Options.ForwardChallenge); + if (target != null) + { + await Context.ChallengeAsync(target, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); await HandleChallengeAsync(properties); Logger.AuthenticationSchemeChallenged(Scheme.Name); @@ -207,6 +230,13 @@ public async Task ChallengeAsync(AuthenticationProperties properties) public async Task ForbidAsync(AuthenticationProperties properties) { + var target = ResolveTarget(Options.ForwardForbid); + if (target != null) + { + await Context.ForbidAsync(target, properties); + return; + } + properties = properties ?? new AuthenticationProperties(); await HandleForbiddenAsync(properties); Logger.AuthenticationSchemeForbidden(Scheme.Name); diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs index 18d4c9788..a547d203b 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationSchemeOptions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication { @@ -36,5 +37,57 @@ public virtual void Validate(string scheme) /// If set, will be used as the service type to get the Events instance instead of the property. ///
public Type EventsType { get; set; } + + /// + /// If set, this specifies a default scheme that authentication handlers should forward all authentication operations to + /// by default. The default forwarding logic will check the most specific ForwardAuthenticate/Challenge/Forbid/SignIn/SignOut + /// setting first, followed by checking the ForwardDefaultSelector, followed by ForwardDefault. The first non null result + /// will be used as the target scheme to forward to. + /// + public string ForwardDefault { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward AuthenticateAsync calls to. + /// For example Context.AuthenticateAsync("ThisScheme") => Context.AuthenticateAsync("ForwardAuthenticateValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardAuthenticate { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward ChallengeAsync calls to. + /// For example Context.ChallengeAsync("ThisScheme") => Context.ChallengeAsync("ForwardChallengeValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardChallenge { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward ForbidAsync calls to. + /// For example Context.ForbidAsync("ThisScheme") => Context.ForbidAsync("ForwardForbidValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardForbid { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward SignInAsync calls to. + /// For example Context.SignInAsync("ThisScheme") => Context.SignInAsync("ForwardSignInValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardSignIn { get; set; } + + /// + /// If set, this specifies the target scheme that this scheme should forward SignOutAsync calls to. + /// For example Context.SignOutAsync("ThisScheme") => Context.SignInAsync("ForwardSignOutValue"); + /// Set the target to the current scheme to disable forwarding and allow normal processing. + /// + public string ForwardSignOut { get; set; } + + /// + /// Used to select a default scheme for the current request that authentication handlers should forward all authentication operations to + /// by default. The default forwarding logic will check the most specific ForwardAuthenticate/Challenge/Forbid/SignIn/SignOut + /// setting first, followed by checking the ForwardDefaultSelector, followed by ForwardDefault. The first non null result + /// will be used as the target scheme to forward to. + /// + public Func ForwardDefaultSelector { get; set; } + } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 789f5ede9..b2726bac8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics; using System.Linq; using System.Net; using System.Net.Http; @@ -11,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using System.Xml.Linq; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -26,6 +26,416 @@ public class CookieTests { private TestClock _clock = new TestClock(); + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddCookie(o => o.ForwardDefault = "auth1"); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, forwardDefault.SignInCount); + } + + [Fact] + public async Task ForwardSignInWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardSignIn = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, specific.SignInCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignOutCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSignOutWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, selector.SignOutCount); + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, selector.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, forwardDefault.SignInCount); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddCookie(o => + { + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 2314b6b3c..684482ed5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -5,11 +5,13 @@ using System.Linq; using System.Net; using System.Net.Http; +using System.Security.Claims; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -24,6 +26,401 @@ namespace Microsoft.AspNetCore.Authentication.Facebook { public class FacebookTests { + private void ConfigureDefaults(FacebookOptions o) + { + o.AppId = "whatever"; + o.AppSecret = "whatever"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = FacebookDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddFacebook(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 944a4827c..8bfbaacde 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -10,6 +10,7 @@ using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -24,6 +25,401 @@ namespace Microsoft.AspNetCore.Authentication.Google { public class GoogleTests { + private void ConfigureDefaults(GoogleOptions o) + { + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = GoogleDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddGoogle(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { @@ -1061,18 +1457,13 @@ private static TestServer CreateServer(Action configureOptions, F .ConfigureServices(services => { services.AddTransient(); - services.AddAuthentication("Auth") - .AddVirtualScheme("Auth", "Auth", o => - { - o.Default = TestExtensions.CookieAuthenticationScheme; - o.Challenge = GoogleDefaults.AuthenticationScheme; - }) - .AddCookie(TestExtensions.CookieAuthenticationScheme) + services.AddAuthentication(TestExtensions.CookieAuthenticationScheme) + .AddCookie(TestExtensions.CookieAuthenticationScheme, o => o.ForwardChallenge = GoogleDefaults.AuthenticationScheme) .AddGoogle(configureOptions) .AddFacebook(o => { - o.AppId = "Test AppId"; - o.AppSecret = "Test AppSecrent"; + o.ClientId = "Test ClientId"; + o.ClientSecret = "Test AppSecrent"; }); }); return new TestServer(builder); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 97adb2105..b472a4162 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; @@ -11,14 +10,13 @@ using System.Text; using System.Threading.Tasks; using System.Xml.Linq; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; using Xunit; @@ -26,6 +24,401 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer { public class JwtBearerTests { + private void ConfigureDefaults(JwtBearerOptions o) + { + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddJwtBearer(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySchemeDefaults() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index b2854e344..480241d35 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -27,6 +27,401 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { public class MicrosoftAccountTests { + private void ConfigureDefaults(MicrosoftAccountOptions o) + { + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddMicrosoftAccount(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 65d865b94..9279f145b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -4,20 +4,416 @@ using System; using System.Collections.Generic; using System.Net; +using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.OAuth { public class OAuthTests { + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.SignInScheme = "auth1"; + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.SignInScheme = "auth1"; + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.SignInScheme = "auth1"; + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.DefaultSignInScheme = "auth1"; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = "default"; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOAuth("default", o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { @@ -131,12 +527,7 @@ public async Task RedirectToIdentityProvider_SetsCorrelationIdCookiePath_ToCallB "Weblie", opt => { - opt.ClientId = "Test Id"; - opt.ClientSecret = "secret"; - opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; - opt.AuthorizationEndpoint = "https://example.com/provider/login"; - opt.TokenEndpoint = "https://example.com/provider/token"; - opt.CallbackPath = "/oauth-callback"; + ConfigureDefaults(opt); }), async ctx => { @@ -162,12 +553,7 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv "Weblie", opt => { - opt.ClientId = "Test Id"; - opt.ClientSecret = "secret"; - opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; - opt.AuthorizationEndpoint = "https://example.com/provider/login"; - opt.TokenEndpoint = "https://example.com/provider/token"; - opt.CallbackPath = "/oauth-callback"; + ConfigureDefaults(opt); opt.CorrelationCookie.Path = "/"; }), async ctx => @@ -186,6 +572,16 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv Assert.Contains("path=/", correlation); } + private void ConfigureDefaults(OAuthOptions o) + { + o.ClientId = "Test Id"; + o.ClientSecret = "secret"; + o.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + o.AuthorizationEndpoint = "https://example.com/provider/login"; + o.TokenEndpoint = "https://example.com/provider/token"; + o.CallbackPath = "/oauth-callback"; + } + [Fact] public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs index 69ba75829..ed368c1ef 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectConfigurationTests.cs @@ -3,10 +3,13 @@ using System; using System.Net; +using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -15,6 +18,421 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect { public class OpenIdConnectConfigurationTests { + private void ConfigureDefaults(OpenIdConnectOptions o) + { + o.Authority = TestServerBuilder.DefaultAuthority; + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, selector.SignOutCount); + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = OpenIdConnectDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddOpenIdConnect(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task MetadataAddressIsGeneratedFromAuthorityWhenMissing() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs b/test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs new file mode 100644 index 000000000..cd9fe9fb1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/TestHandlers.cs @@ -0,0 +1,115 @@ +// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. + +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication.Tests +{ + public class TestAuthHandler : AuthenticationHandler, IAuthenticationSignInHandler + { + public TestAuthHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { } + + public int SignInCount { get; set; } + public int SignOutCount { get; set; } + public int ForbidCount { get; set; } + public int ChallengeCount { get; set; } + public int AuthenticateCount { get; set; } + + protected override Task HandleChallengeAsync(AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + protected override Task HandleForbiddenAsync(AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + protected override Task HandleAuthenticateAsync() + { + AuthenticateCount++; + var principal = new ClaimsPrincipal(); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + principal.AddIdentity(id); + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); + } + + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + SignInCount++; + return Task.CompletedTask; + } + + public Task SignOutAsync(AuthenticationProperties properties) + { + SignOutCount++; + return Task.CompletedTask; + } + } + + public class TestHandler : IAuthenticationSignInHandler + { + public AuthenticationScheme Scheme { get; set; } + public int SignInCount { get; set; } + public int SignOutCount { get; set; } + public int ForbidCount { get; set; } + public int ChallengeCount { get; set; } + public int AuthenticateCount { get; set; } + + public Task AuthenticateAsync() + { + AuthenticateCount++; + var principal = new ClaimsPrincipal(); + var id = new ClaimsIdentity(); + id.AddClaim(new Claim(ClaimTypes.NameIdentifier, Scheme.Name, ClaimValueTypes.String, Scheme.Name)); + principal.AddIdentity(id); + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(principal, new AuthenticationProperties(), Scheme.Name))); + } + + public Task ChallengeAsync(AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + public Task ForbidAsync(AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) + { + Scheme = scheme; + return Task.CompletedTask; + } + + public Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + SignInCount++; + return Task.CompletedTask; + } + + public Task SignOutAsync(AuthenticationProperties properties) + { + SignOutCount++; + return Task.CompletedTask; + } + } + + public class TestHandler2 : TestHandler + { + } + + public class TestHandler3 : TestHandler + { + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index 2a63757b9..c1937d136 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -7,6 +7,7 @@ using System.Security.Claims; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -19,6 +20,401 @@ namespace Microsoft.AspNetCore.Authentication.Twitter { public class TwitterTests { + private void ConfigureDefaults(TwitterOptions o) + { + o.ConsumerKey = "whatever"; + o.ConsumerSecret = "whatever"; + o.SignInScheme = "auth1"; + } + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + }); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignInThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + [Fact] + public async Task ForwardSignOutThrows() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("specific", "specific"); + o.AddScheme("auth1", "auth1"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + services.AddAuthentication(o => + { + o.DefaultScheme = TwitterDefaults.AuthenticationScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }) + .AddTwitter(o => + { + ConfigureDefaults(o); + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + await Assert.ThrowsAsync(() => context.SignOutAsync()); + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + [Fact] public async Task VerifySignInSchemeCannotBeSetToSelf() { From 29ed4ce9f64b6df26706f7e431ff815573004a49 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sat, 3 Feb 2018 03:03:01 +0000 Subject: [PATCH 136/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c5a4ece3c..b3ced8688 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15692 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 + 2.1.0-preview2-15694 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 3.14.2 5.2.0-preview2-41113220915 2.0.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 232cb858c..6f294ef0e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15692 -commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 +version:2.1.0-preview2-15694 +commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b From 59c7cd0efe33687dcdc4f7701933b85dd89a340c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 9 Feb 2018 12:00:17 -0800 Subject: [PATCH 137/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index b3ced8688..140d9ddbc 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,35 +3,35 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15694 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 + 2.1.0-preview2-15698 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 3.14.2 - 5.2.0-preview2-41113220915 + 5.2.0 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 6f294ef0e..3e2b56b91 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15694 -commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b +version:2.1.0-preview2-15698 +commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 From 5de25bb11cfb2bf60d05ea2be36e80d86b38d18b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 11 Feb 2018 12:40:54 -0800 Subject: [PATCH 138/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 140d9ddbc..7fcf154c2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 2.1.0-preview2-15698 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 3.14.2 5.2.0 2.0.0 @@ -41,7 +41,7 @@ 10.0.1 0.8.0 2.3.1 - 2.3.1 + 2.4.0-beta.1.build3945 From f201a2b1708eda884f0b7309b89f18a07bc5fe89 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 18 Feb 2018 12:31:34 -0800 Subject: [PATCH 139/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7fcf154c2..4edb3917c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15698 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 + 2.1.0-preview2-15707 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 3.14.2 5.2.0 2.0.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3e2b56b91..89d0ad3d1 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15698 -commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 +version:2.1.0-preview2-15707 +commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 From dda0921c0a2e3e341bbab2bcc083a2604aa6cc8e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 21 Feb 2018 18:27:13 -0800 Subject: [PATCH 140/248] Use FeatureBranchVersionSuffix when generating VersionSuffix --- version.props | 1 + 1 file changed, 1 insertion(+) diff --git a/version.props b/version.props index 370d5abab..65c8a07e3 100644 --- a/version.props +++ b/version.props @@ -5,6 +5,7 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 + $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From 2b1dab2efed9d3ba74fa082d9f01ccbd1d05bd43 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 26 Feb 2018 11:15:31 -0800 Subject: [PATCH 141/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4edb3917c..ca0ede407 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15707 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 + 2.1.0-preview2-15721 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 3.14.2 5.2.0 2.0.0 2.1.0-preview2-26130-04 - 15.3.0 + 15.6.0 3.0.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 89d0ad3d1..e6c7fddff 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15707 -commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 +version:2.1.0-preview2-15721 +commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 From d95109c96d6b92d04178dea004583796824072da Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Tue, 12 Sep 2017 16:28:07 -0700 Subject: [PATCH 142/248] #43 Add Microsoft.AspNetCore.Authentication.WsFederation, samples, and tests. #1443 Block unsolicited wsfed logins by default. #1520 Update WsFed to use the 2.0 event structure #1425 Implement WsFed remote signout cleanup Rework WsFed RemoteSignOutPath logic to work with ADFS #1581 Update versions, dependencies. --- Security.sln | 40 +- build/dependencies.props | 2 + samples/WsFedSample/Program.cs | 64 +++ .../Properties/launchSettings.json | 28 ++ samples/WsFedSample/Startup.cs | 168 +++++++ samples/WsFedSample/WsFedSample.csproj | 27 ++ .../WsFedSample/compiler/resources/cert.pfx | Bin 0 -> 2483 bytes .../Events/AuthenticationFailedContext.cs | 35 ++ .../Events/MessageReceivedContext.cs | 33 ++ .../Events/RedirectContext.cs | 44 ++ .../Events/RemoteSignoutContext.cs | 30 ++ .../Events/SecurityTokenReceivedContext.cs | 28 ++ .../Events/SecurityTokenValidatedContext.cs | 34 ++ .../Events/WsFederationEvents.cs | 74 +++ .../LoggingExtensions.cs | 85 ++++ ...NetCore.Authentication.WsFederation.csproj | 17 + .../Properties/Resources.Designer.cs | 114 +++++ .../Resources.resx | 138 ++++++ .../WsFederationDefaults.cs | 26 + .../WsFederationExtensions.cs | 58 +++ .../WsFederationHandler.cs | 425 +++++++++++++++++ .../WsFederationOptions.cs | 180 +++++++ .../WsFederationPostConfigureOptions.cs | 89 ++++ ...soft.AspNetCore.Authentication.Test.csproj | 19 + .../WsFederation/CustomStateDataFormat.cs | 58 +++ .../WsFederation/InvalidToken.xml | 83 ++++ .../WsFederation/TestSecurityToken.cs | 27 ++ .../TestSecurityTokenValidator.cs | 31 ++ .../WsFederation/ValidToken.xml | 83 ++++ .../WsFederation/WsFederationTest.cs | 443 ++++++++++++++++++ .../WsFederation/federationmetadata.xml | 132 ++++++ 31 files changed, 2614 insertions(+), 1 deletion(-) create mode 100644 samples/WsFedSample/Program.cs create mode 100644 samples/WsFedSample/Properties/launchSettings.json create mode 100644 samples/WsFedSample/Startup.cs create mode 100644 samples/WsFedSample/WsFedSample.csproj create mode 100644 samples/WsFedSample/compiler/resources/cert.pfx create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml diff --git a/Security.sln b/Security.sln index f598f34eb..3df759651 100644 --- a/Security.sln +++ b/Security.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27004.2002 +VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D2B6A51-2F9F-44F5-8131-EA5CAC053652}" ProjectSection(SolutionItems) = preProject @@ -75,6 +75,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Author EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookiePolicySample", "samples\CookiePolicySample\CookiePolicySample.csproj", "{24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.WsFederation", "src\Microsoft.AspNetCore.Authentication.WsFederation\Microsoft.AspNetCore.Authentication.WsFederation.csproj", "{B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WsFedSample", "samples\WsFedSample\WsFedSample.csproj", "{5EC2E398-E46A-430D-8E4B-E91C8FC3E800}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -481,6 +485,38 @@ Global {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x64.Build.0 = Release|Any CPU {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x86.ActiveCfg = Release|Any CPU {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E}.Release|x86.Build.0 = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|x64.ActiveCfg = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|x64.Build.0 = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|x86.ActiveCfg = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Debug|x86.Build.0 = Debug|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|Any CPU.Build.0 = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|x64.ActiveCfg = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|x64.Build.0 = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|x86.ActiveCfg = Release|Any CPU + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29}.Release|x86.Build.0 = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|x64.ActiveCfg = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|x64.Build.0 = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|x86.ActiveCfg = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Debug|x86.Build.0 = Debug|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|Any CPU.Build.0 = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x64.ActiveCfg = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x64.Build.0 = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x86.ActiveCfg = Release|Any CPU + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -511,6 +547,8 @@ Global {51563775-C659-4907-9BAF-9995BAB87D01} = {7BF11F3A-60B6-4796-B504-579C67FFBA34} {58194599-F07D-47A3-9DF2-E21A22C5EF9E} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} + {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} + {5EC2E398-E46A-430D-8E4B-E91C8FC3E800} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {ABF8089E-43D0-4010-84A7-7A9DCFE49357} diff --git a/build/dependencies.props b/build/dependencies.props index ca0ede407..4ccaf4fcb 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -32,6 +32,7 @@ 2.1.0-preview2-30187 3.14.2 5.2.0 + 5.2.0 2.0.0 2.1.0-preview2-26130-04 15.6.0 @@ -39,6 +40,7 @@ 3.0.1 3.0.1 10.0.1 + 5.2.0 0.8.0 2.3.1 2.4.0-beta.1.build3945 diff --git a/samples/WsFedSample/Program.cs b/samples/WsFedSample/Program.cs new file mode 100644 index 000000000..40e1945c6 --- /dev/null +++ b/samples/WsFedSample/Program.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Reflection; +using System.Security.Cryptography.X509Certificates; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Logging; + +namespace WsFedSample +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddDebug(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + factory.AddFilter("Debug", level => level >= LogLevel.Information); + }) + .UseKestrel(options => + { + options.Listen(IPAddress.Loopback, 44307, listenOptions => + { + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); + }) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + + private static X509Certificate2 LoadCertificate() + { + var assembly = typeof(Startup).GetTypeInfo().Assembly; + var embeddedFileProvider = new EmbeddedFileProvider(assembly, "WsFedSample"); + var certificateFileInfo = embeddedFileProvider.GetFileInfo("compiler/resources/cert.pfx"); + using (var certificateStream = certificateFileInfo.CreateReadStream()) + { + byte[] certificatePayload; + using (var memoryStream = new MemoryStream()) + { + certificateStream.CopyTo(memoryStream); + certificatePayload = memoryStream.ToArray(); + } + + return new X509Certificate2(certificatePayload, "testPassword"); + } + } + } +} diff --git a/samples/WsFedSample/Properties/launchSettings.json b/samples/WsFedSample/Properties/launchSettings.json new file mode 100644 index 000000000..bdf80e248 --- /dev/null +++ b/samples/WsFedSample/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "https://localhost:44307/", + "sslPort": 44318 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "https://localhost:44307/", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WsFedSample": { + "commandName": "Project", + "launchBrowser": true, + "applicationUrl": "https://localhost:44307/", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/samples/WsFedSample/Startup.cs b/samples/WsFedSample/Startup.cs new file mode 100644 index 000000000..0fc32769e --- /dev/null +++ b/samples/WsFedSample/Startup.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.WsFederation; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace WsFedSample +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddAuthentication(sharedOptions => + { + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; + }) + .AddWsFederation(options => + { + options.Wtrealm = "https://Tratcheroutlook.onmicrosoft.com/WsFedSample"; + options.MetadataAddress = "https://login.windows.net/cdc690f9-b6b8-4023-813a-bae7143d1f87/FederationMetadata/2007-06/FederationMetadata.xml"; + // options.CallbackPath = "/"; + // options.SkipUnrecognizedRequests = true; + }) + .AddCookie(); + } + + public void Configure(IApplicationBuilder app) + { + app.UseDeveloperExceptionPage(); + app.UseAuthentication(); + + app.Run(async context => + { + if (context.Request.Path.Equals("/signedout")) + { + await WriteHtmlAsync(context.Response, async res => + { + await res.WriteAsync($"

You have been signed out.

"); + await res.WriteAsync("Sign In"); + }); + return; + } + + if (context.Request.Path.Equals("/signout")) + { + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await WriteHtmlAsync(context.Response, async res => + { + await context.Response.WriteAsync($"

Signed out {HtmlEncode(context.User.Identity.Name)}

"); + await context.Response.WriteAsync("Sign In"); + }); + return; + } + + if (context.Request.Path.Equals("/signout-remote")) + { + // Redirects + await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + await context.SignOutAsync(WsFederationDefaults.AuthenticationScheme, new AuthenticationProperties() + { + RedirectUri = "/signedout" + }); + return; + } + + if (context.Request.Path.Equals("/Account/AccessDenied")) + { + await WriteHtmlAsync(context.Response, async res => + { + await context.Response.WriteAsync($"

Access Denied for user {HtmlEncode(context.User.Identity.Name)} to resource '{HtmlEncode(context.Request.Query["ReturnUrl"])}'

"); + await context.Response.WriteAsync("Sign Out"); + }); + return; + } + + // DefaultAuthenticateScheme causes User to be set + var user = context.User; + + // This is what [Authorize] calls + // var user = await context.AuthenticateAsync(); + + // This is what [Authorize(ActiveAuthenticationSchemes = WsFederationDefaults.AuthenticationScheme)] calls + // var user = await context.AuthenticateAsync(WsFederationDefaults.AuthenticationScheme); + + // Not authenticated + if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated)) + { + // This is what [Authorize] calls + await context.ChallengeAsync(); + + // This is what [Authorize(ActiveAuthenticationSchemes = WsFederationDefaults.AuthenticationScheme)] calls + // await context.ChallengeAsync(WsFederationDefaults.AuthenticationScheme); + + return; + } + + // Authenticated, but not authorized + if (context.Request.Path.Equals("/restricted") && !user.Identities.Any(identity => identity.HasClaim("special", "true"))) + { + await context.ForbidAsync(); + return; + } + + await WriteHtmlAsync(context.Response, async response => + { + await response.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); + await response.WriteAsync("Restricted"); + await response.WriteAsync("Sign Out"); + await response.WriteAsync("Sign Out Remote"); + + await response.WriteAsync("

Claims:

"); + await WriteTableHeader(response, new string[] { "Claim Type", "Value" }, context.User.Claims.Select(c => new string[] { c.Type, c.Value })); + }); + }); + } + + private static async Task WriteHtmlAsync(HttpResponse response, Func writeContent) + { + var bootstrap = ""; + + response.ContentType = "text/html"; + await response.WriteAsync($"{bootstrap}
"); + await writeContent(response); + await response.WriteAsync("
"); + } + + private static async Task WriteTableHeader(HttpResponse response, IEnumerable columns, IEnumerable> data) + { + await response.WriteAsync(""); + await response.WriteAsync(""); + foreach (var column in columns) + { + await response.WriteAsync($""); + } + await response.WriteAsync(""); + foreach (var row in data) + { + await response.WriteAsync(""); + foreach (var column in row) + { + await response.WriteAsync($""); + } + await response.WriteAsync(""); + } + await response.WriteAsync("
{HtmlEncode(column)}
{HtmlEncode(column)}
"); + } + + private static string HtmlEncode(string content) => + string.IsNullOrEmpty(content) ? string.Empty : HtmlEncoder.Default.Encode(content); + } +} diff --git a/samples/WsFedSample/WsFedSample.csproj b/samples/WsFedSample/WsFedSample.csproj new file mode 100644 index 000000000..bc3a59f10 --- /dev/null +++ b/samples/WsFedSample/WsFedSample.csproj @@ -0,0 +1,27 @@ + + + + net461;netcoreapp2.0 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/WsFedSample/compiler/resources/cert.pfx b/samples/WsFedSample/compiler/resources/cert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..7118908c2d730670c16e9f8b2c532a262c951989 GIT binary patch literal 2483 zcmaKuc|27A8pqF>IWr86E&Q@(n=B)p$ug!;QVB6xij*z;uPLG!yCz#DQB)+9G$9m9 zQU)=DWXU?*EZIwG!+0d++P@yZ4Xhoagg?p6B~|Ue7tN=Ny=UD?x#1n1MTq z#c9MHh+D#gd|(a(cN}8i91v^=GcdgW3SmA$49p~gM-dys3jVWdg8+!iVL)pz1LDE5 zSb=|GAn(@R=(Ux!MfS9@}sFu-xDd zIt2+mqSq$glwy_6UNs<2?(qERU!gJ;5j}Pp&6trxG=wi)=@k(w2+fJVnc+qvXVzy(>Om4;L|^)R`t*3nTpAmEmTl(#i!RV#a0t#u6>Q9mY`-Nmcs7$XjXT7 zUmCD`O~_j7!%R#I?cG-7C^hcH)@l?WC1vyw$FFu_(r)jhOq6p}W8sG7NO{YTy8tG4 zrb$tTkag*G?(7lfoGx$4YWui>{{@}-FB2ub=}RX{1zx?j)s-##J9|G7E1@-;7Nuln z9MQoX7FJ76+D#XXT@ZZmLZCufIdf3@OigG6m8I7!GT=7VD|>?6e!z9=eT}*E_tSn6 zl+clHCZ-kcIR#gen#LjMJW8>0QtViaQB#FhqsCb0YPYr3;jRITl@V9Aph24D?r2d` zetCyyCg<*O-u+M& zW^ptmT|}p$VAOZpmbQ1{5fK-6ytEvre#Po}6c2URn`viQAF2+e?Z~PK2&pd>7=7)I zTCYm)@3PFRu_6a6Kb)IpCzQ%e3l%O#SDA+$Pq{Dk{HCqi7z>qd{nVpebffL7h{c4( zmhXn~G+C27S3(IfC)q2KON=YwqHXEo%zc40DgWLzF{%RIdr@RcLu90qMSHf!Y}JaqP<={8_Rfe;ddR5= zKEo;^Yip&^m((#{czE{kUga3-@`*;&EwO}Jt>QdURP2P>ob^j-A!qld-0S_pm)kjs zkNo48oZnMt){W~o8g^f;4#?lRLr-T@f}wH1o~-Iq=NEVtTVEZ`vrW~!>2yh%;Bc~H zHl&OK>n@d`*e19*9#v>zZpU?I);f7}IPIfSSk#N|ujE492Itg)l!)TJ19@FE^x|p= zH16NC7OfK&|6_!AnWfTIf^YPOa&`|nbk3VR0vql6&s@y1V3QOU%(`Re+kJgrz?r9!{^wOQ4W-eng23gc}f(LxIs zH_Ls~5izbjcRQH#WH6s6hR;zn>j_R8aJ$A)6xNneu8UI-vWV8Z@HZu&WwvG5q{1ZS zdZeVf{Pv5-u281~y;aJe*x%Uv0@biMZ$vPbKj}O`(SOWQc~kJX` zXR&d4DtAe@2RH$^ z0os5*;0eIUeJi3Uh`A%44x(XzjClG8BO~-r_A}odiRuHo2-86#`mhrgN5p~<$RLY? zq(kynfFA5{v#p+EA1 z5aoe1763EQHorRm`C&ktKn(OQ1n)$Q{GZz&jRb`eDEMpl<0O#+)DMV(T7nsIzCG{QuM->B9g7Lrl2SE&gW`M!~(un|y0fIn=b^6_$ z9{zEzgYI~39xn0ZP*9qBL%fg7rg$ttt&TOmvfNNO<6FT0ZavM$Y4CYLQGIcIYv9Y& zBGPUh&QTfW;V2!)oIra@s&d968y-y}Y|ww(R$GzWS*V&)k@W0>Slem{|HdTCjm;_5 zwY*A8W3nUbemE^_f0ng$tbd<`sr?TO-_&VCw+F#7P@LkIl$1PzTBoPY1b88EIO>UO zP-NK7+g2yD3U6g3i|iA6+su>54sf_Sk0F=)1|9odnCM4u2Rs z=&Y?-V&VquSN%3FJ2~ZGweP~iLs|w=l@9yu$tj@}Dp?e-2JUsqOoswdXb=E%&0te_ zA2M+{5Hf-dqD7=yw*r@A*xkn(1IS~nfP}k}e?4Bt|9g(eph4hFX_|S6nj1&Sz9z^= zRw~<&-9d@FzTn6S*RVE{Wj5lgLJr9HLB8S9CgOm*>XA8*y4`JE;^s$=bqD#U4;e5C&x&ggKIAVL zrQ)Yd8|{>7Z(6*B&7&4&9(*vDOfHMuR-Dk1IZia*XM^EZUD^{?cWG>J>KrtElc*{K zaVl(7SN2cH4I6Q$bZOpJ8e5LKaG7p;?tJ~#+9QrTYU@f#5`Vo7cEX!szCT}iX-K^2 w#3o+=C+lQz2J+SOEzVX(eJ)e7=eicC{rr9U2VGDcdH?_b literal 0 HcmV?d00001 diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs new file mode 100644 index 000000000..f643fad97 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/AuthenticationFailedContext.cs @@ -0,0 +1,35 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// The context object used in for . + /// + public class AuthenticationFailedContext : RemoteAuthenticationContext + { + /// + /// Creates a new context object + /// + /// + /// + /// + public AuthenticationFailedContext(HttpContext context, AuthenticationScheme scheme, WsFederationOptions options) + : base(context, scheme, options, new AuthenticationProperties()) + { } + + /// + /// The from the request, if any. + /// + public WsFederationMessage ProtocolMessage { get; set; } + + /// + /// The that triggered this event. + /// + public Exception Exception { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs new file mode 100644 index 000000000..4028fa5e3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/MessageReceivedContext.cs @@ -0,0 +1,33 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// The context object used for . + /// + public class MessageReceivedContext : RemoteAuthenticationContext + { + /// + /// Creates a new context object. + /// + /// + /// + /// + /// + public MessageReceivedContext( + HttpContext context, + AuthenticationScheme scheme, + WsFederationOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } + + /// + /// The received on this request. + /// + public WsFederationMessage ProtocolMessage { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs new file mode 100644 index 000000000..654037d0a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RedirectContext.cs @@ -0,0 +1,44 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// When a user configures the to be notified prior to redirecting to an IdentityProvider + /// an instance of is passed to the 'RedirectToAuthenticationEndpoint' or 'RedirectToEndSessionEndpoint' events. + /// + public class RedirectContext : PropertiesContext + { + /// + /// Creates a new context object. + /// + /// + /// + /// + /// + public RedirectContext( + HttpContext context, + AuthenticationScheme scheme, + WsFederationOptions options, + AuthenticationProperties properties) + : base(context, scheme, options, properties) { } + + /// + /// The used to compose the redirect. + /// + public WsFederationMessage ProtocolMessage { get; set; } + + /// + /// If true, will skip any default logic for this redirect. + /// + public bool Handled { get; private set; } + + /// + /// Skips any default logic for this redirect. + /// + public void HandleResponse() => Handled = true; + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs new file mode 100644 index 000000000..8aec24a64 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/RemoteSignoutContext.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// An event context for RemoteSignOut. + /// + public class RemoteSignOutContext : RemoteAuthenticationContext + { + /// + /// + /// + /// + /// + /// + /// + public RemoteSignOutContext(HttpContext context, AuthenticationScheme scheme, WsFederationOptions options, WsFederationMessage message) + : base(context, scheme, options, new AuthenticationProperties()) + => ProtocolMessage = message; + + /// + /// The signout message. + /// + public WsFederationMessage ProtocolMessage { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs new file mode 100644 index 000000000..311f41515 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenReceivedContext.cs @@ -0,0 +1,28 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Security.Claims; +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// This Context can be used to be informed when an 'AuthorizationCode' is redeemed for tokens at the token endpoint. + /// + public class SecurityTokenReceivedContext : RemoteAuthenticationContext + { + /// + /// Creates a + /// + public SecurityTokenReceivedContext(HttpContext context, AuthenticationScheme scheme, WsFederationOptions options, AuthenticationProperties properties) + : base(context, scheme, options, properties) + { + } + + /// + /// The received on this request. + /// + public WsFederationMessage ProtocolMessage { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs new file mode 100644 index 000000000..1f32014b6 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/SecurityTokenValidatedContext.cs @@ -0,0 +1,34 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols.WsFederation; +using Microsoft.IdentityModel.Tokens; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// The context object used for . + /// + public class SecurityTokenValidatedContext : RemoteAuthenticationContext + { + /// + /// Creates a + /// + public SecurityTokenValidatedContext(HttpContext context, AuthenticationScheme scheme, WsFederationOptions options, ClaimsPrincipal principal, AuthenticationProperties properties) + : base(context, scheme, options, properties) + => Principal = principal; + + /// + /// The received on this request. + /// + public WsFederationMessage ProtocolMessage { get; set; } + + /// + /// The that was validated. + /// + public SecurityToken SecurityToken { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs new file mode 100644 index 000000000..55c3936f9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Events/WsFederationEvents.cs @@ -0,0 +1,74 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// Specifies events which the invokes to enable developer control over the authentication process. /> + /// + public class WsFederationEvents : RemoteAuthenticationEvents + { + /// + /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. + /// + public Func OnAuthenticationFailed { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked when a protocol message is first received. + /// + public Func OnMessageReceived { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked to manipulate redirects to the identity provider for SignIn, SignOut, or Challenge. + /// + public Func OnRedirectToIdentityProvider { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked when a wsignoutcleanup request is received at the RemoteSignOutPath endpoint. + /// + public Func OnRemoteSignOut { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked with the security token that has been extracted from the protocol message. + /// + public Func OnSecurityTokenReceived { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. + /// + public Func OnSecurityTokenValidated { get; set; } = context => Task.CompletedTask; + + /// + /// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed. + /// + public virtual Task AuthenticationFailed(AuthenticationFailedContext context) => OnAuthenticationFailed(context); + + /// + /// Invoked when a protocol message is first received. + /// + public virtual Task MessageReceived(MessageReceivedContext context) => OnMessageReceived(context); + + /// + /// Invoked to manipulate redirects to the identity provider for SignIn, SignOut, or Challenge. + /// + public virtual Task RedirectToIdentityProvider(RedirectContext context) => OnRedirectToIdentityProvider(context); + + /// + /// Invoked when a wsignoutcleanup request is received at the RemoteSignOutPath endpoint. + /// + public virtual Task RemoteSignOut(RemoteSignOutContext context) => OnRemoteSignOut(context); + + /// + /// Invoked with the security token that has been extracted from the protocol message. + /// + public virtual Task SecurityTokenReceived(SecurityTokenReceivedContext context) => OnSecurityTokenReceived(context); + + /// + /// Invoked after the security token has passed validation and a ClaimsIdentity has been generated. + /// + public virtual Task SecurityTokenValidated(SecurityTokenValidatedContext context) => OnSecurityTokenValidated(context); + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs new file mode 100644 index 000000000..e28b7e15b --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/LoggingExtensions.cs @@ -0,0 +1,85 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _signInWithoutWresult; + private static Action _signInWithoutToken; + private static Action _exceptionProcessingMessage; + private static Action _malformedRedirectUri; + private static Action _remoteSignOutHandledResponse; + private static Action _remoteSignOutSkipped; + private static Action _remoteSignOut; + + static LoggingExtensions() + { + _signInWithoutWresult = LoggerMessage.Define( + eventId: 1, + logLevel: LogLevel.Debug, + formatString: "Received a sign-in message without a WResult."); + _signInWithoutToken = LoggerMessage.Define( + eventId: 2, + logLevel: LogLevel.Debug, + formatString: "Received a sign-in message without a token."); + _exceptionProcessingMessage = LoggerMessage.Define( + eventId: 3, + logLevel: LogLevel.Error, + formatString: "Exception occurred while processing message."); + _malformedRedirectUri = LoggerMessage.Define( + eventId: 4, + logLevel: LogLevel.Warning, + formatString: "The sign-out redirect URI '{0}' is malformed."); + _remoteSignOutHandledResponse = LoggerMessage.Define( + eventId: 5, + logLevel: LogLevel.Debug, + formatString: "RemoteSignOutContext.HandledResponse"); + _remoteSignOutSkipped = LoggerMessage.Define( + eventId: 6, + logLevel: LogLevel.Debug, + formatString: "RemoteSignOutContext.Skipped"); + _remoteSignOut = LoggerMessage.Define( + eventId: 7, + logLevel: LogLevel.Information, + formatString: "Remote signout request processed."); + } + + public static void SignInWithoutWresult(this ILogger logger) + { + _signInWithoutWresult(logger, null); + } + + public static void SignInWithoutToken(this ILogger logger) + { + _signInWithoutToken(logger, null); + } + + public static void ExceptionProcessingMessage(this ILogger logger, Exception ex) + { + _exceptionProcessingMessage(logger, ex); + } + + public static void MalformedRedirectUri(this ILogger logger, string uri) + { + _malformedRedirectUri(logger, uri, null); + } + + public static void RemoteSignOutHandledResponse(this ILogger logger) + { + _remoteSignOutHandledResponse(logger, null); + } + + public static void RemoteSignOutSkipped(this ILogger logger) + { + _remoteSignOutSkipped(logger, null); + } + + public static void RemoteSignOut(this ILogger logger) + { + _remoteSignOut(logger, null); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj b/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj new file mode 100644 index 000000000..4edb55cb3 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj @@ -0,0 +1,17 @@ + + + + ASP.NET Core middleware that enables an application to support the WsFederation authentication workflow. + netstandard2.0 + true + aspnetcore;authentication;security + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs new file mode 100644 index 000000000..564e826a7 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Properties/Resources.Designer.cs @@ -0,0 +1,114 @@ +// +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + using System.Globalization; + using System.Reflection; + using System.Resources; + + internal static class Resources + { + private static readonly ResourceManager _resourceManager + = new ResourceManager("Microsoft.AspNetCore.Authentication.WsFederation.Resources", typeof(Resources).GetTypeInfo().Assembly); + + /// + /// The service descriptor is missing. + /// + internal static string Exception_MissingDescriptor + { + get => GetString("Exception_MissingDescriptor"); + } + + /// + /// The service descriptor is missing. + /// + internal static string FormatException_MissingDescriptor() + => GetString("Exception_MissingDescriptor"); + + /// + /// No token validator was found for the given token. + /// + internal static string Exception_NoTokenValidatorFound + { + get => GetString("Exception_NoTokenValidatorFound"); + } + + /// + /// No token validator was found for the given token. + /// + internal static string FormatException_NoTokenValidatorFound() + => GetString("Exception_NoTokenValidatorFound"); + + /// + /// The '{0}' option must be provided. + /// + internal static string Exception_OptionMustBeProvided + { + get => GetString("Exception_OptionMustBeProvided"); + } + + /// + /// The '{0}' option must be provided. + /// + internal static string FormatException_OptionMustBeProvided(object p0) + => string.Format(CultureInfo.CurrentCulture, GetString("Exception_OptionMustBeProvided"), p0); + + /// + /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. + /// + internal static string Exception_ValidatorHandlerMismatch + { + get => GetString("Exception_ValidatorHandlerMismatch"); + } + + /// + /// An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. + /// + internal static string FormatException_ValidatorHandlerMismatch() + => GetString("Exception_ValidatorHandlerMismatch"); + + /// + /// The sign in message does not contain a required token. + /// + internal static string SignInMessageTokenIsMissing + { + get => GetString("SignInMessageTokenIsMissing"); + } + + /// + /// The sign in message does not contain a required token. + /// + internal static string FormatSignInMessageTokenIsMissing() + => GetString("SignInMessageTokenIsMissing"); + + /// + /// The sign in message does not contain a required wresult. + /// + internal static string SignInMessageWresultIsMissing + { + get => GetString("SignInMessageWresultIsMissing"); + } + + /// + /// The sign in message does not contain a required wresult. + /// + internal static string FormatSignInMessageWresultIsMissing() + => GetString("SignInMessageWresultIsMissing"); + + private static string GetString(string name, params string[] formatterNames) + { + var value = _resourceManager.GetString(name); + + System.Diagnostics.Debug.Assert(value != null); + + if (formatterNames != null) + { + for (var i = 0; i < formatterNames.Length; i++) + { + value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); + } + } + + return value; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx b/src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx new file mode 100644 index 000000000..e2edafb67 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Resources.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + The service descriptor is missing. + + + No token validator was found for the given token. + + + The '{0}' option must be provided. + + + An ICertificateValidator cannot be specified at the same time as an HttpMessageHandler unless it is a WebRequestHandler. + + + The sign in message does not contain a required token. + + + The sign in message does not contain a required wresult. + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs new file mode 100644 index 000000000..3b97d995b --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationDefaults.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// Default values related to WsFederation authentication handler + /// + public static class WsFederationDefaults + { + /// + /// The default authentication type used when registering the WsFederationHandler. + /// + public const string AuthenticationScheme = "WsFederation"; + + /// + /// The default display name used when registering the WsFederationHandler. + /// + public const string DisplayName = "WsFederation"; + + /// + /// Constant used to identify userstate inside AuthenticationProperties that have been serialized in the 'wctx' parameter. + /// + public static readonly string UserstatePropertiesKey = "WsFederation.Userstate"; + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs new file mode 100644 index 000000000..47091d58d --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationExtensions.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.WsFederation; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Options; + +namespace Microsoft.Extensions.DependencyInjection +{ + /// + /// Extensions for registering the . + /// + public static class WsFederationExtensions + { + /// + /// Registers the using the default authentication scheme, display name, and options. + /// + /// + /// + public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder) + => builder.AddWsFederation(WsFederationDefaults.AuthenticationScheme, _ => { }); + + /// + /// Registers the using the default authentication scheme, display name, and the given options configuration. + /// + /// + /// A delegate that configures the . + /// + public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddWsFederation(WsFederationDefaults.AuthenticationScheme, configureOptions); + + /// + /// Registers the using the given authentication scheme, default display name, and the given options configuration. + /// + /// + /// + /// A delegate that configures the . + /// + public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddWsFederation(authenticationScheme, WsFederationDefaults.DisplayName, configureOptions); + + /// + /// Registers the using the given authentication scheme, display name, and options configuration. + /// + /// + /// + /// + /// A delegate that configures the . + /// + public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + { + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, WsFederationPostConfigureOptions>()); + return builder.AddRemoteScheme(authenticationScheme, displayName, configureOptions); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs new file mode 100644 index 000000000..e47f8431f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs @@ -0,0 +1,425 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols.WsFederation; +using Microsoft.IdentityModel.Tokens; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// A per-request authentication handler for the WsFederation. + /// + public class WsFederationHandler : RemoteAuthenticationHandler, IAuthenticationSignOutHandler + { + private const string CorrelationProperty = ".xsrf"; + private WsFederationConfiguration _configuration; + + /// + /// Creates a new WsFederationAuthenticationHandler + /// + /// + /// + /// + /// + public WsFederationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) + : base(options, logger, encoder, clock) + { + } + + /// + /// The handler calls methods on the events which give the application control at certain points where processing is occurring. + /// If it is not provided a default instance is supplied which does nothing when the methods are called. + /// + protected new WsFederationEvents Events + { + get { return (WsFederationEvents)base.Events; } + set { base.Events = value; } + } + + /// + /// Creates a new instance of the events instance. + /// + /// A new instance of the events instance. + protected override Task CreateEventsAsync() => Task.FromResult(new WsFederationEvents()); + + /// + /// Overridden to handle remote signout requests + /// + /// + public override Task HandleRequestAsync() + { + // RemoteSignOutPath and CallbackPath may be the same, fall through if the message doesn't match. + if (Options.RemoteSignOutPath.HasValue && Options.RemoteSignOutPath == Request.Path && HttpMethods.IsGet(Request.Method) + && string.Equals(Request.Query[WsFederationConstants.WsFederationParameterNames.Wa], + WsFederationConstants.WsFederationActions.SignOutCleanup, StringComparison.OrdinalIgnoreCase)) + { + // We've received a remote sign-out request + return HandleRemoteSignOutAsync(); + } + + return base.HandleRequestAsync(); + } + + /// + /// Handles Challenge + /// + /// + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) + { + if (_configuration == null) + { + _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); + } + + // Save the original challenge URI so we can redirect back to it when we're done. + if (string.IsNullOrEmpty(properties.RedirectUri)) + { + properties.RedirectUri = CurrentUri; + } + + var wsFederationMessage = new WsFederationMessage() + { + IssuerAddress = _configuration.TokenEndpoint ?? string.Empty, + Wtrealm = Options.Wtrealm, + Wa = WsFederationConstants.WsFederationActions.SignIn, + }; + + if (!string.IsNullOrEmpty(Options.Wreply)) + { + wsFederationMessage.Wreply = Options.Wreply; + } + else + { + wsFederationMessage.Wreply = BuildRedirectUri(Options.CallbackPath); + } + + GenerateCorrelationId(properties); + + var redirectContext = new RedirectContext(Context, Scheme, Options, properties) + { + ProtocolMessage = wsFederationMessage + }; + await Events.RedirectToIdentityProvider(redirectContext); + + if (redirectContext.Handled) + { + return; + } + + wsFederationMessage = redirectContext.ProtocolMessage; + + if (!string.IsNullOrEmpty(wsFederationMessage.Wctx)) + { + properties.Items[WsFederationDefaults.UserstatePropertiesKey] = wsFederationMessage.Wctx; + } + + wsFederationMessage.Wctx = Uri.EscapeDataString(Options.StateDataFormat.Protect(properties)); + + var redirectUri = wsFederationMessage.CreateSignInUrl(); + if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) + { + Logger.MalformedRedirectUri(redirectUri); + } + Response.Redirect(redirectUri); + } + + /// + /// Invoked to process incoming authentication messages. + /// + /// + protected override async Task HandleRemoteAuthenticateAsync() + { + WsFederationMessage wsFederationMessage = null; + AuthenticationProperties properties = null; + + // assumption: if the ContentType is "application/x-www-form-urlencoded" it should be safe to read as it is small. + if (HttpMethods.IsPost(Request.Method) + && !string.IsNullOrEmpty(Request.ContentType) + // May have media/type; charset=utf-8, allow partial match. + && Request.ContentType.StartsWith("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase) + && Request.Body.CanRead) + { + var form = await Request.ReadFormAsync(); + + wsFederationMessage = new WsFederationMessage(form.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + } + + if (wsFederationMessage == null || !wsFederationMessage.IsSignInMessage) + { + if (Options.SkipUnrecognizedRequests) + { + // Not for us? + return HandleRequestResult.SkipHandler(); + } + + return HandleRequestResult.Fail("No message."); + } + + try + { + // Retrieve our cached redirect uri + var state = wsFederationMessage.Wctx; + // WsFed allows for uninitiated logins, state may be missing. See AllowUnsolicitedLogins. + properties = Options.StateDataFormat.Unprotect(state); + + if (properties == null) + { + if (!Options.AllowUnsolicitedLogins) + { + return HandleRequestResult.Fail("Unsolicited logins are not allowed."); + } + } + else + { + // Extract the user state from properties and reset. + properties.Items.TryGetValue(WsFederationDefaults.UserstatePropertiesKey, out var userState); + wsFederationMessage.Wctx = userState; + } + + var messageReceivedContext = new MessageReceivedContext(Context, Scheme, Options, properties) + { + ProtocolMessage = wsFederationMessage + }; + await Events.MessageReceived(messageReceivedContext); + if (messageReceivedContext.Result != null) + { + return messageReceivedContext.Result; + } + wsFederationMessage = messageReceivedContext.ProtocolMessage; + properties = messageReceivedContext.Properties; // Provides a new instance if not set. + + // If state did flow from the challenge then validate it. See AllowUnsolicitedLogins above. + if (properties.Items.TryGetValue(CorrelationProperty, out string correlationId) + && !ValidateCorrelationId(properties)) + { + return HandleRequestResult.Fail("Correlation failed.", properties); + } + + if (wsFederationMessage.Wresult == null) + { + Logger.SignInWithoutWresult(); + return HandleRequestResult.Fail(Resources.SignInMessageWresultIsMissing, properties); + } + + var token = wsFederationMessage.GetToken(); + if (string.IsNullOrEmpty(token)) + { + Logger.SignInWithoutToken(); + return HandleRequestResult.Fail(Resources.SignInMessageTokenIsMissing, properties); + } + + var securityTokenReceivedContext = new SecurityTokenReceivedContext(Context, Scheme, Options, properties) + { + ProtocolMessage = wsFederationMessage + }; + await Events.SecurityTokenReceived(securityTokenReceivedContext); + if (securityTokenReceivedContext.Result != null) + { + return securityTokenReceivedContext.Result; + } + wsFederationMessage = securityTokenReceivedContext.ProtocolMessage; + properties = messageReceivedContext.Properties; + + if (_configuration == null) + { + _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); + } + + // Copy and augment to avoid cross request race conditions for updated configurations. + var tvp = Options.TokenValidationParameters.Clone(); + var issuers = new[] { _configuration.Issuer }; + tvp.ValidIssuers = (tvp.ValidIssuers == null ? issuers : tvp.ValidIssuers.Concat(issuers)); + tvp.IssuerSigningKeys = (tvp.IssuerSigningKeys == null ? _configuration.SigningKeys : tvp.IssuerSigningKeys.Concat(_configuration.SigningKeys)); + + ClaimsPrincipal principal = null; + SecurityToken parsedToken = null; + foreach (var validator in Options.SecurityTokenHandlers) + { + if (validator.CanReadToken(token)) + { + principal = validator.ValidateToken(token, tvp, out parsedToken); + break; + } + } + + if (principal == null) + { + throw new SecurityTokenException(Resources.Exception_NoTokenValidatorFound); + } + + if (Options.UseTokenLifetime && parsedToken != null) + { + // Override any session persistence to match the token lifetime. + var issued = parsedToken.ValidFrom; + if (issued != DateTime.MinValue) + { + properties.IssuedUtc = issued.ToUniversalTime(); + } + var expires = parsedToken.ValidTo; + if (expires != DateTime.MinValue) + { + properties.ExpiresUtc = expires.ToUniversalTime(); + } + properties.AllowRefresh = false; + } + + var securityTokenValidatedContext = new SecurityTokenValidatedContext(Context, Scheme, Options, principal, properties) + { + ProtocolMessage = wsFederationMessage, + SecurityToken = parsedToken, + }; + + await Events.SecurityTokenValidated(securityTokenValidatedContext); + if (securityTokenValidatedContext.Result != null) + { + return securityTokenValidatedContext.Result; + } + + // Flow possible changes + principal = securityTokenValidatedContext.Principal; + properties = securityTokenValidatedContext.Properties; + + return HandleRequestResult.Success(new AuthenticationTicket(principal, properties, Scheme.Name)); + } + catch (Exception exception) + { + Logger.ExceptionProcessingMessage(exception); + + // Refresh the configuration for exceptions that may be caused by key rollovers. The user can also request a refresh in the notification. + if (Options.RefreshOnIssuerKeyNotFound && exception.GetType().Equals(typeof(SecurityTokenSignatureKeyNotFoundException))) + { + Options.ConfigurationManager.RequestRefresh(); + } + + var authenticationFailedContext = new AuthenticationFailedContext(Context, Scheme, Options) + { + ProtocolMessage = wsFederationMessage, + Exception = exception + }; + await Events.AuthenticationFailed(authenticationFailedContext); + if (authenticationFailedContext.Result != null) + { + return authenticationFailedContext.Result; + } + + return HandleRequestResult.Fail(exception, properties); + } + } + + /// + /// Handles Signout + /// + /// + public async virtual Task SignOutAsync(AuthenticationProperties properties) + { + var target = ResolveTarget(Options.ForwardSignOut); + if (target != null) + { + await Context.SignOutAsync(target, properties); + return; + } + + if (_configuration == null) + { + _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); + } + + var wsFederationMessage = new WsFederationMessage() + { + IssuerAddress = _configuration.TokenEndpoint ?? string.Empty, + Wtrealm = Options.Wtrealm, + Wa = WsFederationConstants.WsFederationActions.SignOut, + }; + + // Set Wreply in order: + // 1. properties.Redirect + // 2. Options.SignOutWreply + // 3. Options.Wreply + if (properties != null && !string.IsNullOrEmpty(properties.RedirectUri)) + { + wsFederationMessage.Wreply = BuildRedirectUriIfRelative(properties.RedirectUri); + } + else if (!string.IsNullOrEmpty(Options.SignOutWreply)) + { + wsFederationMessage.Wreply = BuildRedirectUriIfRelative(Options.SignOutWreply); + } + else if (!string.IsNullOrEmpty(Options.Wreply)) + { + wsFederationMessage.Wreply = BuildRedirectUriIfRelative(Options.Wreply); + } + + var redirectContext = new RedirectContext(Context, Scheme, Options, properties) + { + ProtocolMessage = wsFederationMessage + }; + await Events.RedirectToIdentityProvider(redirectContext); + + if (!redirectContext.Handled) + { + var redirectUri = redirectContext.ProtocolMessage.CreateSignOutUrl(); + if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) + { + Logger.MalformedRedirectUri(redirectUri); + } + Response.Redirect(redirectUri); + } + } + + /// + /// Handles wsignoutcleanup1.0 messages sent to the RemoteSignOutPath + /// + /// + protected virtual async Task HandleRemoteSignOutAsync() + { + var message = new WsFederationMessage(Request.Query.Select(pair => new KeyValuePair(pair.Key, pair.Value))); + var remoteSignOutContext = new RemoteSignOutContext(Context, Scheme, Options, message); + await Events.RemoteSignOut(remoteSignOutContext); + + if (remoteSignOutContext.Result != null) + { + if (remoteSignOutContext.Result.Handled) + { + Logger.RemoteSignOutHandledResponse(); + return true; + } + if (remoteSignOutContext.Result.Skipped) + { + Logger.RemoteSignOutSkipped(); + return false; + } + } + + Logger.RemoteSignOut(); + + await Context.SignOutAsync(Options.SignOutScheme); + return true; + } + + /// + /// Build a redirect path if the given path is a relative path. + /// + private string BuildRedirectUriIfRelative(string uri) + { + if (string.IsNullOrEmpty(uri)) + { + return uri; + } + + if (!uri.StartsWith("/", StringComparison.Ordinal)) + { + return uri; + } + + return BuildRedirectUri(uri); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs new file mode 100644 index 000000000..4e0612677 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationOptions.cs @@ -0,0 +1,180 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IdentityModel.Tokens.Jwt; +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.WsFederation; +using Microsoft.IdentityModel.Tokens; +using Microsoft.IdentityModel.Tokens.Saml; +using Microsoft.IdentityModel.Tokens.Saml2; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// Configuration options for + /// + public class WsFederationOptions : RemoteAuthenticationOptions + { + private ICollection _securityTokenHandlers = new Collection() + { + new Saml2SecurityTokenHandler(), + new SamlSecurityTokenHandler(), + new JwtSecurityTokenHandler() + }; + private TokenValidationParameters _tokenValidationParameters = new TokenValidationParameters(); + + /// + /// Initializes a new + /// + public WsFederationOptions() + { + CallbackPath = "/signin-wsfed"; + // In ADFS the cleanup messages are sent to the same callback path as the initial login. + // In AAD it sends the cleanup message to a random Reply Url and there's no deterministic way to configure it. + // If you manage to get it configured, then you can set RemoteSignOutPath accordingly. + RemoteSignOutPath = "/signin-wsfed"; + Events = new WsFederationEvents(); + } + + /// + /// Check that the options are valid. Should throw an exception if things are not ok. + /// + public override void Validate() + { + base.Validate(); + + if (ConfigurationManager == null) + { + throw new InvalidOperationException($"Provide {nameof(MetadataAddress)}, " + + $"{nameof(Configuration)}, or {nameof(ConfigurationManager)} to {nameof(WsFederationOptions)}"); + } + } + + /// + /// Configuration provided directly by the developer. If provided, then MetadataAddress and the Backchannel properties + /// will not be used. This information should not be updated during request processing. + /// + public WsFederationConfiguration Configuration { get; set; } + + /// + /// Gets or sets the address to retrieve the wsFederation metadata + /// + public string MetadataAddress { get; set; } + + /// + /// Responsible for retrieving, caching, and refreshing the configuration from metadata. + /// If not provided, then one will be created using the MetadataAddress and Backchannel properties. + /// + public IConfigurationManager ConfigurationManager { get; set; } + + /// + /// Gets or sets if a metadata refresh should be attempted after a SecurityTokenSignatureKeyNotFoundException. This allows for automatic + /// recovery in the event of a signature key rollover. This is enabled by default. + /// + public bool RefreshOnIssuerKeyNotFound { get; set; } = true; + + /// + /// Indicates if requests to the CallbackPath may also be for other components. If enabled the handler will pass + /// requests through that do not contain WsFederation authentication responses. Disabling this and setting the + /// CallbackPath to a dedicated endpoint may provide better error handling. + /// This is disabled by default. + /// + public bool SkipUnrecognizedRequests { get; set; } + + /// + /// Gets or sets the to call when processing WsFederation messages. + /// + public new WsFederationEvents Events + { + get => (WsFederationEvents)base.Events; + set => base.Events = value; + } + + /// + /// Gets or sets the collection of used to read and validate the s. + /// + public ICollection SecurityTokenHandlers + { + get + { + return _securityTokenHandlers; + } + set + { + _securityTokenHandlers = value ?? throw new ArgumentNullException(nameof(SecurityTokenHandlers)); + } + } + + /// + /// Gets or sets the type used to secure data handled by the middleware. + /// + public ISecureDataFormat StateDataFormat { get; set; } + + /// + /// Gets or sets the + /// + /// if 'TokenValidationParameters' is null. + public TokenValidationParameters TokenValidationParameters + { + get + { + return _tokenValidationParameters; + } + set + { + _tokenValidationParameters = value ?? throw new ArgumentNullException(nameof(TokenValidationParameters)); + } + } + + /// + /// Gets or sets the 'wreply'. CallbackPath must be set to match or cleared so it can be generated dynamically. + /// This field is optional. If not set then it will be generated from the current request and the CallbackPath. + /// + public string Wreply { get; set; } + + /// + /// Gets or sets the 'wreply' value used during sign-out. + /// If none is specified then the value from the Wreply field is used. + /// + public string SignOutWreply { get; set; } + + /// + /// Gets or sets the 'wtrealm'. + /// + public string Wtrealm { get; set; } + + /// + /// Indicates that the authentication session lifetime (e.g. cookies) should match that of the authentication token. + /// If the token does not provide lifetime information then normal session lifetimes will be used. + /// This is enabled by default. + /// + public bool UseTokenLifetime { get; set; } = true; + + /// + /// Gets or sets if HTTPS is required for the metadata address or authority. + /// The default is true. This should be disabled only in development environments. + /// + public bool RequireHttpsMetadata { get; set; } = true; + + /// + /// The Ws-Federation protocol allows the user to initiate logins without contacting the application for a Challenge first. + /// However, that flow is susceptible to XSRF and other attacks so it is disabled here by default. + /// + public bool AllowUnsolicitedLogins { get; set; } + + /// + /// Requests received on this path will cause the handler to invoke SignOut using the SignOutScheme. + /// + public PathString RemoteSignOutPath { get; set; } + + /// + /// The Authentication Scheme to use with SignOutAsync from RemoteSignOutPath. SignInScheme will be used if this + /// is not set. + /// + public string SignOutScheme { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs new file mode 100644 index 000000000..62647d4fc --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationPostConfigureOptions.cs @@ -0,0 +1,89 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Net.Http; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; +using Microsoft.IdentityModel.Protocols; +using Microsoft.IdentityModel.Protocols.WsFederation; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + /// + /// Used to setup defaults for all . + /// + public class WsFederationPostConfigureOptions : IPostConfigureOptions + { + private readonly IDataProtectionProvider _dp; + + /// + /// + /// + /// + public WsFederationPostConfigureOptions(IDataProtectionProvider dataProtection) + { + _dp = dataProtection; + } + + /// + /// Invoked to post configure a TOptions instance. + /// + /// The name of the options instance being configured. + /// The options instance to configure. + public void PostConfigure(string name, WsFederationOptions options) + { + options.DataProtectionProvider = options.DataProtectionProvider ?? _dp; + + if (string.IsNullOrEmpty(options.SignOutScheme)) + { + options.SignOutScheme = options.SignInScheme; + } + + if (options.StateDataFormat == null) + { + var dataProtector = options.DataProtectionProvider.CreateProtector( + typeof(WsFederationHandler).FullName, name, "v1"); + options.StateDataFormat = new PropertiesDataFormat(dataProtector); + } + + if (!options.CallbackPath.HasValue && !string.IsNullOrEmpty(options.Wreply) && Uri.TryCreate(options.Wreply, UriKind.Absolute, out var wreply)) + { + // Wreply must be a very specific, case sensitive value, so we can't generate it. Instead we generate CallbackPath from it. + options.CallbackPath = PathString.FromUriComponent(wreply); + } + + if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience)) + { + options.TokenValidationParameters.ValidAudience = options.Wtrealm; + } + + if (options.Backchannel == null) + { + options.Backchannel = new HttpClient(options.BackchannelHttpHandler ?? new HttpClientHandler()); + options.Backchannel.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core WsFederation handler"); + options.Backchannel.Timeout = options.BackchannelTimeout; + options.Backchannel.MaxResponseContentBufferSize = 1024 * 1024 * 10; // 10 MB + } + + if (options.ConfigurationManager == null) + { + if (options.Configuration != null) + { + options.ConfigurationManager = new StaticConfigurationManager(options.Configuration); + } + else if (!string.IsNullOrEmpty(options.MetadataAddress)) + { + if (options.RequireHttpsMetadata && !options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException("The MetadataAddress must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false."); + } + + options.ConfigurationManager = new ConfigurationManager(options.MetadataAddress, new WsFederationConfigurationRetriever(), + new HttpDocumentRetriever(options.Backchannel) { RequireHttps = options.RequireHttpsMetadata }); + } + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 57fed96c0..469726690 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -4,6 +4,24 @@ $(StandardTestTfms) + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + @@ -12,6 +30,7 @@ + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs new file mode 100644 index 000000000..0de867d28 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/CustomStateDataFormat.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Runtime.Serialization; +using System.Text; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + public class CustomStateDataFormat : ISecureDataFormat + { + public const string ValidStateData = "ValidStateData"; + + private string lastSavedAuthenticationProperties; + private DataContractSerializer serializer = new DataContractSerializer(typeof(AuthenticationProperties)); + + public string Protect(AuthenticationProperties data) + { + lastSavedAuthenticationProperties = Serialize(data); + return ValidStateData; + } + + public string Protect(AuthenticationProperties data, string purpose) + { + return Protect(data); + } + + public AuthenticationProperties Unprotect(string state) + { + return state == ValidStateData ? DeSerialize(lastSavedAuthenticationProperties) : null; + } + + public AuthenticationProperties Unprotect(string protectedText, string purpose) + { + return Unprotect(protectedText); + } + + private string Serialize(AuthenticationProperties data) + { + using (MemoryStream memoryStream = new MemoryStream()) + { + serializer.WriteObject(memoryStream, data); + memoryStream.Position = 0; + return new StreamReader(memoryStream).ReadToEnd(); + } + } + + private AuthenticationProperties DeSerialize(string state) + { + var stateDataAsBytes = Encoding.UTF8.GetBytes(state); + + using (var ms = new MemoryStream(stateDataAsBytes, false)) + { + return (AuthenticationProperties)serializer.ReadObject(ms); + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml new file mode 100644 index 000000000..dfdb0d68d --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/InvalidToken.xml @@ -0,0 +1,83 @@ + + + 2014-04-18T20:21:17.341Z + 2014-04-19T08:21:17.341Z + + + +
http://automation1/
+
+
+ + + https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/ + + + + + + + + + + + Lkq0wTyTFxLUU2cyx0XybJqhka5RzRGj6kC4aIpFg+g= + + + bPwNswOB/B9xcdAljIkin9A2vjq+u94JdyvK03mf8vZFGUYNu9uN/Q6ims1DvW1FnP7SgFBwhIvW5OjZyW8fdYGhC2bq36izkxH6ulkWbciOcyELkyHDACLudvh8kP/Q+IwpicefKzAeI2Qu/5MFq16vFg5YgI+dovg8u1fYPPEPmmptW893RNTHWeh9mLRpLYnHyg7aLG6emNRkEu7w9rzeoICeMFybb9BvJl/q/8MFCW/Z5WemQhCi6YXFSEwCO6zJzCFi/3T6ChU/xYgXbFykDLqulsNOCQxdgutyqxJzugt+3PH5IKHHuoqe7UZNUIyELJ4BgwE1sXCGYIi24rg== + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + t0ch1TsP0pi5VoW8q5CGWsCXVZoNtpsg0mbMZPOYb4I + + + + + http://Automation1 + + + + + Test + + + Test + + + user1@praburajgmail.onmicrosoft.com + + + 4afbc689-805b-48cf-a24c-d4aa3248a248 + + + c2f0cd49-5e53-4520-8ed9-4e178dc488c5 + + + https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/ + + + + + urn:oasis:names:tc:SAML:2.0:ac:classes:Password + + + + + + + _660ec874-f70a-4997-a9c4-bd591f1c7469 + + + + + _660ec874-f70a-4997-a9c4-bd591f1c7469 + + + http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0 + http://schemas.xmlsoap.org/ws/2005/02/trust/Issue + http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey +
\ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs new file mode 100644 index 000000000..dfe860724 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityToken.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.IdentityModel.Tokens; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + internal class TestSecurityToken : SecurityToken + { + public override string Id => "id"; + + public override string Issuer => "issuer"; + + public override SecurityKey SecurityKey => throw new NotImplementedException(); + + public override SecurityKey SigningKey + { + get => throw new NotImplementedException(); + set => throw new NotImplementedException(); + } + + public override DateTime ValidFrom => new DateTime(2008, 3, 22); + + public override DateTime ValidTo => new DateTime(2017, 3, 22); + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs new file mode 100644 index 000000000..05882518f --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/TestSecurityTokenValidator.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Security.Claims; +using Microsoft.IdentityModel.Tokens; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + internal class TestSecurityTokenValidator : ISecurityTokenValidator + { + public bool CanValidateToken => true; + + public int MaximumTokenSizeInBytes { get; set; } = 1024 * 5; + + public bool CanReadToken(string securityToken) + { + return true; + } + + public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken) + { + if (!string.IsNullOrEmpty(securityToken) && securityToken.Contains("ThisIsAValidToken")) + { + validatedToken = new TestSecurityToken(); + return new ClaimsPrincipal(new ClaimsIdentity("Test")); + } + + throw new SecurityTokenException("The security token did not contain ThisIsAValidToken"); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml new file mode 100644 index 000000000..2addae96c --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/ValidToken.xml @@ -0,0 +1,83 @@ + + + 2014-04-18T20:21:17.341Z + 2014-04-19T08:21:17.341Z + + + +
http://automation1/
+
+
+ + + https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/ + + + + + + + + + + + Lkq0wTyTFxLUU2cyx0XybJqhka5RzRGj6kC4aIpFg+g= + + + bPwNswOB/B9xcdAljIkin9A2vjq+u94JdyvK03mf8vZFGUYNu9uN/Q6ims1DvW1FnP7SgFBwhIvW5OjZyW8fdYGhC2bq36izkxH6ulkWbciOcyELkyHDACLudvh8kP/Q+IwpicefKzAeI2Qu/5MFq16vFg5YgI+dovg8u1fYPPEPmmptW893RNTHWeh9mLRpLYnHyg7aLG6emNRkEu7w9rzeoICeMFybb9BvJl/q/8MFCW/Z5WemQhCi6YXFSEwCO6zJzCFi/3T6ChU/xYgXbFykDLqulsNOCQxdgutyqxJzugt+3PH5IKHHuoqe7UZNUIyELJ4BgwE1sXCGYIi24rg== + + + ThisIsAValidToken + + + + + t0ch1TsP0pi5VoW8q5CGWsCXVZoNtpsg0mbMZPOYb4I + + + + + http://Automation1 + + + + + Test + + + Test + + + user1@praburajgmail.onmicrosoft.com + + + 4afbc689-805b-48cf-a24c-d4aa3248a248 + + + c2f0cd49-5e53-4520-8ed9-4e178dc488c5 + + + https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/ + + + + + urn:oasis:names:tc:SAML:2.0:ac:classes:Password + + + + + + + _660ec874-f70a-4997-a9c4-bd591f1c7469 + + + + + _660ec874-f70a-4997-a9c4-bd591f1c7469 + + + http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0 + http://schemas.xmlsoap.org/ws/2005/02/trust/Issue + http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey +
\ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs new file mode 100644 index 000000000..bc1ef757f --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/WsFederationTest.cs @@ -0,0 +1,443 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Claims; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Extensions; +using Microsoft.AspNetCore.TestHost; +using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; +using Microsoft.Net.Http.Headers; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.WsFederation +{ + public class WsFederationTest + { + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection(); + services.AddAuthentication().AddWsFederation(); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(WsFederationDefaults.AuthenticationScheme); + Assert.NotNull(scheme); + Assert.Equal("WsFederationHandler", scheme.HandlerType.Name); + Assert.Equal(WsFederationDefaults.AuthenticationScheme, scheme.DisplayName); + } + + [Fact] + public async Task MissingConfigurationThrows() + { + var builder = new WebHostBuilder() + .Configure(ConfigureApp) + .ConfigureServices(services => + { + services.AddAuthentication(sharedOptions => + { + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; + }) + .AddCookie() + .AddWsFederation(); + }); + var server = new TestServer(builder); + var httpClient = server.CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var exception = await Assert.ThrowsAsync(() => httpClient.GetAsync("/")); + Assert.Equal("Provide MetadataAddress, Configuration, or ConfigurationManager to WsFederationOptions", exception.Message); + } + + [Fact] + public async Task ChallengeRedirects() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/"); + Assert.Equal("https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed", response.Headers.Location.GetLeftPart(System.UriPartial.Path)); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + Assert.Equal("http://Automation1", queryItems["wtrealm"]); + Assert.True(queryItems["wctx"].ToString().Equals(CustomStateDataFormat.ValidStateData), "wctx does not equal ValidStateData"); + Assert.Equal(httpClient.BaseAddress + "signin-wsfed", queryItems["wreply"]); + Assert.Equal("wsignin1.0", queryItems["wa"]); + } + + [Fact] + public async Task MapWillNotAffectRedirect() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/mapped-challenge"); + Assert.Equal("https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed", response.Headers.Location.GetLeftPart(System.UriPartial.Path)); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + Assert.Equal("http://Automation1", queryItems["wtrealm"]); + Assert.True(queryItems["wctx"].ToString().Equals(CustomStateDataFormat.ValidStateData), "wctx does not equal ValidStateData"); + Assert.Equal(httpClient.BaseAddress + "signin-wsfed", queryItems["wreply"]); + Assert.Equal("wsignin1.0", queryItems["wa"]); + } + + [Fact] + public async Task PreMappedWillAffectRedirect() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/premapped-challenge"); + Assert.Equal("https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed", response.Headers.Location.GetLeftPart(System.UriPartial.Path)); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + Assert.Equal("http://Automation1", queryItems["wtrealm"]); + Assert.True(queryItems["wctx"].ToString().Equals(CustomStateDataFormat.ValidStateData), "wctx does not equal ValidStateData"); + Assert.Equal(httpClient.BaseAddress + "premapped-challenge/signin-wsfed", queryItems["wreply"]); + Assert.Equal("wsignin1.0", queryItems["wa"]); + } + + [Fact] + public async Task ValidTokenIsAccepted() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/"); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + var request = new HttpRequestMessage(HttpMethod.Post, queryItems["wreply"]); + CopyCookies(response, request); + request.Content = CreateSignInContent("WsFederation/ValidToken.xml", queryItems["wctx"]); + response = await httpClient.SendAsync(request); + + Assert.Equal(HttpStatusCode.Found, response.StatusCode); + + request = new HttpRequestMessage(HttpMethod.Get, response.Headers.Location); + CopyCookies(response, request); + response = await httpClient.SendAsync(request); + + // Did the request end in the actual resource requested for + Assert.Equal(WsFederationDefaults.AuthenticationScheme, await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task ValidUnsolicitedTokenIsRefused() + { + var httpClient = CreateClient(); + var form = CreateSignInContent("WsFederation/ValidToken.xml", suppressWctx: true); + var exception = await Assert.ThrowsAsync(() => httpClient.PostAsync(httpClient.BaseAddress + "signin-wsfed", form)); + Assert.Contains("Unsolicited logins are not allowed.", exception.InnerException.Message); + } + + [Fact] + public async Task ValidUnsolicitedTokenIsAcceptedWhenAllowed() + { + var httpClient = CreateClient(allowUnsolicited: true); + + var form = CreateSignInContent("WsFederation/ValidToken.xml", suppressWctx: true); + var response = await httpClient.PostAsync(httpClient.BaseAddress + "signin-wsfed", form); + + Assert.Equal(HttpStatusCode.Found, response.StatusCode); + + var request = new HttpRequestMessage(HttpMethod.Get, response.Headers.Location); + CopyCookies(response, request); + response = await httpClient.SendAsync(request); + + // Did the request end in the actual resource requested for + Assert.Equal(WsFederationDefaults.AuthenticationScheme, await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task InvalidTokenIsRejected() + { + var httpClient = CreateClient(); + + // Verify if the request is redirected to STS with right parameters + var response = await httpClient.GetAsync("/"); + var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query); + + var request = new HttpRequestMessage(HttpMethod.Post, queryItems["wreply"]); + CopyCookies(response, request); + request.Content = CreateSignInContent("WsFederation/InvalidToken.xml", queryItems["wctx"]); + response = await httpClient.SendAsync(request); + + // Did the request end in the actual resource requested for + Assert.Equal("AuthenticationFailed", await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task RemoteSignoutRequestTriggersSignout() + { + var httpClient = CreateClient(); + + var response = await httpClient.GetAsync("/signin-wsfed?wa=wsignoutcleanup1.0"); + response.EnsureSuccessStatusCode(); + + var cookie = response.Headers.GetValues(HeaderNames.SetCookie).Single(); + Assert.Equal(".AspNetCore.Cookies=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax", cookie); + Assert.Equal("OnRemoteSignOut", response.Headers.GetValues("EventHeader").Single()); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + } + + [Fact] + public async Task EventsResolvedFromDI() + { + var builder = new WebHostBuilder() + .ConfigureServices(services => + { + services.AddSingleton(); + services.AddAuthentication(sharedOptions => + { + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; + }) + .AddCookie() + .AddWsFederation(options => + { + options.Wtrealm = "http://Automation1"; + options.MetadataAddress = "https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/federationmetadata/2007-06/federationmetadata.xml"; + options.BackchannelHttpHandler = new WaadMetadataDocumentHandler(); + options.EventsType = typeof(MyWsFedEvents); + }); + }) + .Configure(app => + { + app.Run(context => context.ChallengeAsync()); + }); + var server = new TestServer(builder); + + var result = await server.CreateClient().GetAsync(""); + Assert.Contains("CustomKey=CustomValue", result.Headers.Location.Query); + } + + private class MyWsFedEvents : WsFederationEvents + { + public override Task RedirectToIdentityProvider(RedirectContext context) + { + context.ProtocolMessage.SetParameter("CustomKey", "CustomValue"); + return base.RedirectToIdentityProvider(context); + } + } + + private FormUrlEncodedContent CreateSignInContent(string tokenFile, string wctx = null, bool suppressWctx = false) + { + var kvps = new List>(); + kvps.Add(new KeyValuePair("wa", "wsignin1.0")); + kvps.Add(new KeyValuePair("wresult", File.ReadAllText(tokenFile))); + if (!string.IsNullOrEmpty(wctx)) + { + kvps.Add(new KeyValuePair("wctx", wctx)); + } + if (suppressWctx) + { + kvps.Add(new KeyValuePair("suppressWctx", "true")); + } + return new FormUrlEncodedContent(kvps); + } + + private void CopyCookies(HttpResponseMessage response, HttpRequestMessage request) + { + var cookies = SetCookieHeaderValue.ParseList(response.Headers.GetValues(HeaderNames.SetCookie).ToList()); + foreach (var cookie in cookies) + { + if (cookie.Value.HasValue) + { + request.Headers.Add(HeaderNames.Cookie, new CookieHeaderValue(cookie.Name, cookie.Value).ToString()); + } + } + } + + private HttpClient CreateClient(bool allowUnsolicited = false) + { + var builder = new WebHostBuilder() + .Configure(ConfigureApp) + .ConfigureServices(services => + { + services.AddAuthentication(sharedOptions => + { + sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; + }) + .AddCookie() + .AddWsFederation(options => + { + options.Wtrealm = "http://Automation1"; + options.MetadataAddress = "https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/federationmetadata/2007-06/federationmetadata.xml"; + options.BackchannelHttpHandler = new WaadMetadataDocumentHandler(); + options.StateDataFormat = new CustomStateDataFormat(); + options.SecurityTokenHandlers = new List() { new TestSecurityTokenValidator() }; + options.UseTokenLifetime = false; + options.AllowUnsolicitedLogins = allowUnsolicited; + options.Events = new WsFederationEvents() + { + OnMessageReceived = context => + { + if (!context.ProtocolMessage.Parameters.TryGetValue("suppressWctx", out var suppress)) + { + Assert.True(context.ProtocolMessage.Wctx.Equals("customValue"), "wctx is not my custom value"); + } + context.HttpContext.Items["MessageReceived"] = true; + return Task.FromResult(0); + }, + OnRedirectToIdentityProvider = context => + { + if (context.ProtocolMessage.IsSignInMessage) + { + // Sign in message + context.ProtocolMessage.Wctx = "customValue"; + } + + return Task.FromResult(0); + }, + OnSecurityTokenReceived = context => + { + context.HttpContext.Items["SecurityTokenReceived"] = true; + return Task.FromResult(0); + }, + OnSecurityTokenValidated = context => + { + Assert.True((bool)context.HttpContext.Items["MessageReceived"], "MessageReceived notification not invoked"); + Assert.True((bool)context.HttpContext.Items["SecurityTokenReceived"], "SecurityTokenReceived notification not invoked"); + + if (context.Principal != null) + { + var identity = context.Principal.Identities.Single(); + identity.AddClaim(new Claim("ReturnEndpoint", "true")); + identity.AddClaim(new Claim("Authenticated", "true")); + identity.AddClaim(new Claim(identity.RoleClaimType, "Guest", ClaimValueTypes.String)); + } + + return Task.FromResult(0); + }, + OnAuthenticationFailed = context => + { + context.HttpContext.Items["AuthenticationFailed"] = true; + //Change the request url to something different and skip Wsfed. This new url will handle the request and let us know if this notification was invoked. + context.HttpContext.Request.Path = new PathString("/AuthenticationFailed"); + context.SkipHandler(); + return Task.FromResult(0); + }, + OnRemoteSignOut = context => + { + context.Response.Headers["EventHeader"] = "OnRemoteSignOut"; + return Task.FromResult(0); + } + }; + }); + }); + var server = new TestServer(builder); + return server.CreateClient(); + } + + private void ConfigureApp(IApplicationBuilder app) + { + app.Map("/PreMapped-Challenge", mapped => + { + mapped.UseAuthentication(); + mapped.Run(async context => + { + await context.ChallengeAsync(WsFederationDefaults.AuthenticationScheme); + }); + }); + + app.UseAuthentication(); + + app.Map("/Logout", subApp => + { + subApp.Run(async context => + { + if (context.User.Identity.IsAuthenticated) + { + var authProperties = new AuthenticationProperties() { RedirectUri = context.Request.GetEncodedUrl() }; + await context.SignOutAsync(WsFederationDefaults.AuthenticationScheme, authProperties); + await context.Response.WriteAsync("Signing out..."); + } + else + { + await context.Response.WriteAsync("SignedOut"); + } + }); + }); + + app.Map("/AuthenticationFailed", subApp => + { + subApp.Run(async context => + { + await context.Response.WriteAsync("AuthenticationFailed"); + }); + }); + + app.Map("/signout-wsfed", subApp => + { + subApp.Run(async context => + { + await context.Response.WriteAsync("signout-wsfed"); + }); + }); + + app.Map("/mapped-challenge", subApp => + { + subApp.Run(async context => + { + await context.ChallengeAsync(WsFederationDefaults.AuthenticationScheme); + }); + }); + + app.Run(async context => + { + var result = context.AuthenticateAsync(); + if (context.User == null || !context.User.Identity.IsAuthenticated) + { + await context.ChallengeAsync(WsFederationDefaults.AuthenticationScheme); + await context.Response.WriteAsync("Unauthorized"); + } + else + { + var identity = context.User.Identities.Single(); + if (identity.NameClaimType == "Name_Failed" && identity.RoleClaimType == "Role_Failed") + { + context.Response.StatusCode = 500; + await context.Response.WriteAsync("SignIn_Failed"); + } + else if (!identity.HasClaim("Authenticated", "true") || !identity.HasClaim("ReturnEndpoint", "true") || !identity.HasClaim(identity.RoleClaimType, "Guest")) + { + await context.Response.WriteAsync("Provider not invoked"); + return; + } + else + { + await context.Response.WriteAsync(WsFederationDefaults.AuthenticationScheme); + } + } + }); + } + + private class WaadMetadataDocumentHandler : HttpMessageHandler + { + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + var metadata = File.ReadAllText(@"WsFederation/federationmetadata.xml"); + var newResponse = new HttpResponseMessage() { Content = new StringContent(metadata, Encoding.UTF8, "text/xml") }; + return Task.FromResult(newResponse); + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml new file mode 100644 index 000000000..920ed66a4 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/WsFederation/federationmetadata.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + wFJy/A1QstqtLHauYGcqwwHvn3HUW25DcWI/XLOmXOM= + + + R6fPw+BiFS9XYdkhwNJRjGxVftA2j9TdkF5d5jgR8uG1QMyuEA/Eizeq1HnnUj2Yi+sqNG+HzaZQclECeiJfi88Ry+keorDCo9KgdnjlZZc+WFzrJZeHjaDIvFD6B4OAN0mTq5kbpwr7+idzSbvyRXAnpvJxOrViZKE4HpwltGAZGDTkjsVkd8Z/wfoN7ehN4Ei7u/mOAiEU4FkWYFU/BfSVRVIUDyyQ7DGfQFJvCwHWFvsq+M1wfOUzQO5K+M9EU2m4VEP1qqbexXaZMAbcjqyUn4eN7doWjWE59jkXGbn+GR8qgCJqLOaYwXnH5XD0pMjy71aKGyLNaUb3wCwjkA== + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + + + + MIIDPjCCAiqgAwIBAgIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTQwMTAxMDcwMDAwWhcNMTYwMTAxMDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkSCWg6q9iYxvJE2NIhSyOiKvqoWCO2GFipgH0sTSAs5FalHQosk9ZNTztX0ywS/AHsBeQPqYygfYVJL6/EgzVuwRk5txr9e3n1uml94fLyq/AXbwo9yAduf4dCHTP8CWR1dnDR+Qnz/4PYlWVEuuHHONOw/blbfdMjhY+C/BYM2E3pRxbohBb3x//CfueV7ddz2LYiH3wjz0QS/7kjPiNCsXcNyKQEOTkbHFi3mu0u13SQwNddhcynd/GTgWN8A+6SN1r4hzpjFKFLbZnBt77ACSiYx+IHK4Mp+NaVEi5wQtSsjQtI++XsokxRDqYLwus1I1SihgbV/STTg5enufuwIDAQABo2IwYDBeBgNVHQEEVzBVgBDLebM6bK3BjWGqIBrBNFeNoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAA4IBAQCJ4JApryF77EKC4zF5bUaBLQHQ1PNtA1uMDbdNVGKCmSf8M65b8h0NwlIjGGGy/unK8P6jWFdm5IlZ0YPTOgzcRZguXDPj7ajyvlVEQ2K2ICvTYiRQqrOhEhZMSSZsTKXFVwNfW6ADDkN3bvVOVbtpty+nBY5UqnI7xbcoHLZ4wYD251uj5+lo13YLnsVrmQ16NCBYq2nQFNPuNJw6t3XUbwBHXpF46aLT1/eGf/7Xx6iy8yPJX4DyrpFTutDz882RWofGEO5t4Cw+zZg70dJ/hH/ODYRMorfXEW+8uKmXMKmX2wyxMKvfiPbTy5LmAU8Jvjs2tLg4rOBcXWLAIarZ + + + + + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + + UPN + UPN of the user + + + Name + The display name for the user + + + Given Name + First name of the user + + + Surname + Last name of the user + + + Authentication Instant + The time (UTC) at which the user authenticated to the identity provider + + + Authentication Method + The method of authentication used by the identity provider + + + TenantId + Identifier for the user's tenant + + + IdentityProvider + Identity provider for the user. + + + + +
https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed
+
+
+ + +
https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed
+
+
+
+ + + + + MIIDPjCCAiqgAwIBAgIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTQwMTAxMDcwMDAwWhcNMTYwMTAxMDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkSCWg6q9iYxvJE2NIhSyOiKvqoWCO2GFipgH0sTSAs5FalHQosk9ZNTztX0ywS/AHsBeQPqYygfYVJL6/EgzVuwRk5txr9e3n1uml94fLyq/AXbwo9yAduf4dCHTP8CWR1dnDR+Qnz/4PYlWVEuuHHONOw/blbfdMjhY+C/BYM2E3pRxbohBb3x//CfueV7ddz2LYiH3wjz0QS/7kjPiNCsXcNyKQEOTkbHFi3mu0u13SQwNddhcynd/GTgWN8A+6SN1r4hzpjFKFLbZnBt77ACSiYx+IHK4Mp+NaVEi5wQtSsjQtI++XsokxRDqYLwus1I1SihgbV/STTg5enufuwIDAQABo2IwYDBeBgNVHQEEVzBVgBDLebM6bK3BjWGqIBrBNFeNoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAA4IBAQCJ4JApryF77EKC4zF5bUaBLQHQ1PNtA1uMDbdNVGKCmSf8M65b8h0NwlIjGGGy/unK8P6jWFdm5IlZ0YPTOgzcRZguXDPj7ajyvlVEQ2K2ICvTYiRQqrOhEhZMSSZsTKXFVwNfW6ADDkN3bvVOVbtpty+nBY5UqnI7xbcoHLZ4wYD251uj5+lo13YLnsVrmQ16NCBYq2nQFNPuNJw6t3XUbwBHXpF46aLT1/eGf/7Xx6iy8yPJX4DyrpFTutDz882RWofGEO5t4Cw+zZg70dJ/hH/ODYRMorfXEW+8uKmXMKmX2wyxMKvfiPbTy5LmAU8Jvjs2tLg4rOBcXWLAIarZ + + + + + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + +
https://sts.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/
+
+
+ + +
https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed
+
+
+ + +
https://login.windows.net/4afbc689-805b-48cf-a24c-d4aa3248a248/wsfed
+
+
+
+ + + + + MIIDPjCCAiqgAwIBAgIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTQwMTAxMDcwMDAwWhcNMTYwMTAxMDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkSCWg6q9iYxvJE2NIhSyOiKvqoWCO2GFipgH0sTSAs5FalHQosk9ZNTztX0ywS/AHsBeQPqYygfYVJL6/EgzVuwRk5txr9e3n1uml94fLyq/AXbwo9yAduf4dCHTP8CWR1dnDR+Qnz/4PYlWVEuuHHONOw/blbfdMjhY+C/BYM2E3pRxbohBb3x//CfueV7ddz2LYiH3wjz0QS/7kjPiNCsXcNyKQEOTkbHFi3mu0u13SQwNddhcynd/GTgWN8A+6SN1r4hzpjFKFLbZnBt77ACSiYx+IHK4Mp+NaVEi5wQtSsjQtI++XsokxRDqYLwus1I1SihgbV/STTg5enufuwIDAQABo2IwYDBeBgNVHQEEVzBVgBDLebM6bK3BjWGqIBrBNFeNoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQsRiM0jheFZhKk49YD0SK1TAJBgUrDgMCHQUAA4IBAQCJ4JApryF77EKC4zF5bUaBLQHQ1PNtA1uMDbdNVGKCmSf8M65b8h0NwlIjGGGy/unK8P6jWFdm5IlZ0YPTOgzcRZguXDPj7ajyvlVEQ2K2ICvTYiRQqrOhEhZMSSZsTKXFVwNfW6ADDkN3bvVOVbtpty+nBY5UqnI7xbcoHLZ4wYD251uj5+lo13YLnsVrmQ16NCBYq2nQFNPuNJw6t3XUbwBHXpF46aLT1/eGf/7Xx6iy8yPJX4DyrpFTutDz882RWofGEO5t4Cw+zZg70dJ/hH/ODYRMorfXEW+8uKmXMKmX2wyxMKvfiPbTy5LmAU8Jvjs2tLg4rOBcXWLAIarZ + + + + + + + MIIDPjCCAiqgAwIBAgIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAMC0xKzApBgNVBAMTImFjY291bnRzLmFjY2Vzc2NvbnRyb2wud2luZG93cy5uZXQwHhcNMTIwNjA3MDcwMDAwWhcNMTQwNjA3MDcwMDAwWjAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArCz8Sn3GGXmikH2MdTeGY1D711EORX/lVXpr+ecGgqfUWF8MPB07XkYuJ54DAuYT318+2XrzMjOtqkT94VkXmxv6dFGhG8YZ8vNMPd4tdj9c0lpvWQdqXtL1TlFRpD/P6UMEigfN0c9oWDg9U7Ilymgei0UXtf1gtcQbc5sSQU0S4vr9YJp2gLFIGK11Iqg4XSGdcI0QWLLkkC6cBukhVnd6BCYbLjTYy3fNs4DzNdemJlxGl8sLexFytBF6YApvSdus3nFXaMCtBGx16HzkK9ne3lobAwL2o79bP4imEGqg+ibvyNmbrwFGnQrBc1jTF9LyQX9q+louxVfHs6ZiVwIDAQABo2IwYDBeBgNVHQEEVzBVgBCxDDsLd8xkfOLKm4Q/SzjtoS8wLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldIIQVWmXY/+9RqFA/OG9kFulHDAJBgUrDgMCHQUAA4IBAQAkJtxxm/ErgySlNk69+1odTMP8Oy6L0H17z7XGG3w4TqvTUSWaxD4hSFJ0e7mHLQLQD7oV/erACXwSZn2pMoZ89MBDjOMQA+e6QzGB7jmSzPTNmQgMLA8fWCfqPrz6zgH+1F1gNp8hJY57kfeVPBiyjuBmlTEBsBlzolY9dd/55qqfQk6cgSeCbHCy/RU/iep0+UsRMlSgPNNmqhj5gmN2AFVCN96zF694LwuPae5CeR2ZcVknexOWHYjFM0MgUSw0ubnGl0h9AJgGyhvNGcjQqu9vd1xkupFgaN+f7P3p3EVN5csBg5H94jEcQZT7EKeTiZ6bTrpDAnrr8tDCy8ng + + + + + + +
\ No newline at end of file From cc8acdff57a200966b6b695c7846dfde073cfe68 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 28 Feb 2018 09:48:07 -0800 Subject: [PATCH 143/248] Update facebook API version to 2.12 #1306 --- .../FacebookDefaults.cs | 6 +++--- .../FacebookTests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs index 6143a4f23..92d1d003e 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -9,10 +9,10 @@ public static class FacebookDefaults public static readonly string DisplayName = "Facebook"; - public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.6/dialog/oauth"; + public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.12/dialog/oauth"; - public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.6/oauth/access_token"; + public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.12/oauth/access_token"; - public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v2.6/me"; + public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v2.12/me"; } } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 684482ed5..99177d66b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -585,7 +585,7 @@ public async Task NestedMapWillNotAffectRedirect() var transaction = await server.SendAsync("http://example.com/base/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.6/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/base/signin-facebook"), location); @@ -617,7 +617,7 @@ public async Task MapWillNotAffectRedirect() var transaction = await server.SendAsync("http://example.com/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.6/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri="+ UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location); @@ -652,7 +652,7 @@ public async Task ChallengeWillTriggerRedirection() var transaction = await server.SendAsync("http://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.6/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=", location); From 21acbf06e88a5f649e90b4a458b4341355791ac4 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 28 Feb 2018 10:01:09 -0800 Subject: [PATCH 144/248] Update google auth endpoint to v2 #1307 --- .../GoogleDefaults.cs | 2 +- test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index e4bd66615..042870318 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -12,7 +12,7 @@ public static class GoogleDefaults public static readonly string DisplayName = "Google"; - public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/auth"; + public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth"; public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 8bfbaacde..c3e80ef71 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -457,7 +457,7 @@ public async Task ChallengeWillTriggerRedirection() var transaction = await server.SendAsync("https://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.ToString(); - Assert.Contains("https://accounts.google.com/o/oauth2/auth?response_type=code", location); + Assert.Contains("https://accounts.google.com/o/oauth2/v2/auth?response_type=code", location); Assert.Contains("&client_id=", location); Assert.Contains("&redirect_uri=", location); Assert.Contains("&scope=", location); From 9839799645a1110990a5fa5fb8ce060566a0e39e Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 2 Mar 2018 09:53:03 -0800 Subject: [PATCH 145/248] Add CookiePolicy logging #1588 --- samples/CookiePolicySample/Program.cs | 2 +- .../CookiePolicyMiddleware.cs | 18 ++- .../LoggingExtensions.cs | 105 ++++++++++++++++++ .../Microsoft.AspNetCore.CookiePolicy.csproj | 1 + .../ResponseCookiesWrapper.cs | 50 +++++++-- .../CookiePolicyTests.cs | 2 +- 6 files changed, 163 insertions(+), 15 deletions(-) create mode 100644 src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs diff --git a/samples/CookiePolicySample/Program.cs b/samples/CookiePolicySample/Program.cs index 12fc8ff28..3fc09a3db 100644 --- a/samples/CookiePolicySample/Program.cs +++ b/samples/CookiePolicySample/Program.cs @@ -12,7 +12,7 @@ public static void Main(string[] args) .ConfigureLogging(factory => { factory.AddConsole(); - factory.AddFilter("Console", level => level >= LogLevel.Information); + factory.AddFilter("Microsoft", LogLevel.Trace); }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) diff --git a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs index b99fed2c3..1a810b7d5 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/CookiePolicyMiddleware.cs @@ -1,10 +1,13 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.CookiePolicy @@ -12,13 +15,20 @@ namespace Microsoft.AspNetCore.CookiePolicy public class CookiePolicyMiddleware { private readonly RequestDelegate _next; + private readonly ILogger _logger; - public CookiePolicyMiddleware( - RequestDelegate next, - IOptions options) + public CookiePolicyMiddleware(RequestDelegate next, IOptions options, ILoggerFactory factory) + { + Options = options.Value; + _next = next ?? throw new ArgumentNullException(nameof(next)); + _logger = factory.CreateLogger(); + } + + public CookiePolicyMiddleware(RequestDelegate next, IOptions options) { Options = options.Value; _next = next; + _logger = NullLogger.Instance; } public CookiePolicyOptions Options { get; set; } @@ -26,7 +36,7 @@ public CookiePolicyMiddleware( public Task Invoke(HttpContext context) { var feature = context.Features.Get() ?? new ResponseCookiesFeature(context.Features); - var wrapper = new ResponseCookiesWrapper(context, Options, feature); + var wrapper = new ResponseCookiesWrapper(context, Options, feature, _logger); context.Features.Set(new CookiesWrapperFeature(wrapper)); context.Features.Set(wrapper); diff --git a/src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs b/src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs new file mode 100644 index 000000000..21b04facc --- /dev/null +++ b/src/Microsoft.AspNetCore.CookiePolicy/LoggingExtensions.cs @@ -0,0 +1,105 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.Extensions.Logging +{ + internal static class LoggingExtensions + { + private static Action _needsConsent; + private static Action _hasConsent; + private static Action _consentGranted; + private static Action _consentWithdrawn; + private static Action _cookieSuppressed; + private static Action _deleteCookieSuppressed; + private static Action _upgradedToSecure; + private static Action _upgradedSameSite; + private static Action _upgradedToHttpOnly; + + static LoggingExtensions() + { + _needsConsent = LoggerMessage.Define( + eventId: 1, + logLevel: LogLevel.Trace, + formatString: "Needs consent: {needsConsent}."); + _hasConsent = LoggerMessage.Define( + eventId: 2, + logLevel: LogLevel.Trace, + formatString: "Has consent: {hasConsent}."); + _consentGranted = LoggerMessage.Define( + eventId: 3, + logLevel: LogLevel.Debug, + formatString: "Consent granted."); + _consentWithdrawn = LoggerMessage.Define( + eventId: 4, + logLevel: LogLevel.Debug, + formatString: "Consent withdrawn."); + _cookieSuppressed = LoggerMessage.Define( + eventId: 5, + logLevel: LogLevel.Debug, + formatString: "Cookie '{key}' suppressed due to consent policy."); + _deleteCookieSuppressed = LoggerMessage.Define( + eventId: 6, + logLevel: LogLevel.Debug, + formatString: "Delete cookie '{key}' suppressed due to developer policy."); + _upgradedToSecure = LoggerMessage.Define( + eventId: 7, + logLevel: LogLevel.Debug, + formatString: "Cookie '{key}' upgraded to 'secure'."); + _upgradedSameSite = LoggerMessage.Define( + eventId: 8, + logLevel: LogLevel.Debug, + formatString: "Cookie '{key}' same site mode upgraded to '{mode}'."); + _upgradedToHttpOnly = LoggerMessage.Define( + eventId: 9, + logLevel: LogLevel.Debug, + formatString: "Cookie '{key}' upgraded to 'httponly'."); + } + + public static void NeedsConsent(this ILogger logger, bool needsConsent) + { + _needsConsent(logger, needsConsent, null); + } + + public static void HasConsent(this ILogger logger, bool hasConsent) + { + _hasConsent(logger, hasConsent, null); + } + + public static void ConsentGranted(this ILogger logger) + { + _consentGranted(logger, null); + } + + public static void ConsentWithdrawn(this ILogger logger) + { + _consentWithdrawn(logger, null); + } + + public static void CookieSuppressed(this ILogger logger, string key) + { + _cookieSuppressed(logger, key, null); + } + + public static void DeleteCookieSuppressed(this ILogger logger, string key) + { + _deleteCookieSuppressed(logger, key, null); + } + + public static void CookieUpgradedToSecure(this ILogger logger, string key) + { + _upgradedToSecure(logger, key, null); + } + + public static void CookieSameSiteUpgraded(this ILogger logger, string key, string mode) + { + _upgradedSameSite(logger, key, mode, null); + } + + public static void CookieUpgradedToHttpOnly(this ILogger logger, string key) + { + _upgradedToHttpOnly(logger, key, null); + } + } +} diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 1a42b04dd..40f97633a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs index e05cc9466..126c4d7bd 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs +++ b/src/Microsoft.AspNetCore.CookiePolicy/ResponseCookiesWrapper.cs @@ -5,21 +5,23 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.CookiePolicy { internal class ResponseCookiesWrapper : IResponseCookies, ITrackingConsentFeature { private const string ConsentValue = "yes"; - + private readonly ILogger _logger; private bool? _isConsentNeeded; private bool? _hasConsent; - public ResponseCookiesWrapper(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature) + public ResponseCookiesWrapper(HttpContext context, CookiePolicyOptions options, IResponseCookiesFeature feature, ILogger logger) { Context = context; Feature = feature; Options = options; + _logger = logger; } private HttpContext Context { get; } @@ -38,6 +40,7 @@ public bool IsConsentNeeded { _isConsentNeeded = Options.CheckConsentNeeded == null ? false : Options.CheckConsentNeeded(Context); + _logger.NeedsConsent(_isConsentNeeded.Value); } return _isConsentNeeded.Value; @@ -52,6 +55,7 @@ public bool HasConsent { var cookie = Context.Request.Cookies[Options.ConsentCookie.Name]; _hasConsent = string.Equals(cookie, ConsentValue, StringComparison.Ordinal); + _logger.HasConsent(_hasConsent.Value); } return _hasConsent.Value; @@ -67,6 +71,7 @@ public void GrantConsent() var cookieOptions = Options.ConsentCookie.Build(Context); // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. Append(Options.ConsentCookie.Name, ConsentValue, cookieOptions); + _logger.ConsentGranted(); } _hasConsent = true; } @@ -78,6 +83,7 @@ public void WithdrawConsent() var cookieOptions = Options.ConsentCookie.Build(Context); // Note policy will be applied. We don't want to bypass policy because we want HttpOnly, Secure, etc. to apply. Delete(Options.ConsentCookie.Name, cookieOptions); + _logger.ConsentWithdrawn(); } _hasConsent = false; } @@ -137,12 +143,16 @@ public void Append(string key, string value, CookieOptions options) { Cookies.Append(key, value, options); } + else + { + _logger.CookieSuppressed(key); + } } private bool ApplyAppendPolicy(ref string key, ref string value, CookieOptions options) { var issueCookie = CanTrack || options.IsEssential; - ApplyPolicy(options); + ApplyPolicy(key, options); if (Options.OnAppendCookie != null) { var context = new AppendCookieContext(Context, options, key, value) @@ -182,7 +192,7 @@ public void Delete(string key, CookieOptions options) // Assume you can always delete cookies unless directly overridden in the user event. var issueCookie = true; - ApplyPolicy(options); + ApplyPolicy(key, options); if (Options.OnDeleteCookie != null) { var context = new DeleteCookieContext(Context, options, key) @@ -201,17 +211,30 @@ public void Delete(string key, CookieOptions options) { Cookies.Delete(key, options); } + else + { + _logger.DeleteCookieSuppressed(key); + } } - private void ApplyPolicy(CookieOptions options) + private void ApplyPolicy(string key, CookieOptions options) { switch (Options.Secure) { case CookieSecurePolicy.Always: - options.Secure = true; + if (!options.Secure) + { + options.Secure = true; + _logger.CookieUpgradedToSecure(key); + } break; case CookieSecurePolicy.SameAsRequest: - options.Secure = Context.Request.IsHttps; + // Never downgrade a cookie + if (Context.Request.IsHttps && !options.Secure) + { + options.Secure = true; + _logger.CookieUpgradedToSecure(key); + } break; case CookieSecurePolicy.None: break; @@ -226,10 +249,15 @@ private void ApplyPolicy(CookieOptions options) if (options.SameSite == SameSiteMode.None) { options.SameSite = SameSiteMode.Lax; + _logger.CookieSameSiteUpgraded(key, "lax"); } break; case SameSiteMode.Strict: - options.SameSite = SameSiteMode.Strict; + if (options.SameSite != SameSiteMode.Strict) + { + options.SameSite = SameSiteMode.Strict; + _logger.CookieSameSiteUpgraded(key, "strict"); + } break; default: throw new InvalidOperationException($"Unrecognized {nameof(SameSiteMode)} value {Options.MinimumSameSitePolicy.ToString()}"); @@ -237,7 +265,11 @@ private void ApplyPolicy(CookieOptions options) switch (Options.HttpOnly) { case HttpOnlyPolicy.Always: - options.HttpOnly = true; + if (!options.HttpOnly) + { + options.HttpOnly = true; + _logger.CookieUpgradedToHttpOnly(key); + } break; case HttpOnlyPolicy.None: break; diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs index 7c34f950a..a2592e557 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/CookiePolicyTests.cs @@ -102,7 +102,7 @@ await RunTest("/secureSame", Assert.Equal("A=A; path=/; samesite=lax", transaction.SetCookie[0]); Assert.Equal("B=B; path=/; samesite=lax", transaction.SetCookie[1]); Assert.Equal("C=C; path=/; samesite=lax", transaction.SetCookie[2]); - Assert.Equal("D=D; path=/; samesite=lax", transaction.SetCookie[3]); + Assert.Equal("D=D; path=/; secure; samesite=lax", transaction.SetCookie[3]); }), new RequestTest("https://example.com/secureSame", transaction => From 1df139eb6d8ef1c1e74a14dd20c9dd13eb6e0e23 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 2 Mar 2018 12:37:19 -0800 Subject: [PATCH 146/248] Clone tickets for sliding refresh #1607 --- .../CookieAuthenticationHandler.cs | 21 +++- .../CookieTests.cs | 116 +++++++++++++++++- 2 files changed, 134 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 9a2fbfbc7..5993f7532 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -31,6 +31,7 @@ public class CookieAuthenticationHandler : private DateTimeOffset? _refreshExpiresUtc; private string _sessionKey; private Task _readCookieTask; + private AuthenticationTicket _refreshTicket; public CookieAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) @@ -99,9 +100,27 @@ private void RequestRefresh(AuthenticationTicket ticket) _refreshIssuedUtc = currentUtc; var timeSpan = expiresUtc.Value.Subtract(issuedUtc.Value); _refreshExpiresUtc = currentUtc.Add(timeSpan); + _refreshTicket = CloneTicket(ticket); } } + private AuthenticationTicket CloneTicket(AuthenticationTicket ticket) + { + var newPrincipal = new ClaimsPrincipal(); + foreach (var identity in ticket.Principal.Identities) + { + newPrincipal.AddIdentity(identity.Clone()); + } + + var newProperties = new AuthenticationProperties(); + foreach (var item in ticket.Properties.Items) + { + newProperties.Items[item.Key] = item.Value; + } + + return new AuthenticationTicket(newPrincipal, newProperties, ticket.AuthenticationScheme); + } + private async Task ReadCookieTicket() { var cookie = Options.CookieManager.GetRequestCookie(Context, Options.Cookie.Name); @@ -190,7 +209,7 @@ protected virtual async Task FinishResponseAsync() return; } - var ticket = (await HandleAuthenticateOnceSafeAsync())?.Ticket; + var ticket = _refreshTicket; if (ticket != null) { var properties = ticket.Properties; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index b2726bac8..945ec82ee 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -515,8 +515,10 @@ public async Task ProtectedCustomRequestShouldRedirectToCustomRedirectUri() private Task SignInAsAlice(HttpContext context) { + var user = new ClaimsIdentity(new GenericIdentity("Alice", "Cookies")); + user.AddClaim(new Claim("marker", "true")); return context.SignInAsync("Cookies", - new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))), + new ClaimsPrincipal(user), new AuthenticationProperties()); } @@ -942,6 +944,61 @@ public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); } + [Fact] + public async Task CookieCanBeRenewedByValidatorWithModifiedProperties() + { + var server = CreateServer(o => + { + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = ctx => + { + ctx.ShouldRenew = true; + var id = ctx.Principal.Identities.First(); + var claim = id.FindFirst("counter"); + if (claim == null) + { + id.AddClaim(new Claim("counter", "1")); + } + else + { + id.RemoveClaim(claim); + id.AddClaim(new Claim("counter", claim.Value + "1")); + } + return Task.FromResult(0); + } + }; + }, + context => + context.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction2.SetCookie); + Assert.Equal("1", FindClaimValue(transaction2, "counter")); + + _clock.Add(TimeSpan.FromMinutes(5)); + + var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction2.CookieNameValue); + Assert.NotNull(transaction3.SetCookie); + Assert.Equal("11", FindClaimValue(transaction3, "counter")); + + _clock.Add(TimeSpan.FromMinutes(6)); + + var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction3.CookieNameValue); + Assert.NotNull(transaction4.SetCookie); + Assert.Equal("111", FindClaimValue(transaction4, "counter")); + + _clock.Add(TimeSpan.FromMinutes(11)); + + var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction4.CookieNameValue); + Assert.Null(transaction5.SetCookie); + Assert.Null(FindClaimValue(transaction5, "counter")); + } + [Fact] public async Task CookieValidatorOnlyCalledOnce() { @@ -1114,6 +1171,51 @@ public async Task CookieIsRenewedWithSlidingExpiration() Assert.Equal("Alice", FindClaimValue(transaction5, ClaimTypes.Name)); } + [Fact] + public async Task CookieIsRenewedWithSlidingExpirationWithoutTransformations() + { + var server = CreateServer(o => + { + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.SlidingExpiration = true; + o.Events.OnValidatePrincipal = c => + { + // https://github.com/aspnet/Security/issues/1607 + // On sliding refresh the transformed principal should not be serialized into the cookie, only the original principal. + Assert.Single(c.Principal.Identities); + Assert.True(c.Principal.Identities.First().HasClaim("marker", "true")); + return Task.CompletedTask; + }; + }, + SignInAsAlice, + claimsTransform: true); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.Null(transaction2.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + + _clock.Add(TimeSpan.FromMinutes(4)); + + var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.Null(transaction3.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction3, ClaimTypes.Name)); + + _clock.Add(TimeSpan.FromMinutes(4)); + + // transaction4 should arrive with a new SetCookie value + var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction4.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction4, ClaimTypes.Name)); + + _clock.Add(TimeSpan.FromMinutes(4)); + + var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction4.CookieNameValue); + Assert.Null(transaction5.SetCookie); + Assert.Equal("Alice", FindClaimValue(transaction5, ClaimTypes.Name)); + } + [Fact] public async Task CookieUsesPathBaseByDefault() { @@ -1643,6 +1745,13 @@ private class ClaimsTransformer : IClaimsTransformation { public Task TransformAsync(ClaimsPrincipal p) { + var firstId = p.Identities.First(); + if (firstId.HasClaim("marker", "true")) + { + firstId.RemoveClaim(firstId.FindFirst("marker")); + } + // TransformAsync could be called twice on one request if you have a default scheme and also + // call AuthenticateAsync. if (!p.Identities.Any(i => i.AuthenticationType == "xform")) { var id = new ClaimsIdentity("xform"); @@ -1658,7 +1767,10 @@ private TestServer CreateServer(Action configureOpt { s.AddSingleton(_clock); s.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(configureOptions); - s.AddSingleton(); + if (claimsTransform) + { + s.AddSingleton(); + } }, testpath, baseAddress); private static TestServer CreateServerWithServices(Action configureServices, Func testpath = null, Uri baseAddress = null) From f5ea6944f0d501915a26a6c343eb67357bc6270a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:06:01 -0800 Subject: [PATCH 147/248] Use dotnet-core feed in repos --- build/sources.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/sources.props b/build/sources.props index 9feff29d0..9215df975 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,10 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); + https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; From 4e3e8bb109f3d1b3d95f7af4775a386d291c2b96 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:06:01 -0800 Subject: [PATCH 148/248] Prepend FeatureBranchVersionPrefix if FeatureBranchVersionSuffix is specified --- version.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.props b/version.props index 65c8a07e3..a11ea1ed5 100644 --- a/version.props +++ b/version.props @@ -5,7 +5,8 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 - $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) + a- + $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From 41bcbd5f0b3fa8bf361cb4a1eae03861cd3841bb Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 8 Mar 2018 13:14:09 -0800 Subject: [PATCH 149/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4ccaf4fcb..d0cb88aa8 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15721 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 + 2.1.0-preview2-15728 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26130-04 + 2.1.0-preview2-26225-03 15.6.0 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e6c7fddff..138d848db 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15721 -commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 +version:2.1.0-preview2-15728 +commithash:393377068ddcf51dfee0536536d455f57a828b06 From 4103d47f0919f9e5b5804d6bd4ee33ad5bb77d15 Mon Sep 17 00:00:00 2001 From: Alexander Klingenbeck Date: Tue, 13 Mar 2018 18:57:36 +0100 Subject: [PATCH 150/248] Rename ns Microsoft.AspNetCore.Authroization.Test to Microsoft.AspNetCore.Authorization.Test (#1693) --- .../AuthorizationPolicyFacts.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs index 3eefb7af7..143be1b9b 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationPolicyFacts.cs @@ -9,7 +9,7 @@ using Microsoft.Extensions.Options; using Xunit; -namespace Microsoft.AspNetCore.Authroization.Test +namespace Microsoft.AspNetCore.Authorization.Test { public class AuthorizationPolicyFacts { From bee77ebf911d477faed36a12bcc7369bf0005e1a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Tue, 13 Mar 2018 11:09:43 -0700 Subject: [PATCH 151/248] Rename VirtualScheme => PolicyScheme (#1665) * VirtualScheme => PolicyScheme * Use SignInHandler base for cookies * PolicySchemeHandlers throw NotImplemented by default * Remove redundant interface --- .../CookieAuthenticationHandler.cs | 23 +--- .../breakingchanges.netcore.json | 6 ++ .../AuthenticationBuilder.cs | 6 +- .../AuthenticationHandler.cs | 1 - .../PolicySchemeHandler.cs | 36 +++++++ .../PolicySchemeOptions.cs | 11 ++ .../SignInAuthenticationHandler.cs | 39 +++++++ .../SignOutAuthenticationHandler.cs | 36 +++++++ .../VirtualAuthenticationHandler.cs | 71 ------------ .../VirtualSchemeOptions.cs | 33 ------ ...{VirtualHandlerTests.cs => PolicyTests.cs} | 102 ++++++------------ 11 files changed, 166 insertions(+), 198 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs create mode 100644 src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs delete mode 100644 src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs rename test/Microsoft.AspNetCore.Authentication.Test/{VirtualHandlerTests.cs => PolicyTests.cs} (85%) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 5993f7532..343cf1b3a 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -14,10 +14,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { - public class CookieAuthenticationHandler : - AuthenticationHandler, - IAuthenticationSignInHandler, - IAuthenticationSignOutHandler + public class CookieAuthenticationHandler : SignInAuthenticationHandler { private const string HeaderValueNoCache = "no-cache"; private const string HeaderValueEpocDate = "Thu, 01 Jan 1970 00:00:00 GMT"; @@ -252,20 +249,13 @@ protected virtual async Task FinishResponseAsync() } } - public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + protected async override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) { if (user == null) { throw new ArgumentNullException(nameof(user)); } - var target = ResolveTarget(Options.ForwardSignIn); - if (target != null) - { - await Context.SignInAsync(target, user, properties); - return; - } - properties = properties ?? new AuthenticationProperties(); _signInCalled = true; @@ -346,15 +336,8 @@ public async virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProper Logger.SignedIn(Scheme.Name); } - public async virtual Task SignOutAsync(AuthenticationProperties properties) + protected async override Task HandleSignOutAsync(AuthenticationProperties properties) { - var target = ResolveTarget(Options.ForwardSignOut); - if (target != null) - { - await Context.SignOutAsync(target, properties); - return; - } - properties = properties ?? new AuthenticationProperties(); _signOutCalled = true; diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json new file mode 100644 index 000000000..7673fc1a0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json @@ -0,0 +1,6 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler, Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs index 7bf8fe96e..401b1f488 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationBuilder.cs @@ -91,15 +91,15 @@ public virtual AuthenticationBuilder AddRemoteScheme(string } /// - /// Adds a based authentication handler which can be used to + /// Adds a based authentication handler which can be used to /// redirect to other authentication schemes. /// /// The name of this scheme. /// The display name of this scheme. /// Used to configure the scheme options. /// The builder. - public virtual AuthenticationBuilder AddVirtualScheme(string authenticationScheme, string displayName, Action configureOptions) - => AddSchemeHelper(authenticationScheme, displayName, configureOptions); + public virtual AuthenticationBuilder AddPolicyScheme(string authenticationScheme, string displayName, Action configureOptions) + => AddSchemeHelper(authenticationScheme, displayName, configureOptions); // Used to ensure that there's always a default sign in scheme that's not itself private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs index 4399ce5f7..5c9a6473f 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationHandler.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; diff --git a/src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs b/src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs new file mode 100644 index 000000000..4dbbb7de2 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/PolicySchemeHandler.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// PolicySchemes are used to redirect authentication methods to another scheme. + /// + public class PolicySchemeHandler : SignInAuthenticationHandler + { + public PolicySchemeHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { } + + protected override Task HandleChallengeAsync(AuthenticationProperties properties) + => throw new NotImplementedException(); + + protected override Task HandleForbiddenAsync(AuthenticationProperties properties) + => throw new NotImplementedException(); + + protected override Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + => throw new NotImplementedException(); + + protected override Task HandleSignOutAsync(AuthenticationProperties properties) + => throw new NotImplementedException(); + + protected override Task HandleAuthenticateAsync() + => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs new file mode 100644 index 000000000..1921c77ec --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/PolicySchemeOptions.cs @@ -0,0 +1,11 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Contains the options used by the . + /// + public class PolicySchemeOptions : AuthenticationSchemeOptions + { } +} diff --git a/src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs new file mode 100644 index 000000000..dbd612dc1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/SignInAuthenticationHandler.cs @@ -0,0 +1,39 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Adds support for SignInAsync + /// + public abstract class SignInAuthenticationHandler : SignOutAuthenticationHandler, IAuthenticationSignInHandler + where TOptions : AuthenticationSchemeOptions, new() + { + public SignInAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { } + + public virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) + { + var target = ResolveTarget(Options.ForwardSignIn); + return (target != null) + ? Context.SignInAsync(target, user, properties) + : HandleSignInAsync(user, properties ?? new AuthenticationProperties()); + } + + /// + /// Override this method to handle SignIn. + /// + /// + /// + /// A Task. + protected abstract Task HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties); + + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs new file mode 100644 index 000000000..015cb39e0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/SignOutAuthenticationHandler.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Adds support for SignOutAsync + /// + public abstract class SignOutAuthenticationHandler : AuthenticationHandler, IAuthenticationSignOutHandler + where TOptions : AuthenticationSchemeOptions, new() + { + public SignOutAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { } + + public virtual Task SignOutAsync(AuthenticationProperties properties) + { + var target = ResolveTarget(Options.ForwardSignOut); + return (target != null) + ? Context.SignOutAsync(target, properties) + : HandleSignOutAsync(properties ?? new AuthenticationProperties()); + } + + /// + /// Override this method to handle SignOut. + /// + /// + /// A Task. + protected abstract Task HandleSignOutAsync(AuthenticationProperties properties); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs deleted file mode 100644 index 4a023bec2..000000000 --- a/src/Microsoft.AspNetCore.Authentication/VirtualAuthenticationHandler.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Forwards calls to another authentication scheme. - /// - public class VirtualAuthenticationHandler : IAuthenticationHandler, IAuthenticationSignInHandler - { - protected IOptionsMonitor OptionsMonitor { get; } - public AuthenticationScheme Scheme { get; private set; } - public VirtualSchemeOptions Options { get; private set; } - protected HttpContext Context { get; private set; } - - public VirtualAuthenticationHandler(IOptionsMonitor options) - { - OptionsMonitor = options; - } - - /// - /// Initialize the handler, resolve the options and validate them. - /// - /// - /// - /// A Task. - public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) - { - if (scheme == null) - { - throw new ArgumentNullException(nameof(scheme)); - } - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - Scheme = scheme; - Context = context; - - Options = OptionsMonitor.Get(Scheme.Name) ?? new VirtualSchemeOptions(); - Options.Validate(); - - return Task.CompletedTask; - } - - protected virtual string ResolveTarget(string scheme) - => scheme ?? Options.DefaultSelector?.Invoke(Context) ?? Options.Default; - - public virtual Task AuthenticateAsync() - => Context.AuthenticateAsync(ResolveTarget(Options.Authenticate)); - - public virtual Task SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) - => Context.SignInAsync(ResolveTarget(Options.SignIn), user, properties); - - public virtual Task SignOutAsync(AuthenticationProperties properties) - => Context.SignOutAsync(ResolveTarget(Options.SignOut), properties); - - public virtual Task ChallengeAsync(AuthenticationProperties properties) - => Context.ChallengeAsync(ResolveTarget(Options.Challenge), properties); - - public virtual Task ForbidAsync(AuthenticationProperties properties) - => Context.ForbidAsync(ResolveTarget(Options.Forbid), properties); - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs b/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs deleted file mode 100644 index 38d819bf5..000000000 --- a/src/Microsoft.AspNetCore.Authentication/VirtualSchemeOptions.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Used to redirect authentication methods to another scheme - /// - public class VirtualSchemeOptions - { - public string Default { get; set; } - - public string Authenticate { get; set; } - public string Challenge { get; set; } - public string Forbid { get; set; } - public string SignIn { get; set; } - public string SignOut { get; set; } - - /// - /// Used to select a default scheme to target based on the request. - /// - public Func DefaultSelector { get; set; } - - - /// - /// Check that the options are valid. Should throw an exception if things are not ok. - /// - public virtual void Validate() { } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs similarity index 85% rename from test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs rename to test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs index a43478c94..368026beb 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/VirtualHandlerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/PolicyTests.cs @@ -12,26 +12,26 @@ namespace Microsoft.AspNetCore.Authentication { - public class VirtualHandlerTests + public class PolicyTests { [Fact] public async Task CanDispatch() { var server = CreateServer(services => { - services.AddAuthentication(o => + services.AddLogging().AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); o.AddScheme("auth3", "auth3"); }) - .AddVirtualScheme("policy1", "policy1", p => + .AddPolicyScheme("policy1", "policy1", p => { - p.Default = "auth1"; + p.ForwardDefault = "auth1"; }) - .AddVirtualScheme("policy2", "policy2", p => + .AddPolicyScheme("policy2", "policy2", p => { - p.Authenticate = "auth2"; + p.ForwardAuthenticate = "auth2"; }); }); @@ -54,16 +54,15 @@ public async Task CanDispatch() [Fact] public async Task DefaultTargetSelectorWinsOverDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => { - p.Default = "auth2"; - p.DefaultSelector = ctx => "auth1"; + .AddPolicyScheme("forward", "forward", p => { + p.ForwardDefault= "auth2"; + p.ForwardDefaultSelector = ctx => "auth1"; }); var handler1 = new TestHandler(); @@ -110,16 +109,15 @@ public async Task DefaultTargetSelectorWinsOverDefaultTarget() [Fact] public async Task NullDefaultTargetSelectorFallsBacktoDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => { - p.Default = "auth1"; - p.DefaultSelector = ctx => null; + .AddPolicyScheme("forward", "forward", p => { + p.ForwardDefault= "auth1"; + p.ForwardDefaultSelector = ctx => null; }); var handler1 = new TestHandler(); @@ -166,21 +164,20 @@ public async Task NullDefaultTargetSelectorFallsBacktoDefaultTarget() [Fact] public async Task SpecificTargetAlwaysWinsOverDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => { - p.Default = "auth2"; - p.DefaultSelector = ctx => "auth2"; - p.Authenticate = "auth1"; - p.SignIn = "auth1"; - p.SignOut = "auth1"; - p.Forbid = "auth1"; - p.Challenge = "auth1"; + .AddPolicyScheme("forward", "forward", p => { + p.ForwardDefault= "auth2"; + p.ForwardDefaultSelector = ctx => "auth2"; + p.ForwardAuthenticate = "auth1"; + p.ForwardSignIn = "auth1"; + p.ForwardSignOut = "auth1"; + p.ForwardForbid = "auth1"; + p.ForwardChallenge = "auth1"; }); var handler1 = new TestHandler(); @@ -227,14 +224,13 @@ public async Task SpecificTargetAlwaysWinsOverDefaultTarget() [Fact] public async Task VirtualSchemeTargetsForwardWithDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => p.Default = "auth1"); + .AddPolicyScheme("forward", "forward", p => p.ForwardDefault= "auth1"); var handler1 = new TestHandler(); services.AddSingleton(handler1); @@ -280,18 +276,17 @@ public async Task VirtualSchemeTargetsForwardWithDefaultTarget() [Fact] public async Task VirtualSchemeTargetsOverrideDefaultTarget() { - var services = new ServiceCollection().AddOptions(); - + var services = new ServiceCollection().AddOptions().AddLogging(); services.AddAuthentication(o => { o.AddScheme("auth1", "auth1"); o.AddScheme("auth2", "auth2"); }) - .AddVirtualScheme("forward", "forward", p => + .AddPolicyScheme("forward", "forward", p => { - p.Default = "auth1"; - p.Challenge = "auth2"; - p.SignIn = "auth2"; + p.ForwardDefault= "auth1"; + p.ForwardChallenge = "auth2"; + p.ForwardSignIn = "auth2"; }); var handler1 = new TestHandler(); @@ -346,9 +341,9 @@ public async Task CanDynamicTargetBasedOnQueryString() o.AddScheme("auth2", "auth2"); o.AddScheme("auth3", "auth3"); }) - .AddVirtualScheme("dynamic", "dynamic", p => + .AddPolicyScheme("dynamic", "dynamic", p => { - p.DefaultSelector = c => c.Request.QueryString.Value.Substring(1); + p.ForwardDefaultSelector = c => c.Request.QueryString.Value.Substring(1); }); }); @@ -360,39 +355,6 @@ public async Task CanDynamicTargetBasedOnQueryString() Assert.Equal("auth3", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "auth3")); } - [Fact] - public async Task TargetsDefaultSchemeByDefault() - { - var server = CreateServer(services => - { - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.AddScheme("default", "default"); - }) - .AddVirtualScheme("virtual", "virtual", p => { }); - }); - - var transaction = await server.SendAsync("http://example.com/auth/virtual"); - Assert.Equal("default", transaction.FindClaimValue(ClaimTypes.NameIdentifier, "default")); - } - - [Fact] - public async Task TargetsDefaultSchemeThrowsWithNoDefault() - { - var server = CreateServer(services => - { - services.AddAuthentication(o => - { - o.AddScheme("default", "default"); - }) - .AddVirtualScheme("virtual", "virtual", p => { }); - }); - - var error = await Assert.ThrowsAsync(() => server.SendAsync("http://example.com/auth/virtual")); - Assert.Contains("No authenticationScheme was specified", error.Message); - } - private class TestHandler : IAuthenticationSignInHandler { public AuthenticationScheme Scheme { get; set; } From 2fecba74511054290e90b88d1502048fc71fa452 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:16:57 -0700 Subject: [PATCH 152/248] Branching for 2.1.0-preview2 --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- build/repo.props | 4 +-- build/sources.props | 2 +- korebuild-lock.txt | 4 +-- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d0cb88aa8..d0dfac301 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15728 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 + 2.1.0-preview2-15742 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26225-03 + 2.1.0-preview2-26314-02 15.6.0 3.0.1 3.0.1 diff --git a/build/repo.props b/build/repo.props index 541470c9f..2ab5a2ae3 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -7,7 +7,7 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9215df975..36045f12b 100644 --- a/build/sources.props +++ b/build/sources.props @@ -6,7 +6,7 @@ $(RestoreSources); https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 138d848db..e40ef6651 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15728 -commithash:393377068ddcf51dfee0536536d455f57a828b06 +version:2.1.0-preview2-15742 +commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 From 701c9f083f419354953726a0e1affd4eda87b3d5 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:28:13 -0700 Subject: [PATCH 153/248] Update version prefix to preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index a11ea1ed5..24f2b00a0 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview2 + preview3 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From be3473914af496764d06069a0e516763cf604335 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 12:33:48 -0700 Subject: [PATCH 154/248] Update KoreBuild channel --- korebuild.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild.json b/korebuild.json index bd5d51a51..678d8bb94 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From 81fb221d9e1d08cdda8d1fabcb43f900848e4bdf Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Tue, 20 Mar 2018 12:42:16 -0700 Subject: [PATCH 155/248] Embed OIDC metadata and mock out the backchannel #1686 --- ...soft.AspNetCore.Authentication.Test.csproj | 7 ++++ .../OpenIdConnect/TestSettings.cs | 40 ++++++++++++++++++- .../OpenIdConnect/wellknownconfig.json | 23 +++++++++++ .../OpenIdConnect/wellknownkeys.json | 31 ++++++++++++++ 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 469726690..6c8d518ff 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -5,6 +5,8 @@ + + @@ -22,6 +24,11 @@ + + + + + diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 509b85e64..6bb5445dc 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -4,10 +4,14 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; +using System.Net.Http; using System.Reflection; using System.Text; using System.Text.Encodings.Web; +using System.Threading; +using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.TestHost; @@ -22,6 +26,7 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect internal class TestSettings { private readonly Action _configureOptions; + private OpenIdConnectOptions _options; public TestSettings() : this(configure: null) { @@ -33,6 +38,7 @@ public TestSettings(Action configure) { configure?.Invoke(o); _options = o; + _options.BackchannelHttpHandler = new MockBackchannel(); }; } @@ -206,8 +212,6 @@ private void ValidateParameters( } } - OpenIdConnectOptions _options = null; - private void ValidateExpectedAuthority(string absoluteUri, ICollection errors, OpenIdConnectRequestType requestType) { string expectedAuthority; @@ -305,5 +309,37 @@ private void ValidateParameter( errors.Add($"Parameter {parameterName} is missing"); } } + + private class MockBackchannel : HttpMessageHandler + { + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + if (request.RequestUri.AbsoluteUri.Equals("https://login.microsoftonline.com/common/.well-known/openid-configuration")) + { + return await ReturnResource("wellknownconfig.json"); + } + if (request.RequestUri.AbsoluteUri.Equals("https://login.microsoftonline.com/common/discovery/keys")) + { + return await ReturnResource("wellknownkeys.json"); + } + + throw new NotImplementedException(); + } + + private async Task ReturnResource(string resource) + { + var resourceName = "Microsoft.AspNetCore.Authentication.Test.OpenIdConnect." + resource; + using (var stream = typeof(MockBackchannel).Assembly.GetManifestResourceStream(resourceName)) + using (var reader = new StreamReader(stream)) + { + var body = await reader.ReadToEndAsync(); + var content = new StringContent(body, Encoding.UTF8, "application/json"); + return new HttpResponseMessage() + { + Content = content, + }; + } + } + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json new file mode 100644 index 000000000..4d46a8cf0 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownconfig.json @@ -0,0 +1,23 @@ +{ + "authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/authorize", + "token_endpoint": "https://login.microsoftonline.com/common/oauth2/token", + "token_endpoint_auth_methods_supported": [ "client_secret_post", "private_key_jwt", "client_secret_basic" ], + "jwks_uri": "https://login.microsoftonline.com/common/discovery/keys", + "response_modes_supported": [ "query", "fragment", "form_post" ], + "subject_types_supported": [ "pairwise" ], + "id_token_signing_alg_values_supported": [ "RS256" ], + "http_logout_supported": true, + "frontchannel_logout_supported": true, + "end_session_endpoint": "https://login.microsoftonline.com/common/oauth2/logout", + "response_types_supported": [ "code", "id_token", "code id_token", "token id_token", "token" ], + "scopes_supported": [ "openid" ], + "issuer": "https://sts.windows.net/{tenantid}/", + "claims_supported": [ "sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "amr", "nonce", "email", "given_name", "family_name", "nickname" ], + "microsoft_multi_refresh_token": true, + "check_session_iframe": "https://login.microsoftonline.com/common/oauth2/checksession", + "userinfo_endpoint": "https://login.microsoftonline.com/common/openid/userinfo", + "tenant_region_scope": null, + "cloud_instance_name": "microsoftonline.com", + "cloud_graph_host_name": "graph.windows.net", + "msgraph_host": "graph.microsoft.com" +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json new file mode 100644 index 000000000..77cc5562a --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/wellknownkeys.json @@ -0,0 +1,31 @@ +{ + "keys": [ + { + "kty": "RSA", + "use": "sig", + "kid": "SSQdhI1cKvhQEDSJxE2gGYs40Q0", + "x5t": "SSQdhI1cKvhQEDSJxE2gGYs40Q0", + "n": "pJUB90EMxiNjgkVz5CLLUuG5bYwirL2LXfVsq_nnY686WzbinkvFnNs6LvrJ6DWD5NV1-0Tq2eZj7WU8H9ytmDPsRnJ0b49gRCJYOg6-SdOe9Tl0lB0IBJE1aWh3OdCVrZLE4LH4-LGIDrkwnCV8dKFkO3EIUYPaEysL4g4wLx-TCfpMWE37XC09P-nBRVkRNcihrzY38_MC42NkRdDwByZemXkQKddnn5Y5o4rVzPGqQy3vjmTjKolYEIBYa7n3yF0848MG0k338bjnyceJgmZzjxttkWTVDikQXSldbu3QCrCAlipbWPUAXaZK8buY8LP80G4U_wx4LuZ_Krq5OQ", + "e": "AQAB", + "x5c": [ "MIIDBTCCAe2gAwIBAgIQHJ7yHxNEM7tBeqcRTMBhhTANBgkqhkiG9w0BAQsFADAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MB4XDTE4MDEwODAwMDAwMFoXDTIwMDEwOTAwMDAwMFowLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKSVAfdBDMYjY4JFc+Qiy1LhuW2MIqy9i131bKv552OvOls24p5LxZzbOi76yeg1g+TVdftE6tnmY+1lPB/crZgz7EZydG+PYEQiWDoOvknTnvU5dJQdCASRNWlodznQla2SxOCx+PixiA65MJwlfHShZDtxCFGD2hMrC+IOMC8fkwn6TFhN+1wtPT/pwUVZETXIoa82N/PzAuNjZEXQ8AcmXpl5ECnXZ5+WOaOK1czxqkMt745k4yqJWBCAWGu598hdPOPDBtJN9/G458nHiYJmc48bbZFk1Q4pEF0pXW7t0AqwgJYqW1j1AF2mSvG7mPCz/NBuFP8MeC7mfyq6uTkCAwEAAaMhMB8wHQYDVR0OBBYEFFVWt/4iTcBiWk+EX1dCKZGoAlBQMA0GCSqGSIb3DQEBCwUAA4IBAQCJrLUiCfldfDFhZLG08DpLcwpn8Mvhm61ZpPANyCawRgaoBOsxFJew1qpC2wfXh3yUwJEIkkTGXAsiWENkeqmjd2XXQwZuIHIo5/KyZLfo2m1CmEH/QXL6uRx1f8liPr4efC8H+7/sduf6nPfk0UpNsAHA6RxJFy2jg2wHU+Ux4jK4Gc5d/rJPhJhvyS9Zax1hbTlf+N32ZvS780VMDb/nf2LdtACL0ya/+KSDGVXS3GhS9FLEXrBNjq921ghVIFJhPzm54yfeupIwz+zfISoTHIYw37i7iNUbkvDrm14a27pwLS/tfSuJHKcGPt1sjMu6SS/pf1BlvdoFkKdLLaUb" ] + }, + { + "kty": "RSA", + "use": "sig", + "kid": "FSimuFrFNoC0sJXGmv13nNZceDc", + "x5t": "FSimuFrFNoC0sJXGmv13nNZceDc", + "n": "yCYaJF8uHoV2L31cjZUDdcodK1Y1EsTLkDD-DEXFyGeHaQ92T9t6MU6zazBzHvJRarG6OMI1GwsFxZ9opSVOeuRjuL3H2ehmUyuKOAnL8uT4cfkdfbg9AIN_63COccfFn0br_xUszZ7lkF5mb63sze-G66YQcbdTCWgsXpxR6491b57Gc4HVTV8cEgU4byezhJIiirrPDmt23QJIjr6XtvUMSNW88u0kX7PKOUnVCns2AG8DB2I-JExTiXwhFVu5JUqgpgmjIngvd5eyNzOgFJMnpWNXabKDP3oMLvQxjdq9xwWuTu0IQLpmUxEF9jVc8vKV1Pu2xHcS7ON5xJrUzw", + "e": "AQAB", + "x5c": [ "MIIDBTCCAe2gAwIBAgIQev76BWqjWZxChmKkGqoAfDANBgkqhkiG9w0BAQsFADAtMSswKQYDVQQDEyJhY2NvdW50cy5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0MB4XDTE4MDIxODAwMDAwMFoXDTIwMDIxOTAwMDAwMFowLTErMCkGA1UEAxMiYWNjb3VudHMuYWNjZXNzY29udHJvbC53aW5kb3dzLm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMgmGiRfLh6Fdi99XI2VA3XKHStWNRLEy5Aw/gxFxchnh2kPdk/bejFOs2swcx7yUWqxujjCNRsLBcWfaKUlTnrkY7i9x9noZlMrijgJy/Lk+HH5HX24PQCDf+twjnHHxZ9G6/8VLM2e5ZBeZm+t7M3vhuumEHG3UwloLF6cUeuPdW+exnOB1U1fHBIFOG8ns4SSIoq6zw5rdt0CSI6+l7b1DEjVvPLtJF+zyjlJ1Qp7NgBvAwdiPiRMU4l8IRVbuSVKoKYJoyJ4L3eXsjczoBSTJ6VjV2mygz96DC70MY3avccFrk7tCEC6ZlMRBfY1XPLyldT7tsR3EuzjecSa1M8CAwEAAaMhMB8wHQYDVR0OBBYEFIks1srixjpSLXeiR8zES5cTY6fBMA0GCSqGSIb3DQEBCwUAA4IBAQCKthfK4C31DMuDyQZVS3F7+4Evld3hjiwqu2uGDK+qFZas/D/eDunxsFpiwqC01RIMFFN8yvmMjHphLHiBHWxcBTS+tm7AhmAvWMdxO5lzJLS+UWAyPF5ICROe8Mu9iNJiO5JlCo0Wpui9RbB1C81Xhax1gWHK245ESL6k7YWvyMYWrGqr1NuQcNS0B/AIT1Nsj1WY7efMJQOmnMHkPUTWryVZlthijYyd7P2Gz6rY5a81DAFqhDNJl2pGIAE6HWtSzeUEh3jCsHEkoglKfm4VrGJEuXcALmfCMbdfTvtu4rlsaP2hQad+MG/KJFlenoTK34EMHeBPDCpqNDz8UVNk" ] + }, + { + "kty": "RSA", + "use": "sig", + "kid": "2S4SCVGs8Sg9LS6AqLIq6DpW-g8", + "x5t": "2S4SCVGs8Sg9LS6AqLIq6DpW-g8", + "n": "oZ-QQrNuB4ei9ATYrT61ebPtvwwYWnsrTpp4ISSp6niZYb92XM0oUTNgqd_C1vGN8J-y9wCbaJWkpBf46CjdZehrqczPhzhHau8WcRXocSB1u_tuZhv1ooAZ4bAcy79UkeLiG60HkuTNJJC8CfaTp1R97szBhuk0Vz5yt4r5SpfewIlBCnZUYwkDS172H9WapQu-3P2Qjh0l-JLyCkdrhvizZUk0atq5_AIDKRU-A0pRGc-EZhUL0LqUMz6c6M2s_4GnQaScv44A5iZUDD15B6e8Apb2yARohkWmOnmRcTVfes8EkfxjzZEzm3cNkvP0ogILyISHKlkzy2OmlU6iXw", + "e": "AQAB", + "x5c": [ "MIIDKDCCAhCgAwIBAgIQBHJvVNxP1oZO4HYKh+rypDANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDExhsb2dpbi5taWNyb3NvZnRvbmxpbmUudXMwHhcNMTYxMTE2MDgwMDAwWhcNMTgxMTE2MDgwMDAwWjAjMSEwHwYDVQQDExhsb2dpbi5taWNyb3NvZnRvbmxpbmUudXMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQChn5BCs24Hh6L0BNitPrV5s+2/DBhaeytOmnghJKnqeJlhv3ZczShRM2Cp38LW8Y3wn7L3AJtolaSkF/joKN1l6GupzM+HOEdq7xZxFehxIHW7+25mG/WigBnhsBzLv1SR4uIbrQeS5M0kkLwJ9pOnVH3uzMGG6TRXPnK3ivlKl97AiUEKdlRjCQNLXvYf1ZqlC77c/ZCOHSX4kvIKR2uG+LNlSTRq2rn8AgMpFT4DSlEZz4RmFQvQupQzPpzozaz/gadBpJy/jgDmJlQMPXkHp7wClvbIBGiGRaY6eZFxNV96zwSR/GPNkTObdw2S8/SiAgvIhIcqWTPLY6aVTqJfAgMBAAGjWDBWMFQGA1UdAQRNMEuAEDUj0BrjP0RTbmoRPTRMY3WhJTAjMSEwHwYDVQQDExhsb2dpbi5taWNyb3NvZnRvbmxpbmUudXOCEARyb1TcT9aGTuB2Cofq8qQwDQYJKoZIhvcNAQELBQADggEBAGnLhDHVz2gLDiu9L34V3ro/6xZDiSWhGyHcGqky7UlzQH3pT5so8iF5P0WzYqVtogPsyC2LPJYSTt2vmQugD4xlu/wbvMFLcV0hmNoTKCF1QTVtEQiAiy0Aq+eoF7Al5fV1S3Sune0uQHimuUFHCmUuF190MLcHcdWnPAmzIc8fv7quRUUsExXmxSX2ktUYQXzqFyIOSnDCuWFm6tpfK5JXS8fW5bpqTlrysXXz/OW/8NFGq/alfjrya4ojrOYLpunGriEtNPwK7hxj1AlCYEWaRHRXaUIW1ByoSff/6Y6+ZhXPUe0cDlNRt/qIz5aflwO7+W8baTS4O8m/icu7ItE=" ] + } + ] +} \ No newline at end of file From 46e62b2b673a8d11b65b5a443715927097138d4f Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 14 Mar 2018 15:35:22 -0700 Subject: [PATCH 156/248] Set 2.0 baselines --- build/dependencies.props | 2 +- korebuild-lock.txt | 4 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 1314 +++++++++++++++++ .../baseline.netcore.json | 47 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 2 +- .../baseline.netframework.json | 2 +- 16 files changed, 1330 insertions(+), 61 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json diff --git a/build/dependencies.props b/build/dependencies.props index d0dfac301..d80ecef5a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,7 +3,7 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15742 + 2.1.0-preview2-15744 2.1.0-preview2-30355 2.1.0-preview2-30355 2.1.0-preview2-30355 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e40ef6651..f531e7b0f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15742 -commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 +version:2.1.0-preview2-15744 +commithash:9e15cb6062ab5b9790d3fa699e018543a6950713 diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json index 1f1115460..52fa29be9 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.CookieExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json index 82a48a6bf..2500e5fb5 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json index 61aae649d..edaade326 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.GoogleExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json index 997cf7bdf..44fc928ca 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.JwtBearerExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json index 5791297b2..966f7e1b1 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json index ffda3cbaf..142e37c6b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OAuthExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json index 9623b214e..a57e2eb87 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OpenIdConnectExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json index b577f07eb..196b85372 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.TwitterExtensions", diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json new file mode 100644 index 000000000..5a8110fbc --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json @@ -0,0 +1,1314 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.WsFederation, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.Extensions.DependencyInjection.WsFederationExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddWsFederation", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddWsFederation", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddWsFederation", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddWsFederation", + "Parameters": [ + { + "Name": "builder", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder" + }, + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.AuthenticationFailedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Exception", + "Parameters": [], + "ReturnType": "System.Exception", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Exception", + "Parameters": [ + { + "Name": "value", + "Type": "System.Exception" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.MessageReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.RedirectContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.PropertiesContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Handled", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleResponse", + "Parameters": [], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.RemoteSignOutContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "message", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.SecurityTokenReceivedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.SecurityTokenValidatedContext", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationContext", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_ProtocolMessage", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ProtocolMessage", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationMessage" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityToken", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.SecurityToken", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityToken", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.SecurityToken" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "scheme", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationScheme" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + }, + { + "Name": "principal", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_OnAuthenticationFailed", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnAuthenticationFailed", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnMessageReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnMessageReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRedirectToIdentityProvider", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRedirectToIdentityProvider", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnRemoteSignOut", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnRemoteSignOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSecurityTokenReceived", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSecurityTokenReceived", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_OnSecurityTokenValidated", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSecurityTokenValidated", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AuthenticationFailed", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.AuthenticationFailedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MessageReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.MessageReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RedirectToIdentityProvider", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.RedirectContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "RemoteSignOut", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SecurityTokenReceived", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.SecurityTokenReceivedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SecurityTokenValidated", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.SecurityTokenValidatedContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationDefaults", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "UserstatePropertiesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AuthenticationScheme", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"WsFederation\"" + }, + { + "Kind": "Field", + "Name": "DisplayName", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "Visibility": "Public", + "GenericParameter": [], + "Constant": true, + "Literal": "\"WsFederation\"" + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteSignOutAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Configuration", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationConfiguration", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Configuration", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.WsFederation.WsFederationConfiguration" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_MetadataAddress", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MetadataAddress", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ConfigurationManager", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Protocols.IConfigurationManager", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConfigurationManager", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Protocols.IConfigurationManager" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RefreshOnIssuerKeyNotFound", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RefreshOnIssuerKeyNotFound", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SkipUnrecognizedRequests", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SkipUnrecognizedRequests", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SecurityTokenHandlers", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SecurityTokenHandlers", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.ICollection" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_StateDataFormat", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.ISecureDataFormat", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_StateDataFormat", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.ISecureDataFormat" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_TokenValidationParameters", + "Parameters": [], + "ReturnType": "Microsoft.IdentityModel.Tokens.TokenValidationParameters", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_TokenValidationParameters", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.IdentityModel.Tokens.TokenValidationParameters" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Wreply", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Wreply", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignOutWreply", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignOutWreply", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Wtrealm", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Wtrealm", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_UseTokenLifetime", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_UseTokenLifetime", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RequireHttpsMetadata", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RequireHttpsMetadata", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowUnsolicitedLogins", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AllowUnsolicitedLogins", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_RemoteSignOutPath", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.PathString", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_RemoteSignOutPath", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.PathString" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SignOutScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SignOutScheme", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationPostConfigureOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.Extensions.Options.IPostConfigureOptions" + ], + "Members": [ + { + "Kind": "Method", + "Name": "PostConfigure", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "options", + "Type": "Microsoft.AspNetCore.Authentication.WsFederation.WsFederationOptions" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.Extensions.Options.IPostConfigureOptions", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json index 6db7d2c81..a6082e8c4 100644 --- a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", @@ -2508,51 +2508,6 @@ ], "GenericParameters": [] }, - { - "Name": "Microsoft.AspNetCore.Authentication.Internal.RequestPathBaseCookieBuilder", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Http.CookieBuilder", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AdditionalPath", - "Parameters": [], - "ReturnType": "System.String", - "Virtual": true, - "Visibility": "Protected", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Build", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "expiresFrom", - "Type": "System.DateTimeOffset" - } - ], - "ReturnType": "Microsoft.AspNetCore.Http.CookieOptions", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, { "Name": "Microsoft.AspNetCore.Builder.AuthAppBuilderExtensions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json index 0bad3ed62..a2a971f82 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", diff --git a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json index 6108db6d2..9910c93f6 100644 --- a/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authorization/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.AuthorizationServiceCollectionExtensions", diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json index 97da7ea5c..050546810 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json index a55bf8f33..65256bed6 100644 --- a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json +++ b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", From 90064ce9dfc79d13058fbd6ec9092bf0f6124449 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 2 Feb 2018 10:53:51 -0800 Subject: [PATCH 157/248] Add ClaimActions for bulk add and remove. #1609 --- samples/OpenIdConnectSample/Startup.cs | 7 +++ .../ClaimActionCollectionMapExtensions.cs | 39 +++++++++++++ .../Claims/MapAllClaimsAction.cs | 42 ++++++++++++++ .../ClaimActionTests.cs | 57 +++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index c05bc8b52..82bfdf54f 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Net.Http; using System.Text.Encodings.Web; @@ -44,6 +45,8 @@ public Startup(IHostingEnvironment env) public void ConfigureServices(IServiceCollection services) { + JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); + services.AddAuthentication(sharedOptions => { sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; @@ -56,9 +59,13 @@ public void ConfigureServices(IServiceCollection services) o.ClientId = Configuration["oidc:clientid"]; o.ClientSecret = Configuration["oidc:clientsecret"]; // for code flow o.Authority = Configuration["oidc:authority"]; + o.ResponseType = OpenIdConnectResponseType.CodeIdToken; o.SaveTokens = true; o.GetClaimsFromUserInfoEndpoint = true; + + o.ClaimActions.MapAllExcept("aud", "iss", "iat", "nbf", "exp", "aio", "c_hash", "uti", "nonce"); + o.Events = new OpenIdConnectEvents() { OnAuthenticationFailed = c => diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs index f3fee6a22..5a178957a 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/ClaimActionCollectionMapExtensions.cs @@ -87,6 +87,27 @@ public static void MapCustomJson(this ClaimActionCollection collection, string c collection.Add(new CustomJsonClaimAction(claimType, valueType, resolver)); } + /// + /// Clears any current ClaimsActions and maps all values from the json user data as claims, excluding duplicates. + /// + /// + public static void MapAll(this ClaimActionCollection collection) + { + collection.Clear(); + collection.Add(new MapAllClaimsAction()); + } + + /// + /// Clears any current ClaimsActions and maps all values from the json user data as claims, excluding the specified types. + /// + /// + /// + public static void MapAllExcept(this ClaimActionCollection collection, params string[] exclusions) + { + collection.MapAll(); + collection.DeleteClaims(exclusions); + } + /// /// Delete all claims from the given ClaimsIdentity with the given ClaimType. /// @@ -96,5 +117,23 @@ public static void DeleteClaim(this ClaimActionCollection collection, string cla { collection.Add(new DeleteClaimAction(claimType)); } + + /// + /// Delete all claims from the ClaimsIdentity with the given claimTypes. + /// + /// + /// + public static void DeleteClaims(this ClaimActionCollection collection, params string[] claimTypes) + { + if (claimTypes == null) + { + throw new ArgumentNullException(nameof(claimTypes)); + } + + foreach (var claimType in claimTypes) + { + collection.Add(new DeleteClaimAction(claimType)); + } + } } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs new file mode 100644 index 000000000..b3bf5d99f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Claims/MapAllClaimsAction.cs @@ -0,0 +1,42 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Security.Claims; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNetCore.Authentication.OAuth.Claims +{ + /// + /// A ClaimAction that selects all top level values from the json user data and adds them as Claims. + /// This excludes duplicate sets of names and values. + /// + public class MapAllClaimsAction : ClaimAction + { + public MapAllClaimsAction() : base("All", ClaimValueTypes.String) + { + } + + public override void Run(JObject userData, ClaimsIdentity identity, string issuer) + { + if (userData == null) + { + return; + } + foreach (var pair in userData) + { + var claimValue = userData.TryGetValue(pair.Key, out var value) ? value.ToString() : null; + + // Avoid adding a claim if there's a duplicate name and value. This often happens in OIDC when claims are + // retrieved both from the id_token and from the user-info endpoint. + var duplicate = identity.FindFirst(c => string.Equals(c.Type, pair.Key, StringComparison.OrdinalIgnoreCase) + && string.Equals(c.Value, claimValue, StringComparison.Ordinal)) != null; + + if (!duplicate) + { + identity.AddClaim(new Claim(pair.Key, claimValue, ClaimValueTypes.String, issuer)); + } + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs index 541e1edf2..b083e9d76 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/ClaimActionTests.cs @@ -51,5 +51,62 @@ public void CanMapArrayValueUserDataToClaims() Assert.Equal("role", roleClaims[1].Type); Assert.Equal("role2", roleClaims[1].Value); } + + [Fact] + public void MapAllSucceeds() + { + var userData = new JObject + { + ["name0"] = "value0", + ["name1"] = "value1", + }; + + var identity = new ClaimsIdentity(); + var action = new MapAllClaimsAction(); + action.Run(userData, identity, "iss"); + + Assert.Equal("name0", identity.FindFirst("name0").Type); + Assert.Equal("value0", identity.FindFirst("name0").Value); + Assert.Equal("name1", identity.FindFirst("name1").Type); + Assert.Equal("value1", identity.FindFirst("name1").Value); + } + + [Fact] + public void MapAllAllowesDulicateKeysWithUniqueValues() + { + var userData = new JObject + { + ["name0"] = "value0", + ["name1"] = "value1", + }; + + var identity = new ClaimsIdentity(); + identity.AddClaim(new Claim("name0", "value2")); + identity.AddClaim(new Claim("name1", "value3")); + var action = new MapAllClaimsAction(); + action.Run(userData, identity, "iss"); + + Assert.Equal(2, identity.FindAll("name0").Count()); + Assert.Equal(2, identity.FindAll("name1").Count()); + } + + [Fact] + public void MapAllSkipsDuplicateValues() + { + var userData = new JObject + { + ["name0"] = "value0", + ["name1"] = "value1", + }; + + var identity = new ClaimsIdentity(); + identity.AddClaim(new Claim("name0", "value0")); + identity.AddClaim(new Claim("name1", "value1")); + var action = new MapAllClaimsAction(); + action.Run(userData, identity, "iss"); + + Assert.Single(identity.FindAll("name0")); + Assert.Single(identity.FindAll("name1")); + } } } From d24fddcf596a705f480a6ca6e43446838a4af2fe Mon Sep 17 00:00:00 2001 From: Patrick Westerhoff Date: Mon, 19 Mar 2018 22:19:57 +0100 Subject: [PATCH 158/248] Clean up tests - Make Facebook test server asynchronous to avoid having to block for the result. - Clean up some formatting. --- .../FacebookTests.cs | 52 +++++++++---------- .../GoogleTests.cs | 34 ++++++------ 2 files changed, 40 insertions(+), 46 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 99177d66b..4ee9117f9 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -426,15 +426,15 @@ public async Task VerifySignInSchemeCannotBeSetToSelf() { var server = CreateServer( app => { }, - services => services.AddAuthentication().AddFacebook(o => { + services => services.AddAuthentication().AddFacebook(o => + { o.AppId = "whatever"; o.AppSecret = "whatever"; o.SignInScheme = FacebookDefaults.AuthenticationScheme; }), - context => + async context => { - // Gross - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); @@ -446,14 +446,14 @@ public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultScheme() { var server = CreateServer( app => { }, - services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => { + services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => + { o.AppId = "whatever"; o.AppSecret = "whatever"; }), - context => + async context => { - // Gross - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); @@ -465,14 +465,14 @@ public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultSignInScheme() { var server = CreateServer( app => { }, - services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => { + services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => + { o.AppId = "whatever"; o.AppSecret = "whatever"; }), - context => + async context => { - // Gross - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); @@ -498,10 +498,9 @@ public async Task ThrowsIfAppIdMissing() var server = CreateServer( app => { }, services => services.AddAuthentication().AddFacebook(o => o.SignInScheme = "Whatever"), - context => + async context => { - // REVIEW: Gross. - Assert.Throws("AppId", () => context.ChallengeAsync("Facebook").GetAwaiter().GetResult()); + await Assert.ThrowsAsync("AppId", () => context.ChallengeAsync("Facebook")); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -514,10 +513,9 @@ public async Task ThrowsIfAppSecretMissing() var server = CreateServer( app => { }, services => services.AddAuthentication().AddFacebook(o => o.AppId = "Whatever"), - context => + async context => { - // REVIEW: Gross. - Assert.Throws("AppSecret", () => context.ChallengeAsync("Facebook").GetAwaiter().GetResult()); + await Assert.ThrowsAsync("AppSecret", () => context.ChallengeAsync("Facebook")); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -550,10 +548,9 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() }; }); }, - context => + async context => { - // REVIEW: Gross. - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -620,7 +617,7 @@ public async Task MapWillNotAffectRedirect() Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); - Assert.Contains("redirect_uri="+ UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location); + Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location); Assert.Contains("scope=", location); Assert.Contains("state=", location); } @@ -643,10 +640,9 @@ public async Task ChallengeWillTriggerRedirection() o.AppSecret = "Test App Secret"; }); }, - context => + async context => { - // REVIEW: gross - context.ChallengeAsync("Facebook").GetAwaiter().GetResult(); + await context.ChallengeAsync("Facebook"); return true; }); var transaction = await server.SendAsync("http://example.com/challenge"); @@ -672,7 +668,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() { services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie() - .AddFacebook(o => + .AddFacebook(o => { o.AppId = "Test App Id"; o.AppSecret = "Test App Secret"; @@ -728,7 +724,7 @@ public async Task CustomUserInfoEndpointHasValidGraphQuery() Assert.Contains("&access_token=", finalUserInfoEndpoint); } - private static TestServer CreateServer(Action configure, Action configureServices, Func handler) + private static TestServer CreateServer(Action configure, Action configureServices, Func> handler) { var builder = new WebHostBuilder() .Configure(app => @@ -736,7 +732,7 @@ private static TestServer CreateServer(Action configure, Ac configure?.Invoke(app); app.Use(async (context, next) => { - if (handler == null || !handler(context)) + if (handler == null || !await handler(context)) { await next(); } diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index c3e80ef71..d9af95936 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -551,28 +551,26 @@ public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() { o.ClientId = "Test Id"; o.ClientSecret = "Test Secret"; - //AutomaticChallenge = true }, context => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/challenge2")) { - var req = context.Request; - var res = context.Response; - if (req.Path == new PathString("/challenge2")) + return context.ChallengeAsync("Google", new AuthenticationProperties(new Dictionary() { - return context.ChallengeAsync("Google", new AuthenticationProperties( - new Dictionary() - { - { "scope", "https://www.googleapis.com/auth/plus.login" }, - { "access_type", "offline" }, - { "approval_prompt", "force" }, - { "prompt", "consent" }, - { "login_hint", "test@example.com" }, - { "include_granted_scopes", "false" } - })); - } + { "scope", "https://www.googleapis.com/auth/plus.login" }, + { "access_type", "offline" }, + { "approval_prompt", "force" }, + { "prompt", "consent" }, + { "login_hint", "test@example.com" }, + { "include_granted_scopes", "false" } + })); + } - return Task.FromResult(null); - }); + return Task.FromResult(null); + }); var transaction = await server.SendAsync("https://example.com/challenge2"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var query = transaction.Response.Headers.Location.Query; @@ -1501,4 +1499,4 @@ public AuthenticationProperties Unprotect(string protectedText, string purpose) } } } -} +} \ No newline at end of file From 06c93669d617fec50bf411c0c53d672019adf9df Mon Sep 17 00:00:00 2001 From: Patrick Westerhoff Date: Fri, 23 Mar 2018 02:09:05 +0100 Subject: [PATCH 159/248] Allow overwriting parameters on challenge requests Add a way to overwrite query arguments that are passed as part of the challenge request to the external authentication provider in OAuth-based authentication providers, including OpenID Connect. This uses the new `AuthenticationProperties.Parameters` collection to pass parameters to the authentication handler which will then look for special items within that property bag, overwriting previously configured values within the authentication options. This can be used for example to overwrite the OAuth scopes that are requested from an authentication provider, or to explicitly trigger a reauthentication by requiring a login prompt with OpenID Connect. By being able to specify this on individual challenge requests (using `HttpContext.ChallengeAsync`), this is independent from the global scheme configuration. Custom ~ChallengeProperties types, e.g. `OAuthChallengeProperties` for OAuth-based authentication providers, provide assistance in setting the challenge request parameters but are not required to make the handlers use the overwritten values. - Adjust authentication handlers to respect the custom parameters, and add ~ChallengeProperties types. - Introduce `OAuthHandler.FormatScope(IEnumerable)` to format a custom set of scopes. Subclasses requiring a different scope format should override this method instead of the parameterless overload. Overriding just `FormatScope()` will prevent handlers from supporting overwriting the OAuth `scope` in a challenge request. - Refactor GoogleHandler to support parameterization through both the `Parameters` and the `Items` collection (former is preferred) to keep compatibility with the old behavior. - Add an OpenIdConnect sample to overwrite the prompt argument in a challenge request. - Add extensive tests. --- samples/OpenIdConnectSample/Startup.cs | 17 ++ .../FacebookHandler.cs | 8 +- .../GoogleChallengeProperties.cs | 89 ++++++++++ .../GoogleHandler.cs | 45 +++-- .../OAuthChallengeProperties.cs | 41 +++++ .../OAuthHandler.cs | 23 ++- .../OpenIdConnectChallengeProperties.cs | 49 ++++++ .../OpenIdConnectHandler.cs | 11 +- .../FacebookTests.cs | 91 ++++++++++ .../GoogleTests.cs | 138 ++++++++++++++- .../MicrosoftAccountTests.cs | 63 +++++++ .../OAuthChallengePropertiesTest.cs | 149 ++++++++++++++++ .../OAuthTests.cs | 82 +++++++++ .../OpenIdConnectChallengeTests.cs | 166 +++++++++++++++++- .../OpenIdConnect/TestSettings.cs | 6 + 15 files changed, 936 insertions(+), 42 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs create mode 100644 src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 82bfdf54f..1aa7625cb 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -225,11 +225,28 @@ await WriteHtmlAsync(response, async res => return; } + if (context.Request.Path.Equals("/login-challenge")) + { + // Challenge the user authentication, and force a login prompt by overwriting the + // "prompt". This could be used for example to require the user to re-enter their + // credentials at the authentication provider, to add an extra confirmation layer. + await context.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new OpenIdConnectChallengeProperties() + { + Prompt = "login", + + // it is also possible to specify different scopes, e.g. + // Scope = new string[] { "openid", "profile", "other" } + }); + + return; + } + await WriteHtmlAsync(response, async res => { await res.WriteAsync($"

Hello Authenticated User {HtmlEncode(user.Identity.Name)}

"); await res.WriteAsync("Refresh tokens"); await res.WriteAsync("Restricted"); + await res.WriteAsync("Login challenge"); await res.WriteAsync("Sign Out"); await res.WriteAsync("Sign Out Remote"); diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs index 0f83c1719..eb4251143 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookHandler.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; using System.Globalization; using System.Net.Http; using System.Security.Claims; @@ -65,12 +66,15 @@ private string GenerateAppSecretProof(string accessToken) } } - protected override string FormatScope() + protected override string FormatScope(IEnumerable scopes) { // Facebook deviates from the OAuth spec here. They require comma separated instead of space separated. // https://developers.facebook.com/docs/reference/dialogs/oauth // http://tools.ietf.org/html/rfc6749#section-3.3 - return string.Join(",", Options.Scope); + return string.Join(",", scopes); } + + protected override string FormatScope() + => base.FormatScope(); } } diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs new file mode 100644 index 000000000..714df4565 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleChallengeProperties.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Authentication.OAuth; + +namespace Microsoft.AspNetCore.Authentication.Google +{ + public class GoogleChallengeProperties : OAuthChallengeProperties + { + /// + /// The parameter key for the "access_type" argument being used for a challenge request. + /// + public static readonly string AccessTypeKey = "access_type"; + + /// + /// The parameter key for the "approval_prompt" argument being used for a challenge request. + /// + public static readonly string ApprovalPromptKey = "approval_prompt"; + + /// + /// The parameter key for the "include_granted_scopes" argument being used for a challenge request. + /// + public static readonly string IncludeGrantedScopesKey = "include_granted_scopes"; + + /// + /// The parameter key for the "login_hint" argument being used for a challenge request. + /// + public static readonly string LoginHintKey = "login_hint"; + + /// + /// The parameter key for the "prompt" argument being used for a challenge request. + /// + public static readonly string PromptParameterKey = "prompt"; + + public GoogleChallengeProperties() + { } + + public GoogleChallengeProperties(IDictionary items) + : base(items) + { } + + public GoogleChallengeProperties(IDictionary items, IDictionary parameters) + : base(items, parameters) + { } + + /// + /// The "access_type" parameter value being used for a challenge request. + /// + public string AccessType + { + get => GetParameter(AccessTypeKey); + set => SetParameter(AccessTypeKey, value); + } + + /// + /// The "approval_prompt" parameter value being used for a challenge request. + /// + public string ApprovalPrompt + { + get => GetParameter(ApprovalPromptKey); + set => SetParameter(ApprovalPromptKey, value); + } + + /// + /// The "include_granted_scopes" parameter value being used for a challenge request. + /// + public bool? IncludeGrantedScopes + { + get => GetParameter(IncludeGrantedScopesKey); + set => SetParameter(IncludeGrantedScopesKey, value); + } + + /// + /// The "login_hint" parameter value being used for a challenge request. + /// + public string LoginHint + { + get => GetParameter(LoginHintKey); + set => SetParameter(LoginHintKey, value); + } + + /// + /// The "prompt" parameter value being used for a challenge request. + /// + public string Prompt + { + get => GetParameter(PromptParameterKey); + set => SetParameter(PromptParameterKey, value); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs index 091896f7c..88d48d446 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleHandler.cs @@ -57,12 +57,12 @@ protected override string BuildChallengeUrl(AuthenticationProperties properties, queryStrings.Add("client_id", Options.ClientId); queryStrings.Add("redirect_uri", redirectUri); - AddQueryString(queryStrings, properties, "scope", FormatScope()); - AddQueryString(queryStrings, properties, "access_type", Options.AccessType); - AddQueryString(queryStrings, properties, "approval_prompt"); - AddQueryString(queryStrings, properties, "prompt"); - AddQueryString(queryStrings, properties, "login_hint"); - AddQueryString(queryStrings, properties, "include_granted_scopes"); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.ScopeKey, FormatScope, Options.Scope); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.AccessTypeKey, Options.AccessType); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.ApprovalPromptKey); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.PromptParameterKey); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.LoginHintKey); + AddQueryString(queryStrings, properties, GoogleChallengeProperties.IncludeGrantedScopesKey, v => v?.ToString().ToLower(), (bool?)null); var state = Options.StateDataFormat.Protect(properties); queryStrings.Add("state", state); @@ -71,29 +71,38 @@ protected override string BuildChallengeUrl(AuthenticationProperties properties, return authorizationEndpoint; } - private static void AddQueryString( + private void AddQueryString( IDictionary queryStrings, AuthenticationProperties properties, string name, - string defaultValue = null) + Func formatter, + T defaultValue) { - string value; - if (!properties.Items.TryGetValue(name, out value)) + string value = null; + var parameterValue = properties.GetParameter(name); + if (parameterValue != null) { - value = defaultValue; + value = formatter(parameterValue); } - else + else if (!properties.Items.TryGetValue(name, out value)) { - // Remove the parameter from AuthenticationProperties so it won't be serialized to state parameter - properties.Items.Remove(name); + value = formatter(defaultValue); } - if (value == null) + // Remove the parameter from AuthenticationProperties so it won't be serialized into the state + properties.Items.Remove(name); + + if (value != null) { - return; + queryStrings[name] = value; } - - queryStrings[name] = value; } + + private void AddQueryString( + IDictionary queryStrings, + AuthenticationProperties properties, + string name, + string defaultValue = null) + => AddQueryString(queryStrings, properties, name, x => x, defaultValue); } } diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs new file mode 100644 index 000000000..fc768a8ac --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthChallengeProperties.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; + +namespace Microsoft.AspNetCore.Authentication.OAuth +{ + public class OAuthChallengeProperties : AuthenticationProperties + { + /// + /// The parameter key for the "scope" argument being used for a challenge request. + /// + public static readonly string ScopeKey = "scope"; + + public OAuthChallengeProperties() + { } + + public OAuthChallengeProperties(IDictionary items) + : base(items) + { } + + public OAuthChallengeProperties(IDictionary items, IDictionary parameters) + : base(items, parameters) + { } + + /// + /// The "scope" parameter value being used for a challenge request. + /// + public ICollection Scope + { + get => GetParameter>(ScopeKey); + set => SetParameter(ScopeKey, value); + } + + /// + /// Set the "scope" parameter value. + /// + /// List of scopes. + public virtual void SetScope(params string[] scopes) + { + Scope = scopes; + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 80680a7cf..808e0f903 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -209,7 +209,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop protected virtual string BuildChallengeUrl(AuthenticationProperties properties, string redirectUri) { - var scope = FormatScope(); + var scopeParameter = properties.GetParameter>(OAuthChallengeProperties.ScopeKey); + var scope = scopeParameter != null ? FormatScope(scopeParameter) : FormatScope(); var state = Options.StateDataFormat.Protect(properties); var parameters = new Dictionary @@ -223,10 +224,20 @@ protected virtual string BuildChallengeUrl(AuthenticationProperties properties, return QueryHelpers.AddQueryString(Options.AuthorizationEndpoint, parameters); } + /// + /// Format a list of OAuth scopes. + /// + /// List of scopes. + /// Formatted scopes. + protected virtual string FormatScope(IEnumerable scopes) + => string.Join(" ", scopes); // OAuth2 3.3 space separated + + /// + /// Format the property. + /// + /// Formatted scopes. + /// Subclasses should rather override . protected virtual string FormatScope() - { - // OAuth2 3.3 space separated - return string.Join(" ", Options.Scope); - } + => FormatScope(Options.Scope); } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs new file mode 100644 index 000000000..0ced488de --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectChallengeProperties.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.IdentityModel.Protocols.OpenIdConnect; + +namespace Microsoft.AspNetCore.Authentication.OpenIdConnect +{ + public class OpenIdConnectChallengeProperties : OAuthChallengeProperties + { + /// + /// The parameter key for the "max_age" argument being used for a challenge request. + /// + public static readonly string MaxAgeKey = OpenIdConnectParameterNames.MaxAge; + + /// + /// The parameter key for the "prompt" argument being used for a challenge request. + /// + public static readonly string PromptKey = OpenIdConnectParameterNames.Prompt; + + public OpenIdConnectChallengeProperties() + { } + + public OpenIdConnectChallengeProperties(IDictionary items) + : base(items) + { } + + public OpenIdConnectChallengeProperties(IDictionary items, IDictionary parameters) + : base(items, parameters) + { } + + /// + /// The "max_age" parameter value being used for a challenge request. + /// + public TimeSpan? MaxAge + { + get => GetParameter(MaxAgeKey); + set => SetParameter(MaxAgeKey, value); + } + + /// + /// The "prompt" parameter value being used for a challenge request. + /// + public string Prompt + { + get => GetParameter(PromptKey); + set => SetParameter(PromptKey, value); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index ce7494fb4..029cf541b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -329,15 +329,16 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop RedirectUri = BuildRedirectUri(Options.CallbackPath), Resource = Options.Resource, ResponseType = Options.ResponseType, - Prompt = Options.Prompt, - Scope = string.Join(" ", Options.Scope) + Prompt = properties.GetParameter(OpenIdConnectParameterNames.Prompt) ?? Options.Prompt, + Scope = string.Join(" ", properties.GetParameter>(OpenIdConnectParameterNames.Scope) ?? Options.Scope), }; // Add the 'max_age' parameter to the authentication request if MaxAge is not null. // See http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest - if (Options.MaxAge.HasValue) + var maxAge = properties.GetParameter(OpenIdConnectParameterNames.MaxAge) ?? Options.MaxAge; + if (maxAge.HasValue) { - message.MaxAge = Convert.ToInt64(Math.Floor((Options.MaxAge.Value).TotalSeconds)) + message.MaxAge = Convert.ToInt64(Math.Floor((maxAge.Value).TotalSeconds)) .ToString(CultureInfo.InvariantCulture); } @@ -783,7 +784,7 @@ protected virtual async Task RedeemAuthorizationCodeAsync( /// The authentication properties. /// which is used to determine if the remote authentication was successful. protected virtual async Task GetUserInformationAsync( - OpenIdConnectMessage message, JwtSecurityToken jwt, + OpenIdConnectMessage message, JwtSecurityToken jwt, ClaimsPrincipal principal, AuthenticationProperties properties) { var userInfoEndpoint = _configuration?.UserInfoEndpoint; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index 4ee9117f9..b909be9fd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -559,6 +559,97 @@ public async Task ChallengeWillTriggerApplyRedirectEvent() Assert.Contains("custom=test", query); } + [Fact] + public async Task ChallengeWillIncludeScopeAsConfigured() + { + var server = CreateServer( + app => app.UseAuthentication(), + services => + { + services.AddAuthentication().AddFacebook(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + }, + async context => + { + await context.ChallengeAsync(FacebookDefaults.AuthenticationScheme); + return true; + }); + + var transaction = await server.SendAsync("http://example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=foo,bar", res.Headers.Location.Query); + } + + [Fact] + public async Task ChallengeWillIncludeScopeAsOverwritten() + { + var server = CreateServer( + app => app.UseAuthentication(), + services => + { + services.AddAuthentication().AddFacebook(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + }, + async context => + { + var properties = new OAuthChallengeProperties(); + properties.SetScope("baz", "qux"); + await context.ChallengeAsync(FacebookDefaults.AuthenticationScheme, properties); + return true; + }); + + var transaction = await server.SendAsync("http://example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz,qux", res.Headers.Location.Query); + } + + [Fact] + public async Task ChallengeWillIncludeScopeAsOverwrittenWithBaseAuthenticationProperties() + { + var server = CreateServer( + app => app.UseAuthentication(), + services => + { + services.AddAuthentication().AddFacebook(o => + { + o.AppId = "Test App Id"; + o.AppSecret = "Test App Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + }, + async context => + { + var properties = new AuthenticationProperties(); + properties.SetParameter(OAuthChallengeProperties.ScopeKey, new string[] { "baz", "qux" }); + await context.ChallengeAsync(FacebookDefaults.AuthenticationScheme, properties); + return true; + }); + + var transaction = await server.SendAsync("http://example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz,qux", res.Headers.Location.Query); + } + [Fact] public async Task NestedMapWillNotAffectRedirect() { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index d9af95936..511a658ff 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; +using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; @@ -545,12 +546,65 @@ public async Task ChallengeWillSetDefaultScope() } [Fact] - public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() + public async Task ChallengeWillUseAuthenticationPropertiesParametersAsQueryArguments() { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); var server = CreateServer(o => { o.ClientId = "Test Id"; o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + }, + context => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/challenge2")) + { + return context.ChallengeAsync("Google", new GoogleChallengeProperties + { + Scope = new string[] { "openid", "https://www.googleapis.com/auth/plus.login" }, + AccessType = "offline", + ApprovalPrompt = "force", + Prompt = "consent", + LoginHint = "test@example.com", + IncludeGrantedScopes = false, + }); + } + + return Task.FromResult(null); + }); + var transaction = await server.SendAsync("https://example.com/challenge2"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + + // verify query arguments + var query = QueryHelpers.ParseQuery(transaction.Response.Headers.Location.Query); + Assert.Equal("openid https://www.googleapis.com/auth/plus.login", query["scope"]); + Assert.Equal("offline", query["access_type"]); + Assert.Equal("force", query["approval_prompt"]); + Assert.Equal("consent", query["prompt"]); + Assert.Equal("false", query["include_granted_scopes"]); + Assert.Equal("test@example.com", query["login_hint"]); + + // verify that the passed items were not serialized + var stateProperties = stateFormat.Unprotect(query["state"]); + Assert.DoesNotContain("scope", stateProperties.Items.Keys); + Assert.DoesNotContain("access_type", stateProperties.Items.Keys); + Assert.DoesNotContain("include_granted_scopes", stateProperties.Items.Keys); + Assert.DoesNotContain("approval_prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("login_hint", stateProperties.Items.Keys); + } + + [Fact] + public async Task ChallengeWillUseAuthenticationPropertiesItemsAsParameters() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; }, context => { @@ -573,13 +627,79 @@ public async Task ChallengeWillUseAuthenticationPropertiesAsParameters() }); var transaction = await server.SendAsync("https://example.com/challenge2"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); - var query = transaction.Response.Headers.Location.Query; - Assert.Contains("scope=" + UrlEncoder.Default.Encode("https://www.googleapis.com/auth/plus.login"), query); - Assert.Contains("access_type=offline", query); - Assert.Contains("approval_prompt=force", query); - Assert.Contains("prompt=consent", query); - Assert.Contains("include_granted_scopes=false", query); - Assert.Contains("login_hint=" + UrlEncoder.Default.Encode("test@example.com"), query); + + // verify query arguments + var query = QueryHelpers.ParseQuery(transaction.Response.Headers.Location.Query); + Assert.Equal("https://www.googleapis.com/auth/plus.login", query["scope"]); + Assert.Equal("offline", query["access_type"]); + Assert.Equal("force", query["approval_prompt"]); + Assert.Equal("consent", query["prompt"]); + Assert.Equal("false", query["include_granted_scopes"]); + Assert.Equal("test@example.com", query["login_hint"]); + + // verify that the passed items were not serialized + var stateProperties = stateFormat.Unprotect(query["state"]); + Assert.DoesNotContain("scope", stateProperties.Items.Keys); + Assert.DoesNotContain("access_type", stateProperties.Items.Keys); + Assert.DoesNotContain("include_granted_scopes", stateProperties.Items.Keys); + Assert.DoesNotContain("approval_prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("login_hint", stateProperties.Items.Keys); + } + + [Fact] + public async Task ChallengeWillUseAuthenticationPropertiesItemsAsQueryArgumentsButParametersWillOverwrite() + { + var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest")); + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = stateFormat; + }, + context => + { + var req = context.Request; + var res = context.Response; + if (req.Path == new PathString("/challenge2")) + { + return context.ChallengeAsync("Google", new GoogleChallengeProperties(new Dictionary + { + ["scope"] = "https://www.googleapis.com/auth/plus.login", + ["access_type"] = "offline", + ["include_granted_scopes"] = "false", + ["approval_prompt"] = "force", + ["prompt"] = "login", + ["login_hint"] = "this-will-be-overwritten@example.com", + }) + { + Prompt = "consent", + LoginHint = "test@example.com", + }); + } + + return Task.FromResult(null); + }); + var transaction = await server.SendAsync("https://example.com/challenge2"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + + // verify query arguments + var query = QueryHelpers.ParseQuery(transaction.Response.Headers.Location.Query); + Assert.Equal("https://www.googleapis.com/auth/plus.login", query["scope"]); + Assert.Equal("offline", query["access_type"]); + Assert.Equal("force", query["approval_prompt"]); + Assert.Equal("consent", query["prompt"]); + Assert.Equal("false", query["include_granted_scopes"]); + Assert.Equal("test@example.com", query["login_hint"]); + + // verify that the passed items were not serialized + var stateProperties = stateFormat.Unprotect(query["state"]); + Assert.DoesNotContain("scope", stateProperties.Items.Keys); + Assert.DoesNotContain("access_type", stateProperties.Items.Keys); + Assert.DoesNotContain("include_granted_scopes", stateProperties.Items.Keys); + Assert.DoesNotContain("approval_prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("prompt", stateProperties.Items.Keys); + Assert.DoesNotContain("login_hint", stateProperties.Items.Keys); } [Fact] @@ -1499,4 +1619,4 @@ public AuthenticationProperties Unprotect(string protectedText, string purpose) } } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index 480241d35..e2e13f270 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -525,6 +525,57 @@ public async Task ChallengeWillTriggerRedirection() Assert.Contains("state=", location); } + [Fact] + public async Task ChallengeWillIncludeScopeAsConfigured() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=foo%20bar", res.Headers.Location.Query); + } + + [Fact] + public async Task ChallengeWillIncludeScopeAsOverwritten() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + var transaction = await server.SendAsync("http://example.com/challengeWithOtherScope"); + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + + [Fact] + public async Task ChallengeWillIncludeScopeAsOverwrittenWithBaseAuthenticationProperties() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.Scope.Clear(); + o.Scope.Add("foo"); + o.Scope.Add("bar"); + }); + var transaction = await server.SendAsync("http://example.com/challengeWithOtherScopeWithBaseAuthenticationProperties"); + var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + [Fact] public async Task AuthenticatedEventCanGetRefreshToken() { @@ -608,6 +659,18 @@ private static TestServer CreateServer(Action configure { await context.ChallengeAsync("Microsoft"); } + else if (req.Path == new PathString("/challengeWithOtherScope")) + { + var properties = new OAuthChallengeProperties(); + properties.SetScope("baz", "qux"); + await context.ChallengeAsync("Microsoft", properties); + } + else if (req.Path == new PathString("/challengeWithOtherScopeWithBaseAuthenticationProperties")) + { + var properties = new AuthenticationProperties(); + properties.SetParameter(OAuthChallengeProperties.ScopeKey, new string[] { "baz", "qux" }); + await context.ChallengeAsync("Microsoft", properties); + } else if (req.Path == new PathString("/me")) { res.Describe(context.User); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs new file mode 100644 index 000000000..c359bb0e8 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthChallengePropertiesTest.cs @@ -0,0 +1,149 @@ +using System; +using Microsoft.AspNetCore.Authentication.Google; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication.OpenIdConnect; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication.Test +{ + public class OAuthChallengePropertiesTest + { + [Fact] + public void ScopeProperty() + { + var properties = new OAuthChallengeProperties + { + Scope = new string[] { "foo", "bar" } + }; + Assert.Equal(new string[] { "foo", "bar" }, properties.Scope); + Assert.Equal(new string[] { "foo", "bar" }, properties.Parameters["scope"]); + } + + [Fact] + public void ScopeProperty_NullValue() + { + var properties = new OAuthChallengeProperties(); + properties.Parameters["scope"] = new string[] { "foo", "bar" }; + Assert.Equal(new string[] { "foo", "bar" }, properties.Scope); + + properties.Scope = null; + Assert.Null(properties.Scope); + } + + [Fact] + public void SetScope() + { + var properties = new OAuthChallengeProperties(); + properties.SetScope("foo", "bar"); + Assert.Equal(new string[] { "foo", "bar" }, properties.Scope); + Assert.Equal(new string[] { "foo", "bar" }, properties.Parameters["scope"]); + } + + [Fact] + public void OidcMaxAge() + { + var properties = new OpenIdConnectChallengeProperties() + { + MaxAge = TimeSpan.FromSeconds(200) + }; + Assert.Equal(TimeSpan.FromSeconds(200), properties.MaxAge); + } + + [Fact] + public void OidcMaxAge_NullValue() + { + var properties = new OpenIdConnectChallengeProperties(); + properties.Parameters["max_age"] = TimeSpan.FromSeconds(500); + Assert.Equal(TimeSpan.FromSeconds(500), properties.MaxAge); + + properties.MaxAge = null; + Assert.Null(properties.MaxAge); + } + + [Fact] + public void OidcPrompt() + { + var properties = new OpenIdConnectChallengeProperties() + { + Prompt = "login" + }; + Assert.Equal("login", properties.Prompt); + Assert.Equal("login", properties.Parameters["prompt"]); + } + + [Fact] + public void OidcPrompt_NullValue() + { + var properties = new OpenIdConnectChallengeProperties(); + properties.Parameters["prompt"] = "consent"; + Assert.Equal("consent", properties.Prompt); + + properties.Prompt = null; + Assert.Null(properties.Prompt); + } + + [Fact] + public void GoogleProperties() + { + var properties = new GoogleChallengeProperties() + { + AccessType = "offline", + ApprovalPrompt = "force", + LoginHint = "test@example.com", + Prompt = "login", + }; + Assert.Equal("offline", properties.AccessType); + Assert.Equal("offline", properties.Parameters["access_type"]); + Assert.Equal("force", properties.ApprovalPrompt); + Assert.Equal("force", properties.Parameters["approval_prompt"]); + Assert.Equal("test@example.com", properties.LoginHint); + Assert.Equal("test@example.com", properties.Parameters["login_hint"]); + Assert.Equal("login", properties.Prompt); + Assert.Equal("login", properties.Parameters["prompt"]); + } + + [Fact] + public void GoogleProperties_NullValues() + { + var properties = new GoogleChallengeProperties(); + properties.Parameters["access_type"] = "offline"; + properties.Parameters["approval_prompt"] = "force"; + properties.Parameters["login_hint"] = "test@example.com"; + properties.Parameters["prompt"] = "login"; + Assert.Equal("offline", properties.AccessType); + Assert.Equal("force", properties.ApprovalPrompt); + Assert.Equal("test@example.com", properties.LoginHint); + Assert.Equal("login", properties.Prompt); + + properties.AccessType = null; + Assert.Null(properties.AccessType); + + properties.ApprovalPrompt = null; + Assert.Null(properties.ApprovalPrompt); + + properties.LoginHint = null; + Assert.Null(properties.LoginHint); + + properties.Prompt = null; + Assert.Null(properties.Prompt); + } + + [Fact] + public void GoogleIncludeGrantedScopes() + { + var properties = new GoogleChallengeProperties() + { + IncludeGrantedScopes = true + }; + Assert.True(properties.IncludeGrantedScopes); + Assert.Equal(true, properties.Parameters["include_granted_scopes"]); + + properties.IncludeGrantedScopes = false; + Assert.False(properties.IncludeGrantedScopes); + Assert.Equal(false, properties.Parameters["include_granted_scopes"]); + + properties.IncludeGrantedScopes = null; + Assert.Null(properties.IncludeGrantedScopes); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 9279f145b..4b822b611 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -572,6 +572,88 @@ public async Task RedirectToAuthorizeEndpoint_CorrelationIdCookieOptions_CanBeOv Assert.Contains("path=/", correlation); } + [Fact] + public async Task RedirectToAuthorizeEndpoint_HasScopeAsConfigured() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + ConfigureDefaults(opt); + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }), + async ctx => + { + await ctx.ChallengeAsync("Weblie"); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=foo%20bar", res.Headers.Location.Query); + } + + [Fact] + public async Task RedirectToAuthorizeEndpoint_HasScopeAsOverwritten() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + ConfigureDefaults(opt); + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }), + async ctx => + { + var properties = new OAuthChallengeProperties(); + properties.SetScope("baz", "qux"); + await ctx.ChallengeAsync("Weblie", properties); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + + [Fact] + public async Task RedirectToAuthorizeEndpoint_HasScopeAsOverwrittenWithBaseAuthenticationProperties() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + ConfigureDefaults(opt); + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }), + async ctx => + { + var properties = new AuthenticationProperties(); + properties.SetParameter(OAuthChallengeProperties.ScopeKey, new string[] { "baz", "qux" }); + await ctx.ChallengeAsync("Weblie", properties); + return true; + }); + + var transaction = await server.SendAsync("https://www.example.com/challenge"); + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + private void ConfigureDefaults(OAuthOptions o) { o.ClientId = "Test Id"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs index 7ab81c9dd..cbafc4622 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectChallengeTests.cs @@ -51,14 +51,14 @@ public async Task ChallengeRedirectIsIssuedCorrectly() [Fact] public async Task AuthorizationRequestDoesNotIncludeTelemetryParametersWhenDisabled() { - var setting = new TestSettings(opt => + var settings = new TestSettings(opt => { opt.ClientId = "Test Id"; opt.Authority = TestServerBuilder.DefaultAuthority; opt.DisableTelemetry = true; }); - var server = setting.CreateTestServer(); + var server = settings.CreateTestServer(); var transaction = await server.SendAsync(ChallengeEndpoint); var res = transaction.Response; @@ -425,6 +425,7 @@ public async Task Challenge_WithDefaultMaxAge_HasExpectedMaxAgeParam() var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); settings.ValidateChallengeRedirect( res.Headers.Location, OpenIdConnectParameterNames.MaxAge); @@ -446,9 +447,170 @@ public async Task Challenge_WithSpecificMaxAge_HasExpectedMaxAgeParam() var res = transaction.Response; + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); settings.ValidateChallengeRedirect( res.Headers.Location, OpenIdConnectParameterNames.MaxAge); } + + [Fact] + public async Task Challenge_HasExpectedPromptParam() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Prompt = "consent"; + }); + + var server = settings.CreateTestServer(); + var transaction = await server.SendAsync(ChallengeEndpoint); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location, OpenIdConnectParameterNames.Prompt); + Assert.Contains("prompt=consent", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenPromptParam() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Prompt = "consent"; + }); + var properties = new OpenIdConnectChallengeProperties() + { + Prompt = "login", + }; + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("prompt=login", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenPromptParamFromBaseAuthenticationProperties() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Prompt = "consent"; + }); + var properties = new AuthenticationProperties(); + properties.SetParameter(OpenIdConnectChallengeProperties.PromptKey, "login"); + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("prompt=login", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenScopeParam() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }); + var properties = new OpenIdConnectChallengeProperties(); + properties.SetScope("baz", "qux"); + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenScopeParamFromBaseAuthenticationProperties() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.Scope.Clear(); + opt.Scope.Add("foo"); + opt.Scope.Add("bar"); + }); + var properties = new AuthenticationProperties(); + properties.SetParameter(OpenIdConnectChallengeProperties.ScopeKey, new string[] { "baz", "qux" }); + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenMaxAgeParam() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.MaxAge = TimeSpan.FromSeconds(500); + }); + var properties = new OpenIdConnectChallengeProperties() + { + MaxAge = TimeSpan.FromSeconds(1234), + }; + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("max_age=1234", res.Headers.Location.Query); + } + + [Fact] + public async Task Challenge_HasOverwrittenMaxAgeParaFromBaseAuthenticationPropertiesm() + { + var settings = new TestSettings(opt => + { + opt.ClientId = "Test Id"; + opt.Authority = TestServerBuilder.DefaultAuthority; + opt.MaxAge = TimeSpan.FromSeconds(500); + }); + var properties = new AuthenticationProperties(); + properties.SetParameter(OpenIdConnectChallengeProperties.MaxAgeKey, TimeSpan.FromSeconds(1234)); + + var server = settings.CreateTestServer(properties); + var transaction = await server.SendAsync(TestServerBuilder.TestHost + TestServerBuilder.ChallengeWithProperties); + + var res = transaction.Response; + + Assert.Equal(HttpStatusCode.Redirect, res.StatusCode); + settings.ValidateChallengeRedirect(res.Headers.Location); + Assert.Contains("max_age=1234", res.Headers.Location.Query); + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index 6bb5445dc..a1e0233f3 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -206,6 +206,9 @@ private void ValidateParameters( case OpenIdConnectParameterNames.MaxAge: ValidateMaxAge(actualValues, errors, htmlEncoded); break; + case OpenIdConnectParameterNames.Prompt: + ValidatePrompt(actualValues, errors, htmlEncoded); + break; default: throw new InvalidOperationException($"Unknown parameter \"{paramToValidate}\"."); } @@ -284,6 +287,9 @@ private void ValidateMaxAge(IDictionary actualQuery, ICollection } } + private void ValidatePrompt(IDictionary actualParams, ICollection errors, bool htmlEncoded) => + ValidateParameter(OpenIdConnectParameterNames.Prompt, _options.Prompt, actualParams, errors, htmlEncoded); + private void ValidateParameter( string parameterName, string expectedValue, From 405e7bce54b021ee18070d3cf40b25d4dab27870 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 23 Mar 2018 14:55:41 -0700 Subject: [PATCH 160/248] Update dependencies --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d80ecef5a..90c4b7414 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,42 +4,42 @@ 2.1.0-preview2-15744 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 + 2.1.0-preview2-30433 3.14.2 5.2.0 5.2.0 2.0.0 2.1.0-preview2-26314-02 - 15.6.0 + 15.6.1 3.0.1 3.0.1 3.0.1 - 10.0.1 + 11.0.1 5.2.0 0.8.0 2.3.1 From bbff105e4dd5105722159fe792c17b2b39baaea3 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 25 Mar 2018 15:54:30 -0700 Subject: [PATCH 161/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 60 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d0cb88aa8..23bd79dbc 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15728 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 + 2.1.0-preview3-17001 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26225-03 - 15.6.0 + 2.1.0-preview2-26314-02 + 15.6.1 3.0.1 3.0.1 3.0.1 - 10.0.1 + 11.0.1 5.2.0 0.8.0 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 138d848db..3a326c7d5 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15728 -commithash:393377068ddcf51dfee0536536d455f57a828b06 +version:2.1.0-preview3-17001 +commithash:dda68c56abf0d3b911fe6a2315872c446b314585 From 0d0f703e3e074fe60b8e9fc3846ce03547022305 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Wed, 28 Mar 2018 11:03:00 -0700 Subject: [PATCH 162/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 90c4b7414..303f56bca 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15744 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 - 2.1.0-preview2-30433 + 2.1.0-preview2-15749 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26314-02 + 2.1.0-preview2-26326-03 15.6.1 3.0.1 3.0.1 3.0.1 - 11.0.1 + 11.0.2 5.2.0 0.8.0 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index f531e7b0f..b8e036fe2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15744 -commithash:9e15cb6062ab5b9790d3fa699e018543a6950713 +version:2.1.0-preview2-15749 +commithash:5544c9ab20fa5e24b9e155d8958a3c3b6f5f9df9 From e98a0d243a7a5d8076ab85c3438739118cdd53ff Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 3 Apr 2018 22:41:47 +0000 Subject: [PATCH 163/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 23bd79dbc..fabe53792 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17001 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 + 2.1.0-preview3-17002 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview2-26314-02 + 2.1.0-preview3-26331-01 15.6.1 3.0.1 3.0.1 3.0.1 - 11.0.1 + 11.0.2 5.2.0 0.8.0 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3a326c7d5..b3af0b8bc 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17001 -commithash:dda68c56abf0d3b911fe6a2315872c446b314585 +version:2.1.0-preview3-17002 +commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f From ec5d71d2dcd77e969a29f13137f8ce337a3d4b92 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Apr 2018 14:25:39 -0700 Subject: [PATCH 164/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index fabe53792..9f302ba91 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17002 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 + 2.1.0-preview3-17018 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview3-26331-01 + 2.1.0-preview3-26413-05 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b3af0b8bc..b419d767b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17002 -commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f +version:2.1.0-preview3-17018 +commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be From 30493e2fd63907d0484b940c069d681dcb962591 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Apr 2018 17:02:13 -0700 Subject: [PATCH 165/248] Branching for 2.1.0-rc1 --- build/repo.props | 3 ++- korebuild.json | 4 ++-- version.props | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/repo.props b/build/repo.props index 541470c9f..a4f86fb2f 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -7,6 +7,7 @@ Internal.AspNetCore.Universe.Lineup + 2.1.0-rc1-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/korebuild.json b/korebuild.json index bd5d51a51..678d8bb94 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } diff --git a/version.props b/version.props index 24f2b00a0..e27532787 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview3 + rc1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 6e0377bad8c44e1394234500bfddb90e87fcaed6 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Apr 2018 17:02:18 -0700 Subject: [PATCH 166/248] Update version number to 2.2.0 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index 24f2b00a0..44985cedb 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.1.0 - preview3 + 2.2.0 + preview1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 2e3a1071a884de19d33daa00bbdc2b7614d73646 Mon Sep 17 00:00:00 2001 From: Devin Garner Date: Tue, 17 Apr 2018 10:34:10 -0600 Subject: [PATCH 167/248] Correct Twitter OAuth signing code & refactor copy/pasted code. #1695 (#1720) --- .../TwitterHandler.cs | 182 ++++++------------ 1 file changed, 63 insertions(+), 119 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 670e76f7e..d0d54bf74 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -148,53 +148,92 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop await Events.RedirectToAuthorizationEndpoint(redirectContext); } - private async Task ObtainRequestTokenAsync(string callBackUri, AuthenticationProperties properties) + private async Task ExecuteRequestAsync(string url, HttpMethod httpMethod, RequestToken accessToken = null, Dictionary extraOAuthPairs = null, Dictionary queryParameters = null, Dictionary formData = null) { - Logger.ObtainRequestToken(); - - var nonce = Guid.NewGuid().ToString("N"); - - var authorizationParts = new SortedDictionary + var authorizationParts = new SortedDictionary(extraOAuthPairs ?? new Dictionary()) { - { "oauth_callback", callBackUri }, { "oauth_consumer_key", Options.ConsumerKey }, - { "oauth_nonce", nonce }, + { "oauth_nonce", Guid.NewGuid().ToString("N") }, { "oauth_signature_method", "HMAC-SHA1" }, { "oauth_timestamp", GenerateTimeStamp() }, { "oauth_version", "1.0" } }; + if (accessToken != null) + { + authorizationParts.Add("oauth_token", accessToken.Token); + } + + var signatureParts = new SortedDictionary(authorizationParts); + if (queryParameters != null) + { + foreach (var queryParameter in queryParameters) + { + signatureParts.Add(queryParameter.Key, queryParameter.Value); + } + } + if (formData != null) + { + foreach (var formItem in formData) + { + signatureParts.Add(formItem.Key, formItem.Value); + } + } + var parameterBuilder = new StringBuilder(); - foreach (var authorizationKey in authorizationParts) + foreach (var signaturePart in signatureParts) { - parameterBuilder.AppendFormat("{0}={1}&", UrlEncoder.Encode(authorizationKey.Key), UrlEncoder.Encode(authorizationKey.Value)); + parameterBuilder.AppendFormat("{0}={1}&", Uri.EscapeDataString(signaturePart.Key), Uri.EscapeDataString(signaturePart.Value)); } parameterBuilder.Length--; var parameterString = parameterBuilder.ToString(); var canonicalizedRequestBuilder = new StringBuilder(); - canonicalizedRequestBuilder.Append(HttpMethod.Post.Method); + canonicalizedRequestBuilder.Append(httpMethod.Method); canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(RequestTokenEndpoint)); + canonicalizedRequestBuilder.Append(Uri.EscapeDataString(url)); canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString)); + canonicalizedRequestBuilder.Append(Uri.EscapeDataString(parameterString)); - var signature = ComputeSignature(Options.ConsumerSecret, null, canonicalizedRequestBuilder.ToString()); + var signature = ComputeSignature(Options.ConsumerSecret, accessToken?.TokenSecret, canonicalizedRequestBuilder.ToString()); authorizationParts.Add("oauth_signature", signature); + var queryString = ""; + if (queryParameters != null) + { + var queryStringBuilder = new StringBuilder("?"); + foreach (var queryParam in queryParameters) + { + queryStringBuilder.AppendFormat("{0}={1}&", queryParam.Key, queryParam.Value); + } + queryStringBuilder.Length--; + queryString = queryStringBuilder.ToString(); + } + var authorizationHeaderBuilder = new StringBuilder(); authorizationHeaderBuilder.Append("OAuth "); foreach (var authorizationPart in authorizationParts) { - authorizationHeaderBuilder.AppendFormat( - "{0}=\"{1}\", ", authorizationPart.Key, UrlEncoder.Encode(authorizationPart.Value)); + authorizationHeaderBuilder.AppendFormat("{0}=\"{1}\",", authorizationPart.Key, Uri.EscapeDataString(authorizationPart.Value)); } - authorizationHeaderBuilder.Length = authorizationHeaderBuilder.Length - 2; + authorizationHeaderBuilder.Length--; - var request = new HttpRequestMessage(HttpMethod.Post, RequestTokenEndpoint); + var request = new HttpRequestMessage(httpMethod, url + queryString); request.Headers.Add("Authorization", authorizationHeaderBuilder.ToString()); - var response = await Backchannel.SendAsync(request, Context.RequestAborted); + if (formData != null) + { + request.Content = new FormUrlEncodedContent(formData); + } + + return await Backchannel.SendAsync(request, Context.RequestAborted); + } + + private async Task ObtainRequestTokenAsync(string callBackUri, AuthenticationProperties properties) + { + Logger.ObtainRequestToken(); + + var response = await ExecuteRequestAsync(RequestTokenEndpoint, HttpMethod.Post, extraOAuthPairs: new Dictionary() { { "oauth_callback", callBackUri } }); response.EnsureSuccessStatusCode(); var responseText = await response.Content.ReadAsStringAsync(); @@ -213,58 +252,8 @@ private async Task ObtainAccessTokenAsync(RequestToken token, strin Logger.ObtainAccessToken(); - var nonce = Guid.NewGuid().ToString("N"); - - var authorizationParts = new SortedDictionary - { - { "oauth_consumer_key", Options.ConsumerKey }, - { "oauth_nonce", nonce }, - { "oauth_signature_method", "HMAC-SHA1" }, - { "oauth_token", token.Token }, - { "oauth_timestamp", GenerateTimeStamp() }, - { "oauth_verifier", verifier }, - { "oauth_version", "1.0" }, - }; - - var parameterBuilder = new StringBuilder(); - foreach (var authorizationKey in authorizationParts) - { - parameterBuilder.AppendFormat("{0}={1}&", UrlEncoder.Encode(authorizationKey.Key), UrlEncoder.Encode(authorizationKey.Value)); - } - parameterBuilder.Length--; - var parameterString = parameterBuilder.ToString(); - - var canonicalizedRequestBuilder = new StringBuilder(); - canonicalizedRequestBuilder.Append(HttpMethod.Post.Method); - canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(AccessTokenEndpoint)); - canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString)); - - var signature = ComputeSignature(Options.ConsumerSecret, token.TokenSecret, canonicalizedRequestBuilder.ToString()); - authorizationParts.Add("oauth_signature", signature); - authorizationParts.Remove("oauth_verifier"); - - var authorizationHeaderBuilder = new StringBuilder(); - authorizationHeaderBuilder.Append("OAuth "); - foreach (var authorizationPart in authorizationParts) - { - authorizationHeaderBuilder.AppendFormat( - "{0}=\"{1}\", ", authorizationPart.Key, UrlEncoder.Encode(authorizationPart.Value)); - } - authorizationHeaderBuilder.Length = authorizationHeaderBuilder.Length - 2; - - var request = new HttpRequestMessage(HttpMethod.Post, AccessTokenEndpoint); - request.Headers.Add("Authorization", authorizationHeaderBuilder.ToString()); - - var formPairs = new Dictionary() - { - { "oauth_verifier", verifier }, - }; - - request.Content = new FormUrlEncodedContent(formPairs); - - var response = await Backchannel.SendAsync(request, Context.RequestAborted); + var formPost = new Dictionary { { "oauth_verifier", verifier } }; + var response = await ExecuteRequestAsync(AccessTokenEndpoint, HttpMethod.Post, token, formData: formPost); if (!response.IsSuccessStatusCode) { @@ -289,53 +278,8 @@ private async Task RetrieveUserDetailsAsync(AccessToken accessToken, Cl { Logger.RetrieveUserDetails(); - var nonce = Guid.NewGuid().ToString("N"); - - var authorizationParts = new SortedDictionary - { - { "oauth_consumer_key", Options.ConsumerKey }, - { "oauth_nonce", nonce }, - { "oauth_signature_method", "HMAC-SHA1" }, - { "oauth_timestamp", GenerateTimeStamp() }, - { "oauth_token", accessToken.Token }, - { "oauth_version", "1.0" } - }; - - var parameterBuilder = new StringBuilder(); - foreach (var authorizationKey in authorizationParts) - { - parameterBuilder.AppendFormat("{0}={1}&", UrlEncoder.Encode(authorizationKey.Key), UrlEncoder.Encode(authorizationKey.Value)); - } - parameterBuilder.Length--; - var parameterString = parameterBuilder.ToString(); - - var resource_url = "https://api.twitter.com/1.1/account/verify_credentials.json"; - var resource_query = "include_email=true"; - var canonicalizedRequestBuilder = new StringBuilder(); - canonicalizedRequestBuilder.Append(HttpMethod.Get.Method); - canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(resource_url)); - canonicalizedRequestBuilder.Append("&"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(resource_query)); - canonicalizedRequestBuilder.Append("%26"); - canonicalizedRequestBuilder.Append(UrlEncoder.Encode(parameterString)); - - var signature = ComputeSignature(Options.ConsumerSecret, accessToken.TokenSecret, canonicalizedRequestBuilder.ToString()); - authorizationParts.Add("oauth_signature", signature); - - var authorizationHeaderBuilder = new StringBuilder(); - authorizationHeaderBuilder.Append("OAuth "); - foreach (var authorizationPart in authorizationParts) - { - authorizationHeaderBuilder.AppendFormat( - "{0}=\"{1}\", ", authorizationPart.Key, UrlEncoder.Encode(authorizationPart.Value)); - } - authorizationHeaderBuilder.Length = authorizationHeaderBuilder.Length - 2; - - var request = new HttpRequestMessage(HttpMethod.Get, resource_url + "?include_email=true"); - request.Headers.Add("Authorization", authorizationHeaderBuilder.ToString()); + var response = await ExecuteRequestAsync("https://api.twitter.com/1.1/account/verify_credentials.json", HttpMethod.Get, accessToken, queryParameters: new Dictionary() { { "include_email", "true" } }); - var response = await Backchannel.SendAsync(request, Context.RequestAborted); if (!response.IsSuccessStatusCode) { Logger.LogError("Email request failed with a status code of " + response.StatusCode); @@ -361,8 +305,8 @@ private string ComputeSignature(string consumerSecret, string tokenSecret, strin algorithm.Key = Encoding.ASCII.GetBytes( string.Format(CultureInfo.InvariantCulture, "{0}&{1}", - UrlEncoder.Encode(consumerSecret), - string.IsNullOrEmpty(tokenSecret) ? string.Empty : UrlEncoder.Encode(tokenSecret))); + Uri.EscapeDataString(consumerSecret), + string.IsNullOrEmpty(tokenSecret) ? string.Empty : Uri.EscapeDataString(tokenSecret))); var hash = algorithm.ComputeHash(Encoding.ASCII.GetBytes(signatureData)); return Convert.ToBase64String(hash); } From 5e8f54a55fcf77fe20f1ca8c466b4cc60f366352 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 19 Apr 2018 16:44:34 -0700 Subject: [PATCH 168/248] Set NETStandardImplicitPackageVersion via dependencies.props --- Directory.Build.targets | 1 + build/dependencies.props | 1 + 2 files changed, 2 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 894b1d0cf..53b3f6e1d 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -2,5 +2,6 @@ $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(NETStandardLibrary20PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index 9f302ba91..4dc778d54 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -36,6 +36,7 @@ 2.0.0 2.1.0-preview3-26413-05 15.6.1 + 2.0.1 3.0.1 3.0.1 3.0.1 From f3fc9c714829edadd8e7d7b6000fee1c6a5b5ef1 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 19 Apr 2018 22:35:33 -0700 Subject: [PATCH 169/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4dc778d54..2cb9387b7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17018 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 + 2.1.0-rc1-15774 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview3-26413-05 + 2.1.0-rc1-26419-02 15.6.1 - 2.0.1 3.0.1 3.0.1 3.0.1 + 2.0.1 11.0.2 5.2.0 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b419d767b..9d4ef8c88 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17018 -commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be +version:2.1.0-rc1-15774 +commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 From db19d87bfa41fa5a11a318d12f8f1f1e0e27c3df Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 23 Apr 2018 12:25:11 -0700 Subject: [PATCH 170/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 2cb9387b7..6a1705582 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rc1-15774 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 + 2.2.0-preview1-17037 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-rc1-26419-02 + 2.1.0-preview3-26413-05 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b419d767b..f27a67b44 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17018 -commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be +version:2.2.0-preview1-17037 +commithash:557055a86cbdc359c97d4fb1c2d23a3dc7ae731e From 02ddceac287052775c4205738d5a61838420da6e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Apr 2018 12:31:25 -0700 Subject: [PATCH 171/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 6a1705582..b28166798 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17037 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 + 2.2.0-preview1-17042 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-preview3-26413-05 + 2.2.0-preview1-26424-04 15.6.1 3.0.1 3.0.1 3.0.1 - 2.0.1 + 2.0.3 11.0.2 5.2.0 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index f27a67b44..335e579e0 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17037 -commithash:557055a86cbdc359c97d4fb1c2d23a3dc7ae731e +version:2.2.0-preview1-17042 +commithash:edf0705d014293c260de763543784330514db9a3 From 3cc514c875512c1426f7ae07d4a8e36ffcbbfb30 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Mon, 30 Apr 2018 14:51:45 -0700 Subject: [PATCH 172/248] Bump version to 2.1.0-rtm --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index e27532787..b9552451d 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - rc1 + rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From a2cb92b358daf7552294060cd947d85afcc07049 Mon Sep 17 00:00:00 2001 From: Alexey Malinin Date: Tue, 1 May 2018 23:22:27 +0700 Subject: [PATCH 173/248] Code improvements of JwtBearer module (#1742) * Use pattern matching to check exception type in JwtBearerHandler * Use expression body to configure events in JwtBearerHandler --- .../JwtBearerHandler.cs | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 6d5c7f5f5..452d9639f 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -32,8 +32,8 @@ public JwtBearerHandler(IOptionsMonitor options, ILoggerFactor /// protected new JwtBearerEvents Events { - get { return (JwtBearerEvents)base.Events; } - set { base.Events = value; } + get => (JwtBearerEvents)base.Events; + set => base.Events = value; } protected override Task CreateEventsAsync() => Task.FromResult(new JwtBearerEvents()); @@ -267,9 +267,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop private static string CreateErrorDescription(Exception authFailure) { IEnumerable exceptions; - if (authFailure is AggregateException) + if (authFailure is AggregateException agEx) { - var agEx = authFailure as AggregateException; exceptions = agEx.InnerExceptions; } else @@ -283,37 +282,32 @@ private static string CreateErrorDescription(Exception authFailure) { // Order sensitive, some of these exceptions derive from others // and we want to display the most specific message possible. - if (ex is SecurityTokenInvalidAudienceException) + switch (ex) { - messages.Add("The audience is invalid"); - } - else if (ex is SecurityTokenInvalidIssuerException) - { - messages.Add("The issuer is invalid"); - } - else if (ex is SecurityTokenNoExpirationException) - { - messages.Add("The token has no expiration"); - } - else if (ex is SecurityTokenInvalidLifetimeException) - { - messages.Add("The token lifetime is invalid"); - } - else if (ex is SecurityTokenNotYetValidException) - { - messages.Add("The token is not valid yet"); - } - else if (ex is SecurityTokenExpiredException) - { - messages.Add("The token is expired"); - } - else if (ex is SecurityTokenSignatureKeyNotFoundException) - { - messages.Add("The signature key was not found"); - } - else if (ex is SecurityTokenInvalidSignatureException) - { - messages.Add("The signature is invalid"); + case SecurityTokenInvalidAudienceException _: + messages.Add("The audience is invalid"); + break; + case SecurityTokenInvalidIssuerException _: + messages.Add("The issuer is invalid"); + break; + case SecurityTokenNoExpirationException _: + messages.Add("The token has no expiration"); + break; + case SecurityTokenInvalidLifetimeException _: + messages.Add("The token lifetime is invalid"); + break; + case SecurityTokenNotYetValidException _: + messages.Add("The token is not valid yet"); + break; + case SecurityTokenExpiredException _: + messages.Add("The token is expired"); + break; + case SecurityTokenSignatureKeyNotFoundException _: + messages.Add("The signature key was not found"); + break; + case SecurityTokenInvalidSignatureException _: + messages.Add("The signature is invalid"); + break; } } From 4dbcfa5e508221b3d71a2ff7d66979282dacee33 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 4 May 2018 07:50:04 -0700 Subject: [PATCH 174/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 2cb9387b7..d55f378cc 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,43 +3,43 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rc1-15774 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 + 2.1.0-rtm-15783 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-rc1-26419-02 + 2.1.0-rtm-26502-02 15.6.1 3.0.1 3.0.1 3.0.1 - 2.0.1 + 2.0.3 11.0.2 5.2.0 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 9d4ef8c88..3673744db 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rc1-15774 -commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 +version:2.1.0-rtm-15783 +commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 From 8bd15fcec12ea1f4209da8fdb8f2f4bcc41547b4 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 6 May 2018 12:30:25 -0700 Subject: [PATCH 175/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index b28166798..6f1ddb34d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17042 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 + 2.2.0-preview1-17047 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 335e579e0..a16d4b9ee 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17042 -commithash:edf0705d014293c260de763543784330514db9a3 +version:2.2.0-preview1-17047 +commithash:e1957b52ddc8b62bd39c5c400322fccb5364624c From a10c3cb23b0a2e13a8a88e2cccc19e76e8b696ed Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 7 May 2018 15:15:40 -0700 Subject: [PATCH 176/248] Upgrade to netcoreapp22 --- Directory.Build.targets | 5 +- build/dependencies.props | 57 ++++++++++--------- build/repo.props | 3 +- korebuild-lock.txt | 4 +- .../CookiePolicySample.csproj | 4 +- samples/CookieSample/CookieSample.csproj | 4 +- .../CookieSessionSample.csproj | 4 +- .../JwtBearerSample/JwtBearerSample.csproj | 4 +- .../OpenIdConnect.AzureAdSample.csproj | 4 +- .../OpenIdConnectSample.csproj | 4 +- samples/SocialSample/SocialSample.csproj | 4 +- samples/WsFedSample/WsFedSample.csproj | 2 +- test/Directory.Build.props | 6 +- .../OpenIdConnect/TestSettings.cs | 2 +- 14 files changed, 56 insertions(+), 51 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 53b3f6e1d..78626b773 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,7 +1,10 @@ - + $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(MicrosoftNETCoreApp22PackageVersion) $(NETStandardLibrary20PackageVersion) + + 99.9 diff --git a/build/dependencies.props b/build/dependencies.props index 6f1ddb34d..79f94d403 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,40 +1,41 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17047 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 + 2.2.0-preview1-17048 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 3.14.2 5.2.0 5.2.0 2.0.0 2.2.0-preview1-26424-04 + 2.2.0-preview1-26502-01 15.6.1 3.0.1 3.0.1 diff --git a/build/repo.props b/build/repo.props index 541470c9f..6fc6af601 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -13,5 +13,6 @@ + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a16d4b9ee..2573a0399 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17047 -commithash:e1957b52ddc8b62bd39c5c400322fccb5364624c +version:2.2.0-preview1-17048 +commithash:de14a0ee5fb48508ee8a29c14280a2928f8dabf8 diff --git a/samples/CookiePolicySample/CookiePolicySample.csproj b/samples/CookiePolicySample/CookiePolicySample.csproj index fb2e7d917..48227eb07 100644 --- a/samples/CookiePolicySample/CookiePolicySample.csproj +++ b/samples/CookiePolicySample/CookiePolicySample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 193137b86..1029f1819 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 6241edd66..19bd04374 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 84b436581..3e0192a23 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 aspnet5-JwtBearerSample-20151210102827 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index b14b9590f..2abd57cd8 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index 23e87d4f2..bb02ef159 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index a423ae21a..a08b9799d 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,7 +1,7 @@ - + - net461;netcoreapp2.1 + net461;netcoreapp2.2 aspnet5-SocialSample-20151210111056 diff --git a/samples/WsFedSample/WsFedSample.csproj b/samples/WsFedSample/WsFedSample.csproj index bc3a59f10..4fb38fa3e 100644 --- a/samples/WsFedSample/WsFedSample.csproj +++ b/samples/WsFedSample/WsFedSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.0 + net461 diff --git a/test/Directory.Build.props b/test/Directory.Build.props index b842a4831..e3d2d9f14 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,10 +1,10 @@ - + - netcoreapp2.1 + netcoreapp2.2 $(DeveloperBuildTestTfms) - $(StandardTestTfms);netcoreapp2.0 + $(StandardTestTfms) $(StandardTestTfms);net461 diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index a1e0233f3..b32e0723f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -259,7 +259,7 @@ private void ValidateState(IDictionary actualParams, ICollection ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => -#if NETCOREAPP2_0 || NETCOREAPP2_1 +#if NETCOREAPP2_2 ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NETSTANDARD1_4", actualParams, errors, htmlEncoded); #elif NET461 ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET451", actualParams, errors, htmlEncoded); From 23b2b00e0ecd4d6c57698156d7679aa4caea7838 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 13 May 2018 14:22:46 -0700 Subject: [PATCH 177/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 60 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 79f94d403..5c678ea41 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,41 +1,41 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17048 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 + 2.2.0-preview1-17051 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 3.14.2 5.2.0 5.2.0 2.0.0 - 2.2.0-preview1-26424-04 - 2.2.0-preview1-26502-01 + 2.1.0-rc1 + 2.2.0-preview1-26509-06 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2573a0399..89629b454 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17048 -commithash:de14a0ee5fb48508ee8a29c14280a2928f8dabf8 +version:2.2.0-preview1-17051 +commithash:253c3a480063bc3abaa5cde42f6e27b58457ef9b From 1aa78a585324d80bf99bf83e7c28fbd9038fc610 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 16 May 2018 15:41:01 -0700 Subject: [PATCH 178/248] Rewrite JwtBearer token test #640 --- .../JwtBearerTests.cs | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index b472a4162..20d625d31 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Net; using System.Net.Http; @@ -432,19 +433,37 @@ public async Task VerifySchemeDefaults() Assert.Null(scheme.DisplayName); } - [ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179 + [Fact] public async Task BearerTokenValidation() { + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); + var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + + var claims = new[] + { + new Claim(ClaimTypes.NameIdentifier, "Bob") + }; + + var token = new JwtSecurityToken( + issuer: "issuer.contoso.com", + audience: "audience.contoso.com", + claims: claims, + expires: DateTime.Now.AddMinutes(30), + signingCredentials: creds); + + var tokenText = new JwtSecurityTokenHandler().WriteToken(token); + var server = CreateServer(o => { - o.Authority = "https://login.windows.net/tushartest.onmicrosoft.com"; - o.Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualJwt"; - o.TokenValidationParameters.ValidateLifetime = false; + o.TokenValidationParameters = new TokenValidationParameters() + { + ValidIssuer = "issuer.contoso.com", + ValidAudience = "audience.contoso.com", + IssuerSigningKey = key, + }; }); - var newBearerToken = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtyaU1QZG1Cdng2OHNrVDgtbVBBQjNCc2VlQSJ9.eyJhdWQiOiJodHRwczovL1R1c2hhclRlc3Qub25taWNyb3NvZnQuY29tL1RvZG9MaXN0U2VydmljZS1NYW51YWxKd3QiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9hZmJlY2UwMy1hZWFhLTRmM2YtODVlNy1jZTA4ZGQyMGNlNTAvIiwiaWF0IjoxNDE4MzMwNjE0LCJuYmYiOjE0MTgzMzA2MTQsImV4cCI6MTQxODMzNDUxNCwidmVyIjoiMS4wIiwidGlkIjoiYWZiZWNlMDMtYWVhYS00ZjNmLTg1ZTctY2UwOGRkMjBjZTUwIiwiYW1yIjpbInB3ZCJdLCJvaWQiOiI1Mzk3OTdjMi00MDE5LTQ2NTktOWRiNS03MmM0Yzc3NzhhMzMiLCJ1cG4iOiJWaWN0b3JAVHVzaGFyVGVzdC5vbm1pY3Jvc29mdC5jb20iLCJ1bmlxdWVfbmFtZSI6IlZpY3RvckBUdXNoYXJUZXN0Lm9ubWljcm9zb2Z0LmNvbSIsInN1YiI6IkQyMm9aMW9VTzEzTUFiQXZrdnFyd2REVE80WXZJdjlzMV9GNWlVOVUwYnciLCJmYW1pbHlfbmFtZSI6Ikd1cHRhIiwiZ2l2ZW5fbmFtZSI6IlZpY3RvciIsImFwcGlkIjoiNjEzYjVhZjgtZjJjMy00MWI2LWExZGMtNDE2Yzk3ODAzMGI3IiwiYXBwaWRhY3IiOiIwIiwic2NwIjoidXNlcl9pbXBlcnNvbmF0aW9uIiwiYWNyIjoiMSJ9.N_Kw1EhoVGrHbE6hOcm7ERdZ7paBQiNdObvp2c6T6n5CE8p0fZqmUd-ya_EqwElcD6SiKSiP7gj0gpNUnOJcBl_H2X8GseaeeMxBrZdsnDL8qecc6_ygHruwlPltnLTdka67s1Ow4fDSHaqhVTEk6lzGmNEcbNAyb0CxQxU6o7Fh0yHRiWoLsT8yqYk8nKzsHXfZBNby4aRo3_hXaa4i0SZLYfDGGYPdttG4vT_u54QGGd4Wzbonv2gjDlllOVGOwoJS6kfl1h8mk0qxdiIaT_ChbDWgkWvTB7bTvBE-EgHgV0XmAo0WtJeSxgjsG3KhhEPsONmqrSjhIUV4IVnF2w"; + var newBearerToken = "Bearer " + tokenText; var response = await SendAsync(server, "http://example.com/oauth", newBearerToken); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); } From fb80636cb53cb5d29c810a28fb15e2690677cb4e Mon Sep 17 00:00:00 2001 From: Rick Anderson Date: Fri, 18 May 2018 14:56:14 -1000 Subject: [PATCH 179/248] Cookie Policy sample essential cookie (#1762) --- samples/CookiePolicySample/Startup.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/samples/CookiePolicySample/Startup.cs b/samples/CookiePolicySample/Startup.cs index 7ce9c2d2d..4dcc6d4dc 100644 --- a/samples/CookiePolicySample/Startup.cs +++ b/samples/CookiePolicySample/Startup.cs @@ -58,6 +58,13 @@ private void NestedApp(IApplicationBuilder app) case "/RemoveTempCookie": context.Response.Cookies.Delete("Temp"); break; + case "/CreateEssentialCookie": + context.Response.Cookies.Append("EssentialCookie", "2", + new CookieOptions() { IsEssential = true }); + break; + case "/RemoveEssentialCookie": + context.Response.Cookies.Delete("EssentialCookie"); + break; case "/GrantConsent": context.Features.Get().GrantConsent(); break; @@ -84,6 +91,8 @@ private async Task HomePage(HttpContext context) await response.WriteAsync($"Logout
\r\n"); await response.WriteAsync($"Create Temp Cookie
\r\n"); await response.WriteAsync($"Remove Temp Cookie
\r\n"); + await response.WriteAsync($"Create Essential Cookie
\r\n"); + await response.WriteAsync($"Remove Essential Cookie
\r\n"); await response.WriteAsync($"Grant Consent
\r\n"); await response.WriteAsync($"Withdraw Consent
\r\n"); await response.WriteAsync("
\r\n"); From e031eff146c8aad43e63cd8d32e8fe382a0c8d66 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 20 May 2018 19:46:07 +0000 Subject: [PATCH 180/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5c678ea41..b839b4984 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
- 2.2.0-preview1-17051 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 + 2.2.0-preview1-17060 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 89629b454..cf2fff7de 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17051 -commithash:253c3a480063bc3abaa5cde42f6e27b58457ef9b +version:2.2.0-preview1-17060 +commithash:25b4b134d6f8f7b461928f0d495cfc695ccabb5b From 0f18ff1b9fecd99abc7682f93f182d874e95ea07 Mon Sep 17 00:00:00 2001 From: Tim Hess Date: Wed, 23 May 2018 10:25:19 -0500 Subject: [PATCH 181/248] Include AuthenticationTicket.Properties in AuthenticationTicket success result handling #1765 (#1767) --- src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs index 3f6c2d917..da9b6ea01 100644 --- a/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs @@ -33,7 +33,7 @@ public class HandleRequestResult : AuthenticateResult { throw new ArgumentNullException(nameof(ticket)); } - return new HandleRequestResult() { Ticket = ticket }; + return new HandleRequestResult() { Ticket = ticket, Properties = ticket.Properties }; } /// From 9ee5ed4bf908bf09fce2d4d4797a908cc927b72c Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 23 May 2018 15:35:23 -0700 Subject: [PATCH 182/248] Bumping version from 2.1.0 to 2.1.1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index b9552451d..669c87482 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@ - + - 2.1.0 + 2.1.1 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From 20a4aa0bb093b8617b1a30dab1ded2eda460d3e0 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Fri, 25 May 2018 16:17:12 -0700 Subject: [PATCH 183/248] Update bootstrapper scripts (automated commit) [ci skip] --- run.ps1 | 25 +++++++++++++++++++------ run.sh | 33 +++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/run.ps1 b/run.ps1 index 27dcf848f..3b2738246 100644 --- a/run.ps1 +++ b/run.ps1 @@ -26,12 +26,18 @@ The base url where build tools can be downloaded. Overrides the value from the c .PARAMETER Update Updates KoreBuild to the latest version even if a lock file is present. +.PARAMETER Reinstall +Re-installs KoreBuild + .PARAMETER ConfigFile The path to the configuration file that stores values. Defaults to korebuild.json. .PARAMETER ToolsSourceSuffix The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. +.PARAMETER CI +Sets up CI specific settings and variables. + .PARAMETER Arguments Arguments to be passed to the command @@ -65,8 +71,10 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile, + [switch]$Reinstall, [string]$ToolsSourceSuffix, + [string]$ConfigFile = $null, + [switch]$CI, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -93,6 +101,10 @@ function Get-KoreBuild { $version = $version.TrimStart('version:').Trim() $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + if ($Reinstall -and (Test-Path $korebuildPath)) { + Remove-Item -Force -Recurse $korebuildPath + } + if (!(Test-Path $korebuildPath)) { Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" New-Item -ItemType Directory -Path $korebuildPath | Out-Null @@ -101,9 +113,9 @@ function Get-KoreBuild { try { $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { + if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) { # Use built-in commands where possible as they are cross-plat compatible - Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath + Microsoft.PowerShell.Archive\Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath } else { # Fallback to old approach for old installations of PowerShell @@ -167,8 +179,9 @@ if (Test-Path $ConfigFile) { } } catch { - Write-Warning "$ConfigFile could not be read. Its settings will be ignored." - Write-Warning $Error[0] + Write-Host -ForegroundColor Red $Error[0] + Write-Error "$ConfigFile contains invalid JSON." + exit 1 } } @@ -188,7 +201,7 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI Invoke-KoreBuildCommand $Command @Arguments } finally { diff --git a/run.sh b/run.sh index 834961fc3..02aac1587 100755 --- a/run.sh +++ b/run.sh @@ -14,10 +14,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" [ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" verbose=false update=false +reinstall=false repo_path="$DIR" channel='' tools_source='' tools_source_suffix='' +ci=false # # Functions @@ -38,6 +40,8 @@ __usage() { echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo " --reinstall Reinstall KoreBuild." + echo " --ci Apply CI specific settings and environment variables." echo "" echo "Description:" echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." @@ -62,6 +66,10 @@ get_korebuild() { version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then + rm -rf "$korebuild_path" + fi + { if [ ! -d "$korebuild_path" ]; then mkdir -p "$korebuild_path" @@ -175,6 +183,12 @@ while [[ $# -gt 0 ]]; do -u|--update|-Update) update=true ;; + --reinstall|-[Rr]einstall) + reinstall=true + ;; + --ci|-[Cc][Ii]) + ci=true + ;; --verbose|-Verbose) verbose=true ;; @@ -206,17 +220,28 @@ if [ -f "$config_file" ]; then config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" else - __warn "$config_file is invalid JSON. Its settings will be ignored." + _error "$config_file contains invalid JSON." + exit 1 fi elif __machine_has python ; then if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" else - __warn "$config_file is invalid JSON. Its settings will be ignored." + _error "$config_file contains invalid JSON." + exit 1 + fi + elif __machine_has python3 ; then + if python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then + config_channel="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" + config_tools_source="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" + else + _error "$config_file contains invalid JSON." + exit 1 fi else - __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' + _error 'Missing required command: jq or python. Could not parse the JSON file.' + exit 1 fi [ ! -z "${config_channel:-}" ] && channel="$config_channel" @@ -227,5 +252,5 @@ fi [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci" invoke_korebuild_command "$command" "$@" From 12e9585faf69e1ea9eee5f09a8620ccfe4666091 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 27 May 2018 19:28:55 +0000 Subject: [PATCH 184/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index b839b4984..af20bdc47 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17060 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 + 2.2.0-preview1-17064 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 3.14.2 5.2.0 5.2.0 2.0.0 2.1.0-rc1 - 2.2.0-preview1-26509-06 + 2.2.0-preview1-26526-03 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index cf2fff7de..3028b6676 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17060 -commithash:25b4b134d6f8f7b461928f0d495cfc695ccabb5b +version:2.2.0-preview1-17064 +commithash:5380a2461b135b261646f31d1c919ab0a7b577a8 From e538375c443a11d96370eb767fce7bb559e00dc9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 29 May 2018 09:52:21 -0700 Subject: [PATCH 185/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d55f378cc..7d3788a5b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rtm-15783 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 + 2.1.1-rtm-15790 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-rtm-26502-02 + 2.1.0 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3673744db..cd5b409a1 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rtm-15783 -commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 +version:2.1.1-rtm-15790 +commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 From 0d4438d4c9bbcacf985452f5c27066dff52cb4a0 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 3 Jun 2018 19:28:12 +0000 Subject: [PATCH 186/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index af20bdc47..c31e4c85e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17064 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 + 2.2.0-preview1-17067 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0-rc1 - 2.2.0-preview1-26526-03 + 2.1.0 + 2.2.0-preview1-26531-03 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3028b6676..06ba6285b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17064 -commithash:5380a2461b135b261646f31d1c919ab0a7b577a8 +version:2.2.0-preview1-17067 +commithash:2af0e2e3d02329b4f0290061ab9bd8c7ca1aa26f From 569eef4f7d255cbf23eb36cde69df01c0ce47105 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 5 Jun 2018 22:35:03 -0700 Subject: [PATCH 187/248] Add certificate names for code signing --- Directory.Build.props | 2 ++ korebuild-lock.txt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index adbda10ef..91cd995d7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,6 +14,8 @@ $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true + Microsoft + MicrosoftNuGet true true diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 06ba6285b..b679b8042 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17067 -commithash:2af0e2e3d02329b4f0290061ab9bd8c7ca1aa26f +version:2.2.0-preview1-17075 +commithash:d9f07c7f313a0af1d49f003f5424b4dbbdd3e09f From 38004ce37a6f006df950c9dcd7a566e5e1bcb631 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 7 Jun 2018 19:47:27 +0000 Subject: [PATCH 188/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c31e4c85e..81399c5d7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17067 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 + 2.2.0-preview1-17081 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 3.14.2 5.2.0 5.2.0 2.0.0 2.1.0 - 2.2.0-preview1-26531-03 + 2.2.0-preview1-26606-01 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b679b8042..deb7e546f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17075 -commithash:d9f07c7f313a0af1d49f003f5424b4dbbdd3e09f +version:2.2.0-preview1-17081 +commithash:73f09c256e2a54270951562ecc0ef4a953926c36 From cabaaef2ab834b61548a701858f5b0e83f94bead Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 7 Jun 2018 15:48:06 -0700 Subject: [PATCH 189/248] Adding VSTS file --- .vsts-pipelines/builds/ci-internal.yml | 13 +++++++++++++ .vsts-pipelines/builds/ci-public.yml | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .vsts-pipelines/builds/ci-internal.yml create mode 100644 .vsts-pipelines/builds/ci-public.yml diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml new file mode 100644 index 000000000..d7ceb7637 --- /dev/null +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -0,0 +1,13 @@ +trigger: +- dev +- release/* + +resources: + repositories: + - repository: buildtools + type: git + name: aspnet-BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml new file mode 100644 index 000000000..b7f25723f --- /dev/null +++ b/.vsts-pipelines/builds/ci-public.yml @@ -0,0 +1,15 @@ +trigger: +- dev +- release/* + +# See https://github.com/aspnet/BuildTools +resources: + repositories: + - repository: buildtools + type: github + endpoint: DotNet-Bot GitHub Connection + name: aspnet/BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/project-ci.yml@buildtools From ac1a9ef6d183a94646a4b5e57b7be1c6e53b5605 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 12 Jun 2018 19:33:42 +0000 Subject: [PATCH 190/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7d3788a5b..6fd8fd099 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.1-rtm-15790 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 + 2.1.1-rtm-15793 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 3.14.2 5.2.0 5.2.0 2.0.0 - 2.1.0 + 2.1.1 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index cd5b409a1..bc84e0cd5 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15790 -commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 +version:2.1.1-rtm-15793 +commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a From b8a488bf9e44e0f03c6c072756568b19859dc225 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 14 Jun 2018 10:30:43 -0700 Subject: [PATCH 191/248] Set 2.1 baselines --- .../baseline.netcore.json | 20 +- .../breakingchanges.netcore.json | 6 - .../baseline.netcore.json | 84 ++- .../baseline.netcore.json | 278 ++++++- .../baseline.netcore.json | 96 ++- .../baseline.netcore.json | 59 +- .../baseline.netcore.json | 202 ++++- .../baseline.netcore.json | 208 ++++- .../baseline.netcore.json | 128 +++- .../baseline.netcore.json | 24 +- .../baseline.netcore.json | 714 ++++++++++++++++-- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 138 +++- .../baseline.netframework.json | 2 +- 14 files changed, 1831 insertions(+), 130 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json index 52fa29be9..b218669b7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.CookieExtensions", @@ -239,10 +239,8 @@ "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler" - ], + "BaseType": "Microsoft.AspNetCore.Authentication.SignInAuthenticationHandler", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -306,7 +304,7 @@ }, { "Kind": "Method", - "Name": "SignInAsync", + "Name": "HandleSignInAsync", "Parameters": [ { "Name": "user", @@ -319,13 +317,13 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SignOutAsync", + "Name": "HandleSignOutAsync", "Parameters": [ { "Name": "properties", @@ -334,8 +332,8 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json deleted file mode 100644 index 7673fc1a0..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json +++ /dev/null @@ -1,6 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler, Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json index 2500e5fb5..5d95efca6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions", @@ -160,6 +160,88 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [ + { + "Name": "scopes", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json index edaade326..0a623b3b8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.GoogleExtensions", @@ -97,6 +97,206 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleChallengeProperties", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthChallengeProperties", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AccessType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ApprovalPrompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ApprovalPrompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IncludeGrantedScopes", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IncludeGrantedScopes", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_LoginHint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_LoginHint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Prompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Prompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + }, + { + "Name": "parameters", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessTypeKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "ApprovalPromptKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "IncludeGrantedScopesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "LoginHintKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "PromptParameterKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", "Visibility": "Public", @@ -160,6 +360,82 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "BuildChallengeUrl", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json index 44fc928ca..d3839022b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.JwtBearerExtensions", @@ -609,6 +609,100 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json index 966f7e1b1..877e9035a 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions", @@ -160,6 +160,63 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json index 142e37c6b..9c2394704 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OAuthExtensions", @@ -417,6 +417,41 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "MapAll", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapAllExcept", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "exclusions", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "DeleteClaim", @@ -435,6 +470,26 @@ "Extension": true, "Visibility": "Public", "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteClaims", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimTypes", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] } ], "GenericParameters": [] @@ -697,6 +752,97 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthChallengeProperties", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Scope", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Scope", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.ICollection" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SetScope", + "Parameters": [ + { + "Name": "scopes", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + }, + { + "Name": "parameters", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "ScopeKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthDefaults", "Visibility": "Public", @@ -848,6 +994,20 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [ + { + "Name": "scopes", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "FormatScope", @@ -1605,6 +1765,46 @@ } ], "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.MapAllClaimsAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Run", + "Parameters": [ + { + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] } ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json index a57e2eb87..d5c10d18d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OpenIdConnectExtensions", @@ -637,6 +637,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_OnSignedOutCallbackRedirect", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSignedOutCallbackRedirect", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_OnRemoteSignOut", @@ -791,6 +812,20 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "SignedOutCallbackRedirect", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "RemoteSignOut", @@ -1265,6 +1300,113 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectChallengeProperties", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthChallengeProperties", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_MaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Prompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Prompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + }, + { + "Name": "parameters", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "MaxAgeKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "PromptKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", "Visibility": "Public", @@ -1347,6 +1489,17 @@ "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" ], "Members": [ + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Backchannel", @@ -1394,17 +1547,6 @@ "Visibility": "Protected", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "HandleRemoteSignOutAsync", @@ -1748,6 +1890,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_MaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_ProtocolValidator", @@ -1916,6 +2079,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Prompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Prompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Scope", diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json index 196b85372..03ee64562 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.TwitterExtensions", @@ -600,6 +600,122 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "token", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.AccessToken" + }, + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions", "Visibility": "Public", @@ -741,6 +857,16 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json index 5a8110fbc..41150cbc0 100644 --- a/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.WsFederation, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.WsFederation, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.WsFederationExtensions", @@ -765,6 +765,17 @@ "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" ], "Members": [ + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Events", @@ -796,17 +807,6 @@ "Visibility": "Protected", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "HandleChallengeAsync", diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json index a6082e8c4..08eeb5e7b 100644 --- a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", @@ -126,6 +126,28 @@ } ] }, + { + "Kind": "Method", + "Name": "AddPolicyScheme", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -338,6 +360,20 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "ResolveTarget", + "Parameters": [ + { + "Name": "scheme", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "AuthenticateAsync", @@ -545,6 +581,20 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [ + { + "Name": "scheme", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_ClaimsIssuer", @@ -608,6 +658,153 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ForwardDefault", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardDefault", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardAuthenticate", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardAuthenticate", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardChallenge", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardChallenge", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardForbid", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardForbid", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardSignIn", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardSignIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardSignOut", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardSignOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardDefaultSelector", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardDefaultSelector", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -1752,6 +1949,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -1966,59 +2184,313 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_UtcNow", + "Name": "get_Handled", "Parameters": [], - "ReturnType": "System.DateTimeOffset", + "ReturnType": "System.Boolean", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler" - ], - "Members": [ + }, { "Kind": "Method", - "Name": "get_SignInScheme", + "Name": "get_Skipped", "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Protected", + "ReturnType": "System.Boolean", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "Visibility": "Protected", + "Name": "Success", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Events", + "Name": "Fail", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "System.Void", - "Visibility": "Protected", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failure", + "Type": "System.Exception" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Handle", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PolicySchemeHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.SignInAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleForbiddenAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignInAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PolicySchemeOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_SignInScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", "GenericParameter": [] }, { @@ -2156,6 +2628,21 @@ "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [ + { + "Name": "scheme", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "Validate", @@ -2387,97 +2874,164 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Name": "Microsoft.AspNetCore.Authentication.SignInAuthenticationHandler", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "ImplementedInterfaces": [], + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.SignOutAuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler" + ], "Members": [ { "Kind": "Method", - "Name": "get_Handled", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Success", + "Name": "SignInAsync", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Fail", + "Name": "HandleSignInAsync", "Parameters": [ { - "Name": "failure", - "Type": "System.Exception" + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Fail", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "failureMessage", - "Type": "System.String" + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SignOutAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" + ], + "Members": [ { "Kind": "Method", - "Name": "Handle", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SkipHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], "Visibility": "Public", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] }, { "Name": "Microsoft.AspNetCore.Authentication.SystemClock", diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json index a2a971f82..e8708538d 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json index 050546810..01a16c57a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", @@ -116,6 +116,48 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ConsentCookie", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConsentCookie", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CheckConsentNeeded", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CheckConsentNeeded", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_OnAppendCookie", @@ -232,6 +274,43 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_IsConsentNeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasConsent", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IssueCookie", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IssueCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -299,6 +378,26 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "factory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -361,6 +460,43 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_IsConsentNeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasConsent", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IssueCookie", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IssueCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json index 65256bed6..bfc0c0076 100644 --- a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json +++ b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", From aa24887d4371660fdf1e2100a0c1d9957d42fb63 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 14 Jun 2018 10:30:43 -0700 Subject: [PATCH 192/248] Set 2.1 baselines --- .../baseline.netcore.json | 20 +- .../breakingchanges.netcore.json | 6 - .../baseline.netcore.json | 84 ++- .../baseline.netcore.json | 278 ++++++- .../baseline.netcore.json | 96 ++- .../baseline.netcore.json | 59 +- .../baseline.netcore.json | 202 ++++- .../baseline.netcore.json | 208 ++++- .../baseline.netcore.json | 128 +++- .../baseline.netcore.json | 24 +- .../baseline.netcore.json | 714 ++++++++++++++++-- .../baseline.netcore.json | 2 +- .../baseline.netcore.json | 138 +++- .../baseline.netframework.json | 2 +- 14 files changed, 1831 insertions(+), 130 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json index 52fa29be9..b218669b7 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Cookies, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.CookieExtensions", @@ -239,10 +239,8 @@ "Name": "Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler" - ], + "BaseType": "Microsoft.AspNetCore.Authentication.SignInAuthenticationHandler", + "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", @@ -306,7 +304,7 @@ }, { "Kind": "Method", - "Name": "SignInAsync", + "Name": "HandleSignInAsync", "Parameters": [ { "Name": "user", @@ -319,13 +317,13 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SignOutAsync", + "Name": "HandleSignOutAsync", "Parameters": [ { "Name": "properties", @@ -334,8 +332,8 @@ ], "ReturnType": "System.Threading.Tasks.Task", "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", - "Visibility": "Public", + "Override": true, + "Visibility": "Protected", "GenericParameter": [] }, { diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json deleted file mode 100644 index 7673fc1a0..000000000 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json +++ /dev/null @@ -1,6 +0,0 @@ - [ - { - "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler, Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", - "Kind": "Removal" - } - ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json index 2500e5fb5..5d95efca6 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Facebook, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.FacebookAuthenticationOptionsExtensions", @@ -160,6 +160,88 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [ + { + "Name": "scopes", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Facebook.FacebookOptions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json index edaade326..0a623b3b8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Google/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Google, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.GoogleExtensions", @@ -97,6 +97,206 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleChallengeProperties", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthChallengeProperties", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AccessType", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AccessType", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ApprovalPrompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ApprovalPrompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IncludeGrantedScopes", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IncludeGrantedScopes", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_LoginHint", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_LoginHint", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Prompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Prompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + }, + { + "Name": "parameters", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessTypeKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "ApprovalPromptKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "IncludeGrantedScopesKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "LoginHintKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "PromptParameterKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleDefaults", "Visibility": "Public", @@ -160,6 +360,82 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "BuildChallengeUrl", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "redirectUri", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Google.GoogleHelper", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json index 44fc928ca..d3839022b 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.JwtBearer, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.JwtBearerExtensions", @@ -609,6 +609,100 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "dataProtection", + "Type": "Microsoft.AspNetCore.DataProtection.IDataProtectionProvider" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerOptions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json index 966f7e1b1..877e9035a 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.MicrosoftAccount, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.MicrosoftAccountExtensions", @@ -160,6 +160,63 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "tokens", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.OAuthTokenResponse" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.MicrosoftAccount.MicrosoftAccountOptions", "Visibility": "Public", diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json index 142e37c6b..9c2394704 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OAuth, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OAuthExtensions", @@ -417,6 +417,41 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "MapAll", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "MapAllExcept", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "exclusions", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "DeleteClaim", @@ -435,6 +470,26 @@ "Extension": true, "Visibility": "Public", "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DeleteClaims", + "Parameters": [ + { + "Name": "collection", + "Type": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimActionCollection" + }, + { + "Name": "claimTypes", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "System.Void", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] } ], "GenericParameters": [] @@ -697,6 +752,97 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthChallengeProperties", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Scope", + "Parameters": [], + "ReturnType": "System.Collections.Generic.ICollection", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Scope", + "Parameters": [ + { + "Name": "value", + "Type": "System.Collections.Generic.ICollection" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SetScope", + "Parameters": [ + { + "Name": "scopes", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + }, + { + "Name": "parameters", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "ScopeKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.OAuth.OAuthDefaults", "Visibility": "Public", @@ -848,6 +994,20 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "FormatScope", + "Parameters": [ + { + "Name": "scopes", + "Type": "System.Collections.Generic.IEnumerable" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "FormatScope", @@ -1605,6 +1765,46 @@ } ], "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.OAuth.Claims.MapAllClaimsAction", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.Claims.ClaimAction", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Run", + "Parameters": [ + { + "Name": "userData", + "Type": "Newtonsoft.Json.Linq.JObject" + }, + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "issuer", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] } ] } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json index a57e2eb87..d5c10d18d 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.OpenIdConnect, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.OpenIdConnectExtensions", @@ -637,6 +637,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_OnSignedOutCallbackRedirect", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_OnSignedOutCallbackRedirect", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_OnRemoteSignOut", @@ -791,6 +812,20 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "SignedOutCallbackRedirect", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Authentication.OpenIdConnect.RemoteSignOutContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "RemoteSignOut", @@ -1265,6 +1300,113 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectChallengeProperties", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.OAuth.OAuthChallengeProperties", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_MaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Prompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Prompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "items", + "Type": "System.Collections.Generic.IDictionary" + }, + { + "Name": "parameters", + "Type": "System.Collections.Generic.IDictionary" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "MaxAgeKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "PromptKey", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectDefaults", "Visibility": "Public", @@ -1347,6 +1489,17 @@ "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" ], "Members": [ + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Backchannel", @@ -1394,17 +1547,6 @@ "Visibility": "Protected", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "HandleRemoteSignOutAsync", @@ -1748,6 +1890,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_MaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_MaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_ProtocolValidator", @@ -1916,6 +2079,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Prompt", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Prompt", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Scope", diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json index 196b85372..03ee64562 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.Twitter, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.TwitterExtensions", @@ -600,6 +600,122 @@ ], "GenericParameters": [] }, + { + "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.TwitterEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateEventsAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleRemoteAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateTicketAsync", + "Parameters": [ + { + "Name": "identity", + "Type": "System.Security.Claims.ClaimsIdentity" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + }, + { + "Name": "token", + "Type": "Microsoft.AspNetCore.Authentication.Twitter.AccessToken" + }, + { + "Name": "user", + "Type": "Newtonsoft.Json.Linq.JObject" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, { "Name": "Microsoft.AspNetCore.Authentication.Twitter.TwitterOptions", "Visibility": "Public", @@ -741,6 +857,16 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json index 5a8110fbc..41150cbc0 100644 --- a/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.WsFederation, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication.WsFederation, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Extensions.DependencyInjection.WsFederationExtensions", @@ -765,6 +765,17 @@ "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" ], "Members": [ + { + "Kind": "Method", + "Name": "HandleRequestAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_Events", @@ -796,17 +807,6 @@ "Visibility": "Protected", "GenericParameter": [] }, - { - "Kind": "Method", - "Name": "HandleRequestAsync", - "Parameters": [], - "ReturnType": "System.Threading.Tasks.Task", - "Virtual": true, - "Override": true, - "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler", - "Visibility": "Public", - "GenericParameter": [] - }, { "Kind": "Method", "Name": "HandleChallengeAsync", diff --git a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json index a6082e8c4..08eeb5e7b 100644 --- a/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authentication/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authentication, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", @@ -126,6 +126,28 @@ } ] }, + { + "Kind": "Method", + "Name": "AddPolicyScheme", + "Parameters": [ + { + "Name": "authenticationScheme", + "Type": "System.String" + }, + { + "Name": "displayName", + "Type": "System.String" + }, + { + "Name": "configureOptions", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationBuilder", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -338,6 +360,20 @@ "Visibility": "Protected", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "ResolveTarget", + "Parameters": [ + { + "Name": "scheme", + "Type": "System.String" + } + ], + "ReturnType": "System.String", + "Virtual": true, + "Visibility": "Protected", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "AuthenticateAsync", @@ -545,6 +581,20 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [ + { + "Name": "scheme", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_ClaimsIssuer", @@ -608,6 +658,153 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ForwardDefault", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardDefault", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardAuthenticate", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardAuthenticate", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardChallenge", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardChallenge", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardForbid", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardForbid", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardSignIn", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardSignIn", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardSignOut", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardSignOut", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ForwardDefaultSelector", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ForwardDefaultSelector", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -1752,6 +1949,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_Properties", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.AuthenticationProperties", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Properties", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -1966,59 +2184,313 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", "ImplementedInterfaces": [], "Members": [ { "Kind": "Method", - "Name": "get_UtcNow", + "Name": "get_Handled", "Parameters": [], - "ReturnType": "System.DateTimeOffset", + "ReturnType": "System.Boolean", + "Visibility": "Public", "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler" - ], - "Members": [ + }, { "Kind": "Method", - "Name": "get_SignInScheme", + "Name": "get_Skipped", "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Protected", + "ReturnType": "System.Boolean", + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "get_Events", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", - "Visibility": "Protected", + "Name": "Success", + "Parameters": [ + { + "Name": "ticket", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "set_Events", + "Name": "Fail", "Parameters": [ { - "Name": "value", - "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" + "Name": "failure", + "Type": "System.Exception" } ], - "ReturnType": "System.Void", - "Visibility": "Protected", + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failure", + "Type": "System.Exception" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Fail", + "Parameters": [ + { + "Name": "failureMessage", + "Type": "System.String" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Handle", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SkipHandler", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.ISystemClock", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_UtcNow", + "Parameters": [], + "ReturnType": "System.DateTimeOffset", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PolicySchemeHandler", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.SignInAuthenticationHandler", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "HandleChallengeAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleForbiddenAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignInAsync", + "Parameters": [ + { + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "HandleAuthenticateAsync", + "Parameters": [], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Override": true, + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.PolicySchemeOptions", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationRequestHandler" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_SignInScheme", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Events", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents", + "Visibility": "Protected", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_Events", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Authentication.RemoteAuthenticationEvents" + } + ], + "ReturnType": "System.Void", + "Visibility": "Protected", "GenericParameter": [] }, { @@ -2156,6 +2628,21 @@ "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "Validate", + "Parameters": [ + { + "Name": "scheme", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "Validate", @@ -2387,97 +2874,164 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.Authentication.HandleRequestResult", + "Name": "Microsoft.AspNetCore.Authentication.SignInAuthenticationHandler", "Visibility": "Public", "Kind": "Class", - "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticateResult", - "ImplementedInterfaces": [], + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.SignOutAuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler" + ], "Members": [ { "Kind": "Method", - "Name": "get_Handled", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Skipped", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Success", + "Name": "SignInAsync", "Parameters": [ { - "Name": "ticket", - "Type": "Microsoft.AspNetCore.Authentication.AuthenticationTicket" + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignInHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "Fail", + "Name": "HandleSignInAsync", "Parameters": [ { - "Name": "failure", - "Type": "System.Exception" + "Name": "user", + "Type": "System.Security.Claims.ClaimsPrincipal" + }, + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", "GenericParameter": [] }, { - "Kind": "Method", - "Name": "Fail", + "Kind": "Constructor", + "Name": ".ctor", "Parameters": [ { - "Name": "failureMessage", - "Type": "System.String" + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" } ], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, "Visibility": "Public", "GenericParameter": [] - }, + } + ], + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] + }, + { + "Name": "Microsoft.AspNetCore.Authentication.SignOutAuthenticationHandler", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "BaseType": "Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler" + ], + "Members": [ { "Kind": "Method", - "Name": "Handle", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, + "Name": "SignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Authentication.IAuthenticationSignOutHandler", "Visibility": "Public", "GenericParameter": [] }, { "Kind": "Method", - "Name": "SkipHandler", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Authentication.HandleRequestResult", - "Static": true, - "Visibility": "Public", + "Name": "HandleSignOutAsync", + "Parameters": [ + { + "Name": "properties", + "Type": "Microsoft.AspNetCore.Authentication.AuthenticationProperties" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Virtual": true, + "Abstract": true, + "Visibility": "Protected", "GenericParameter": [] }, { "Kind": "Constructor", "Name": ".ctor", - "Parameters": [], + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptionsMonitor" + }, + { + "Name": "logger", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + }, + { + "Name": "encoder", + "Type": "System.Text.Encodings.Web.UrlEncoder" + }, + { + "Name": "clock", + "Type": "Microsoft.AspNetCore.Authentication.ISystemClock" + } + ], "Visibility": "Public", "GenericParameter": [] } ], - "GenericParameters": [] + "GenericParameters": [ + { + "ParameterName": "TOptions", + "ParameterPosition": 0, + "New": true, + "BaseTypeOrInterfaces": [ + "Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions" + ] + } + ] }, { "Name": "Microsoft.AspNetCore.Authentication.SystemClock", diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json index a2a971f82..e8708538d 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Authorization.Policy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Authorization.Policy, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Authorization.Policy.IPolicyEvaluator", diff --git a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json index 050546810..01a16c57a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.CookiePolicy/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.CookiePolicy, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions", @@ -116,6 +116,48 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_ConsentCookie", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Http.CookieBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_ConsentCookie", + "Parameters": [ + { + "Name": "value", + "Type": "Microsoft.AspNetCore.Http.CookieBuilder" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_CheckConsentNeeded", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_CheckConsentNeeded", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_OnAppendCookie", @@ -232,6 +274,43 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_IsConsentNeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasConsent", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IssueCookie", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IssueCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -299,6 +378,26 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "factory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -361,6 +460,43 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_IsConsentNeeded", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_HasConsent", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_IssueCookie", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IssueCookie", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", diff --git a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json index 65256bed6..bfc0c0076 100644 --- a/src/Microsoft.Owin.Security.Interop/baseline.netframework.json +++ b/src/Microsoft.Owin.Security.Interop/baseline.netframework.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.Owin.Security.Interop, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.Owin.Security.Interop.AspNetTicketDataFormat", From d8821d7eb120744f5439bcf85ad39c72537e85d3 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 25 Jun 2018 11:29:05 -0700 Subject: [PATCH 193/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 81399c5d7..db9d0bec1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17081 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 + 2.2.0-preview1-17090 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 3.14.2 5.2.0 5.2.0 2.0.0 2.1.0 - 2.2.0-preview1-26606-01 + 2.2.0-preview1-26618-02 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index deb7e546f..a8109db52 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17081 -commithash:73f09c256e2a54270951562ecc0ef4a953926c36 +version:2.2.0-preview1-17090 +commithash:b19e903e946579cd9482089bce7d917e8bacd765 From 26fbad061475e4cf8d27d0e364048a924ead953b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 27 Jun 2018 13:39:51 -0700 Subject: [PATCH 194/248] Bumping version from 2.1.1 to 2.1.2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 669c87482..478dfd16e 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.1 + 2.1.2 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From 866b0b66a4f06fd7aba74f12f20e14f4f153e30b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 28 Jun 2018 16:21:46 -0700 Subject: [PATCH 195/248] Update infrastructure for the 2.2 release --- .vsts-pipelines/builds/ci-internal.yml | 4 ++-- .vsts-pipelines/builds/ci-public.yml | 6 +++--- build/repo.props | 1 + korebuild.json | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml index d7ceb7637..dc7b8a3cb 100644 --- a/.vsts-pipelines/builds/ci-internal.yml +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* resources: @@ -7,7 +7,7 @@ resources: - repository: buildtools type: git name: aspnet-BuildTools - ref: refs/heads/dev + ref: refs/heads/release/2.2 phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml index b7f25723f..f5087d9c3 100644 --- a/.vsts-pipelines/builds/ci-public.yml +++ b/.vsts-pipelines/builds/ci-public.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* # See https://github.com/aspnet/BuildTools @@ -9,7 +9,7 @@ resources: type: github endpoint: DotNet-Bot GitHub Connection name: aspnet/BuildTools - ref: refs/heads/dev - + ref: refs/heads/release/2.2 + phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/build/repo.props b/build/repo.props index 6fc6af601..077c753e6 100644 --- a/build/repo.props +++ b/build/repo.props @@ -7,6 +7,7 @@ Internal.AspNetCore.Universe.Lineup + 2.2.0-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/korebuild.json b/korebuild.json index bd5d51a51..d217d06e3 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.2/tools/korebuild.schema.json", + "channel": "release/2.2" } From 7229c6086603d424ce14a3870d654228128ac6c6 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 28 Jun 2018 16:48:58 -0700 Subject: [PATCH 196/248] Bumping version from 2.2.0 to 3.0.0 --- version.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.props b/version.props index 44985cedb..71a78cddd 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - + - 2.2.0 - preview1 + 3.0.0 + alpha1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 238f461488746608108d2358a2a3ad3a1117ee9f Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Mon, 2 Jul 2018 12:40:35 -0700 Subject: [PATCH 197/248] [automated] Change default branch to master --- .appveyor.yml | 2 +- .travis.yml | 2 +- .vsts-pipelines/builds/ci-internal.yml | 4 ++-- .vsts-pipelines/builds/ci-public.yml | 6 +++--- korebuild.json | 4 ++-- run.ps1 | 6 +++--- run.sh | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 4eea96ab6..d45bd5a1f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ init: - git config --global core.autocrlf true branches: only: - - dev + - master - /^release\/.*$/ - /^(.*\/)?ci-.*$/ build_script: diff --git a/.travis.yml b/.travis.yml index 64bdbb444..ab3980055 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ addons: - libunwind8 branches: only: - - dev + - master - /^release\/.*$/ - /^(.*\/)?ci-.*$/ before_install: diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml index d7ceb7637..c2c5336fd 100644 --- a/.vsts-pipelines/builds/ci-internal.yml +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* resources: @@ -7,7 +7,7 @@ resources: - repository: buildtools type: git name: aspnet-BuildTools - ref: refs/heads/dev + ref: refs/heads/master phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml index b7f25723f..507c89b02 100644 --- a/.vsts-pipelines/builds/ci-public.yml +++ b/.vsts-pipelines/builds/ci-public.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* # See https://github.com/aspnet/BuildTools @@ -9,7 +9,7 @@ resources: type: github endpoint: DotNet-Bot GitHub Connection name: aspnet/BuildTools - ref: refs/heads/dev - + ref: refs/heads/master + phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/korebuild.json b/korebuild.json index bd5d51a51..8a276a7f3 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", + "channel": "master" } diff --git a/run.ps1 b/run.ps1 index 3b2738246..34604c717 100644 --- a/run.ps1 +++ b/run.ps1 @@ -52,8 +52,8 @@ in the file are overridden by command line parameters. Example config file: ```json { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", + "channel": "master", "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" } ``` @@ -192,7 +192,7 @@ if (!$DotNetHome) { else { Join-Path $PSScriptRoot '.dotnet'} } -if (!$Channel) { $Channel = 'dev' } +if (!$Channel) { $Channel = 'master' } if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } # Execute diff --git a/run.sh b/run.sh index 02aac1587..61f7a5338 100755 --- a/run.sh +++ b/run.sh @@ -248,7 +248,7 @@ if [ -f "$config_file" ]; then [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" fi -[ -z "$channel" ] && channel='dev' +[ -z "$channel" ] && channel='master' [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild From d0d72782745edc41c79c501ff2210058a4eadb46 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 3 Jul 2018 16:27:20 +0000 Subject: [PATCH 198/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index db9d0bec1..5b20d12ff 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17090 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 + 3.0.0-alpha1-10000 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 + 3.0.0-alpha1-10016 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a8109db52..f0b76184f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17090 -commithash:b19e903e946579cd9482089bce7d917e8bacd765 +version:3.0.0-alpha1-10000 +commithash:b7b88d08d55abc8b71de9abf16e26fc713e332cd From 8b30c7359769cd9e3360c065d610598aa99da0c6 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 8 Jul 2018 12:28:09 -0700 Subject: [PATCH 199/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 60 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index db9d0bec1..7186de797 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17090 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 + 2.2.0-preview1-17099 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 3.14.2 5.2.0 5.2.0 - 2.0.0 - 2.1.0 + 2.0.7 + 2.1.1 2.2.0-preview1-26618-02 15.6.1 3.0.1 @@ -45,7 +45,7 @@ 5.2.0 0.8.0 2.3.1 - 2.4.0-beta.1.build3945 + 2.4.0-rc.1.build4038 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a8109db52..27e2e80f9 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17090 -commithash:b19e903e946579cd9482089bce7d917e8bacd765 +version:2.2.0-preview1-17099 +commithash:263ed1db9866b6b419b1f5d5189a712aa218acb3 From 36276e737842267ebb88a2cacb7c6223e117da6d Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 8 Jul 2018 20:09:29 +0000 Subject: [PATCH 200/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5b20d12ff..f013f62a6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10000 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 - 3.0.0-alpha1-10016 + 3.0.0-alpha1-10005 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 + 3.0.0-alpha1-10044 3.14.2 5.2.0 5.2.0 @@ -45,7 +45,7 @@ 5.2.0 0.8.0 2.3.1 - 2.4.0-beta.1.build3945 + 2.4.0-rc.1.build4038 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index f0b76184f..f357ac9f7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10000 -commithash:b7b88d08d55abc8b71de9abf16e26fc713e332cd +version:3.0.0-alpha1-10005 +commithash:05570853de976a526462ca140a55b1ac59d9a351 From d2a8d3a61c4f393170be4f6e49b287d0f3a4d96d Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 11 Jul 2018 13:14:51 -0700 Subject: [PATCH 201/248] Fix cookie regression (#1811) --- .../CookieAuthenticationHandler.cs | 11 +-- .../CookieTests.cs | 84 +++++++++++++++++++ 2 files changed, 90 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 343cf1b3a..b77a51ef4 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -85,7 +85,7 @@ private void CheckForRefresh(AuthenticationTicket ticket) } } - private void RequestRefresh(AuthenticationTicket ticket) + private void RequestRefresh(AuthenticationTicket ticket, ClaimsPrincipal replacedPrincipal = null) { var issuedUtc = ticket.Properties.IssuedUtc; var expiresUtc = ticket.Properties.ExpiresUtc; @@ -97,14 +97,15 @@ private void RequestRefresh(AuthenticationTicket ticket) _refreshIssuedUtc = currentUtc; var timeSpan = expiresUtc.Value.Subtract(issuedUtc.Value); _refreshExpiresUtc = currentUtc.Add(timeSpan); - _refreshTicket = CloneTicket(ticket); + _refreshTicket = CloneTicket(ticket, replacedPrincipal); } } - private AuthenticationTicket CloneTicket(AuthenticationTicket ticket) + private AuthenticationTicket CloneTicket(AuthenticationTicket ticket, ClaimsPrincipal replacedPrincipal) { + var principal = replacedPrincipal ?? ticket.Principal; var newPrincipal = new ClaimsPrincipal(); - foreach (var identity in ticket.Principal.Identities) + foreach (var identity in principal.Identities) { newPrincipal.AddIdentity(identity.Clone()); } @@ -183,7 +184,7 @@ protected override async Task HandleAuthenticateAsync() if (context.ShouldRenew) { - RequestRefresh(result.Ticket); + RequestRefresh(result.Ticket, context.Principal); } return AuthenticateResult.Success(new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name)); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 945ec82ee..766d1e2e5 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -900,6 +900,80 @@ public async Task CookieCanBeRenewedByValidator() Assert.Null(FindClaimValue(transaction5, ClaimTypes.Name)); } + [Fact] + public async Task CookieCanBeReplacedByValidator() + { + var server = CreateServer(o => + { + o.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = ctx => + { + ctx.ShouldRenew = true; + ctx.ReplacePrincipal(new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice2", "Cookies2")))); + return Task.FromResult(0); + } + }; + }, + context => + context.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction2.SetCookie); + Assert.Equal("Alice2", FindClaimValue(transaction2, ClaimTypes.Name)); + } + + [Fact] + public async Task CookieCanBeUpdatedByValidatorDuringRefresh() + { + var replace = false; + var server = CreateServer(o => + { + o.ExpireTimeSpan = TimeSpan.FromMinutes(10); + o.Events = new CookieAuthenticationEvents + { + OnValidatePrincipal = ctx => + { + if (replace) + { + ctx.ShouldRenew = true; + ctx.ReplacePrincipal(new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice2", "Cookies2")))); + ctx.Properties.Items["updated"] = "yes"; + } + return Task.FromResult(0); + } + }; + }, + context => + context.SignInAsync("Cookies", + new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity("Alice", "Cookies"))))); + + var transaction1 = await SendAsync(server, "http://example.com/testpath"); + + var transaction2 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + + var transaction3 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.Equal("Alice", FindClaimValue(transaction2, ClaimTypes.Name)); + Assert.Null(FindPropertiesValue(transaction3, "updated")); + + replace = true; + + var transaction4 = await SendAsync(server, "http://example.com/me/Cookies", transaction1.CookieNameValue); + Assert.NotNull(transaction4.SetCookie); + Assert.Equal("Alice2", FindClaimValue(transaction4, ClaimTypes.Name)); + Assert.Equal("yes", FindPropertiesValue(transaction4, "updated")); + + replace = false; + + var transaction5 = await SendAsync(server, "http://example.com/me/Cookies", transaction4.CookieNameValue); + Assert.Equal("Alice2", FindClaimValue(transaction5, ClaimTypes.Name)); + Assert.Equal("yes", FindPropertiesValue(transaction4, "updated")); + } + [Fact] public async Task CookieCanBeRenewedByValidatorWithSlidingExpiry() { @@ -1730,6 +1804,16 @@ private static string FindClaimValue(Transaction transaction, string claimType) return claim.Attribute("value").Value; } + private static string FindPropertiesValue(Transaction transaction, string key) + { + var property = transaction.ResponseElement.Elements("extra").SingleOrDefault(elt => elt.Attribute("type").Value == key); + if (property == null) + { + return null; + } + return property.Attribute("value").Value; + } + private static async Task GetAuthData(TestServer server, string url, string cookie) { var request = new HttpRequestMessage(HttpMethod.Get, url); From c9122a842847974fb58eebf13acc88c2d090c6e1 Mon Sep 17 00:00:00 2001 From: Tim Hess Date: Wed, 23 May 2018 10:25:19 -0500 Subject: [PATCH 202/248] Include AuthenticationTicket.Properties in AuthenticationTicket success result handling #1765 (#1767) --- src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs index 3f6c2d917..da9b6ea01 100644 --- a/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs +++ b/src/Microsoft.AspNetCore.Authentication/HandleRequestResult.cs @@ -33,7 +33,7 @@ public class HandleRequestResult : AuthenticateResult { throw new ArgumentNullException(nameof(ticket)); } - return new HandleRequestResult() { Ticket = ticket }; + return new HandleRequestResult() { Ticket = ticket, Properties = ticket.Properties }; } /// From 47caa67a65b1f3f4f48607c39ff1caa2676cfe01 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 16 May 2018 15:41:01 -0700 Subject: [PATCH 203/248] Rewrite JwtBearer token test #640 --- .../JwtBearerTests.cs | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index b472a4162..20d625d31 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Net; using System.Net.Http; @@ -432,19 +433,37 @@ public async Task VerifySchemeDefaults() Assert.Null(scheme.DisplayName); } - [ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179 + [Fact] public async Task BearerTokenValidation() { + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); + var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + + var claims = new[] + { + new Claim(ClaimTypes.NameIdentifier, "Bob") + }; + + var token = new JwtSecurityToken( + issuer: "issuer.contoso.com", + audience: "audience.contoso.com", + claims: claims, + expires: DateTime.Now.AddMinutes(30), + signingCredentials: creds); + + var tokenText = new JwtSecurityTokenHandler().WriteToken(token); + var server = CreateServer(o => { - o.Authority = "https://login.windows.net/tushartest.onmicrosoft.com"; - o.Audience = "https://TusharTest.onmicrosoft.com/TodoListService-ManualJwt"; - o.TokenValidationParameters.ValidateLifetime = false; + o.TokenValidationParameters = new TokenValidationParameters() + { + ValidIssuer = "issuer.contoso.com", + ValidAudience = "audience.contoso.com", + IssuerSigningKey = key, + }; }); - var newBearerToken = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImtyaU1QZG1Cdng2OHNrVDgtbVBBQjNCc2VlQSJ9.eyJhdWQiOiJodHRwczovL1R1c2hhclRlc3Qub25taWNyb3NvZnQuY29tL1RvZG9MaXN0U2VydmljZS1NYW51YWxKd3QiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9hZmJlY2UwMy1hZWFhLTRmM2YtODVlNy1jZTA4ZGQyMGNlNTAvIiwiaWF0IjoxNDE4MzMwNjE0LCJuYmYiOjE0MTgzMzA2MTQsImV4cCI6MTQxODMzNDUxNCwidmVyIjoiMS4wIiwidGlkIjoiYWZiZWNlMDMtYWVhYS00ZjNmLTg1ZTctY2UwOGRkMjBjZTUwIiwiYW1yIjpbInB3ZCJdLCJvaWQiOiI1Mzk3OTdjMi00MDE5LTQ2NTktOWRiNS03MmM0Yzc3NzhhMzMiLCJ1cG4iOiJWaWN0b3JAVHVzaGFyVGVzdC5vbm1pY3Jvc29mdC5jb20iLCJ1bmlxdWVfbmFtZSI6IlZpY3RvckBUdXNoYXJUZXN0Lm9ubWljcm9zb2Z0LmNvbSIsInN1YiI6IkQyMm9aMW9VTzEzTUFiQXZrdnFyd2REVE80WXZJdjlzMV9GNWlVOVUwYnciLCJmYW1pbHlfbmFtZSI6Ikd1cHRhIiwiZ2l2ZW5fbmFtZSI6IlZpY3RvciIsImFwcGlkIjoiNjEzYjVhZjgtZjJjMy00MWI2LWExZGMtNDE2Yzk3ODAzMGI3IiwiYXBwaWRhY3IiOiIwIiwic2NwIjoidXNlcl9pbXBlcnNvbmF0aW9uIiwiYWNyIjoiMSJ9.N_Kw1EhoVGrHbE6hOcm7ERdZ7paBQiNdObvp2c6T6n5CE8p0fZqmUd-ya_EqwElcD6SiKSiP7gj0gpNUnOJcBl_H2X8GseaeeMxBrZdsnDL8qecc6_ygHruwlPltnLTdka67s1Ow4fDSHaqhVTEk6lzGmNEcbNAyb0CxQxU6o7Fh0yHRiWoLsT8yqYk8nKzsHXfZBNby4aRo3_hXaa4i0SZLYfDGGYPdttG4vT_u54QGGd4Wzbonv2gjDlllOVGOwoJS6kfl1h8mk0qxdiIaT_ChbDWgkWvTB7bTvBE-EgHgV0XmAo0WtJeSxgjsG3KhhEPsONmqrSjhIUV4IVnF2w"; + var newBearerToken = "Bearer " + tokenText; var response = await SendAsync(server, "http://example.com/oauth", newBearerToken); Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); } From aef7ff7959817fcc7bbd440dbc5eb1c7f7d98af0 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 12 Jul 2018 14:13:25 -0700 Subject: [PATCH 204/248] Add JwtBearer test for SaveToken #1768 --- .../JwtBearerTests.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index 20d625d31..d7fcdb4ca 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -468,6 +468,43 @@ public async Task BearerTokenValidation() Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); } + [Fact] + public async Task SaveBearerToken() + { + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128))); + var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + + var claims = new[] + { + new Claim(ClaimTypes.NameIdentifier, "Bob") + }; + + var token = new JwtSecurityToken( + issuer: "issuer.contoso.com", + audience: "audience.contoso.com", + claims: claims, + expires: DateTime.Now.AddMinutes(30), + signingCredentials: creds); + + var tokenText = new JwtSecurityTokenHandler().WriteToken(token); + + var server = CreateServer(o => + { + o.SaveToken = true; + o.TokenValidationParameters = new TokenValidationParameters() + { + ValidIssuer = "issuer.contoso.com", + ValidAudience = "audience.contoso.com", + IssuerSigningKey = key, + }; + }); + + var newBearerToken = "Bearer " + tokenText; + var response = await SendAsync(server, "http://example.com/token", newBearerToken); + Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode); + Assert.Equal(tokenText, await response.Response.Content.ReadAsStringAsync()); + } + [Fact] public async Task SignInThrows() { @@ -1140,6 +1177,11 @@ private static TestServer CreateServer(Action options = null, await context.Response.WriteAsync(identifier.Value); } + else if (context.Request.Path == new PathString("/token")) + { + var token = await context.GetTokenAsync("access_token"); + await context.Response.WriteAsync(token); + } else if (context.Request.Path == new PathString("/unauthorized")) { // Simulate Authorization failure From d8e10d087040adeadc677528eaeb0c04b76ee506 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 11 Jul 2018 18:49:48 -0700 Subject: [PATCH 205/248] Updating dependencies to 2.1.2 and adding a section for pinned variable versions --- build/dependencies.props | 17 ++++++++++++----- korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 6fd8fd099..5e6f87963 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,8 +2,10 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - 2.1.1-rtm-15793 + + + + 2.1.3-rtm-15802 2.1.1 2.1.1 2.1.1 @@ -13,8 +15,8 @@ 2.1.1 2.1.1 2.1.1 - 2.1.1 - 2.1.1 + 2.1.2 + 2.1.2 2.1.1 2.1.1 2.1.0 @@ -34,7 +36,7 @@ 5.2.0 5.2.0 2.0.0 - 2.1.1 + 2.1.2 15.6.1 3.0.1 3.0.1 @@ -46,5 +48,10 @@ 2.3.1 2.4.0-beta.1.build3945 + + + + + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index bc84e0cd5..251c227c8 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15793 -commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a +version:2.1.3-rtm-15802 +commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a From 930ed239e41d7547edf06f31efa3461d1a2c6bad Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 12 Jul 2018 11:58:34 -0700 Subject: [PATCH 206/248] Pin version variables to the ASP.NET Core 2.1.2 baseline This reverts our previous policy of cascading versions on all servicing updates. This moves variables into the 'pinned' section, and points them to the latest stable release (versions that were used at the time of the 2.1.2 release). --- build/dependencies.props | 47 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5e6f87963..828f9c7ab 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,8 +4,30 @@ - + 2.1.3-rtm-15802 + 3.14.2 + 5.2.0 + 5.2.0 + 2.0.0 + 2.1.2 + 15.6.1 + 3.0.1 + 3.0.1 + 3.0.1 + 2.0.3 + 11.0.2 + 5.2.0 + 0.8.0 + 2.3.1 + 2.4.0-beta.1.build3945 + + + + + + + 2.1.1 2.1.1 2.1.1 @@ -32,26 +54,5 @@ 2.1.1 2.1.1 2.1.1 - 3.14.2 - 5.2.0 - 5.2.0 - 2.0.0 - 2.1.2 - 15.6.1 - 3.0.1 - 3.0.1 - 3.0.1 - 2.0.3 - 11.0.2 - 5.2.0 - 0.8.0 - 2.3.1 - 2.4.0-beta.1.build3945 - - - - - - - + \ No newline at end of file From 320dd47694d4b7bc7f11737c5e9b7034713ca58f Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Jul 2018 12:27:24 -0700 Subject: [PATCH 207/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7186de797..a7c9e6a3e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,37 +4,37 @@ 2.2.0-preview1-17099 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 3.14.2 5.2.0 5.2.0 - 2.0.7 - 2.1.1 + 2.0.9 + 2.1.2 2.2.0-preview1-26618-02 15.6.1 3.0.1 @@ -43,7 +43,7 @@ 2.0.3 11.0.2 5.2.0 - 0.8.0 + 0.9.0 2.3.1 2.4.0-rc.1.build4038 From f948c0020b501defbb6b0015b437562f114a74f9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Jul 2018 20:11:51 +0000 Subject: [PATCH 208/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 60 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index f013f62a6..d4a38538f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,38 +3,38 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10005 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 - 3.0.0-alpha1-10044 + 3.0.0-alpha1-10009 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 + 3.0.0-alpha1-10081 3.14.2 5.2.0 5.2.0 - 2.0.0 - 2.1.0 + 2.0.9 + 2.1.2 2.2.0-preview1-26618-02 15.6.1 3.0.1 @@ -43,7 +43,7 @@ 2.0.3 11.0.2 5.2.0 - 0.8.0 + 0.9.0 2.3.1 2.4.0-rc.1.build4038 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index f357ac9f7..4db537685 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10005 -commithash:05570853de976a526462ca140a55b1ac59d9a351 +version:3.0.0-alpha1-10009 +commithash:86be4707e47d2f1930a982f2b59eacfc4196da33 From f31166cbbcb24c34deba11da3b1aa1fae82d1d59 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 22 Jul 2018 12:26:31 -0700 Subject: [PATCH 209/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a7c9e6a3e..f97a52471 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 2.2.0-preview1-17099 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 3.14.2 5.2.0 5.2.0 From 48b8fc7c02ada57c9d6293142b9ada4ac07ad8be Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 22 Jul 2018 13:14:06 -0700 Subject: [PATCH 210/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d4a38538f..efaeec400 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10009 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 - 3.0.0-alpha1-10081 + 3.0.0-alpha1-10011 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 + 3.0.0-alpha1-10123 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 4db537685..9a67ee9c2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10009 -commithash:86be4707e47d2f1930a982f2b59eacfc4196da33 +version:3.0.0-alpha1-10011 +commithash:717c2eb1f91dafd2580c1a9b8e5064d12dd8c054 From 3b554fd9b2dc078ed0c47e62f8b93a3c3d2d314c Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 24 Jul 2018 10:57:22 -0700 Subject: [PATCH 211/248] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64ff041d5..eac4268e4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ Contributing ====== -Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. +Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo. From 899a3a2e88d14124fe4155aaeab7c174197c1655 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 26 Jul 2018 14:50:52 -0700 Subject: [PATCH 212/248] Refactor common tests --- .../CookieTests.cs | 426 +-------------- .../FacebookTests.cs | 487 +---------------- .../GoogleTests.cs | 443 +-------------- .../JwtBearerTests.cs | 422 +-------------- .../MicrosoftAccountTests.cs | 443 +-------------- .../OAuthTests.cs | 439 +-------------- .../RemoteAuthenticationTests.cs | 92 ++++ .../SharedAuthenticationTests.cs | 510 ++++++++++++++++++ .../TwitterTests.cs | 437 +-------------- 9 files changed, 714 insertions(+), 2985 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/RemoteAuthenticationTests.cs create mode 100644 test/Microsoft.AspNetCore.Authentication.Test/SharedAuthenticationTests.cs diff --git a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs index 766d1e2e5..107fc5db1 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/CookieTests.cs @@ -10,7 +10,6 @@ using System.Text; using System.Threading.Tasks; using System.Xml.Linq; -using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -22,431 +21,16 @@ namespace Microsoft.AspNetCore.Authentication.Cookies { - public class CookieTests + public class CookieTests : SharedAuthenticationTests { private TestClock _clock = new TestClock(); - [Fact] - public async Task CanForwardDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - }) - .AddCookie(o => o.ForwardDefault = "auth1"); - - var forwardDefault = new TestHandler(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await context.SignOutAsync(); - Assert.Equal(1, forwardDefault.SignOutCount); - - await context.SignInAsync(new ClaimsPrincipal()); - Assert.Equal(1, forwardDefault.SignInCount); - } - - [Fact] - public async Task ForwardSignInWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddCookie(o => - { - o.ForwardDefault = "auth1"; - o.ForwardSignIn = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.SignInAsync(new ClaimsPrincipal()); - Assert.Equal(1, specific.SignInCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignOutCount); + protected override string DefaultScheme => CookieAuthenticationDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(CookieAuthenticationHandler); - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardSignOutWinsOverDefault() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddCookie(o => - { - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.SignOutAsync(); - Assert.Equal(1, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardForbidWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddCookie(o => - { - o.ForwardDefault = "auth1"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ForbidAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(1, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardAuthenticateWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddCookie(o => - { - o.ForwardDefault = "auth1"; - o.ForwardAuthenticate = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(1, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardChallengeWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.AddScheme("specific", "specific"); - o.AddScheme("auth1", "auth1"); - }) - .AddCookie(o => - { - o.ForwardDefault = "auth1"; - o.ForwardChallenge = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ChallengeAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(1, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardSelectorWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddCookie(o => - { - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, selector.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, selector.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, selector.ChallengeCount); - - await context.SignOutAsync(); - Assert.Equal(1, selector.SignOutCount); - - await context.SignInAsync(new ClaimsPrincipal()); - Assert.Equal(1, selector.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task NullForwardSelectorUsesDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddCookie(o => - { - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => null; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await context.SignOutAsync(); - Assert.Equal(1, forwardDefault.SignOutCount); - - await context.SignInAsync(new ClaimsPrincipal()); - Assert.Equal(1, forwardDefault.SignInCount); - - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task SpecificForwardWinsOverSelectorAndDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddCookie(o => - { - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - o.ForwardAuthenticate = "specific"; - o.ForwardChallenge = "specific"; - o.ForwardSignIn = "specific"; - o.ForwardSignOut = "specific"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, specific.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, specific.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, specific.ChallengeCount); - - await context.SignOutAsync(); - Assert.Equal(1, specific.SignOutCount); - - await context.SignInAsync(new ClaimsPrincipal()); - Assert.Equal(1, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - } - - [Fact] - public async Task VerifySchemeDefaults() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddCookie(); - var sp = services.BuildServiceProvider(); - var schemeProvider = sp.GetRequiredService(); - var scheme = await schemeProvider.GetSchemeAsync(CookieAuthenticationDefaults.AuthenticationScheme); - Assert.NotNull(scheme); - Assert.Equal("CookieAuthenticationHandler", scheme.HandlerType.Name); - Assert.Null(scheme.DisplayName); + services.AddCookie(configure); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index b909be9fd..6802c60e7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -1,17 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Security.Claims; -using System.Text; -using System.Text.Encodings.Web; -using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -20,476 +11,38 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; +using System; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Text.Encodings.Web; +using System.Threading.Tasks; using Xunit; namespace Microsoft.AspNetCore.Authentication.Facebook { - public class FacebookTests + public class FacebookTests : RemoteAuthenticationTests { - private void ConfigureDefaults(FacebookOptions o) - { - o.AppId = "whatever"; - o.AppSecret = "whatever"; - o.SignInScheme = "auth1"; - } + protected override string DefaultScheme => FacebookDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(FacebookHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - [Fact] - public async Task CanForwardDefault() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - }) - .AddFacebook(o => + services.AddFacebook(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; + configure.Invoke(o); }); - - var forwardDefault = new TestHandler(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignInThrows() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddFacebook(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); } - - [Fact] - public async Task ForwardSignOutThrows() + + protected override void ConfigureDefaults(FacebookOptions o) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddFacebook(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - } - - [Fact] - public async Task ForwardForbidWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddFacebook(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ForbidAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(1, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardAuthenticateWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddFacebook(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardAuthenticate = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(1, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardChallengeWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("specific", "specific"); - o.AddScheme("auth1", "auth1"); - }) - .AddFacebook(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardChallenge = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ChallengeAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(1, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardSelectorWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddFacebook(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, selector.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, selector.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, selector.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task NullForwardSelectorUsesDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddFacebook(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => null; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task SpecificForwardWinsOverSelectorAndDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = FacebookDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddFacebook(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - o.ForwardAuthenticate = "specific"; - o.ForwardChallenge = "specific"; - o.ForwardSignIn = "specific"; - o.ForwardSignOut = "specific"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, specific.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, specific.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, specific.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - } - - [Fact] - public async Task VerifySignInSchemeCannotBeSetToSelf() - { - var server = CreateServer( - app => { }, - services => services.AddAuthentication().AddFacebook(o => - { - o.AppId = "whatever"; - o.AppSecret = "whatever"; - o.SignInScheme = FacebookDefaults.AuthenticationScheme; - }), - async context => - { - await context.ChallengeAsync("Facebook"); - return true; - }); - var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); - Assert.Contains("cannot be set to itself", error.Message); - } - - [Fact] - public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultScheme() - { - var server = CreateServer( - app => { }, - services => services.AddAuthentication(o => o.DefaultScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => - { - o.AppId = "whatever"; - o.AppSecret = "whatever"; - }), - async context => - { - await context.ChallengeAsync("Facebook"); - return true; - }); - var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); - Assert.Contains("cannot be set to itself", error.Message); - } - - [Fact] - public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultSignInScheme() - { - var server = CreateServer( - app => { }, - services => services.AddAuthentication(o => o.DefaultSignInScheme = FacebookDefaults.AuthenticationScheme).AddFacebook(o => - { - o.AppId = "whatever"; - o.AppSecret = "whatever"; - }), - async context => - { - await context.ChallengeAsync("Facebook"); - return true; - }); - var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); - Assert.Contains("cannot be set to itself", error.Message); - } - - [Fact] - public async Task VerifySchemeDefaults() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddFacebook(); - var sp = services.BuildServiceProvider(); - var schemeProvider = sp.GetRequiredService(); - var scheme = await schemeProvider.GetSchemeAsync(FacebookDefaults.AuthenticationScheme); - Assert.NotNull(scheme); - Assert.Equal("FacebookHandler", scheme.HandlerType.Name); - Assert.Equal(FacebookDefaults.AuthenticationScheme, scheme.DisplayName); + o.AppId = "whatever"; + o.AppSecret = "whatever"; + o.SignInScheme = "auth1"; } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 511a658ff..19d7d898b 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -1,16 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Security.Claims; -using System.Text; -using System.Text.Encodings.Web; -using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; @@ -20,431 +10,40 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Claims; +using System.Text; +using System.Text.Encodings.Web; +using System.Threading.Tasks; using Xunit; namespace Microsoft.AspNetCore.Authentication.Google { - public class GoogleTests + public class GoogleTests : RemoteAuthenticationTests { - private void ConfigureDefaults(GoogleOptions o) - { - o.ClientId = "whatever"; - o.ClientSecret = "whatever"; - o.SignInScheme = "auth1"; - } - - [Fact] - public async Task CanForwardDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - }) - .AddGoogle(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - }); - - var forwardDefault = new TestHandler(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignInThrows() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddGoogle(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignOutThrows() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddGoogle(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - } + protected override string DefaultScheme => GoogleDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(GoogleHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - [Fact] - public async Task ForwardForbidWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddGoogle(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ForbidAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(1, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardAuthenticateWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddGoogle(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardAuthenticate = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(1, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardChallengeWinsOverDefault() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("specific", "specific"); - o.AddScheme("auth1", "auth1"); - }) - .AddGoogle(o => + services.AddGoogle(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardChallenge = "specific"; + configure.Invoke(o); }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ChallengeAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(1, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); } - [Fact] - public async Task ForwardSelectorWinsOverDefault() + protected override void ConfigureDefaults(GoogleOptions o) { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddGoogle(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, selector.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, selector.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, selector.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task NullForwardSelectorUsesDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddGoogle(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => null; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task SpecificForwardWinsOverSelectorAndDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = GoogleDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddGoogle(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - o.ForwardAuthenticate = "specific"; - o.ForwardChallenge = "specific"; - o.ForwardSignIn = "specific"; - o.ForwardSignOut = "specific"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, specific.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, specific.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, specific.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - } - - [Fact] - public async Task VerifySignInSchemeCannotBeSetToSelf() - { - var server = CreateServer(o => - { - o.ClientId = "Test Id"; - o.ClientSecret = "Test Secret"; - o.SignInScheme = GoogleDefaults.AuthenticationScheme; - }); - var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); - Assert.Contains("cannot be set to itself", error.Message); - } - - [Fact] - public async Task VerifySchemeDefaults() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddGoogle(); - var sp = services.BuildServiceProvider(); - var schemeProvider = sp.GetRequiredService(); - var scheme = await schemeProvider.GetSchemeAsync(GoogleDefaults.AuthenticationScheme); - Assert.NotNull(scheme); - Assert.Equal("GoogleHandler", scheme.HandlerType.Name); - Assert.Equal(GoogleDefaults.AuthenticationScheme, scheme.DisplayName); + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + o.SignInScheme = "auth1"; } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs index d7fcdb4ca..ad77803cd 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/JwtBearerTests.cs @@ -1,6 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; using System; using System.IdentityModel.Tokens.Jwt; using System.Linq; @@ -11,426 +17,28 @@ using System.Text; using System.Threading.Tasks; using System.Xml.Linq; -using Microsoft.AspNetCore.Authentication.Tests; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.TestHost; -using Microsoft.AspNetCore.Testing.xunit; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.IdentityModel.Tokens; using Xunit; namespace Microsoft.AspNetCore.Authentication.JwtBearer { - public class JwtBearerTests + public class JwtBearerTests : SharedAuthenticationTests { - private void ConfigureDefaults(JwtBearerOptions o) - { - } - - [Fact] - public async Task CanForwardDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - }) - .AddJwtBearer(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - }); - - var forwardDefault = new TestHandler(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); + protected override string DefaultScheme => JwtBearerDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(JwtBearerHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignInThrows() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddJwtBearer(o => + services.AddJwtBearer(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; + configure.Invoke(o); }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); } - [Fact] - public async Task ForwardSignOutThrows() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddJwtBearer(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - } - - [Fact] - public async Task ForwardForbidWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.DefaultSignInScheme = "auth1"; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddJwtBearer(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ForbidAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(1, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardAuthenticateWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.DefaultSignInScheme = "auth1"; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddJwtBearer(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardAuthenticate = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(1, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardChallengeWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.DefaultSignInScheme = "auth1"; - o.AddScheme("specific", "specific"); - o.AddScheme("auth1", "auth1"); - }) - .AddJwtBearer(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardChallenge = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ChallengeAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(1, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardSelectorWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddJwtBearer(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, selector.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, selector.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, selector.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task NullForwardSelectorUsesDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddJwtBearer(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => null; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task SpecificForwardWinsOverSelectorAndDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddJwtBearer(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - o.ForwardAuthenticate = "specific"; - o.ForwardChallenge = "specific"; - o.ForwardSignIn = "specific"; - o.ForwardSignOut = "specific"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, specific.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, specific.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, specific.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - } - - [Fact] - public async Task VerifySchemeDefaults() + private void ConfigureDefaults(JwtBearerOptions o) { - var services = new ServiceCollection(); - services.AddAuthentication().AddJwtBearer(); - var sp = services.BuildServiceProvider(); - var schemeProvider = sp.GetRequiredService(); - var scheme = await schemeProvider.GetSchemeAsync(JwtBearerDefaults.AuthenticationScheme); - Assert.NotNull(scheme); - Assert.Equal("JwtBearerHandler", scheme.HandlerType.Name); - Assert.Null(scheme.DisplayName); } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs index e2e13f270..26a5484c8 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/MicrosoftAccountTests.cs @@ -1,14 +1,5 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Security.Claims; -using System.Text; -using System.Text.Encodings.Web; -using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Builder; @@ -16,436 +7,42 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; using Newtonsoft.Json; +using System; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Claims; +using System.Text; +using System.Text.Encodings.Web; +using System.Threading.Tasks; using Xunit; namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount { - public class MicrosoftAccountTests + public class MicrosoftAccountTests : RemoteAuthenticationTests { - private void ConfigureDefaults(MicrosoftAccountOptions o) - { - o.ClientId = "whatever"; - o.ClientSecret = "whatever"; - o.SignInScheme = "auth1"; - } - - [Fact] - public async Task CanForwardDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - }) - .AddMicrosoftAccount(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - }); - - var forwardDefault = new TestHandler(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignInThrows() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddMicrosoftAccount(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignOutThrows() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddMicrosoftAccount(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); + protected override string DefaultScheme => MicrosoftAccountDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(MicrosoftAccountHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - } - - [Fact] - public async Task ForwardForbidWinsOverDefault() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddMicrosoftAccount(o => + services.AddMicrosoftAccount(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardForbid = "specific"; + configure.Invoke(o); }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ForbidAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(1, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); } - [Fact] - public async Task ForwardAuthenticateWinsOverDefault() + protected override void ConfigureDefaults(MicrosoftAccountOptions o) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddMicrosoftAccount(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardAuthenticate = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(1, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardChallengeWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("specific", "specific"); - o.AddScheme("auth1", "auth1"); - }) - .AddMicrosoftAccount(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardChallenge = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ChallengeAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(1, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardSelectorWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddMicrosoftAccount(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, selector.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, selector.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, selector.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task NullForwardSelectorUsesDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddMicrosoftAccount(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => null; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task SpecificForwardWinsOverSelectorAndDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = MicrosoftAccountDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddMicrosoftAccount(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - o.ForwardAuthenticate = "specific"; - o.ForwardChallenge = "specific"; - o.ForwardSignIn = "specific"; - o.ForwardSignOut = "specific"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, specific.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, specific.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, specific.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - } - - [Fact] - public async Task VerifySignInSchemeCannotBeSetToSelf() - { - var server = CreateServer(o => - { - o.ClientId = "Test Id"; - o.ClientSecret = "Test Secret"; - o.SignInScheme = MicrosoftAccountDefaults.AuthenticationScheme; - }); - var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); - Assert.Contains("cannot be set to itself", error.Message); - } - - [Fact] - public async Task VerifySchemeDefaults() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddMicrosoftAccount(); - var sp = services.BuildServiceProvider(); - var schemeProvider = sp.GetRequiredService(); - var scheme = await schemeProvider.GetSchemeAsync(MicrosoftAccountDefaults.AuthenticationScheme); - Assert.NotNull(scheme); - Assert.Equal("MicrosoftAccountHandler", scheme.HandlerType.Name); - Assert.Equal(MicrosoftAccountDefaults.AuthenticationScheme, scheme.DisplayName); + o.ClientId = "whatever"; + o.ClientSecret = "whatever"; + o.SignInScheme = "auth1"; } [Fact] diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 4b822b611..87131b8d7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -1,447 +1,34 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using System.Collections.Generic; -using System.Net; -using System.Security.Claims; -using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authentication.Tests; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; using Xunit; namespace Microsoft.AspNetCore.Authentication.OAuth { - public class OAuthTests + public class OAuthTests : RemoteAuthenticationTests { - [Fact] - public async Task CanForwardDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.AddScheme("auth1", "auth1"); - }) - .AddOAuth("default", o => - { - ConfigureDefaults(o); - o.SignInScheme = "auth1"; - o.ForwardDefault = "auth1"; - }); - - var forwardDefault = new TestHandler(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignInThrows() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddOAuth("default", o => - { - ConfigureDefaults(o); - o.SignInScheme = "auth1"; - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignOutThrows() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddOAuth("default", o => - { - ConfigureDefaults(o); - o.SignInScheme = "auth1"; - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); + protected override string DefaultScheme => OAuthDefaults.DisplayName; + protected override Type HandlerType => typeof(OAuthHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - } - - [Fact] - public async Task ForwardForbidWinsOverDefault() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.DefaultSignInScheme = "auth1"; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddOAuth("default", o => + services.AddOAuth(DefaultScheme, o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardForbid = "specific"; + configure.Invoke(o); }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ForbidAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(1, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardAuthenticateWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.DefaultSignInScheme = "auth1"; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddOAuth("default", o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardAuthenticate = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(1, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardChallengeWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.DefaultSignInScheme = "auth1"; - o.AddScheme("specific", "specific"); - o.AddScheme("auth1", "auth1"); - }) - .AddOAuth("default", o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardChallenge = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ChallengeAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(1, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardSelectorWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddOAuth("default", o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, selector.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, selector.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, selector.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task NullForwardSelectorUsesDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddOAuth("default", o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => null; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task SpecificForwardWinsOverSelectorAndDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = "default"; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddOAuth("default", o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - o.ForwardAuthenticate = "specific"; - o.ForwardChallenge = "specific"; - o.ForwardSignIn = "specific"; - o.ForwardSignOut = "specific"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, specific.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, specific.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, specific.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - } - - - [Fact] - public async Task VerifySignInSchemeCannotBeSetToSelf() - { - var server = CreateServer( - services => services.AddAuthentication().AddOAuth("weeblie", o => - { - o.SignInScheme = "weeblie"; - o.ClientId = "whatever"; - o.ClientSecret = "whatever"; - o.CallbackPath = "/whatever"; - o.AuthorizationEndpoint = "/whatever"; - o.TokenEndpoint = "/whatever"; - })); - var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/")); - Assert.Contains("cannot be set to itself", error.Message); - } - - [Fact] - public async Task VerifySchemeDefaults() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddOAuth("oauth", o => { }); - var sp = services.BuildServiceProvider(); - var schemeProvider = sp.GetRequiredService(); - var scheme = await schemeProvider.GetSchemeAsync("oauth"); - Assert.NotNull(scheme); - Assert.Equal("OAuthHandler`1", scheme.HandlerType.Name); - Assert.Equal(OAuthDefaults.DisplayName, scheme.DisplayName); } [Fact] @@ -654,7 +241,7 @@ public async Task RedirectToAuthorizeEndpoint_HasScopeAsOverwrittenWithBaseAuthe Assert.Contains("scope=baz%20qux", res.Headers.Location.Query); } - private void ConfigureDefaults(OAuthOptions o) + protected override void ConfigureDefaults(OAuthOptions o) { o.ClientId = "Test Id"; o.ClientSecret = "secret"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/RemoteAuthenticationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/RemoteAuthenticationTests.cs new file mode 100644 index 000000000..d477e7534 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/RemoteAuthenticationTests.cs @@ -0,0 +1,92 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication +{ + public abstract class RemoteAuthenticationTests : SharedAuthenticationTests where TOptions : RemoteAuthenticationOptions + { + protected override string DisplayName => DefaultScheme; + + private TestServer CreateServer(Action configureOptions, Func testpath = null, bool isDefault = true) + => CreateServerWithServices(s => + { + var builder = s.AddAuthentication(); + if (isDefault) + { + s.Configure(o => o.DefaultScheme = DefaultScheme); + } + RegisterAuth(builder, configureOptions); + s.AddSingleton(Clock); + }, testpath); + + + protected virtual TestServer CreateServerWithServices(Action configureServices, Func testpath = null) + { + //private static TestServer CreateServer(Action configure, Action configureServices, Func> handler) + var builder = new WebHostBuilder() + .Configure(app => + { + app.Use(async (context, next) => + { + if (testpath != null) + { + await testpath(context); + } + await next(); + }); + }) + .ConfigureServices(configureServices); + return new TestServer(builder); + } + + protected abstract void ConfigureDefaults(TOptions o); + + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelf() + { + var server = CreateServer( + o => + { + ConfigureDefaults(o); + o.SignInScheme = DefaultScheme; + }, + context => context.ChallengeAsync(DefaultScheme)); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultScheme() + { + var server = CreateServer( + o => o.SignInScheme = null, + context => context.ChallengeAsync(DefaultScheme), + isDefault: true); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + + [Fact] + public async Task VerifySignInSchemeCannotBeSetToSelfUsingDefaultSignInScheme() + { + var server = CreateServerWithServices( + services => + { + var builder = services.AddAuthentication(o => o.DefaultSignInScheme = DefaultScheme); + RegisterAuth(builder, o => o.SignInScheme = null); + }, + context => context.ChallengeAsync(DefaultScheme)); + var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); + Assert.Contains("cannot be set to itself", error.Message); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/SharedAuthenticationTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/SharedAuthenticationTests.cs new file mode 100644 index 000000000..4590c4915 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authentication.Test/SharedAuthenticationTests.cs @@ -0,0 +1,510 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Authentication.Tests; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Security.Claims; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Authentication +{ + public abstract class SharedAuthenticationTests where TOptions : AuthenticationSchemeOptions + { + protected TestClock Clock { get; } = new TestClock(); + + protected abstract string DefaultScheme { get; } + protected virtual string DisplayName { get; } + protected abstract Type HandlerType { get; } + + protected virtual bool SupportsSignIn { get => true; } + protected virtual bool SupportsSignOut { get => true; } + + protected abstract void RegisterAuth(AuthenticationBuilder services, Action configure); + + [Fact] + public async Task CanForwardDefault() + { + var services = new ServiceCollection().AddLogging(); + + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + }); + RegisterAuth(builder, o => o.ForwardDefault = "auth1"); + + var forwardDefault = new TestHandler(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + if (SupportsSignOut) + { + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + if (SupportsSignIn) + { + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, forwardDefault.SignInCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + } + + [Fact] + public async Task ForwardSignInWinsOverDefault() + { + if (SupportsSignIn) + { + var services = new ServiceCollection().AddLogging(); + + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, o => + { + o.ForwardDefault = "auth1"; + o.ForwardSignIn = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, specific.SignInCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignOutCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + } + + [Fact] + public async Task ForwardSignOutWinsOverDefault() + { + if (SupportsSignOut) + { + var services = new ServiceCollection().AddLogging(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, o => + { + o.ForwardDefault = "auth1"; + o.ForwardSignOut = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + } + + [Fact] + public async Task ForwardForbidWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, o => + { + o.ForwardDefault = "auth1"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ForbidAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(1, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardAuthenticateWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, o => + { + o.ForwardDefault = "auth1"; + o.ForwardAuthenticate = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(1, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardChallengeWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, o => + { + o.ForwardDefault = "auth1"; + o.ForwardChallenge = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.ChallengeAsync(); + Assert.Equal(0, specific.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(1, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + } + + [Fact] + public async Task ForwardSelectorWinsOverDefault() + { + var services = new ServiceCollection().AddLogging(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, o => + { + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, selector.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, selector.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, selector.ChallengeCount); + + if (SupportsSignOut) + { + await context.SignOutAsync(); + Assert.Equal(1, selector.SignOutCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + if (SupportsSignIn) + { + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, selector.SignInCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task NullForwardSelectorUsesDefault() + { + var services = new ServiceCollection().AddLogging(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, o => + { + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => null; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, forwardDefault.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, forwardDefault.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, forwardDefault.ChallengeCount); + + if (SupportsSignOut) + { + await context.SignOutAsync(); + Assert.Equal(1, forwardDefault.SignOutCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + if (SupportsSignIn) + { + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, forwardDefault.SignInCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + Assert.Equal(0, specific.AuthenticateCount); + Assert.Equal(0, specific.ForbidCount); + Assert.Equal(0, specific.ChallengeCount); + Assert.Equal(0, specific.SignInCount); + Assert.Equal(0, specific.SignOutCount); + } + + [Fact] + public async Task SpecificForwardWinsOverSelectorAndDefault() + { + var services = new ServiceCollection().AddLogging(); + var builder = services.AddAuthentication(o => + { + o.DefaultScheme = DefaultScheme; + o.AddScheme("auth1", "auth1"); + o.AddScheme("selector", "selector"); + o.AddScheme("specific", "specific"); + }); + RegisterAuth(builder, o => + { + o.ForwardDefault = "auth1"; + o.ForwardDefaultSelector = _ => "selector"; + o.ForwardAuthenticate = "specific"; + o.ForwardChallenge = "specific"; + o.ForwardSignIn = "specific"; + o.ForwardSignOut = "specific"; + o.ForwardForbid = "specific"; + }); + + var specific = new TestHandler(); + services.AddSingleton(specific); + var forwardDefault = new TestHandler2(); + services.AddSingleton(forwardDefault); + var selector = new TestHandler3(); + services.AddSingleton(selector); + + var sp = services.BuildServiceProvider(); + var context = new DefaultHttpContext(); + context.RequestServices = sp; + + await context.AuthenticateAsync(); + Assert.Equal(1, specific.AuthenticateCount); + + await context.ForbidAsync(); + Assert.Equal(1, specific.ForbidCount); + + await context.ChallengeAsync(); + Assert.Equal(1, specific.ChallengeCount); + + if (SupportsSignOut) + { + await context.SignOutAsync(); + Assert.Equal(1, specific.SignOutCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignOutAsync()); + } + + if (SupportsSignIn) + { + await context.SignInAsync(new ClaimsPrincipal()); + Assert.Equal(1, specific.SignInCount); + } + else + { + await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); + } + + Assert.Equal(0, forwardDefault.AuthenticateCount); + Assert.Equal(0, forwardDefault.ForbidCount); + Assert.Equal(0, forwardDefault.ChallengeCount); + Assert.Equal(0, forwardDefault.SignInCount); + Assert.Equal(0, forwardDefault.SignOutCount); + Assert.Equal(0, selector.AuthenticateCount); + Assert.Equal(0, selector.ForbidCount); + Assert.Equal(0, selector.ChallengeCount); + Assert.Equal(0, selector.SignInCount); + Assert.Equal(0, selector.SignOutCount); + } + + [Fact] + public async Task VerifySchemeDefaults() + { + var services = new ServiceCollection(); + var builder = services.AddAuthentication(); + RegisterAuth(builder, o => { }); + var sp = services.BuildServiceProvider(); + var schemeProvider = sp.GetRequiredService(); + var scheme = await schemeProvider.GetSchemeAsync(DefaultScheme); + Assert.NotNull(scheme); + Assert.Equal(HandlerType, scheme.HandlerType); + Assert.Equal(DisplayName, scheme.DisplayName); + } + } +} diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index c1937d136..c438b1f3f 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -1,5 +1,11 @@ // Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; using System; using System.Linq; using System.Net; @@ -7,438 +13,31 @@ using System.Security.Claims; using System.Text; using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication.Tests; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Authentication.Twitter { - public class TwitterTests + public class TwitterTests : RemoteAuthenticationTests { - private void ConfigureDefaults(TwitterOptions o) - { - o.ConsumerKey = "whatever"; - o.ConsumerSecret = "whatever"; - o.SignInScheme = "auth1"; - } - - [Fact] - public async Task CanForwardDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - }) - .AddTwitter(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - }); - - var forwardDefault = new TestHandler(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignInThrows() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddTwitter(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); + protected override string DefaultScheme => TwitterDefaults.AuthenticationScheme; + protected override Type HandlerType => typeof(TwitterHandler); + protected override bool SupportsSignIn { get => false; } + protected override bool SupportsSignOut { get => false; } - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - } - - [Fact] - public async Task ForwardSignOutThrows() + protected override void RegisterAuth(AuthenticationBuilder services, Action configure) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddTwitter(o => + services.AddTwitter(o => { ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardSignOut = "specific"; + configure.Invoke(o); }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await Assert.ThrowsAsync(() => context.SignOutAsync()); } - [Fact] - public async Task ForwardForbidWinsOverDefault() + protected override void ConfigureDefaults(TwitterOptions o) { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddTwitter(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ForbidAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(1, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardAuthenticateWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("specific", "specific"); - }) - .AddTwitter(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardAuthenticate = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(1, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardChallengeWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("specific", "specific"); - o.AddScheme("auth1", "auth1"); - }) - .AddTwitter(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardChallenge = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.ChallengeAsync(); - Assert.Equal(0, specific.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(1, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - } - - [Fact] - public async Task ForwardSelectorWinsOverDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddTwitter(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, selector.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, selector.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, selector.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task NullForwardSelectorUsesDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddTwitter(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => null; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, forwardDefault.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, forwardDefault.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, forwardDefault.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - Assert.Equal(0, specific.AuthenticateCount); - Assert.Equal(0, specific.ForbidCount); - Assert.Equal(0, specific.ChallengeCount); - Assert.Equal(0, specific.SignInCount); - Assert.Equal(0, specific.SignOutCount); - } - - [Fact] - public async Task SpecificForwardWinsOverSelectorAndDefault() - { - var services = new ServiceCollection().AddLogging(); - services.AddAuthentication(o => - { - o.DefaultScheme = TwitterDefaults.AuthenticationScheme; - o.AddScheme("auth1", "auth1"); - o.AddScheme("selector", "selector"); - o.AddScheme("specific", "specific"); - }) - .AddTwitter(o => - { - ConfigureDefaults(o); - o.ForwardDefault = "auth1"; - o.ForwardDefaultSelector = _ => "selector"; - o.ForwardAuthenticate = "specific"; - o.ForwardChallenge = "specific"; - o.ForwardSignIn = "specific"; - o.ForwardSignOut = "specific"; - o.ForwardForbid = "specific"; - }); - - var specific = new TestHandler(); - services.AddSingleton(specific); - var forwardDefault = new TestHandler2(); - services.AddSingleton(forwardDefault); - var selector = new TestHandler3(); - services.AddSingleton(selector); - - var sp = services.BuildServiceProvider(); - var context = new DefaultHttpContext(); - context.RequestServices = sp; - - await context.AuthenticateAsync(); - Assert.Equal(1, specific.AuthenticateCount); - - await context.ForbidAsync(); - Assert.Equal(1, specific.ForbidCount); - - await context.ChallengeAsync(); - Assert.Equal(1, specific.ChallengeCount); - - await Assert.ThrowsAsync(() => context.SignOutAsync()); - await Assert.ThrowsAsync(() => context.SignInAsync(new ClaimsPrincipal())); - - Assert.Equal(0, forwardDefault.AuthenticateCount); - Assert.Equal(0, forwardDefault.ForbidCount); - Assert.Equal(0, forwardDefault.ChallengeCount); - Assert.Equal(0, forwardDefault.SignInCount); - Assert.Equal(0, forwardDefault.SignOutCount); - Assert.Equal(0, selector.AuthenticateCount); - Assert.Equal(0, selector.ForbidCount); - Assert.Equal(0, selector.ChallengeCount); - Assert.Equal(0, selector.SignInCount); - Assert.Equal(0, selector.SignOutCount); - } - - [Fact] - public async Task VerifySignInSchemeCannotBeSetToSelf() - { - var server = CreateServer(o => - { - o.ConsumerKey = "Test Consumer Key"; - o.ConsumerSecret = "Test Consumer Secret"; - o.SignInScheme = TwitterDefaults.AuthenticationScheme; - }); - var error = await Assert.ThrowsAsync(() => server.SendAsync("https://example.com/challenge")); - Assert.Contains("cannot be set to itself", error.Message); - } - - [Fact] - public async Task VerifySchemeDefaults() - { - var services = new ServiceCollection(); - services.AddAuthentication().AddTwitter(); - var sp = services.BuildServiceProvider(); - var schemeProvider = sp.GetRequiredService(); - var scheme = await schemeProvider.GetSchemeAsync(TwitterDefaults.AuthenticationScheme); - Assert.NotNull(scheme); - Assert.Equal("TwitterHandler", scheme.HandlerType.Name); - Assert.Equal(TwitterDefaults.AuthenticationScheme, scheme.DisplayName); + o.ConsumerKey = "whatever"; + o.ConsumerSecret = "whatever"; + o.SignInScheme = "auth1"; } [Fact] From 860c187fca76e9d46a1158cec952d108cbfbc565 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Jul 2018 12:25:49 -0700 Subject: [PATCH 213/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 59 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index f97a52471..49a994d6e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17099 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 + 2.2.0-preview1-17102 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 3.14.2 5.2.0 5.2.0 @@ -43,9 +43,10 @@ 2.0.3 11.0.2 5.2.0 - 0.9.0 + 0.10.0 2.3.1 - 2.4.0-rc.1.build4038 + 2.4.0 + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 27e2e80f9..6b8da29e6 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17099 -commithash:263ed1db9866b6b419b1f5d5189a712aa218acb3 +version:2.2.0-preview1-17102 +commithash:e7e2b5a97ca92cfc6acc4def534cb0901a6d1eb9 From 2ddfd9ec4614df5f541525d063044f7ff8b07185 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Jul 2018 20:09:53 +0000 Subject: [PATCH 214/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 59 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index efaeec400..ed2f39082 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10011 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 - 3.0.0-alpha1-10123 + 3.0.0-alpha1-10015 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 + 3.0.0-alpha1-10173 3.14.2 5.2.0 5.2.0 @@ -43,9 +43,10 @@ 2.0.3 11.0.2 5.2.0 - 0.9.0 + 0.10.0 2.3.1 - 2.4.0-rc.1.build4038 + 2.4.0 + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 9a67ee9c2..1e75dc3a2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10011 -commithash:717c2eb1f91dafd2580c1a9b8e5064d12dd8c054 +version:3.0.0-alpha1-10015 +commithash:3f36e5c2f061712f76f2766c435d2555681d5c55 From 1e14a22e0dfe3ebc9c1ddadb69585cee8df471f6 Mon Sep 17 00:00:00 2001 From: Wouter Date: Tue, 31 Jul 2018 13:40:49 +0200 Subject: [PATCH 215/248] Change description of role in RequireRole method The description of the pram roles feels ambiguous. Make it clear that the user should belong to one of the roles and not all of them. As documented: https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles?view=aspnetcore-2.1 --- .../AuthorizationPolicyBuilder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs index 37335df8f..c2fd22afb 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -147,7 +147,7 @@ public AuthorizationPolicyBuilder RequireClaim(string claimType) /// Adds a /// to the current instance. /// - /// The roles required. + /// The allowed roles. /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireRole(params string[] roles) { @@ -163,7 +163,7 @@ public AuthorizationPolicyBuilder RequireRole(params string[] roles) /// Adds a /// to the current instance. /// - /// The roles required. + /// The allowed roles. /// A reference to this instance after the operation has completed. public AuthorizationPolicyBuilder RequireRole(IEnumerable roles) { @@ -247,4 +247,4 @@ public AuthorizationPolicy Build() return new AuthorizationPolicy(Requirements, AuthenticationSchemes.Distinct()); } } -} \ No newline at end of file +} From fd9255d1465cad37656f92bec6b45c212b0ac043 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 5 Aug 2018 19:26:51 +0000 Subject: [PATCH 216/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 49a994d6e..0e02888f1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17102 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 + 2.2.0-preview1-20180731.1 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 6b8da29e6..c7af2292c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17102 -commithash:e7e2b5a97ca92cfc6acc4def534cb0901a6d1eb9 +version:2.2.0-preview1-20180731.1 +commithash:29fde58465439f4bb9df40830635ed758e063daf From 9f44ef5b5628f3cb5f02d9c7ccc1df6d74fee90b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 5 Aug 2018 20:04:32 +0000 Subject: [PATCH 217/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index ed2f39082..5f1d18e29 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-10015 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 - 3.0.0-alpha1-10173 + 3.0.0-alpha1-20180731.2 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 + 3.0.0-alpha1-10221 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1e75dc3a2..8f9f6066e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-10015 -commithash:3f36e5c2f061712f76f2766c435d2555681d5c55 +version:3.0.0-alpha1-20180731.2 +commithash:1179f1083695ac9213c8a70a4d1d6c45a52caf41 From 899dce9960ee8426c6615f597a977e40065dce97 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 6 Aug 2018 20:50:20 +0000 Subject: [PATCH 218/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 0e02888f1..c195a895e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 2.2.0-preview1-20180731.1 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 3.14.2 5.2.0 5.2.0 From ef80c3beb72ee37ed8f525f627912f1efcede663 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 12 Aug 2018 19:28:50 +0000 Subject: [PATCH 219/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c195a895e..100236d46 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180731.1 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 + 2.2.0-preview1-20180807.2 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index c7af2292c..3fbcc8018 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180731.1 -commithash:29fde58465439f4bb9df40830635ed758e063daf +version:2.2.0-preview1-20180807.2 +commithash:11495dbd236104434e08cb1152fcb58cf2a20923 From f084067d6a255fde3d12c07988157311ba52c51a Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 12 Aug 2018 20:14:03 +0000 Subject: [PATCH 220/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5f1d18e29..6c563e9b7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180731.2 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 - 3.0.0-alpha1-10221 + 3.0.0-alpha1-20180810.1 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 + 3.0.0-alpha1-10275 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 8f9f6066e..e417a01b5 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180731.2 -commithash:1179f1083695ac9213c8a70a4d1d6c45a52caf41 +version:3.0.0-alpha1-20180810.1 +commithash:45c32b4f020e14a9295be31866051a18d293309d From 79f8442ce2e37aa506433fe6cfa4df9e31b601a5 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 19 Aug 2018 19:28:38 +0000 Subject: [PATCH 221/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 6c563e9b7..6cf929cc2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180810.1 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 - 3.0.0-alpha1-10275 + 3.0.0-alpha1-20180817.3 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 + 3.0.0-alpha1-10321 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e417a01b5..e5330b3d3 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180810.1 -commithash:45c32b4f020e14a9295be31866051a18d293309d +version:3.0.0-alpha1-20180817.3 +commithash:134cdbee9bee29dd3ccb654c67663b27b9ffa6c8 From 1cb07e1019493faa9ad5a1ae6f3b4937620e249c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 21 Aug 2018 13:33:52 -0700 Subject: [PATCH 222/248] Update package branding for 2.2.0-preview2 --- build/dependencies.props | 2 +- version.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 100236d46..51881441d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -47,6 +47,6 @@ 2.3.1 2.4.0 - +
diff --git a/version.props b/version.props index 44985cedb..15637ba78 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview1 + preview2 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 7a7dcec569619e40c1f2e2996333aeb10c1f5ad5 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 26 Aug 2018 19:28:22 +0000 Subject: [PATCH 223/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 6cf929cc2..f89ecc205 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180817.3 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 - 3.0.0-alpha1-10321 + 3.0.0-alpha1-20180821.3 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 + 3.0.0-alpha1-10352 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e5330b3d3..767a47179 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180817.3 -commithash:134cdbee9bee29dd3ccb654c67663b27b9ffa6c8 +version:3.0.0-alpha1-20180821.3 +commithash:0939a90812deb1c604eb9a4768869687495fc1dd From c6f5786418c2478dfc7f5a604d8b65911f9f0c1b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 2 Sep 2018 12:26:16 -0700 Subject: [PATCH 224/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 51881441d..b0386a923 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180807.2 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 + 2.2.0-preview1-20180821.1 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3fbcc8018..ad704918d 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180807.2 -commithash:11495dbd236104434e08cb1152fcb58cf2a20923 +version:2.2.0-preview1-20180821.1 +commithash:c8d0cc52cd1abb697be24e288ffd54f8fae8bf17 From e2a07fbddcc5b1d9fb45ed94159f88fda87cbe0c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 2 Sep 2018 19:27:32 +0000 Subject: [PATCH 225/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index f89ecc205..be569db69 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 3.0.0-alpha1-20180821.3 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 - 3.0.0-alpha1-10352 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 + 3.0.0-alpha1-10393 3.14.2 5.2.0 5.2.0 From ff479de7b185269bd3dc8310a0ef46c3c539e02b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 5 Sep 2018 16:36:16 -0700 Subject: [PATCH 226/248] Update branding to 2.2.0-preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 15637ba78..704cac087 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview2 + preview3 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From f8959fd6a842cb325a09cc99efee82d05ae6a202 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 6 Sep 2018 00:00:16 +0000 Subject: [PATCH 227/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index be569db69..a6108f771 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,38 +4,38 @@ 3.0.0-alpha1-20180821.3 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 - 3.0.0-alpha1-10393 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 + 3.0.0-alpha1-10400 3.14.2 5.2.0 5.2.0 2.0.9 - 2.1.2 - 2.2.0-preview1-26618-02 + 2.1.3 + 2.2.0-preview2-26905-02 15.6.1 3.0.1 3.0.1 From 6ec79a3dd33ab60ba5f5dd6cde34f13f23c2a786 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 9 Sep 2018 12:28:32 -0700 Subject: [PATCH 228/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 58 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index b0386a923..de9d4de79 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180821.1 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 + 2.2.0-preview1-20180907.8 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 3.14.2 5.2.0 5.2.0 2.0.9 - 2.1.2 - 2.2.0-preview1-26618-02 + 2.1.3 + 2.2.0-preview2-26905-02 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index ad704918d..312f82f9a 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180821.1 -commithash:c8d0cc52cd1abb697be24e288ffd54f8fae8bf17 +version:2.2.0-preview1-20180907.8 +commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 From 5cd5de3bb8558c61f02b29c3979e5f71af98cc70 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 9 Sep 2018 19:29:49 +0000 Subject: [PATCH 229/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a6108f771..4245f2fd4 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180821.3 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 - 3.0.0-alpha1-10400 + 3.0.0-alpha1-20180907.9 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 + 3.0.0-alpha1-10419 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 767a47179..b614cab6e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180821.3 -commithash:0939a90812deb1c604eb9a4768869687495fc1dd +version:3.0.0-alpha1-20180907.9 +commithash:f997365a8832ff0a3cbd9a98df45734ac2723fa0 From b3ad10ef517b367e29511d252b0a999bda2ba86e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 16 Sep 2018 12:27:11 -0700 Subject: [PATCH 230/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index de9d4de79..e6a11ccd7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180907.8 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 + 2.2.0-preview1-20180911.1 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 312f82f9a..7124f3744 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180907.8 -commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 +version:2.2.0-preview1-20180911.1 +commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 From 7b6c9cf0eeb149f2142dedd55a17430e7831ea99 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 16 Sep 2018 19:29:05 +0000 Subject: [PATCH 231/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4245f2fd4..a9ec2c341 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180907.9 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 - 3.0.0-alpha1-10419 + 3.0.0-alpha1-20180911.2 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 + 3.0.0-alpha1-10454 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b614cab6e..a817c10d2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180907.9 -commithash:f997365a8832ff0a3cbd9a98df45734ac2723fa0 +version:3.0.0-alpha1-20180911.2 +commithash:2a2b7dbea1b247930c41da497f4ea0b2bb756818 From 9c7f0b0b0d664c3c9e0cb045a4749c07a7be2d2e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 23 Sep 2018 12:27:28 -0700 Subject: [PATCH 232/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a9ec2c341..2fab2c7bf 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180911.2 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 - 3.0.0-alpha1-10454 + 3.0.0-alpha1-20180919.1 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 + 3.0.0-alpha1-10495 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a817c10d2..d66a13bdc 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180911.2 -commithash:2a2b7dbea1b247930c41da497f4ea0b2bb756818 +version:3.0.0-alpha1-20180919.1 +commithash:3066ae0a230870ea07e3f132605b5e5493f8bbd4 From 862f78122885cdb725d4a25f8ce07e34ccb860f4 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 23 Sep 2018 19:30:15 +0000 Subject: [PATCH 233/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index e6a11ccd7..04b0266a5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180911.1 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 + 2.2.0-preview1-20180918.1 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7124f3744..649bf2ba0 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180911.1 -commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 +version:2.2.0-preview1-20180918.1 +commithash:ad5e3fc53442741a0dd49bce437d2ac72f4b5800 From 383201902731f07041b9fdc73256b0859d1c3660 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Tue, 25 Sep 2018 13:56:58 -0700 Subject: [PATCH 234/248] Update Facebook to v3.1 endpoints #92 --- samples/SocialSample/Startup.cs | 6 ++++++ .../FacebookDefaults.cs | 7 ++++--- .../FacebookOptions.cs | 1 - .../GoogleDefaults.cs | 2 ++ .../MicrosoftAccountDefaults.cs | 1 + .../TwitterDefaults.cs | 9 +++++++++ .../TwitterHandler.cs | 9 +++------ .../FacebookTests.cs | 6 +++--- 8 files changed, 28 insertions(+), 13 deletions(-) diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs index 35896e84b..b5032072b 100644 --- a/samples/SocialSample/Startup.cs +++ b/samples/SocialSample/Startup.cs @@ -59,6 +59,7 @@ public void ConfigureServices(IServiceCollection services) .AddCookie(o => o.LoginPath = new PathString("/login")) // You must first create an app with Facebook and add its ID and Secret to your user-secrets. // https://developers.facebook.com/apps/ + // https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login .AddFacebook(o => { o.AppId = Configuration["facebook:appid"]; @@ -74,6 +75,8 @@ public void ConfigureServices(IServiceCollection services) }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project + // https://developers.google.com/identity/protocols/OAuth2WebServer + // https://developers.google.com/+/web/people/ .AddOAuth("Google-AccessToken", "Google AccessToken only", o => { o.ClientId = Configuration["google:clientid"]; @@ -92,6 +95,8 @@ public void ConfigureServices(IServiceCollection services) }) // You must first create an app with Google and add its ID and Secret to your user-secrets. // https://console.developers.google.com/project + // https://developers.google.com/identity/protocols/OAuth2WebServer + // https://developers.google.com/+/web/people/ .AddGoogle(o => { o.ClientId = Configuration["google:clientid"]; @@ -108,6 +113,7 @@ public void ConfigureServices(IServiceCollection services) }) // You must first create an app with Twitter and add its key and Secret to your user-secrets. // https://apps.twitter.com/ + // https://developer.twitter.com/en/docs/basics/authentication/api-reference/access_token .AddTwitter(o => { o.ConsumerKey = Configuration["twitter:consumerkey"]; diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs index 92d1d003e..ff9bb40bf 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookDefaults.cs @@ -9,10 +9,11 @@ public static class FacebookDefaults public static readonly string DisplayName = "Facebook"; - public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v2.12/dialog/oauth"; + // https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login + public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v3.1/dialog/oauth"; - public static readonly string TokenEndpoint = "https://graph.facebook.com/v2.12/oauth/access_token"; + public static readonly string TokenEndpoint = "https://graph.facebook.com/v3.1/oauth/access_token"; - public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v2.12/me"; + public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v3.1/me"; } } diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs index 7010bb20a..c2078a017 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/FacebookOptions.cs @@ -26,7 +26,6 @@ public FacebookOptions() AuthorizationEndpoint = FacebookDefaults.AuthorizationEndpoint; TokenEndpoint = FacebookDefaults.TokenEndpoint; UserInformationEndpoint = FacebookDefaults.UserInformationEndpoint; - Scope.Add("public_profile"); Scope.Add("email"); Fields.Add("name"); Fields.Add("email"); diff --git a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs index 042870318..26b3b8f01 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Google/GoogleDefaults.cs @@ -12,10 +12,12 @@ public static class GoogleDefaults public static readonly string DisplayName = "Google"; + // https://developers.google.com/identity/protocols/OAuth2WebServer public static readonly string AuthorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth"; public static readonly string TokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"; + // https://developers.google.com/+/web/people/ public static readonly string UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me"; } } diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs index 1b0859c5b..0421fa14b 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/MicrosoftAccountDefaults.cs @@ -9,6 +9,7 @@ public static class MicrosoftAccountDefaults public static readonly string DisplayName = "Microsoft"; + // https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_user public static readonly string AuthorizationEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"; public static readonly string TokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token"; diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs index a39a3f036..bdab80e59 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterDefaults.cs @@ -8,5 +8,14 @@ public static class TwitterDefaults public const string AuthenticationScheme = "Twitter"; public static readonly string DisplayName = "Twitter"; + + // https://developer.twitter.com/en/docs/basics/authentication/api-reference/request_token + internal const string RequestTokenEndpoint = "https://api.twitter.com/oauth/request_token"; + + // https://developer.twitter.com/en/docs/basics/authentication/api-reference/authenticate + internal const string AuthenticationEndpoint = "https://api.twitter.com/oauth/authenticate?oauth_token="; + + // https://developer.twitter.com/en/docs/basics/authentication/api-reference/access_token + internal const string AccessTokenEndpoint = "https://api.twitter.com/oauth/access_token"; } } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index d0d54bf74..51dabbd99 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -22,9 +22,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter public class TwitterHandler : RemoteAuthenticationHandler { private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - private const string RequestTokenEndpoint = "https://api.twitter.com/oauth/request_token"; - private const string AuthenticationEndpoint = "https://api.twitter.com/oauth/authenticate?oauth_token="; - private const string AccessTokenEndpoint = "https://api.twitter.com/oauth/access_token"; private HttpClient Backchannel => Options.Backchannel; @@ -138,7 +135,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // If CallbackConfirmed is false, this will throw var requestToken = await ObtainRequestTokenAsync(BuildRedirectUri(Options.CallbackPath), properties); - var twitterAuthenticationEndpoint = AuthenticationEndpoint + requestToken.Token; + var twitterAuthenticationEndpoint = TwitterDefaults.AuthenticationEndpoint + requestToken.Token; var cookieOptions = Options.StateCookie.Build(Context, Clock.UtcNow); @@ -233,7 +230,7 @@ private async Task ObtainRequestTokenAsync(string callBackUri, Aut { Logger.ObtainRequestToken(); - var response = await ExecuteRequestAsync(RequestTokenEndpoint, HttpMethod.Post, extraOAuthPairs: new Dictionary() { { "oauth_callback", callBackUri } }); + var response = await ExecuteRequestAsync(TwitterDefaults.RequestTokenEndpoint, HttpMethod.Post, extraOAuthPairs: new Dictionary() { { "oauth_callback", callBackUri } }); response.EnsureSuccessStatusCode(); var responseText = await response.Content.ReadAsStringAsync(); @@ -253,7 +250,7 @@ private async Task ObtainAccessTokenAsync(RequestToken token, strin Logger.ObtainAccessToken(); var formPost = new Dictionary { { "oauth_verifier", verifier } }; - var response = await ExecuteRequestAsync(AccessTokenEndpoint, HttpMethod.Post, token, formData: formPost); + var response = await ExecuteRequestAsync(TwitterDefaults.AccessTokenEndpoint, HttpMethod.Post, token, formData: formPost); if (!response.IsSuccessStatusCode) { diff --git a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs index b909be9fd..0a5440e40 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/FacebookTests.cs @@ -673,7 +673,7 @@ public async Task NestedMapWillNotAffectRedirect() var transaction = await server.SendAsync("http://example.com/base/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v3.1/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/base/signin-facebook"), location); @@ -705,7 +705,7 @@ public async Task MapWillNotAffectRedirect() var transaction = await server.SendAsync("http://example.com/login"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v3.1/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location); @@ -739,7 +739,7 @@ public async Task ChallengeWillTriggerRedirection() var transaction = await server.SendAsync("http://example.com/challenge"); Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); var location = transaction.Response.Headers.Location.AbsoluteUri; - Assert.Contains("https://www.facebook.com/v2.12/dialog/oauth", location); + Assert.Contains("https://www.facebook.com/v3.1/dialog/oauth", location); Assert.Contains("response_type=code", location); Assert.Contains("client_id=", location); Assert.Contains("redirect_uri=", location); From 59bbd966902fa195c8bbd0a168475bb361bc9aa7 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Thu, 27 Sep 2018 15:22:42 -0700 Subject: [PATCH 235/248] Update LICENSE.txt --- LICENSE.txt | 207 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 197 insertions(+), 10 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 7b2956ece..b3b180cd5 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,14 +1,201 @@ -Copyright (c) .NET Foundation and Contributors + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -All rights reserved. + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at + 1. Definitions. - http://www.apache.org/licenses/LICENSE-2.0 + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) .NET Foundation and Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From b16af1600ed04f47396bca86cb0f5f73490bf1cd Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 28 Sep 2018 17:10:39 -0700 Subject: [PATCH 236/248] automated: bulk infrastructure updates. Update bootstrapper scripts and remove unnecessary signing properties --- Directory.Build.props | 3 --- run.ps1 | 6 +++--- run.sh | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 91cd995d7..eb9d9535e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,9 +14,6 @@ $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true - Microsoft - MicrosoftNuGet - true true diff --git a/run.ps1 b/run.ps1 index 3b2738246..34604c717 100644 --- a/run.ps1 +++ b/run.ps1 @@ -52,8 +52,8 @@ in the file are overridden by command line parameters. Example config file: ```json { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", + "channel": "master", "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" } ``` @@ -192,7 +192,7 @@ if (!$DotNetHome) { else { Join-Path $PSScriptRoot '.dotnet'} } -if (!$Channel) { $Channel = 'dev' } +if (!$Channel) { $Channel = 'master' } if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } # Execute diff --git a/run.sh b/run.sh index 02aac1587..4c1fed564 100755 --- a/run.sh +++ b/run.sh @@ -220,7 +220,7 @@ if [ -f "$config_file" ]; then config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi elif __machine_has python ; then @@ -228,7 +228,7 @@ if [ -f "$config_file" ]; then config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi elif __machine_has python3 ; then @@ -236,11 +236,11 @@ if [ -f "$config_file" ]; then config_channel="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" config_tools_source="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi else - _error 'Missing required command: jq or python. Could not parse the JSON file.' + __error 'Missing required command: jq or python. Could not parse the JSON file.' exit 1 fi @@ -248,7 +248,7 @@ if [ -f "$config_file" ]; then [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" fi -[ -z "$channel" ] && channel='dev' +[ -z "$channel" ] && channel='master' [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild From 564d53641ddba29f502d350cd4a95484b313acd9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 30 Sep 2018 12:27:37 -0700 Subject: [PATCH 237/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index bcac6f0ec..b83428bb6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,32 +4,32 @@ 3.0.0-alpha1-20180919.1 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 - 3.0.0-alpha1-10495 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 + 3.0.0-alpha1-10549 3.14.2 5.2.0 5.2.0 From 889abf6f6ec4119dbd27c1a8d07a7566e0e91627 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 30 Sep 2018 12:30:31 -0700 Subject: [PATCH 238/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 04b0266a5..5582bc18f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180918.1 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 + 2.2.0-preview1-20180928.5 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 3.14.2 5.2.0 5.2.0 2.0.9 2.1.3 - 2.2.0-preview2-26905-02 + 2.2.0-preview3-26927-02 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 649bf2ba0..26697a21f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180918.1 -commithash:ad5e3fc53442741a0dd49bce437d2ac72f4b5800 +version:2.2.0-preview1-20180928.5 +commithash:43faa29f679f47b88689d645b39e6be5e0055d70 From ecfb19993a3ed965de2a7738b597949924ca88d1 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 7 Oct 2018 12:29:16 -0700 Subject: [PATCH 239/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index b83428bb6..6b6523c76 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 3.0.0-alpha1-20180919.1 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 - 3.0.0-alpha1-10549 + 3.0.0-alpha1-20181004.7 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 + 3.0.0-alpha1-10584 3.14.2 5.2.0 5.2.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index d66a13bdc..591cfd52f 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20180919.1 -commithash:3066ae0a230870ea07e3f132605b5e5493f8bbd4 +version:3.0.0-alpha1-20181004.7 +commithash:27fabdaf2b1d4753c3d2749581694ca65d78f7f2 From fcfa161cb7db735dfb4c386237b5858a4dc5926b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 7 Oct 2018 19:31:54 +0000 Subject: [PATCH 240/248] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 56 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5582bc18f..0d1a80ebb 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,39 +3,39 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180928.5 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 + 2.2.0-preview2-20181004.6 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 3.14.2 5.2.0 5.2.0 2.0.9 2.1.3 - 2.2.0-preview3-26927-02 + 2.2.0-preview3-27001-02 15.6.1 3.0.1 3.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 26697a21f..96fe3217e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180928.5 -commithash:43faa29f679f47b88689d645b39e6be5e0055d70 +version:2.2.0-preview2-20181004.6 +commithash:c04c4b2f5018632647f96210ab01876661302dac From 5d5438a7f0842019e852b2bb911ed86dc0360cf7 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 11 Oct 2018 15:27:24 -0700 Subject: [PATCH 241/248] Relax test SkuTelemetry strictness #1875 --- .../OpenIdConnect/TestSettings.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs index b32e0723f..eb045b438 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/TestSettings.cs @@ -195,7 +195,7 @@ private void ValidateParameters( ValidateState(actualValues, errors, htmlEncoded); break; case OpenIdConnectParameterNames.SkuTelemetry: - ValidateSkuTelemetry(actualValues, errors, htmlEncoded); + ValidateSkuTelemetry(actualValues, errors); break; case OpenIdConnectParameterNames.VersionTelemetry: ValidateVersionTelemetry(actualValues, errors, htmlEncoded); @@ -258,14 +258,13 @@ private void ValidateResource(IDictionary actualParams, ICollect private void ValidateState(IDictionary actualParams, ICollection errors, bool htmlEncoded) => ValidateParameter(OpenIdConnectParameterNames.State, ExpectedState, actualParams, errors, htmlEncoded); - private void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => -#if NETCOREAPP2_2 - ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NETSTANDARD1_4", actualParams, errors, htmlEncoded); -#elif NET461 - ValidateParameter(OpenIdConnectParameterNames.SkuTelemetry, "ID_NET451", actualParams, errors, htmlEncoded); -#else -#error Invalid target framework. -#endif + private static void ValidateSkuTelemetry(IDictionary actualParams, ICollection errors) + { + if (!actualParams.ContainsKey(OpenIdConnectParameterNames.SkuTelemetry)) + { + errors.Add($"Parameter {OpenIdConnectParameterNames.SkuTelemetry} is missing"); + } + } private void ValidateVersionTelemetry(IDictionary actualParams, ICollection errors, bool htmlEncoded) => ValidateParameter(OpenIdConnectParameterNames.VersionTelemetry, typeof(OpenIdConnectMessage).GetTypeInfo().Assembly.GetName().Version.ToString(), actualParams, errors, htmlEncoded); From 32177cad1eb1eb6be8ad89a7dba1a1637c0d0786 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 22 Oct 2018 23:50:52 -0500 Subject: [PATCH 242/248] Added missing Div tag in JwtBearer sample. (#1888) --- samples/JwtBearerSample/wwwroot/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/JwtBearerSample/wwwroot/index.html b/samples/JwtBearerSample/wwwroot/index.html index f71dccb69..4715ebd42 100644 --- a/samples/JwtBearerSample/wwwroot/index.html +++ b/samples/JwtBearerSample/wwwroot/index.html @@ -64,5 +64,6 @@

Todo List

+ From cb83e4f48502057176b62d53e98de1d43db44a33 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 8 Nov 2018 15:42:35 +1300 Subject: [PATCH 243/248] Authorization middleware (#1894) --- .gitignore | 1 + Security.sln | 21 + .../AuthorizationMiddlewareBenchmark.cs | 53 ++ .../AuthorizationPolicyBenchmark.cs | 28 ++ ...oft.AspNetCore.Security.Performance.csproj | 24 + .../Properties/AssemblyInfo.cs | 1 + .../readme.md | 16 + build/dependencies.props | 67 +-- .../AuthorizationAppBuilderExtensions.cs | 29 ++ ...tionEndpointConventionBuilderExtensions.cs | 50 ++ .../AuthorizationMiddleware.cs | 104 ++++ ...oft.AspNetCore.Authorization.Policy.csproj | 4 +- .../AuthorizationOptions.cs | 16 +- .../AuthorizationPolicy.cs | 84 ++-- .../DefaultAuthorizationPolicyProvider.cs | 23 +- .../IAuthorizationPolicyProvider.cs | 6 + .../AuthorizationAppBuilderExtensionsTests.cs | 65 +++ ...ndpointConventionBuilderExtensionsTests.cs | 63 +++ .../AuthorizationMiddlewareTests.cs | 459 ++++++++++++++++++ .../DefaultAuthorizationServiceTests.cs | 10 + ...osoft.AspNetCore.Authorization.Test.csproj | 3 + .../TestObjects/TestAuthenticationService.cs | 58 +++ 22 files changed, 1122 insertions(+), 63 deletions(-) create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationMiddlewareBenchmark.cs create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationPolicyBenchmark.cs create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/Properties/AssemblyInfo.cs create mode 100644 benchmarks/Microsoft.AspNetCore.Security.Performance/readme.md create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationAppBuilderExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationEndpointConventionBuilderExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationMiddleware.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/AuthorizationAppBuilderExtensionsTests.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/AuthorizationEndpointConventionBuilderExtensionsTests.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/AuthorizationMiddlewareTests.cs create mode 100644 test/Microsoft.AspNetCore.Authorization.Test/TestObjects/TestAuthenticationService.cs diff --git a/.gitignore b/.gitignore index d5717b3f3..3d7e16e84 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ project.lock.json /.vs/ .vscode/ global.json +BenchmarkDotNet.Artifacts/ diff --git a/Security.sln b/Security.sln index 3df759651..240100e8c 100644 --- a/Security.sln +++ b/Security.sln @@ -79,6 +79,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WsFedSample", "samples\WsFedSample\WsFedSample.csproj", "{5EC2E398-E46A-430D-8E4B-E91C8FC3E800}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{55052FE3-F8C2-4E6C-97B0-C02ED1DBEA62}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Security.Performance", "benchmarks\Microsoft.AspNetCore.Security.Performance\Microsoft.AspNetCore.Security.Performance.csproj", "{556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -517,6 +521,22 @@ Global {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x64.Build.0 = Release|Any CPU {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x86.ActiveCfg = Release|Any CPU {5EC2E398-E46A-430D-8E4B-E91C8FC3E800}.Release|x86.Build.0 = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|x64.ActiveCfg = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|x64.Build.0 = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|x86.ActiveCfg = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Debug|x86.Build.0 = Debug|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|Any CPU.Build.0 = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|x64.ActiveCfg = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|x64.Build.0 = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|x86.ActiveCfg = Release|Any CPU + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -549,6 +569,7 @@ Global {24A28F5D-E5A9-4CA8-B0D2-924A1F8BE14E} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} {B1FC6AAF-9BF2-4CDA-84A2-AA8BF7603F29} = {4D2B6A51-2F9F-44F5-8131-EA5CAC053652} {5EC2E398-E46A-430D-8E4B-E91C8FC3E800} = {F8C0AA27-F3FB-4286-8E4C-47EF86B539FF} + {556C4FAA-F4B1-4EA9-8921-CB1DF7D94C2A} = {55052FE3-F8C2-4E6C-97B0-C02ED1DBEA62} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {ABF8089E-43D0-4010-84A7-7A9DCFE49357} diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationMiddlewareBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationMiddlewareBenchmark.cs new file mode 100644 index 000000000..90cb135de --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationMiddlewareBenchmark.cs @@ -0,0 +1,53 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Security +{ + public class AuthorizationMiddlewareBenchmark + { + private AuthorizationMiddleware _authorizationMiddleware; + private DefaultHttpContext _httpContextNoEndpoint; + private DefaultHttpContext _httpContextHasEndpoint; + + [GlobalSetup] + public void Setup() + { + var policyProvider = new DefaultAuthorizationPolicyProvider(Options.Create(new AuthorizationOptions())); + _authorizationMiddleware = new AuthorizationMiddleware((context) => Task.CompletedTask, policyProvider); + + _httpContextNoEndpoint = new DefaultHttpContext(); + + var feature = new EndpointFeature + { + Endpoint = new Endpoint((context) => Task.CompletedTask, EndpointMetadataCollection.Empty, "Test endpoint") + }; + _httpContextHasEndpoint = new DefaultHttpContext(); + _httpContextHasEndpoint.Features.Set(feature); + } + + [Benchmark] + public Task Invoke_NoEndpoint_NoAuthorization() + { + return _authorizationMiddleware.Invoke(_httpContextNoEndpoint); + } + + [Benchmark] + public Task Invoke_HasEndpoint_NoAuthorization() + { + return _authorizationMiddleware.Invoke(_httpContextHasEndpoint); + } + + private class EndpointFeature : IEndpointFeature + { + public Endpoint Endpoint { get; set; } + } + } +} diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationPolicyBenchmark.cs b/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationPolicyBenchmark.cs new file mode 100644 index 000000000..86afdcd5a --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/AuthorizationPolicyBenchmark.cs @@ -0,0 +1,28 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using BenchmarkDotNet.Attributes; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore.Security +{ + public class AuthorizationPolicyBenchmark + { + private DefaultAuthorizationPolicyProvider _policyProvider; + + [GlobalSetup] + public void Setup() + { + _policyProvider = new DefaultAuthorizationPolicyProvider(Options.Create(new AuthorizationOptions())); + } + + [Benchmark] + public Task CombineAsync() + { + return AuthorizationPolicy.CombineAsync(_policyProvider, Array.Empty()); + } + } +} diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj b/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj new file mode 100644 index 000000000..7226b64be --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp2.2 + Exe + true + true + false + Microsoft.AspNetCore.Security + + + + + + + + + + + + + + + diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/Properties/AssemblyInfo.cs b/benchmarks/Microsoft.AspNetCore.Security.Performance/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..cfb0b19c2 --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/Properties/AssemblyInfo.cs @@ -0,0 +1 @@ +[assembly: BenchmarkDotNet.Attributes.AspNetCoreBenchmark] \ No newline at end of file diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/readme.md b/benchmarks/Microsoft.AspNetCore.Security.Performance/readme.md new file mode 100644 index 000000000..cbe60261b --- /dev/null +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/readme.md @@ -0,0 +1,16 @@ +Compile the solution in Release mode (so binaries are available in release) + +To run a specific benchmark add it as parameter. +``` +dotnet run -c Release --framework +``` + +To run all benchmarks use '*' as the name. +``` +dotnet run -c Release --framework * +``` + +If you run without any parameters, you'll be offered the list of all benchmarks and get to choose. +``` +dotnet run -c Release --framework +``` \ No newline at end of file diff --git a/build/dependencies.props b/build/dependencies.props index a870f2f49..230a942c0 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,46 +3,51 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+ 0.10.13 3.0.0-alpha1-20181004.7 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.0.0-alpha1-10584 - 3.14.2 - 5.2.0 - 5.2.0 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10657 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-a-alpha1-endpoint-extensions-namespace-16778 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-preview-181105-05 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-preview-181105-05 + 3.0.0-preview-181105-05 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-alpha1-10706 + 3.0.0-preview-181105-05 + 3.0.0-alpha1-10706 + 3.19.8 + 5.3.0 + 5.3.0 2.0.9 2.1.3 - 2.2.0-preview3-27001-02 + 2.2.0-rtm-27105-02 15.6.1 3.0.1 3.0.1 3.0.1 + 4.10.0 2.0.3 11.0.2 - 5.2.0 + 5.3.0 0.10.0 2.3.1 2.4.0 diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationAppBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationAppBuilderExtensions.cs new file mode 100644 index 000000000..66f0eb6f1 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationAppBuilderExtensions.cs @@ -0,0 +1,29 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Authorization; + +namespace Microsoft.AspNetCore.Builder +{ + /// + /// Extension methods to add authorization capabilities to an HTTP application pipeline. + /// + public static class AuthorizationAppBuilderExtensions + { + /// + /// Adds the to the specified , which enables authorization capabilities. + /// + /// The to add the middleware to. + /// A reference to this instance after the operation has completed. + public static IApplicationBuilder UseAuthorization(this IApplicationBuilder app) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + + return app.UseMiddleware(); + } + } +} diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationEndpointConventionBuilderExtensions.cs b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationEndpointConventionBuilderExtensions.cs new file mode 100644 index 000000000..81b05d70a --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationEndpointConventionBuilderExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Routing; + +namespace Microsoft.AspNetCore.Builder +{ + public static class AuthorizationEndpointConventionBuilderExtensions + { + public static IEndpointConventionBuilder RequireAuthorization(this IEndpointConventionBuilder builder, params IAuthorizeData[] authorizeData) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (authorizeData == null) + { + throw new ArgumentNullException(nameof(authorizeData)); + } + + builder.Apply(endpointBuilder => + { + foreach (var data in authorizeData) + { + endpointBuilder.Metadata.Add(data); + } + }); + return builder; + } + + public static IEndpointConventionBuilder RequireAuthorization(this IEndpointConventionBuilder builder, params string[] policyNames) + { + if (builder == null) + { + throw new ArgumentNullException(nameof(builder)); + } + + if (policyNames == null) + { + throw new ArgumentNullException(nameof(policyNames)); + } + + return builder.RequireAuthorization(policyNames.Select(n => new AuthorizeAttribute(n)).ToArray()); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationMiddleware.cs b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationMiddleware.cs new file mode 100644 index 000000000..1da5b123f --- /dev/null +++ b/src/Microsoft.AspNetCore.Authorization.Policy/AuthorizationMiddleware.cs @@ -0,0 +1,104 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization.Policy; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Endpoints; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.AspNetCore.Authorization +{ + public class AuthorizationMiddleware + { + private readonly RequestDelegate _next; + private readonly IAuthorizationPolicyProvider _policyProvider; + + public AuthorizationMiddleware(RequestDelegate next, IAuthorizationPolicyProvider policyProvider) + { + if (next == null) + { + throw new ArgumentNullException(nameof(next)); + } + + if (policyProvider == null) + { + throw new ArgumentNullException(nameof(policyProvider)); + } + + _next = next; + _policyProvider = policyProvider; + } + + public async Task Invoke(HttpContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + var endpoint = context.GetEndpoint(); + var authorizeData = endpoint?.Metadata.GetOrderedMetadata() ?? Array.Empty(); + var policy = await AuthorizationPolicy.CombineAsync(_policyProvider, authorizeData); + if (policy == null) + { + await _next(context); + return; + } + + // Policy evaluator has transient lifetime so it fetched from request services instead of injecting in constructor + var policyEvaluator = context.RequestServices.GetRequiredService(); + + var authenticateResult = await policyEvaluator.AuthenticateAsync(policy, context); + + // Allow Anonymous skips all authorization + if (endpoint?.Metadata.GetMetadata() != null) + { + await _next(context); + return; + } + + // Note that the resource will be null if there is no matched endpoint + var authorizeResult = await policyEvaluator.AuthorizeAsync(policy, authenticateResult, context, resource: endpoint); + + if (authorizeResult.Challenged) + { + if (policy.AuthenticationSchemes.Any()) + { + foreach (var scheme in policy.AuthenticationSchemes) + { + await context.ChallengeAsync(scheme); + } + } + else + { + await context.ChallengeAsync(); + } + + return; + } + else if (authorizeResult.Forbidden) + { + if (policy.AuthenticationSchemes.Any()) + { + foreach (var scheme in policy.AuthenticationSchemes) + { + await context.ForbidAsync(scheme); + } + } + else + { + await context.ForbidAsync(); + } + + return; + } + + await _next(context); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index 16e4aa262..aba88dd50 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -3,7 +3,7 @@ ASP.NET Core authorization policy helper classes. netstandard2.0 - $(NoWarn);CS1591 + $(NoWarn);CS1591;NU1605 true aspnetcore;authorization @@ -14,6 +14,8 @@ + + diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs index 6899913af..f0c5527d2 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationOptions.cs @@ -20,13 +20,25 @@ public class AuthorizationOptions public bool InvokeHandlersAfterFailure { get; set; } = true; /// - /// Gets or sets the default authorization policy. + /// Gets or sets the default authorization policy. Defaults to require authenticated users. /// /// - /// The default policy is to require any authenticated user. + /// The default policy used when evaluating with no policy name specified. /// public AuthorizationPolicy DefaultPolicy { get; set; } = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + /// + /// Gets or sets the required authorization policy. Defaults to null. + /// + /// + /// By default the required policy is null. + /// + /// If a required policy has been specified then it is always evaluated, even if there are no + /// instances for a resource. If a resource has + /// then they are evaluated together with the required policy. + /// + public AuthorizationPolicy RequiredPolicy { get; set; } + /// /// Add an authorization policy with the provided name. /// diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs index 36e0ca7c3..b3b54f300 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicy.cs @@ -120,46 +120,74 @@ public static async Task CombineAsync(IAuthorizationPolicyP throw new ArgumentNullException(nameof(authorizeData)); } - var policyBuilder = new AuthorizationPolicyBuilder(); - var any = false; - foreach (var authorizeDatum in authorizeData) + // Avoid allocating enumerator if the data is known to be empty + var skipEnumeratingData = false; + if (authorizeData is IList dataList) { - any = true; - var useDefaultPolicy = true; - if (!string.IsNullOrWhiteSpace(authorizeDatum.Policy)) + skipEnumeratingData = dataList.Count == 0; + } + + AuthorizationPolicyBuilder policyBuilder = null; + if (!skipEnumeratingData) + { + foreach (var authorizeDatum in authorizeData) { - var policy = await policyProvider.GetPolicyAsync(authorizeDatum.Policy); - if (policy == null) + if (policyBuilder == null) { - throw new InvalidOperationException(Resources.FormatException_AuthorizationPolicyNotFound(authorizeDatum.Policy)); + policyBuilder = new AuthorizationPolicyBuilder(); } - policyBuilder.Combine(policy); - useDefaultPolicy = false; - } - var rolesSplit = authorizeDatum.Roles?.Split(','); - if (rolesSplit != null && rolesSplit.Any()) - { - var trimmedRolesSplit = rolesSplit.Where(r => !string.IsNullOrWhiteSpace(r)).Select(r => r.Trim()); - policyBuilder.RequireRole(trimmedRolesSplit); - useDefaultPolicy = false; - } - var authTypesSplit = authorizeDatum.AuthenticationSchemes?.Split(','); - if (authTypesSplit != null && authTypesSplit.Any()) - { - foreach (var authType in authTypesSplit) + + var useDefaultPolicy = true; + if (!string.IsNullOrWhiteSpace(authorizeDatum.Policy)) + { + var policy = await policyProvider.GetPolicyAsync(authorizeDatum.Policy); + if (policy == null) + { + throw new InvalidOperationException(Resources.FormatException_AuthorizationPolicyNotFound(authorizeDatum.Policy)); + } + policyBuilder.Combine(policy); + useDefaultPolicy = false; + } + + var rolesSplit = authorizeDatum.Roles?.Split(','); + if (rolesSplit != null && rolesSplit.Any()) + { + var trimmedRolesSplit = rolesSplit.Where(r => !string.IsNullOrWhiteSpace(r)).Select(r => r.Trim()); + policyBuilder.RequireRole(trimmedRolesSplit); + useDefaultPolicy = false; + } + + var authTypesSplit = authorizeDatum.AuthenticationSchemes?.Split(','); + if (authTypesSplit != null && authTypesSplit.Any()) { - if (!string.IsNullOrWhiteSpace(authType)) + foreach (var authType in authTypesSplit) { - policyBuilder.AuthenticationSchemes.Add(authType.Trim()); + if (!string.IsNullOrWhiteSpace(authType)) + { + policyBuilder.AuthenticationSchemes.Add(authType.Trim()); + } } } + + if (useDefaultPolicy) + { + policyBuilder.Combine(await policyProvider.GetDefaultPolicyAsync()); + } } - if (useDefaultPolicy) + } + + var requiredPolicy = await policyProvider.GetRequiredPolicyAsync(); + if (requiredPolicy != null) + { + if (policyBuilder == null) { - policyBuilder.Combine(await policyProvider.GetDefaultPolicyAsync()); + policyBuilder = new AuthorizationPolicyBuilder(); } + + policyBuilder.Combine(requiredPolicy); } - return any ? policyBuilder.Build() : null; + + return policyBuilder?.Build(); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs index 0e4329dcc..f5e665273 100644 --- a/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/DefaultAuthorizationPolicyProvider.cs @@ -14,6 +14,8 @@ namespace Microsoft.AspNetCore.Authorization public class DefaultAuthorizationPolicyProvider : IAuthorizationPolicyProvider { private readonly AuthorizationOptions _options; + private Task _cachedDefaultPolicy; + private Task _cachedRequiredPolicy; /// /// Creates a new instance of . @@ -35,7 +37,26 @@ public DefaultAuthorizationPolicyProvider(IOptions options /// The default authorization policy. public Task GetDefaultPolicyAsync() { - return Task.FromResult(_options.DefaultPolicy); + return GetCachedPolicy(ref _cachedDefaultPolicy, _options.DefaultPolicy); + } + + /// + /// Gets the required authorization policy. + /// + /// The required authorization policy. + public Task GetRequiredPolicyAsync() + { + return GetCachedPolicy(ref _cachedRequiredPolicy, _options.RequiredPolicy); + } + + private Task GetCachedPolicy(ref Task cachedPolicy, AuthorizationPolicy currentPolicy) + { + var local = cachedPolicy; + if (local == null || local.Result != currentPolicy) + { + cachedPolicy = local = Task.FromResult(currentPolicy); + } + return local; } /// diff --git a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs index 9e9d0f468..4560d11e0 100644 --- a/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Authorization/IAuthorizationPolicyProvider.cs @@ -22,5 +22,11 @@ public interface IAuthorizationPolicyProvider /// /// The default authorization policy. Task GetDefaultPolicyAsync(); + + /// + /// Gets the required authorization policy. + /// + /// The required authorization policy. + Task GetRequiredPolicyAsync(); } } diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationAppBuilderExtensionsTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationAppBuilderExtensionsTests.cs new file mode 100644 index 000000000..c6fb596f1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationAppBuilderExtensionsTests.cs @@ -0,0 +1,65 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization.Test.TestObjects; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder.Internal; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Endpoints; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Microsoft.AspNetCore.Authorization.Test +{ + public class AuthorizationAppBuilderExtensionsTests + { + [Fact] + public async Task UseAuthorization_RegistersMiddleware() + { + // Arrange + var authenticationService = new TestAuthenticationService(); + var services = CreateServices(authenticationService); + + var app = new ApplicationBuilder(services); + + app.UseAuthorization(); + + var appFunc = app.Build(); + + var endpoint = new Endpoint( + null, + new EndpointMetadataCollection(new AuthorizeAttribute()), + "Test endpoint"); + + var httpContext = new DefaultHttpContext(); + httpContext.RequestServices = services; + httpContext.SetEndpoint(endpoint); + + // Act + await appFunc(httpContext); + + // Assert + Assert.True(authenticationService.ChallengeCalled); + } + + private IServiceProvider CreateServices(IAuthenticationService authenticationService) + { + var services = new ServiceCollection(); + + services.AddAuthorization(options => { }); + services.AddAuthorizationPolicyEvaluator(); + services.AddLogging(); + services.AddSingleton(authenticationService); + + var serviceProvder = services.BuildServiceProvider(); + + return serviceProvder; + } + } +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationEndpointConventionBuilderExtensionsTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationEndpointConventionBuilderExtensionsTests.cs new file mode 100644 index 000000000..a2ab8fa8b --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationEndpointConventionBuilderExtensionsTests.cs @@ -0,0 +1,63 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Routing.Patterns; +using Xunit; + +namespace Microsoft.AspNetCore.Authorization.Test +{ + public class AuthorizationEndpointConventionBuilderExtensionsTests + { + [Fact] + public void RequireAuthorization_IAuthorizeData() + { + // Arrange + var builder = new TestEndpointConventionBuilder(); + var metadata = new AuthorizeAttribute(); + + // Act + builder.RequireAuthorization(metadata); + + // Assert + var convention = Assert.Single(builder.Conventions); + + var endpointModel = new RouteEndpointModel((context) => Task.CompletedTask, RoutePatternFactory.Parse("/"), 0); + convention(endpointModel); + + Assert.Equal(metadata, Assert.Single(endpointModel.Metadata)); + } + + [Fact] + public void RequireAuthorization_PolicyName() + { + // Arrange + var builder = new TestEndpointConventionBuilder(); + + // Act + builder.RequireAuthorization("policy"); + + // Assert + var convention = Assert.Single(builder.Conventions); + + var endpointModel = new RouteEndpointModel((context) => Task.CompletedTask, RoutePatternFactory.Parse("/"), 0); + convention(endpointModel); + + Assert.Equal("policy", Assert.IsAssignableFrom(Assert.Single(endpointModel.Metadata)).Policy); + } + + private class TestEndpointConventionBuilder : IEndpointConventionBuilder + { + public IList> Conventions { get; } = new List>(); + + public void Apply(Action convention) + { + Conventions.Add(convention); + } + } + } +} diff --git a/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationMiddlewareTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationMiddlewareTests.cs new file mode 100644 index 000000000..655a4fbf8 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/AuthorizationMiddlewareTests.cs @@ -0,0 +1,459 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization.Infrastructure; +using Microsoft.AspNetCore.Authorization.Test.TestObjects; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Endpoints; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Authorization.Test +{ + public class AuthorizationMiddlewareTests + { + [Fact] + public async Task NoEndpoint_AnonymousUser_Allows() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + } + + [Fact] + public async Task NoEndpointWithRequired_AnonymousUser_Challenges() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetRequiredPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + } + + [Fact] + public async Task HasEndpointWithoutAuth_AnonymousUser_Allows() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint()); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + } + + [Fact] + public async Task HasEndpointWithRequiredWithoutAuth_AnonymousUser_Challenges() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + policyProvider.Setup(p => p.GetRequiredPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint()); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + } + + [Fact] + public async Task HasEndpointWithAuth_AnonymousUser_Challenges() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.True(authenticationService.ChallengeCalled); + } + + [Fact] + public async Task HasEndpointWithAuth_AnonymousUser_ChallengePerScheme() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().AddAuthenticationSchemes("schema1", "schema2").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.Equal(2, authenticationService.ChallengeCount); + } + + [Fact] + public async Task OnAuthorizationAsync_WillCallPolicyProvider() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAssertion(_ => true).Build(); + var policyProvider = new Mock(); + var getPolicyCount = 0; + var getRequiredPolicyCount = 0; + policyProvider.Setup(p => p.GetPolicyAsync(It.IsAny())).ReturnsAsync(policy) + .Callback(() => getPolicyCount++); + policyProvider.Setup(p => p.GetRequiredPolicyAsync()).ReturnsAsync(policy) + .Callback(() => getRequiredPolicyCount++); + var next = new TestRequestDelegate(); + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new AuthorizeAttribute("whatever"))); + + // Act & Assert + await middleware.Invoke(context); + Assert.Equal(1, getPolicyCount); + Assert.Equal(1, getRequiredPolicyCount); + Assert.Equal(1, next.CalledCount); + + await middleware.Invoke(context); + Assert.Equal(2, getPolicyCount); + Assert.Equal(2, getRequiredPolicyCount); + Assert.Equal(2, next.CalledCount); + + await middleware.Invoke(context); + Assert.Equal(3, getPolicyCount); + Assert.Equal(3, getRequiredPolicyCount); + Assert.Equal(3, next.CalledCount); + } + + [Fact] + public async Task Invoke_ValidClaimShouldNotFail() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewPage").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute())); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + } + + [Fact] + public async Task HasEndpointWithAuthAndAllowAnonymous_AnonymousUser_Allows() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(anonymous: true, endpoint: CreateEndpoint(new AuthorizeAttribute(), new AllowAnonymousAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + Assert.False(authenticationService.ChallengeCalled); + } + + [Fact] + public async Task HasEndpointWithAuth_AuthenticatedUser_Allows() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + Assert.False(authenticationService.ChallengeCalled); + } + + [Fact] + public async Task Invoke_AuthSchemesFailShouldSetEmptyPrincipalOnContext() + { + // Arrange + var policy = new AuthorizationPolicyBuilder("Fails").RequireAuthenticatedUser().Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.NotNull(context.User?.Identity); + Assert.True(authenticationService.AuthenticateCalled); + Assert.True(authenticationService.ChallengeCalled); + } + + [Fact] + public async Task Invoke_SingleValidClaimShouldSucceed() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireClaim("Permission", "CanViewComment", "CanViewPage").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute())); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.True(next.Called); + } + + [Fact] + public async Task AuthZResourceShouldBeEndpoint() + { + // Arrange + object resource = null; + var policy = new AuthorizationPolicyBuilder().RequireAssertion(c => + { + resource = c.Resource; + return true; + }).Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var endpoint = CreateEndpoint(new AuthorizeAttribute()); + var context = GetHttpContext(endpoint: endpoint); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.Equal(endpoint, resource); + } + + [Fact] + public async Task Invoke_RequireUnknownRoleShouldForbid() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireRole("Wut").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.False(authenticationService.ChallengeCalled); + Assert.True(authenticationService.ForbidCalled); + } + + [Fact] + public async Task Invoke_RequireUnknownRole_ForbidPerScheme() + { + // Arrange + var policy = new AuthorizationPolicyBuilder().RequireRole("Wut").AddAuthenticationSchemes("Basic", "Bearer").Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.Equal(2, authenticationService.ForbidCount); + } + + [Fact] + public async Task Invoke_InvalidClaimShouldForbid() + { + // Arrange + var policy = new AuthorizationPolicyBuilder() + .RequireClaim("Permission", "CanViewComment") + .Build(); + var policyProvider = new Mock(); + policyProvider.Setup(p => p.GetDefaultPolicyAsync()).ReturnsAsync(policy); + var next = new TestRequestDelegate(); + var authenticationService = new TestAuthenticationService(); + + var middleware = CreateMiddleware(next.Invoke, policyProvider.Object); + var context = GetHttpContext(endpoint: CreateEndpoint(new AuthorizeAttribute()), authenticationService: authenticationService); + + // Act + await middleware.Invoke(context); + + // Assert + Assert.False(next.Called); + Assert.False(authenticationService.ChallengeCalled); + Assert.True(authenticationService.ForbidCalled); + } + + private AuthorizationMiddleware CreateMiddleware(RequestDelegate requestDelegate = null, IAuthorizationPolicyProvider policyProvider = null) + { + requestDelegate = requestDelegate ?? ((context) => Task.CompletedTask); + + return new AuthorizationMiddleware(requestDelegate, policyProvider); + } + + private Endpoint CreateEndpoint(params object[] metadata) + { + return new Endpoint(context => Task.CompletedTask, new EndpointMetadataCollection(metadata), "Test endpoint"); + } + + private HttpContext GetHttpContext( + bool anonymous = false, + Action registerServices = null, + Endpoint endpoint = null, + IAuthenticationService authenticationService = null) + { + var basicPrincipal = new ClaimsPrincipal( + new ClaimsIdentity( + new Claim[] { + new Claim("Permission", "CanViewPage"), + new Claim(ClaimTypes.Role, "Administrator"), + new Claim(ClaimTypes.Role, "User"), + new Claim(ClaimTypes.NameIdentifier, "John")}, + "Basic")); + + var validUser = basicPrincipal; + + var bearerIdentity = new ClaimsIdentity( + new Claim[] { + new Claim("Permission", "CupBearer"), + new Claim(ClaimTypes.Role, "Token"), + new Claim(ClaimTypes.NameIdentifier, "John Bear")}, + "Bearer"); + + validUser.AddIdentity(bearerIdentity); + + // ServiceProvider + var serviceCollection = new ServiceCollection(); + + authenticationService = authenticationService ?? Mock.Of(); + + serviceCollection.AddSingleton(authenticationService); + serviceCollection.AddOptions(); + serviceCollection.AddLogging(); + serviceCollection.AddAuthorization(); + serviceCollection.AddAuthorizationPolicyEvaluator(); + registerServices?.Invoke(serviceCollection); + + var serviceProvider = serviceCollection.BuildServiceProvider(); + + //// HttpContext + var httpContext = new DefaultHttpContext(); + if (endpoint != null) + { + httpContext.SetEndpoint(endpoint); + } + httpContext.RequestServices = serviceProvider; + if (!anonymous) + { + httpContext.User = validUser; + } + + return httpContext; + } + + private class TestRequestDelegate + { + private readonly int _statusCode; + + public bool Called => CalledCount > 0; + public int CalledCount { get; private set; } + + public TestRequestDelegate(int statusCode = 200) + { + _statusCode = statusCode; + } + + public Task Invoke(HttpContext context) + { + CalledCount++; + context.Response.StatusCode = _statusCode; + return Task.CompletedTask; + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs index ef17b9462..230e95c4c 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs +++ b/test/Microsoft.AspNetCore.Authorization.Test/DefaultAuthorizationServiceTests.cs @@ -1025,6 +1025,11 @@ public Task GetDefaultPolicyAsync() return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); } + public Task GetRequiredPolicyAsync() + { + return Task.FromResult(null); + } + public Task GetPolicyAsync(string policyName) { return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); @@ -1059,6 +1064,11 @@ public Task GetDefaultPolicyAsync() return Task.FromResult(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()); } + public Task GetRequiredPolicyAsync() + { + return Task.FromResult(null); + } + public Task GetPolicyAsync(string policyName) { return Task.FromResult(new AuthorizationPolicyBuilder().RequireClaim(policyName).Build()); diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index d4379c3aa..40a8fff12 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -2,6 +2,7 @@ $(StandardTestTfms) + $(NoWarn);NU1605 @@ -11,8 +12,10 @@ + + diff --git a/test/Microsoft.AspNetCore.Authorization.Test/TestObjects/TestAuthenticationService.cs b/test/Microsoft.AspNetCore.Authorization.Test/TestObjects/TestAuthenticationService.cs new file mode 100644 index 000000000..0c17693d1 --- /dev/null +++ b/test/Microsoft.AspNetCore.Authorization.Test/TestObjects/TestAuthenticationService.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authorization.Test.TestObjects +{ + public class TestAuthenticationService : IAuthenticationService + { + public bool ChallengeCalled => ChallengeCount > 0; + public bool ForbidCalled => ForbidCount > 0; + public bool AuthenticateCalled => AuthenticateCount > 0; + + public int ChallengeCount { get; private set; } + public int ForbidCount { get; private set; } + public int AuthenticateCount { get; private set; } + + public Task AuthenticateAsync(HttpContext context, string scheme) + { + AuthenticateCount++; + + var identity = context.User.Identities.SingleOrDefault(i => i.AuthenticationType == scheme); + if (identity != null) + { + return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(identity), scheme))); + } + + return Task.FromResult(AuthenticateResult.Fail("Denied")); + } + + public Task ChallengeAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + ChallengeCount++; + return Task.CompletedTask; + } + + public Task ForbidAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + ForbidCount++; + return Task.CompletedTask; + } + + public Task SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + + public Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file From 42dd66647dd389c242ff796a530b880c7b9d7a90 Mon Sep 17 00:00:00 2001 From: Ben McCallum Date: Tue, 13 Nov 2018 23:05:55 +0100 Subject: [PATCH 244/248] refactor: Rename param from requiredValues to allowedValues to better indicate usage. (#1908) --- .../AuthorizationPolicyBuilder.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs index 37335df8f..ddca49d3a 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizationPolicyBuilder.cs @@ -96,16 +96,16 @@ public AuthorizationPolicyBuilder Combine(AuthorizationPolicy policy) /// to the current instance. /// /// The claim type required. - /// Values the claim must process one or more of for evaluation to succeed. + /// Values the claim must process one or more of for evaluation to succeed. /// A reference to this instance after the operation has completed. - public AuthorizationPolicyBuilder RequireClaim(string claimType, params string[] requiredValues) + public AuthorizationPolicyBuilder RequireClaim(string claimType, params string[] allowedValues) { if (claimType == null) { throw new ArgumentNullException(nameof(claimType)); } - return RequireClaim(claimType, (IEnumerable)requiredValues); + return RequireClaim(claimType, (IEnumerable)allowedValues); } /// @@ -113,16 +113,16 @@ public AuthorizationPolicyBuilder RequireClaim(string claimType, params string[] /// to the current instance. /// /// The claim type required. - /// Values the claim must process one or more of for evaluation to succeed. + /// Values the claim must process one or more of for evaluation to succeed. /// A reference to this instance after the operation has completed. - public AuthorizationPolicyBuilder RequireClaim(string claimType, IEnumerable requiredValues) + public AuthorizationPolicyBuilder RequireClaim(string claimType, IEnumerable allowedValues) { if (claimType == null) { throw new ArgumentNullException(nameof(claimType)); } - Requirements.Add(new ClaimsAuthorizationRequirement(claimType, requiredValues)); + Requirements.Add(new ClaimsAuthorizationRequirement(claimType, allowedValues)); return this; } From 7e14b052ea9cb935ec4f5cb0485b4edb5d41297a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Fri, 16 Nov 2018 00:12:42 +0100 Subject: [PATCH 245/248] Add AccessDeniedPath support to the OIDC/OAuth2/Twitter providers (#1887) * Add AccessDeniedPath support to the OIDC/OAuth2/Twitter providers * Update the code documentation and remove an unnecessary call to SignOutAsync() * Introduce a new AccessDenied event and move most of the access denied handling logic to RemoteAuthenticationHandler * Add ReturnUrlParameter support to RemoteAuthenticationHandler * Remove AccessDeniedException and introduce RemoteAuthenticationHandler.HandleAccessDeniedErrorAsync() * Use OriginalPath instead of Request.Path * Update obsolete code comments * Add unit tests for the new AccessDenied event * Allow customizing the access denied path/return URL/return URL parameter from the AccessDenied event --- samples/OpenIdConnectSample/Startup.cs | 11 ++ .../CookieAuthenticationHandler.cs | 4 +- .../OAuthHandler.cs | 12 +- .../OAuthOptions.cs | 6 +- .../OpenIdConnectHandler.cs | 14 ++- .../TwitterHandler.cs | 10 +- .../TwitterOptions.cs | 2 +- .../WsFederationHandler.cs | 2 +- .../Events/AccessDeniedContext.cs | 44 ++++++++ .../Events/RemoteAuthenticationEvents.cs | 8 +- .../LoggingExtensions.cs | 52 +++++++-- .../RemoteAuthenticationHandler.cs | 44 ++++++++ .../RemoteAuthenticationOptions.cs | 16 +++ .../GoogleTests.cs | 68 +++++++++++- .../OAuthTests.cs | 103 +++++++++++++++++- .../OpenIdConnect/OpenIdConnectEventTests.cs | 60 +++++++++- .../TwitterTests.cs | 90 ++++++++++++++- 17 files changed, 510 insertions(+), 36 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication/Events/AccessDeniedContext.cs diff --git a/samples/OpenIdConnectSample/Startup.cs b/samples/OpenIdConnectSample/Startup.cs index 1aa7625cb..a2b5a9a5c 100644 --- a/samples/OpenIdConnectSample/Startup.cs +++ b/samples/OpenIdConnectSample/Startup.cs @@ -63,6 +63,7 @@ public void ConfigureServices(IServiceCollection services) o.ResponseType = OpenIdConnectResponseType.CodeIdToken; o.SaveTokens = true; o.GetClaimsFromUserInfoEndpoint = true; + o.AccessDeniedPath = "/access-denied-from-remote"; o.ClaimActions.MapAllExcept("aud", "iss", "iat", "nbf", "exp", "aio", "c_hash", "uti", "nonce"); @@ -126,6 +127,16 @@ await WriteHtmlAsync(response, async res => return; } + if (context.Request.Path.Equals("/access-denied-from-remote")) + { + await WriteHtmlAsync(response, async res => + { + await res.WriteAsync($"

Access Denied error received from the remote authorization server

"); + await res.WriteAsync("Home"); + }); + return; + } + if (context.Request.Path.Equals("/Account/AccessDenied")) { await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index b77a51ef4..ff6bb3cbc 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -422,7 +422,7 @@ protected override async Task HandleForbiddenAsync(AuthenticationProperties prop var returnUrl = properties.RedirectUri; if (string.IsNullOrEmpty(returnUrl)) { - returnUrl = OriginalPathBase + Request.Path + Request.QueryString; + returnUrl = OriginalPathBase + OriginalPath + Request.QueryString; } var accessDeniedUri = Options.AccessDeniedPath + QueryString.Create(Options.ReturnUrlParameter, returnUrl); var redirectContext = new RedirectContext(Context, Scheme, Options, properties, BuildRedirectUri(accessDeniedUri)); @@ -434,7 +434,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop var redirectUri = properties.RedirectUri; if (string.IsNullOrEmpty(redirectUri)) { - redirectUri = OriginalPathBase + Request.Path + Request.QueryString; + redirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } var loginUri = Options.LoginPath + QueryString.Create(Options.ReturnUrlParameter, redirectUri); diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index 808e0f903..05ba4df68 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -63,6 +63,16 @@ protected override async Task HandleRemoteAuthenticateAsync var error = query["error"]; if (!StringValues.IsNullOrEmpty(error)) { + // Note: access_denied errors are special protocol errors indicating the user didn't + // approve the authorization demand requested by the remote authorization server. + // Since it's a frequent scenario (that is not caused by incorrect configuration), + // denied errors are handled differently using HandleAccessDeniedErrorAsync(). + // Visit https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for more information. + if (StringValues.Equals(error, "access_denied")) + { + return await HandleAccessDeniedErrorAsync(properties); + } + var failureMessage = new StringBuilder(); failureMessage.Append(error); var errorDescription = query["error_description"]; @@ -194,7 +204,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop { if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } // OAuth2 10.12 CSRF diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs index 3c71f055f..4eacbd0b3 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthOptions.cs @@ -3,11 +3,9 @@ using System; using System.Collections.Generic; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Authentication.OAuth.Claims; -using Microsoft.AspNetCore.Http.Authentication; using System.Globalization; +using Microsoft.AspNetCore.Authentication.OAuth.Claims; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication.OAuth { diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs index 029cf541b..8b0b72428 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs @@ -186,7 +186,7 @@ public async virtual Task SignOutAsync(AuthenticationProperties properties) properties.RedirectUri = BuildRedirectUriIfRelative(Options.SignedOutRedirectUri); if (string.IsNullOrWhiteSpace(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } } Logger.PostSignOutRedirect(properties.RedirectUri); @@ -312,7 +312,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // 2. CurrentUri if RedirectUri is not set) if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } Logger.PostAuthenticationLocalRedirect(properties.RedirectUri); @@ -520,6 +520,16 @@ protected override async Task HandleRemoteAuthenticateAsync // if any of the error fields are set, throw error null if (!string.IsNullOrEmpty(authorizationResponse.Error)) { + // Note: access_denied errors are special protocol errors indicating the user didn't + // approve the authorization demand requested by the remote authorization server. + // Since it's a frequent scenario (that is not caused by incorrect configuration), + // denied errors are handled differently using HandleAccessDeniedErrorAsync(). + // Visit https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for more information. + if (string.Equals(authorizationResponse.Error, "access_denied", StringComparison.Ordinal)) + { + return await HandleAccessDeniedErrorAsync(properties); + } + return HandleRequestResult.Fail(CreateOpenIdConnectProtocolException(authorizationResponse, response: null), properties); } diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs index 51dabbd99..cc8591ed3 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterHandler.cs @@ -55,12 +55,14 @@ protected override async Task HandleRemoteAuthenticateAsync var properties = requestToken.Properties; - // REVIEW: see which of these are really errors - var denied = query["denied"]; if (!StringValues.IsNullOrEmpty(denied)) { - return HandleRequestResult.Fail("The user denied permissions.", properties); + // Note: denied errors are special protocol errors indicating the user didn't + // approve the authorization demand requested by the remote authorization server. + // Since it's a frequent scenario (that is not caused by incorrect configuration), + // denied errors are handled differently using HandleAccessDeniedErrorAsync(). + return await HandleAccessDeniedErrorAsync(properties); } var returnedToken = query["oauth_token"]; @@ -130,7 +132,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop { if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } // If CallbackConfirmed is false, this will throw diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs index 03396807e..269516ae1 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/TwitterOptions.cs @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Security.Claims; using System.Globalization; +using System.Security.Claims; using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.AspNetCore.Http; diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs index e47f8431f..c4bb8fff7 100644 --- a/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/WsFederationHandler.cs @@ -83,7 +83,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop // Save the original challenge URI so we can redirect back to it when we're done. if (string.IsNullOrEmpty(properties.RedirectUri)) { - properties.RedirectUri = CurrentUri; + properties.RedirectUri = OriginalPathBase + OriginalPath + Request.QueryString; } var wsFederationMessage = new WsFederationMessage() diff --git a/src/Microsoft.AspNetCore.Authentication/Events/AccessDeniedContext.cs b/src/Microsoft.AspNetCore.Authentication/Events/AccessDeniedContext.cs new file mode 100644 index 000000000..f01d69453 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/Events/AccessDeniedContext.cs @@ -0,0 +1,44 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Authentication +{ + /// + /// Provides access denied failure context information to handler providers. + /// + public class AccessDeniedContext : HandleRequestContext + { + public AccessDeniedContext( + HttpContext context, + AuthenticationScheme scheme, + RemoteAuthenticationOptions options) + : base(context, scheme, options) + { + } + + /// + /// Gets or sets the endpoint path the user agent will be redirected to. + /// By default, this property is set to . + /// + public PathString AccessDeniedPath { get; set; } + + /// + /// Additional state values for the authentication session. + /// + public AuthenticationProperties Properties { get; set; } + + /// + /// Gets or sets the return URL that will be flowed up to the access denied page. + /// If is not set, this property is not used. + /// + public string ReturnUrl { get; set; } + + /// + /// Gets or sets the parameter name that will be used to flow the return URL. + /// By default, this property is set to . + /// + public string ReturnUrlParameter { get; set; } + } +} diff --git a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs index ca0f4a5c0..be4c6ab49 100644 --- a/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs +++ b/src/Microsoft.AspNetCore.Authentication/Events/RemoteAuthenticationEvents.cs @@ -8,12 +8,18 @@ namespace Microsoft.AspNetCore.Authentication { public class RemoteAuthenticationEvents { + public Func OnAccessDenied { get; set; } = context => Task.CompletedTask; public Func OnRemoteFailure { get; set; } = context => Task.CompletedTask; public Func OnTicketReceived { get; set; } = context => Task.CompletedTask; /// - /// Invoked when there is a remote failure + /// Invoked when an access denied error was returned by the remote server. + /// + public virtual Task AccessDenied(AccessDeniedContext context) => OnAccessDenied(context); + + /// + /// Invoked when there is a remote failure. /// public virtual Task RemoteFailure(RemoteFailureContext context) => OnRemoteFailure(context); diff --git a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs index 8cba6c0d5..042bfabca 100644 --- a/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/LoggingExtensions.cs @@ -7,17 +7,20 @@ namespace Microsoft.Extensions.Logging { internal static class LoggingExtensions { - private static Action _authSchemeAuthenticated; - private static Action _authSchemeNotAuthenticated; - private static Action _authSchemeNotAuthenticatedWithFailure; - private static Action _authSchemeChallenged; - private static Action _authSchemeForbidden; - private static Action _remoteAuthenticationError; - private static Action _signInHandled; - private static Action _signInSkipped; - private static Action _correlationPropertyNotFound; - private static Action _correlationCookieNotFound; - private static Action _unexpectedCorrelationCookieValue; + private static readonly Action _authSchemeAuthenticated; + private static readonly Action _authSchemeNotAuthenticated; + private static readonly Action _authSchemeNotAuthenticatedWithFailure; + private static readonly Action _authSchemeChallenged; + private static readonly Action _authSchemeForbidden; + private static readonly Action _remoteAuthenticationError; + private static readonly Action _signInHandled; + private static readonly Action _signInSkipped; + private static readonly Action _correlationPropertyNotFound; + private static readonly Action _correlationCookieNotFound; + private static readonly Action _unexpectedCorrelationCookieValue; + private static readonly Action _accessDeniedError; + private static readonly Action _accessDeniedContextHandled; + private static readonly Action _accessDeniedContextSkipped; static LoggingExtensions() { @@ -65,6 +68,18 @@ static LoggingExtensions() eventId: 16, logLevel: LogLevel.Warning, formatString: "The correlation cookie value '{CorrelationCookieName}' did not match the expected value '{CorrelationCookieValue}'."); + _accessDeniedError = LoggerMessage.Define( + eventId: 17, + logLevel: LogLevel.Information, + formatString: "Access was denied by the resource owner or by the remote server."); + _accessDeniedContextHandled = LoggerMessage.Define( + eventId: 18, + logLevel: LogLevel.Debug, + formatString: "The AccessDenied event returned Handled."); + _accessDeniedContextSkipped = LoggerMessage.Define( + eventId: 19, + logLevel: LogLevel.Debug, + formatString: "The AccessDenied event returned Skipped."); } public static void AuthenticationSchemeAuthenticated(this ILogger logger, string authenticationScheme) @@ -121,5 +136,20 @@ public static void UnexpectedCorrelationCookieValue(this ILogger logger, string { _unexpectedCorrelationCookieValue(logger, cookieName, cookieValue, null); } + + public static void AccessDeniedError(this ILogger logger) + { + _accessDeniedError(logger, null); + } + + public static void AccessDeniedContextHandled(this ILogger logger) + { + _accessDeniedContextHandled(logger, null); + } + + public static void AccessDeniedContextSkipped(this ILogger logger) + { + _accessDeniedContextSkipped(logger, null); + } } } diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index bea4895d6..c72583b5c 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -5,6 +5,7 @@ using System.Security.Cryptography; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -241,5 +242,48 @@ protected virtual bool ValidateCorrelationId(AuthenticationProperties properties return true; } + + protected virtual async Task HandleAccessDeniedErrorAsync(AuthenticationProperties properties) + { + Logger.AccessDeniedError(); + var context = new AccessDeniedContext(Context, Scheme, Options) + { + AccessDeniedPath = Options.AccessDeniedPath, + Properties = properties, + ReturnUrl = properties?.RedirectUri, + ReturnUrlParameter = Options.ReturnUrlParameter + }; + await Events.AccessDenied(context); + + if (context.Result != null) + { + if (context.Result.Handled) + { + Logger.AccessDeniedContextHandled(); + } + else if (context.Result.Skipped) + { + Logger.AccessDeniedContextSkipped(); + } + + return context.Result; + } + + // If an access denied endpoint was specified, redirect the user agent. + // Otherwise, invoke the RemoteFailure event for further processing. + if (context.AccessDeniedPath.HasValue) + { + string uri = context.AccessDeniedPath; + if (!string.IsNullOrEmpty(context.ReturnUrlParameter) && !string.IsNullOrEmpty(context.ReturnUrl)) + { + uri = QueryHelpers.AddQueryString(uri, context.ReturnUrlParameter, context.ReturnUrl); + } + Response.Redirect(uri); + + return HandleRequestResult.Handle(); + } + + return HandleRequestResult.Fail("Access was denied by the resource owner or by the remote server.", properties); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs index 1bd3b210e..188b7a991 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationOptions.cs @@ -89,6 +89,22 @@ public override void Validate() /// public PathString CallbackPath { get; set; } + /// + /// Gets or sets the optional path the user agent is redirected to if the user + /// doesn't approve the authorization demand requested by the remote server. + /// This property is not set by default. In this case, an exception is thrown + /// if an access_denied response is returned by the remote authorization server. + /// + public PathString AccessDeniedPath { get; set; } + + /// + /// Gets or sets the name of the parameter used to convey the original location + /// of the user before the remote challenge was triggered up to the access denied page. + /// This property is only used when the is explicitly specified. + /// + // Note: this deliberately matches the default parameter name used by the cookie handler. + public string ReturnUrlParameter { get; set; } = "ReturnUrl"; + /// /// Gets or sets the authentication scheme corresponding to the middleware /// responsible of persisting user's identity after a successful authentication. diff --git a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs index 19d7d898b..ce158eaf2 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/GoogleTests.cs @@ -357,6 +357,70 @@ public async Task ReplyPathWithoutStateQueryStringWillBeRejected() Assert.Equal("The oauth state was missing or invalid.", error.GetBaseException().Message); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task ReplyPathWithAccessDeniedErrorFails(bool redirect) + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = new TestStateDataFormat(); + o.Events = redirect ? new OAuthEvents() + { + OnAccessDenied = ctx => + { + ctx.Response.Redirect("/error?FailureMessage=AccessDenied"); + ctx.HandleResponse(); + return Task.FromResult(0); + } + } : new OAuthEvents(); + }); + var sendTask = server.SendAsync("https://example.com/signin-google?error=access_denied&error_description=SoBad&error_uri=foobar&state=protected_state", + ".AspNetCore.Correlation.Google.correlationId=N"); + if (redirect) + { + var transaction = await sendTask; + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/error?FailureMessage=AccessDenied", transaction.Response.Headers.GetValues("Location").First()); + } + else + { + var error = await Assert.ThrowsAnyAsync(() => sendTask); + Assert.Equal("Access was denied by the resource owner or by the remote server.", error.GetBaseException().Message); + } + } + + [Fact] + public async Task ReplyPathWithAccessDeniedError_AllowsCustomizingPath() + { + var server = CreateServer(o => + { + o.ClientId = "Test Id"; + o.ClientSecret = "Test Secret"; + o.StateDataFormat = new TestStateDataFormat(); + o.AccessDeniedPath = "/access-denied"; + o.Events = new OAuthEvents() + { + OnAccessDenied = ctx => + { + Assert.Equal("/access-denied", ctx.AccessDeniedPath.Value); + Assert.Equal("http://testhost/redirect", ctx.ReturnUrl); + Assert.Equal("ReturnUrl", ctx.ReturnUrlParameter); + ctx.AccessDeniedPath = "/custom-denied-page"; + ctx.ReturnUrl = "http://www.google.com/"; + ctx.ReturnUrlParameter = "rurl"; + return Task.FromResult(0); + } + }; + }); + var transaction = await server.SendAsync("https://example.com/signin-google?error=access_denied&error_description=SoBad&error_uri=foobar&state=protected_state", + ".AspNetCore.Correlation.Google.correlationId=N"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/custom-denied-page?rurl=http%3A%2F%2Fwww.google.com%2F", transaction.Response.Headers.GetValues("Location").First()); + } + [Theory] [InlineData(true)] [InlineData(false)] @@ -378,7 +442,7 @@ public async Task ReplyPathWithErrorFails(bool redirect) } : new OAuthEvents(); }); var sendTask = server.SendAsync("https://example.com/signin-google?error=OMG&error_description=SoBad&error_uri=foobar&state=protected_state", - ".AspNetCore.Correlation.Google.corrilationId=N"); + ".AspNetCore.Correlation.Google.correlationId=N"); if (redirect) { var transaction = await sendTask; @@ -1205,7 +1269,7 @@ public AuthenticationProperties Unprotect(string protectedText) Assert.Equal("protected_state", protectedText); var properties = new AuthenticationProperties(new Dictionary() { - { ".xsrf", "corrilationId" }, + { ".xsrf", "correlationId" }, { "testkey", "testvalue" } }); properties.RedirectUri = "http://testhost/redirect"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs index 87131b8d7..838798cea 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OAuthTests.cs @@ -251,6 +251,101 @@ protected override void ConfigureDefaults(OAuthOptions o) o.CallbackPath = "/oauth-callback"; } + [Fact] + public async Task HandleRequestAsync_RedirectsToAccessDeniedPathWhenExplicitlySet() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + opt.ClientId = "Test Id"; + opt.ClientSecret = "secret"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.AuthorizationEndpoint = "https://example.com/provider/login"; + opt.TokenEndpoint = "https://example.com/provider/token"; + opt.CallbackPath = "/oauth-callback"; + opt.AccessDeniedPath = "/access-denied"; + opt.StateDataFormat = new TestStateDataFormat(); + opt.Events.OnRemoteFailure = context => throw new InvalidOperationException("This event should not be called."); + })); + + var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=access_denied&state=protected_state", + ".AspNetCore.Correlation.Weblie.correlationId=N"); + + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + Assert.Equal("/access-denied?ReturnUrl=http%3A%2F%2Ftesthost%2Fredirect", transaction.Response.Headers.Location.ToString()); + } + + [Fact] + public async Task HandleRequestAsync_InvokesAccessDeniedEvent() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + opt.ClientId = "Test Id"; + opt.ClientSecret = "secret"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.AuthorizationEndpoint = "https://example.com/provider/login"; + opt.TokenEndpoint = "https://example.com/provider/token"; + opt.CallbackPath = "/oauth-callback"; + opt.StateDataFormat = new TestStateDataFormat(); + opt.Events = new OAuthEvents() + { + OnAccessDenied = context => + { + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.Response.StatusCode = StatusCodes.Status406NotAcceptable; + context.HandleResponse(); + return Task.CompletedTask; + } + }; + })); + + var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=access_denied&state=protected_state", + ".AspNetCore.Correlation.Weblie.correlationId=N"); + + Assert.Equal(HttpStatusCode.NotAcceptable, transaction.Response.StatusCode); + Assert.Null(transaction.Response.Headers.Location); + } + + [Fact] + public async Task HandleRequestAsync_InvokesRemoteFailureEventWhenAccessDeniedPathIsNotExplicitlySet() + { + var server = CreateServer( + s => s.AddAuthentication().AddOAuth( + "Weblie", + opt => + { + opt.ClientId = "Test Id"; + opt.ClientSecret = "secret"; + opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; + opt.AuthorizationEndpoint = "https://example.com/provider/login"; + opt.TokenEndpoint = "https://example.com/provider/token"; + opt.CallbackPath = "/oauth-callback"; + opt.StateDataFormat = new TestStateDataFormat(); + opt.Events = new OAuthEvents() + { + OnRemoteFailure = context => + { + Assert.Equal("Access was denied by the resource owner or by the remote server.", context.Failure.Message); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.Response.StatusCode = StatusCodes.Status406NotAcceptable; + context.HandleResponse(); + return Task.CompletedTask; + } + }; + })); + + var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=access_denied&state=protected_state", + ".AspNetCore.Correlation.Weblie.correlationId=N"); + + Assert.Equal(HttpStatusCode.NotAcceptable, transaction.Response.StatusCode); + Assert.Null(transaction.Response.Headers.Location); + } + [Fact] public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() { @@ -270,7 +365,7 @@ public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() { OnRemoteFailure = context => { - Assert.Contains("declined", context.Failure.Message); + Assert.Contains("custom_error", context.Failure.Message); Assert.Equal("testvalue", context.Properties.Items["testkey"]); context.Response.StatusCode = StatusCodes.Status406NotAcceptable; context.HandleResponse(); @@ -279,8 +374,8 @@ public async Task RemoteAuthenticationFailed_OAuthError_IncludesProperties() }; })); - var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=declined&state=protected_state", - ".AspNetCore.Correlation.Weblie.corrilationId=N"); + var transaction = await server.SendAsync("https://www.example.com/oauth-callback?error=custom_error&state=protected_state", + ".AspNetCore.Correlation.Weblie.correlationId=N"); Assert.Equal(HttpStatusCode.NotAcceptable, transaction.Response.StatusCode); Assert.Null(transaction.Response.Headers.Location); @@ -323,7 +418,7 @@ public AuthenticationProperties Unprotect(string protectedText) Assert.Equal("protected_state", protectedText); var properties = new AuthenticationProperties(new Dictionary() { - { ".xsrf", "corrilationId" }, + { ".xsrf", "correlationId" }, { "testkey", "testvalue" } }); properties.RedirectUri = "http://testhost/redirect"; diff --git a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs index 7530b00c3..090bf3dec 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/OpenIdConnect/OpenIdConnectEventTests.cs @@ -783,6 +783,52 @@ public async Task OnAuthenticationFailed_HandledWithTicket_SkipToTicketReceived( events.ValidateExpectations(); } + [Fact] + public async Task OnAccessDenied_Skip_NoMoreEventsRun() + { + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectAccessDenied = true + }; + events.OnAccessDenied = context => + { + context.SkipHandler(); + return Task.FromResult(0); + }; + var server = CreateServer(events, AppWritePath); + + var response = await PostAsync(server, "signin-oidc", "error=access_denied&state=protected_state"); + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Equal("/signin-oidc", await response.Content.ReadAsStringAsync()); + events.ValidateExpectations(); + } + + [Fact] + public async Task OnAccessDenied_Handled_NoMoreEventsRun() + { + var events = new ExpectedOidcEvents() + { + ExpectMessageReceived = true, + ExpectAccessDenied = true + }; + events.OnAccessDenied = context => + { + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.HandleResponse(); + context.Response.StatusCode = StatusCodes.Status202Accepted; + return Task.FromResult(0); + }; + var server = CreateServer(events, AppNotImpl); + + var response = await PostAsync(server, "signin-oidc", "error=access_denied&state=protected_state"); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + Assert.Equal("", await response.Content.ReadAsStringAsync()); + events.ValidateExpectations(); + } + [Fact] public async Task OnRemoteFailure_Skip_NoMoreEventsRun() { @@ -1099,6 +1145,9 @@ private class ExpectedOidcEvents : OpenIdConnectEvents public bool ExpectTokenValidated { get; set; } public bool InvokedTokenValidated { get; set; } + public bool ExpectAccessDenied { get; set; } + public bool InvokedAccessDenied { get; set; } + public bool ExpectRemoteFailure { get; set; } public bool InvokedRemoteFailure { get; set; } @@ -1168,6 +1217,12 @@ public override Task TicketReceived(TicketReceivedContext context) return base.TicketReceived(context); } + public override Task AccessDenied(AccessDeniedContext context) + { + InvokedAccessDenied = true; + return base.AccessDenied(context); + } + public override Task RemoteFailure(RemoteFailureContext context) { InvokedRemoteFailure = true; @@ -1201,6 +1256,7 @@ public void ValidateExpectations() Assert.Equal(ExpectUserInfoReceived, InvokedUserInfoReceived); Assert.Equal(ExpectAuthenticationFailed, InvokeAuthenticationFailed); Assert.Equal(ExpectTicketReceived, InvokedTicketReceived); + Assert.Equal(ExpectAccessDenied, InvokedAccessDenied); Assert.Equal(ExpectRemoteFailure, InvokedRemoteFailure); Assert.Equal(ExpectRedirectForSignOut, InvokedRedirectForSignOut); Assert.Equal(ExpectRemoteSignOut, InvokedRemoteSignOut); @@ -1248,7 +1304,7 @@ private TestServer CreateServer(OpenIdConnectEvents events, RequestDelegate appC private Task PostAsync(TestServer server, string path, string form) { var client = server.CreateClient(); - var cookie = ".AspNetCore.Correlation." + OpenIdConnectDefaults.AuthenticationScheme + ".corrilationId=N"; + var cookie = ".AspNetCore.Correlation." + OpenIdConnectDefaults.AuthenticationScheme + ".correlationId=N"; client.DefaultRequestHeaders.Add("Cookie", cookie); return client.PostAsync("signin-oidc", new StringContent(form, Encoding.ASCII, "application/x-www-form-urlencoded")); @@ -1273,7 +1329,7 @@ public AuthenticationProperties Unprotect(string protectedText) Assert.Equal("protected_state", protectedText); var properties = new AuthenticationProperties(new Dictionary() { - { ".xsrf", "corrilationId" }, + { ".xsrf", "correlationId" }, { OpenIdConnectDefaults.RedirectUriForCodePropertiesKey, "redirect_uri" }, { "testkey", "testvalue" } }); diff --git a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs index c438b1f3f..8eb7a5cd7 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs +++ b/test/Microsoft.AspNetCore.Authentication.Test/TwitterTests.cs @@ -174,6 +174,94 @@ public async Task ChallengeWillTriggerRedirection() Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); } + [Fact] + public async Task HandleRequestAsync_RedirectsToAccessDeniedPathWhenExplicitlySet() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.BackchannelHttpHandler = new TestHttpMessageHandler + { + Sender = BackchannelRequestToken + }; + o.AccessDeniedPath = "/access-denied"; + o.Events.OnRemoteFailure = context => throw new InvalidOperationException("This event should not be called."); + }, + async context => + { + var properties = new AuthenticationProperties(); + properties.Items["testkey"] = "testvalue"; + await context.ChallengeAsync("Twitter", properties); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + var location = transaction.Response.Headers.Location.AbsoluteUri; + Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); + Assert.True(transaction.Response.Headers.TryGetValues(HeaderNames.SetCookie, out var setCookie)); + Assert.True(SetCookieHeaderValue.TryParseList(setCookie.ToList(), out var setCookieValues)); + Assert.Single(setCookieValues); + var setCookieValue = setCookieValues.Single(); + var cookie = new CookieHeaderValue(setCookieValue.Name, setCookieValue.Value); + + var request = new HttpRequestMessage(HttpMethod.Get, "/signin-twitter?denied=ABCDEFG"); + request.Headers.Add(HeaderNames.Cookie, cookie.ToString()); + var client = server.CreateClient(); + var response = await client.SendAsync(request); + + Assert.Equal(HttpStatusCode.Redirect, response.StatusCode); + Assert.Equal("/access-denied?ReturnUrl=%2Fchallenge", response.Headers.Location.ToString()); + } + + [Fact] + public async Task BadCallbackCallsAccessDeniedWithState() + { + var server = CreateServer(o => + { + o.ConsumerKey = "Test Consumer Key"; + o.ConsumerSecret = "Test Consumer Secret"; + o.BackchannelHttpHandler = new TestHttpMessageHandler + { + Sender = BackchannelRequestToken + }; + o.Events = new TwitterEvents() + { + OnAccessDenied = context => + { + Assert.NotNull(context.Properties); + Assert.Equal("testvalue", context.Properties.Items["testkey"]); + context.Response.StatusCode = StatusCodes.Status406NotAcceptable; + context.HandleResponse(); + return Task.CompletedTask; + } + }; + }, + async context => + { + var properties = new AuthenticationProperties(); + properties.Items["testkey"] = "testvalue"; + await context.ChallengeAsync("Twitter", properties); + return true; + }); + var transaction = await server.SendAsync("http://example.com/challenge"); + Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode); + var location = transaction.Response.Headers.Location.AbsoluteUri; + Assert.Contains("https://api.twitter.com/oauth/authenticate?oauth_token=", location); + Assert.True(transaction.Response.Headers.TryGetValues(HeaderNames.SetCookie, out var setCookie)); + Assert.True(SetCookieHeaderValue.TryParseList(setCookie.ToList(), out var setCookieValues)); + Assert.Single(setCookieValues); + var setCookieValue = setCookieValues.Single(); + var cookie = new CookieHeaderValue(setCookieValue.Name, setCookieValue.Value); + + var request = new HttpRequestMessage(HttpMethod.Get, "/signin-twitter?denied=ABCDEFG"); + request.Headers.Add(HeaderNames.Cookie, cookie.ToString()); + var client = server.CreateClient(); + var response = await client.SendAsync(request); + + Assert.Equal(HttpStatusCode.NotAcceptable, response.StatusCode); + } + [Fact] public async Task BadCallbackCallsRemoteAuthFailedWithState() { @@ -190,7 +278,7 @@ public async Task BadCallbackCallsRemoteAuthFailedWithState() OnRemoteFailure = context => { Assert.NotNull(context.Failure); - Assert.Equal("The user denied permissions.", context.Failure.Message); + Assert.Equal("Access was denied by the resource owner or by the remote server.", context.Failure.Message); Assert.NotNull(context.Properties); Assert.Equal("testvalue", context.Properties.Items["testkey"]); context.Response.StatusCode = StatusCodes.Status406NotAcceptable; From d1ee5a22fbda54fc2352d937d7064b451a95b72a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 16 Nov 2018 14:25:30 -0800 Subject: [PATCH 246/248] Remove obsolete apis (#1915) --- .../CookieAuthenticationOptions.cs | 63 ------------------- .../breakingchanges.netcore.json | 52 +++++++++++++++ .../JwtBearerHandler.cs | 2 +- .../breakingchanges.netcore.json | 7 +++ ...thenticationServiceCollectionExtensions.cs | 42 ------------- .../breakingchanges.netcore.json | 22 +++++++ .../AuthorizeAttribute.cs | 10 --- 7 files changed, 82 insertions(+), 116 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json create mode 100644 src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs index 35017f9c4..78156caec 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs @@ -147,68 +147,5 @@ public CookieBuilder Cookie /// /// public TimeSpan ExpireTimeSpan { get; set; } - - #region Obsolete API - /// - /// - /// This property is obsolete and will be removed in a future version. The recommended alternative is on . - /// - /// - /// Determines the cookie name used to persist the identity. The default value is ".AspNetCore.Cookies". - /// This value should be changed if you change the name of the AuthenticationScheme, especially if your - /// system uses the cookie authentication handler multiple times. - /// - /// - [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Name) + ".")] - public string CookieName { get => Cookie.Name; set => Cookie.Name = value; } - - /// - /// - /// This property is obsolete and will be removed in a future version. The recommended alternative is on . - /// - /// - /// Determines the domain used to create the cookie. Is not provided by default. - /// - /// - [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Domain) + ".")] - public string CookieDomain { get => Cookie.Domain; set => Cookie.Domain = value; } - - /// - /// - /// This property is obsolete and will be removed in a future version. The recommended alternative is on . - /// - /// - /// Determines the path used to create the cookie. The default value is "/" for highest browser compatibility. - /// - /// - [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Path) + ".")] - public string CookiePath { get => Cookie.Path; set => Cookie.Path = value; } - - /// - /// - /// This property is obsolete and will be removed in a future version. The recommended alternative is on . - /// - /// - /// Determines if the browser should allow the cookie to be accessed by client-side javascript. The - /// default is true, which means the cookie will only be passed to http requests and is not made available - /// to script on the page. - /// - /// - [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.HttpOnly) + ".")] - public bool CookieHttpOnly { get => Cookie.HttpOnly; set => Cookie.HttpOnly = value; } - - /// - /// - /// This property is obsolete and will be removed in a future version. The recommended alternative is on . - /// - /// - /// Determines if the cookie should only be transmitted on HTTPS request. The default is to limit the cookie - /// to HTTPS requests if the page which is doing the SignIn is also HTTPS. If you have an HTTPS sign in page - /// and portions of your site are HTTP you may need to change this value. - /// - /// - [Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.SecurePolicy) + ".")] - public CookieSecurePolicy CookieSecure { get => Cookie.SecurePolicy; set => Cookie.SecurePolicy = value; } - #endregion } } diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json new file mode 100644 index 000000000..7a1ab7962 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/breakingchanges.netcore.json @@ -0,0 +1,52 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public Microsoft.AspNetCore.Http.CookieSecurePolicy get_CookieSecure()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Boolean get_CookieHttpOnly()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.String get_CookieDomain()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.String get_CookieName()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.String get_CookiePath()", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookieDomain(System.String value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookieHttpOnly(System.Boolean value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookieName(System.String value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookiePath(System.String value)", + "Kind": "Removal" + }, + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationOptions : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions", + "MemberId": "public System.Void set_CookieSecure(Microsoft.AspNetCore.Http.CookieSecurePolicy value)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs index 452d9639f..4f03ccd69 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/JwtBearerHandler.cs @@ -22,7 +22,7 @@ public class JwtBearerHandler : AuthenticationHandler { private OpenIdConnectConfiguration _configuration; - public JwtBearerHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, IDataProtectionProvider dataProtection, ISystemClock clock) + public JwtBearerHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json new file mode 100644 index 000000000..d17003a80 --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/breakingchanges.netcore.json @@ -0,0 +1,7 @@ + [ + { + "TypeId": "public class Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler : Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "MemberId": "public .ctor(Microsoft.Extensions.Options.IOptionsMonitor options, Microsoft.Extensions.Logging.ILoggerFactory logger, System.Text.Encodings.Web.UrlEncoder encoder, Microsoft.AspNetCore.DataProtection.IDataProtectionProvider dataProtection, Microsoft.AspNetCore.Authentication.ISystemClock clock)", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs index b274eaace..6c381b84a 100644 --- a/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Authentication/AuthenticationServiceCollectionExtensions.cs @@ -46,48 +46,6 @@ public static AuthenticationBuilder AddAuthentication(this IServiceCollection se return builder; } - [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] - public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureScheme, Action configureOptions) - where TOptions : AuthenticationSchemeOptions, new() - where THandler : AuthenticationHandler - { - services.AddAuthentication(o => - { - o.AddScheme(authenticationScheme, scheme => { - scheme.HandlerType = typeof(THandler); - scheme.DisplayName = displayName; - configureScheme?.Invoke(scheme); - }); - }); - if (configureOptions != null) - { - services.Configure(authenticationScheme, configureOptions); - } - services.AddTransient(); - return services; - } - - [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] - public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, Action configureOptions) - where TOptions : AuthenticationSchemeOptions, new() - where THandler : AuthenticationHandler - => services.AddScheme(authenticationScheme, displayName: null, configureScheme: null, configureOptions: configureOptions); - - [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] - public static IServiceCollection AddScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureOptions) - where TOptions : AuthenticationSchemeOptions, new() - where THandler : AuthenticationHandler - => services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); - - [Obsolete("AddScheme is obsolete. Use AddAuthentication().AddScheme instead.")] - public static IServiceCollection AddRemoteScheme(this IServiceCollection services, string authenticationScheme, string displayName, Action configureOptions) - where TOptions : RemoteAuthenticationOptions, new() - where THandler : RemoteAuthenticationHandler - { - services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureSignInScheme>()); - return services.AddScheme(authenticationScheme, displayName, configureScheme: null, configureOptions: configureOptions); - } - // Used to ensure that there's always a sign in scheme private class EnsureSignInScheme : IPostConfigureOptions where TOptions : RemoteAuthenticationOptions { diff --git a/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json new file mode 100644 index 000000000..d5bc6954e --- /dev/null +++ b/src/Microsoft.AspNetCore.Authentication/breakingchanges.netcore.json @@ -0,0 +1,22 @@ + [ + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddRemoteScheme(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.String authenticationScheme, System.String displayName, System.Action configureOptions) where T0 : Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions, new() where T1 : Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScheme(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.String authenticationScheme, System.Action configureOptions) where T0 : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions, new() where T1 : Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScheme(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.String authenticationScheme, System.String displayName, System.Action configureScheme, System.Action configureOptions) where T0 : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions, new() where T1 : Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Kind": "Removal" + }, + { + "TypeId": "public static class Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions", + "MemberId": "public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddScheme(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.String authenticationScheme, System.String displayName, System.Action configureOptions) where T0 : Microsoft.AspNetCore.Authentication.AuthenticationSchemeOptions, new() where T1 : Microsoft.AspNetCore.Authentication.AuthenticationHandler", + "Kind": "Removal" + } + ] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs index 63bfa30d4..b1f0f8bae 100644 --- a/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs +++ b/src/Microsoft.AspNetCore.Authorization/AuthorizeAttribute.cs @@ -39,15 +39,5 @@ public AuthorizeAttribute(string policy) /// Gets or sets a comma delimited list of schemes from which user information is constructed. /// public string AuthenticationSchemes { get; set; } - - /// - /// Gets or sets a comma delimited list of schemes from which user information is constructed. - /// - [Obsolete("Use AuthenticationSchemes instead.", error: false)] - public string ActiveAuthenticationSchemes - { - get => AuthenticationSchemes; - set => AuthenticationSchemes = value; - } } } From e0538784647990905f9c5fdc5bc2f0e5c7388909 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 19 Nov 2018 09:47:07 -0800 Subject: [PATCH 247/248] Upgrade packages and projects to target netcoreapp3.0 (aspnet/Security#1916) Changes: * Upgrade dependencies and build tools * Change TFM on Microsoft.AspNetCore.* packages to netcoreapp3.0 * Remove .NET Framework tests * Disable Owin interop tests. They need to be completely refactored --- Directory.Build.targets | 6 +- ...oft.AspNetCore.Security.Performance.csproj | 2 +- build/dependencies.props | 64 +++++++++---------- build/repo.props | 7 +- korebuild-lock.txt | 4 +- .../CookiePolicySample.csproj | 2 +- samples/CookieSample/CookieSample.csproj | 2 +- .../CookieSessionSample.csproj | 2 +- .../JwtBearerSample/JwtBearerSample.csproj | 2 +- .../OpenIdConnect.AzureAdSample.csproj | 2 +- .../OpenIdConnectSample.csproj | 2 +- samples/SocialSample/SocialSample.csproj | 2 +- samples/WsFedSample/WsFedSample.csproj | 2 +- ...t.AspNetCore.Authentication.Cookies.csproj | 2 +- ....AspNetCore.Authentication.Facebook.csproj | 2 +- ...ft.AspNetCore.Authentication.Google.csproj | 2 +- ...AspNetCore.Authentication.JwtBearer.csproj | 2 +- ...ore.Authentication.MicrosoftAccount.csproj | 2 +- ...oft.AspNetCore.Authentication.OAuth.csproj | 2 +- ...etCore.Authentication.OpenIdConnect.csproj | 2 +- ...t.AspNetCore.Authentication.Twitter.csproj | 2 +- ...NetCore.Authentication.WsFederation.csproj | 2 +- ...Microsoft.AspNetCore.Authentication.csproj | 2 +- ...oft.AspNetCore.Authorization.Policy.csproj | 2 +- .../Microsoft.AspNetCore.Authorization.csproj | 2 +- .../Microsoft.AspNetCore.CookiePolicy.csproj | 2 +- test/Directory.Build.props | 7 -- ...soft.AspNetCore.Authentication.Test.csproj | 2 +- ...osoft.AspNetCore.Authorization.Test.csproj | 2 +- ....ChunkingCookieManager.Sources.Test.csproj | 2 +- ...rosoft.AspNetCore.CookiePolicy.Test.csproj | 2 +- .../CookieInteropTests.cs | 5 ++ ...icrosoft.Owin.Security.Interop.Test.csproj | 3 +- .../TicketInteropTests.cs | 3 + 34 files changed, 71 insertions(+), 80 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 78626b773..7e3f8df92 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,10 +1,6 @@ - $(MicrosoftNETCoreApp20PackageVersion) - $(MicrosoftNETCoreApp21PackageVersion) - $(MicrosoftNETCoreApp22PackageVersion) + $(MicrosoftNETCoreAppPackageVersion) $(NETStandardLibrary20PackageVersion) - - 99.9 diff --git a/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj b/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj index 7226b64be..2f16dd669 100644 --- a/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj +++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp3.0 Exe true true diff --git a/build/dependencies.props b/build/dependencies.props index 230a942c0..163a3d400 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,42 +4,40 @@ 0.10.13 - 3.0.0-alpha1-20181004.7 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10657 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-a-alpha1-endpoint-extensions-namespace-16778 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-preview-181105-05 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-preview-181105-05 - 3.0.0-preview-181105-05 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-alpha1-10706 - 3.0.0-preview-181105-05 - 3.0.0-alpha1-10706 + 3.0.0-build-20181114.5 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-preview-181113-11 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-alpha1-10742 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 + 3.0.0-preview-181113-11 3.19.8 5.3.0 5.3.0 - 2.0.9 - 2.1.3 - 2.2.0-rtm-27105-02 + 3.0.0-preview1-26907-05 15.6.1 3.0.1 3.0.1 diff --git a/build/repo.props b/build/repo.props index 6fc6af601..4402da1d0 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,9 +1,6 @@ - - - Internal.AspNetCore.Universe.Lineup @@ -11,8 +8,6 @@ - - - + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 591cfd52f..73613543d 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:3.0.0-alpha1-20181004.7 -commithash:27fabdaf2b1d4753c3d2749581694ca65d78f7f2 +version:3.0.0-build-20181114.5 +commithash:880e9a204d4ee4a18dfd83c9fb05a192a28bca60 diff --git a/samples/CookiePolicySample/CookiePolicySample.csproj b/samples/CookiePolicySample/CookiePolicySample.csproj index 48227eb07..010edb018 100644 --- a/samples/CookiePolicySample/CookiePolicySample.csproj +++ b/samples/CookiePolicySample/CookiePolicySample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 diff --git a/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj index 1029f1819..bc92d68a2 100644 --- a/samples/CookieSample/CookieSample.csproj +++ b/samples/CookieSample/CookieSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj index 19bd04374..6230c98a5 100644 --- a/samples/CookieSessionSample/CookieSessionSample.csproj +++ b/samples/CookieSessionSample/CookieSessionSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj index 3e0192a23..58bf5e2d9 100644 --- a/samples/JwtBearerSample/JwtBearerSample.csproj +++ b/samples/JwtBearerSample/JwtBearerSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 aspnet5-JwtBearerSample-20151210102827 diff --git a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj index 2abd57cd8..61754b60b 100644 --- a/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj +++ b/samples/OpenIdConnect.AzureAdSample/OpenIdConnect.AzureAdSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj index bb02ef159..137ee47ba 100644 --- a/samples/OpenIdConnectSample/OpenIdConnectSample.csproj +++ b/samples/OpenIdConnectSample/OpenIdConnectSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 aspnet5-OpenIdConnectSample-20151210110318 diff --git a/samples/SocialSample/SocialSample.csproj b/samples/SocialSample/SocialSample.csproj index a08b9799d..e1e2262b0 100644 --- a/samples/SocialSample/SocialSample.csproj +++ b/samples/SocialSample/SocialSample.csproj @@ -1,7 +1,7 @@ - net461;netcoreapp2.2 + netcoreapp3.0 aspnet5-SocialSample-20151210111056 diff --git a/samples/WsFedSample/WsFedSample.csproj b/samples/WsFedSample/WsFedSample.csproj index 4fb38fa3e..e1191ac81 100644 --- a/samples/WsFedSample/WsFedSample.csproj +++ b/samples/WsFedSample/WsFedSample.csproj @@ -1,7 +1,7 @@ - net461 + netcoreapp3.0 diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj index b188a58e0..093f60a3d 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/Microsoft.AspNetCore.Authentication.Cookies.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to use cookie based authentication. - netstandard2.0 + netcoreapp3.0 $(DefineConstants);SECURITY $(NoWarn);CS1591 true diff --git a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj index 62aee1367..f57fe26e0 100644 --- a/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Facebook/Microsoft.AspNetCore.Authentication.Facebook.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support Facebook's OAuth 2.0 authentication workflow. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj index de8867f91..eba5b98ad 100644 --- a/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Google/Microsoft.AspNetCore.Authentication.Google.csproj @@ -2,7 +2,7 @@ ASP.NET Core contains middleware to support Google's OpenId and OAuth 2.0 authentication workflows. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj index e5bae5a3d..8a26c58f3 100644 --- a/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj +++ b/src/Microsoft.AspNetCore.Authentication.JwtBearer/Microsoft.AspNetCore.Authentication.JwtBearer.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj index 0eddc6f76..1841157c9 100644 --- a/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj +++ b/src/Microsoft.AspNetCore.Authentication.MicrosoftAccount/Microsoft.AspNetCore.Authentication.MicrosoftAccount.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the Microsoft Account authentication workflow. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj index 5c8a5e3a9..97d4a9703 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/Microsoft.AspNetCore.Authentication.OAuth.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support any standard OAuth 2.0 authentication workflow. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj index b7f4c1704..65ca6b842 100644 --- a/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the OpenID Connect authentication workflow. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj index f720d08f0..4f2aae616 100644 --- a/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj +++ b/src/Microsoft.AspNetCore.Authentication.Twitter/Microsoft.AspNetCore.Authentication.Twitter.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj b/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj index 4edb55cb3..ae4d52aff 100644 --- a/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj +++ b/src/Microsoft.AspNetCore.Authentication.WsFederation/Microsoft.AspNetCore.Authentication.WsFederation.csproj @@ -2,7 +2,7 @@ ASP.NET Core middleware that enables an application to support the WsFederation authentication workflow. - netstandard2.0 + netcoreapp3.0 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj index 7e3ce4eb3..9ae0a7bcc 100644 --- a/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj +++ b/src/Microsoft.AspNetCore.Authentication/Microsoft.AspNetCore.Authentication.csproj @@ -2,7 +2,7 @@ ASP.NET Core common types used by the various authentication middleware components. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authentication;security diff --git a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj index aba88dd50..d3ad99a51 100644 --- a/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj +++ b/src/Microsoft.AspNetCore.Authorization.Policy/Microsoft.AspNetCore.Authorization.Policy.csproj @@ -2,7 +2,7 @@ ASP.NET Core authorization policy helper classes. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591;NU1605 true aspnetcore;authorization diff --git a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj index ac4aa6c32..9192ac8cf 100644 --- a/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj +++ b/src/Microsoft.AspNetCore.Authorization/Microsoft.AspNetCore.Authorization.csproj @@ -5,7 +5,7 @@ Commonly used types: Microsoft.AspNetCore.Authorization.AllowAnonymousAttribute Microsoft.AspNetCore.Authorization.AuthorizeAttribute - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore;authorization diff --git a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj index 40f97633a..81760d50a 100644 --- a/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj +++ b/src/Microsoft.AspNetCore.CookiePolicy/Microsoft.AspNetCore.CookiePolicy.csproj @@ -2,7 +2,7 @@ ASP.NET Core cookie policy classes to control the behavior of cookies. - netstandard2.0 + netcoreapp3.0 $(NoWarn);CS1591 true aspnetcore diff --git a/test/Directory.Build.props b/test/Directory.Build.props index e3d2d9f14..c42d54465 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,13 +1,6 @@ - - netcoreapp2.2 - $(DeveloperBuildTestTfms) - $(StandardTestTfms) - $(StandardTestTfms);net461 - - diff --git a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj index 6c8d518ff..c7a380868 100644 --- a/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj +++ b/test/Microsoft.AspNetCore.Authentication.Test/Microsoft.AspNetCore.Authentication.Test.csproj @@ -1,7 +1,7 @@  - $(StandardTestTfms) + netcoreapp3.0 diff --git a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj index 40a8fff12..9ff42a070 100644 --- a/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj +++ b/test/Microsoft.AspNetCore.Authorization.Test/Microsoft.AspNetCore.Authorization.Test.csproj @@ -1,7 +1,7 @@  - $(StandardTestTfms) + netcoreapp3.0 $(NoWarn);NU1605 diff --git a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj index 20cd400ce..2f38abff9 100644 --- a/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj +++ b/test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test/Microsoft.AspNetCore.ChunkingCookieManager.Sources.Test.csproj @@ -1,7 +1,7 @@  - $(StandardTestTfms) + netcoreapp3.0 diff --git a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj index d7a42f3ef..3dc3df2e2 100644 --- a/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj +++ b/test/Microsoft.AspNetCore.CookiePolicy.Test/Microsoft.AspNetCore.CookiePolicy.Test.csproj @@ -1,7 +1,7 @@  - $(StandardTestTfms) + netcoreapp3.0 diff --git a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs index e2e4fd7d0..24bf09722 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/CookieInteropTests.cs @@ -1,6 +1,10 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +/* See https://github.com/aspnet/AspNetCore/issues/4074. + +This test is was disabled as a part of changing frameworks. This test will need to be re-written using separate .NET Core and .NET Framework processes. + using System.Collections.Generic; using System.IO; using System.Linq; @@ -330,3 +334,4 @@ private class Transaction } } +*/ diff --git a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj index f369f1f01..57b224ef6 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj +++ b/test/Microsoft.Owin.Security.Interop.Test/Microsoft.Owin.Security.Interop.Test.csproj @@ -2,10 +2,11 @@ net461 + + false - diff --git a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs index 769adc015..ccff1e936 100644 --- a/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs +++ b/test/Microsoft.Owin.Security.Interop.Test/TicketInteropTests.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +/* + using System; using System.Linq; using System.Security.Claims; @@ -87,5 +89,6 @@ public void InteropSerializerCanReadNewTicket() } } } +*/ From 26d27d871b7992022c082dc207e3d126e1d9d278 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 21 Nov 2018 16:05:52 -0800 Subject: [PATCH 248/248] Update README.md --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e8e64c293..66c2aa45e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ -ASP.NET Security -======== +ASP.NET Security [Archived] +=========================== -AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/fujhh8n956v5ohfd/branch/dev?svg=true)](https://ci.appveyor.com/project/aspnetci/Security/branch/dev) - -Travis: [![Travis](https://travis-ci.org/aspnet/Security.svg?branch=dev)](https://travis-ci.org/aspnet/Security) +**This GitHub project has been archived.** Ongoing development on this project can be found in . Contains the security and authorization middlewares for ASP.NET Core. @@ -14,4 +12,4 @@ A list of community projects related to authentication and security for ASP.NET ASP.NET Security will not include Basic Authentication middleware due to its potential insecurity and performance problems. If you host under IIS you can enable it via IIS configuration. -This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo. +This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [AspNetCore](https://github.com/aspnet/AspNetCore) repo.