diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/BasicTests.cs b/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/BasicTests.cs index 9cfd1c4..1531b47 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/BasicTests.cs +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/BasicTests.cs @@ -1,3 +1,17 @@ +// Copyright 2018 IntelliTect +// +// 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. + using System.Net; using System.Net.Http; using System.Security.Principal; diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/TestHost.WindowsAuth.Test.csproj b/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/TestHost.WindowsAuth.Test.csproj index d1db902..a98e550 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/TestHost.WindowsAuth.Test.csproj +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/TestHost.WindowsAuth.Test.csproj @@ -9,11 +9,14 @@ - - - - - + + + + all + runtime; build; native; contentfiles; analyzers + + + diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/WebExampleServerFixture.cs b/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/WebExampleServerFixture.cs index 5a17066..43bec7e 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/WebExampleServerFixture.cs +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth.Test/WebExampleServerFixture.cs @@ -1,4 +1,18 @@ -using IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample; +// Copyright 2018 IntelliTect +// +// 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. + +using IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample; namespace IntelliTect.AspNetCore.TestHost.WindowsAuth.Test { diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Controllers/ValuesController.cs b/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Controllers/ValuesController.cs index 2d1d096..c119d91 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Controllers/ValuesController.cs +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Controllers/ValuesController.cs @@ -1,4 +1,18 @@ -using Microsoft.AspNetCore.Authorization; +// Copyright 2018 IntelliTect +// +// 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. + +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample.Controllers diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Program.cs b/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Program.cs index 037cdcf..17cde6d 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Program.cs +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Program.cs @@ -1,4 +1,18 @@ -using Microsoft.AspNetCore; +// Copyright 2018 IntelliTect +// +// 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. + +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; namespace IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Startup.cs b/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Startup.cs index 4b45536..1789fd4 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Startup.cs +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/Startup.cs @@ -1,4 +1,18 @@ -using Microsoft.AspNetCore.Builder; +// Copyright 2018 IntelliTect +// +// 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. + +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -23,7 +37,10 @@ public void ConfigureServices(IServiceCollection services) // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - if (env.IsDevelopment()) app.UseDeveloperExceptionPage(); + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } app.UseMvc(); } diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/TestHost.WindowsAuth.WebExample.csproj b/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/TestHost.WindowsAuth.WebExample.csproj index 7e2549f..7ef47c8 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/TestHost.WindowsAuth.WebExample.csproj +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth.WebExample/TestHost.WindowsAuth.WebExample.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth.sln b/IntelliTect.AspNetCore.TestHost.WindowsAuth.sln index 8f2d4e7..d95e84a 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth.sln +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth.sln @@ -12,6 +12,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{53989A80-E732-4DE8-AD8A-1875389BE3A0}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore + azure-pipelines.yml = azure-pipelines.yml README.md = README.md EndProjectSection EndProject diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth/AddAuthenticationStartupFilter.cs b/IntelliTect.AspNetCore.TestHost.WindowsAuth/AddAuthenticationStartupFilter.cs index faa9838..2fba122 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth/AddAuthenticationStartupFilter.cs +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth/AddAuthenticationStartupFilter.cs @@ -1,6 +1,20 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; +// Copyright 2018 IntelliTect +// +// 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. + using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; namespace IntelliTect.AspNetCore.TestHost.WindowsAuth { diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth/NativeMethods.cs b/IntelliTect.AspNetCore.TestHost.WindowsAuth/NativeMethods.cs new file mode 100644 index 0000000..f966c34 --- /dev/null +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth/NativeMethods.cs @@ -0,0 +1,35 @@ +// Copyright 2018 IntelliTect +// +// 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. + +using System; +using System.Runtime.InteropServices; + +namespace IntelliTect.AspNetCore.TestHost.WindowsAuth +{ + internal static class NativeMethods + { + [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + public static extern bool LogonUser( + string lpszUsername, + string lpszDomain, + string lpszPassword, + int dwLogonType, + int dwLogonProvider, + out IntPtr phToken + ); + + [DllImport("kernel32.dll", SetLastError = true)] + public static extern bool CloseHandle(IntPtr hHandle); + } +} \ No newline at end of file diff --git a/IntelliTect.AspNetCore.TestHost.WindowsAuth/TestHost.WindowsAuth.csproj b/IntelliTect.AspNetCore.TestHost.WindowsAuth/TestHost.WindowsAuth.csproj index 7d167c4..b7ce563 100644 --- a/IntelliTect.AspNetCore.TestHost.WindowsAuth/TestHost.WindowsAuth.csproj +++ b/IntelliTect.AspNetCore.TestHost.WindowsAuth/TestHost.WindowsAuth.csproj @@ -1,4 +1,4 @@ - +