diff --git a/appveyor.yml b/.appveyor.yml
similarity index 50%
rename from appveyor.yml
rename to .appveyor.yml
index 4f85bae46..d45bd5a1f 100644
--- a/appveyor.yml
+++ b/.appveyor.yml
@@ -1,19 +1,17 @@
-init:
- - git config --global core.autocrlf true
+init:
+- git config --global core.autocrlf true
branches:
only:
- - master
- - release
- - dev
- - /^(.*\/)?ci-.*$/
- - /^rel\/.*/
+ - master
+ - /^release\/.*$/
+ - /^(.*\/)?ci-.*$/
build_script:
- - ps: .\build.ps1
+- 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/.gitignore b/.gitignore
index bac5b7505..3d7e16e84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,4 +30,4 @@ project.lock.json
/.vs/
.vscode/
global.json
-korebuild-lock.txt
+BenchmarkDotNet.Artifacts/
diff --git a/.travis.yml b/.travis.yml
index 6c59666f3..ab3980055 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\/.*/
+ - master
+ - /^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/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml
new file mode 100644
index 000000000..c2c5336fd
--- /dev/null
+++ b/.vsts-pipelines/builds/ci-internal.yml
@@ -0,0 +1,13 @@
+trigger:
+- master
+- release/*
+
+resources:
+ repositories:
+ - repository: buildtools
+ type: git
+ name: aspnet-BuildTools
+ 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
new file mode 100644
index 000000000..507c89b02
--- /dev/null
+++ b/.vsts-pipelines/builds/ci-public.yml
@@ -0,0 +1,15 @@
+trigger:
+- master
+- release/*
+
+# See https://github.com/aspnet/BuildTools
+resources:
+ repositories:
+ - repository: buildtools
+ type: github
+ endpoint: DotNet-Bot GitHub Connection
+ name: aspnet/BuildTools
+ ref: refs/heads/master
+
+phases:
+- template: .vsts-pipelines/templates/project-ci.yml@buildtools
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.
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 000000000..eb9d9535e
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+ Microsoft ASP.NET Core
+ https://github.com/aspnet/Security
+ git
+ $(MSBuildThisFileDirectory)
+ $(MSBuildThisFileDirectory)build\Key.snk
+ true
+ true
+
+
diff --git a/Directory.Build.targets b/Directory.Build.targets
new file mode 100644
index 000000000..7e3f8df92
--- /dev/null
+++ b/Directory.Build.targets
@@ -0,0 +1,6 @@
+
+
+ $(MicrosoftNETCoreAppPackageVersion)
+ $(NETStandardLibrary20PackageVersion)
+
+
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.
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/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: [](https://ci.appveyor.com/project/aspnetci/Security/branch/dev)
-
-Travis: [](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.
diff --git a/Security.sln b/Security.sln
index 2e5ee56d0..240100e8c 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
-MinimumVisualStudioVersion = 10.0.40219.1
+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
+ 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,15 +62,27 @@ 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
+ 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}"
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
+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
@@ -455,6 +473,70 @@ 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
+ {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
+ {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
@@ -484,6 +566,10 @@ 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}
+ {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..2f16dd669
--- /dev/null
+++ b/benchmarks/Microsoft.AspNetCore.Security.Performance/Microsoft.AspNetCore.Security.Performance.csproj
@@ -0,0 +1,24 @@
+
+
+
+ netcoreapp3.0
+ 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.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/build/common.props b/build/common.props
deleted file mode 100644
index ea940214e..000000000
--- a/build/common.props
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
- Microsoft ASP.NET Core
- https://github.com/aspnet/Security
- git
- $(MSBuildThisFileDirectory)Key.snk
- true
- true
- $(VersionSuffix)-$(BuildNumber)
- true
-
-
-
-
-
-
-
diff --git a/build/dependencies.props b/build/dependencies.props
index a97cae9f6..163a3d400 100644
--- a/build/dependencies.props
+++ b/build/dependencies.props
@@ -1,16 +1,56 @@
-
+
- 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-*
- 2.3.0-beta2-*
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+
+ 0.10.13
+ 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
+ 3.0.0-preview1-26907-05
+ 15.6.1
+ 3.0.1
+ 3.0.1
+ 3.0.1
+ 4.10.0
+ 2.0.3
+ 11.0.2
+ 5.3.0
+ 0.10.0
+ 2.3.1
+ 2.4.0
+
+
+
+
diff --git a/build/repo.props b/build/repo.props
index d4bab3eeb..4402da1d0 100644
--- a/build/repo.props
+++ b/build/repo.props
@@ -1,5 +1,13 @@
+
+
+
+
+ Internal.AspNetCore.Universe.Lineup
+ https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json
+
+
-
+
diff --git a/build/sources.props b/build/sources.props
new file mode 100644
index 000000000..9215df975
--- /dev/null
+++ b/build/sources.props
@@ -0,0 +1,17 @@
+
+
+
+
+ $(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;
+
+
+ $(RestoreSources);
+ https://api.nuget.org/v3/index.json;
+
+
+
diff --git a/korebuild-lock.txt b/korebuild-lock.txt
new file mode 100644
index 000000000..73613543d
--- /dev/null
+++ b/korebuild-lock.txt
@@ -0,0 +1,2 @@
+version:3.0.0-build-20181114.5
+commithash:880e9a204d4ee4a18dfd83c9fb05a192a28bca60
diff --git a/korebuild.json b/korebuild.json
new file mode 100644
index 000000000..8a276a7f3
--- /dev/null
+++ b/korebuild.json
@@ -0,0 +1,4 @@
+{
+ "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json",
+ "channel": "master"
+}
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 60%
rename from build.ps1
rename to run.ps1
index d5eb4d5cf..34604c717 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.
@@ -23,32 +26,42 @@ 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 version.xml.
+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 MSBuildArgs
-Arguments to be passed to MSBuild
+.PARAMETER CI
+Sets up CI specific settings and variables.
+
+.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/master/tools/korebuild.schema.json",
+ "channel": "master",
+ "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 +71,12 @@ param(
[string]$ToolsSource,
[Alias('u')]
[switch]$Update,
- [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'),
+ [switch]$Reinstall,
+ [string]$ToolsSourceSuffix,
+ [string]$ConfigFile = $null,
+ [switch]$CI,
[Parameter(ValueFromRemainingArguments = $true)]
- [string[]]$MSBuildArgs
+ [string[]]$Arguments
)
Set-StrictMode -Version 2
@@ -75,7 +91,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
@@ -85,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
@@ -92,10 +112,10 @@ function Get-KoreBuild {
try {
$tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip"
- Get-RemoteFile $remotePath $tmpfile
- if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) {
+ Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix
+ 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
@@ -120,7 +140,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
@@ -130,7 +150,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 {
@@ -147,10 +167,22 @@ 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-Host -ForegroundColor Red $Error[0]
+ Write-Error "$ConfigFile contains invalid JSON."
+ exit 1
+ }
}
if (!$DotNetHome) {
@@ -160,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
@@ -169,8 +201,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 -CI:$CI
+ Invoke-KoreBuildCommand $Command @Arguments
}
finally {
Remove-Module 'KoreBuild' -ErrorAction Ignore
diff --git a/run.sh b/run.sh
new file mode 100755
index 000000000..4c1fed564
--- /dev/null
+++ b/run.sh
@@ -0,0 +1,256 @@
+#!/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
+reinstall=false
+repo_path="$DIR"
+channel=''
+tools_source=''
+tools_source_suffix=''
+ci=false
+
+#
+# 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 " --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."
+ 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" "$tools_source_suffix"
+ 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 [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then
+ rm -rf "$korebuild_path"
+ fi
+
+ {
+ 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" "$tools_source_suffix"; 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
+ local remote_path_suffix=$3
+
+ 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}${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}${remote_path_suffix}" || 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
+ ;;
+ --tools-source-suffix|-ToolsSourceSuffix)
+ shift
+ tools_source_suffix="${1:-}"
+ [ -z "$tools_source_suffix" ] && __usage
+ ;;
+ -u|--update|-Update)
+ update=true
+ ;;
+ --reinstall|-[Rr]einstall)
+ reinstall=true
+ ;;
+ --ci|-[Cc][Ii])
+ ci=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
+ __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
+ __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
+ __error 'Missing required command: jq or python. Could not parse the JSON file.'
+ exit 1
+ fi
+
+ [ ! -z "${config_channel:-}" ] && channel="$config_channel"
+ [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source"
+fi
+
+[ -z "$channel" ] && channel='master'
+[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools'
+
+get_korebuild
+set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci"
+invoke_korebuild_command "$command" "$@"
diff --git a/samples/CookiePolicySample/CookiePolicySample.csproj b/samples/CookiePolicySample/CookiePolicySample.csproj
new file mode 100644
index 000000000..010edb018
--- /dev/null
+++ b/samples/CookiePolicySample/CookiePolicySample.csproj
@@ -0,0 +1,18 @@
+
+
+
+ netcoreapp3.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/CookiePolicySample/Program.cs b/samples/CookiePolicySample/Program.cs
new file mode 100644
index 000000000..3fc09a3db
--- /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("Microsoft", LogLevel.Trace);
+ })
+ .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..4dcc6d4dc
--- /dev/null
+++ b/samples/CookiePolicySample/Startup.cs
@@ -0,0 +1,127 @@
+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 "/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;
+ 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($"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");
+ 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/samples/CookieSample/CookieSample.csproj b/samples/CookieSample/CookieSample.csproj
index 64438de77..bc92d68a2 100644
--- a/samples/CookieSample/CookieSample.csproj
+++ b/samples/CookieSample/CookieSample.csproj
@@ -1,9 +1,7 @@
-
-
- net461;netcoreapp2.0
+ netcoreapp3.0
@@ -11,12 +9,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/samples/CookieSessionSample/CookieSessionSample.csproj b/samples/CookieSessionSample/CookieSessionSample.csproj
index cb07f4385..6230c98a5 100644
--- a/samples/CookieSessionSample/CookieSessionSample.csproj
+++ b/samples/CookieSessionSample/CookieSessionSample.csproj
@@ -1,9 +1,7 @@
-
-
- net461;netcoreapp2.0
+ netcoreapp3.0
@@ -11,12 +9,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/samples/JwtBearerSample/JwtBearerSample.csproj b/samples/JwtBearerSample/JwtBearerSample.csproj
index fe2a5fa9d..58bf5e2d9 100644
--- a/samples/JwtBearerSample/JwtBearerSample.csproj
+++ b/samples/JwtBearerSample/JwtBearerSample.csproj
@@ -1,9 +1,7 @@
-
-
- net461;netcoreapp2.0
+ netcoreapp3.0
aspnet5-JwtBearerSample-20151210102827
@@ -12,12 +10,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
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();
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
+