Skip to content

Commit

Permalink
Merged ASPNET_CORE_RTM_Migration into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SharePointRadi committed Sep 22, 2016
2 parents 17ffb6d + 6339738 commit 817b198
Show file tree
Hide file tree
Showing 23 changed files with 237 additions and 196 deletions.
20 changes: 19 additions & 1 deletion Middleware.ActiveDirectory.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.ActiveDirectory", "src\Microsoft.AspNetCore.Authentication.ActiveDirectory\Microsoft.AspNetCore.Authentication.ActiveDirectory.xproj", "{404A11C5-8F4E-480E-BAE7-9FF2D7060BCE}"
EndProject
Expand All @@ -16,6 +16,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication", "..\..\aspnet\Security\src\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.xproj", "{2286250A-52C8-4126-9F93-B1E45F0AD078}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authentication.Cookies", "..\..\aspnet\Security\src\Microsoft.AspNetCore.Authentication.Cookies\Microsoft.AspNetCore.Authentication.Cookies.xproj", "{FC152CC4-054B-457E-8D91-389C5DE3C561}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Authorization", "..\..\aspnet\Security\src\Microsoft.AspNetCore.Authorization\Microsoft.AspNetCore.Authorization.xproj", "{6AB3E514-5894-4131-9399-DC7D5284ADDB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -30,6 +36,18 @@ Global
{64853030-74EE-47CE-9362-159AEF99939F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64853030-74EE-47CE-9362-159AEF99939F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64853030-74EE-47CE-9362-159AEF99939F}.Release|Any CPU.Build.0 = Release|Any CPU
{2286250A-52C8-4126-9F93-B1E45F0AD078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2286250A-52C8-4126-9F93-B1E45F0AD078}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2286250A-52C8-4126-9F93-B1E45F0AD078}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2286250A-52C8-4126-9F93-B1E45F0AD078}.Release|Any CPU.Build.0 = Release|Any CPU
{FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC152CC4-054B-457E-8D91-389C5DE3C561}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC152CC4-054B-457E-8D91-389C5DE3C561}.Release|Any CPU.Build.0 = Release|Any CPU
{6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AB3E514-5894-4131-9399-DC7D5284ADDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AB3E514-5894-4131-9399-DC7D5284ADDB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 4 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"projects": [ "src" ]
"projects": [ "src", "../../aspnet/Security/src", "../../aspnet/HttpAbstractions/src" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;

namespace Sample_AspNet5.Mvc6.Ntlm.Controllers
{
public class HomeController : Controller
{
[AllowAnonymous]
public IActionResult Index()
{
return View();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"iisSettings": {
"windowsAuthentication": false,
"windowsAuthentication": true,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:6286/",
Expand All @@ -12,14 +12,13 @@
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"Hosting:Environment": "Development"
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"web": {
"commandName": "web",
"launchUrl": "http://localhost:5000/windowsauthentication/ntlm",
"environmentVariables": {
"Hosting:Environment": "Development"
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>64853030-74ee-47ce-9362-159aef99939f</ProjectGuid>
<RootNamespace>Sample_AspNet5.Mvc6.Ntlm</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
Expand All @@ -19,5 +20,5 @@
<DnxInvisibleContent Include=".bowerrc" />
<DnxInvisibleContent Include="package.json" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
55 changes: 33 additions & 22 deletions samples/Sample-AspNet5.Mvc6.Ntlm/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authentication.ActiveDirectory;
using Microsoft.AspNet.Authentication.Cookies;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Authentication;
using Microsoft.AspNetCore.Authentication.ActiveDirectory.Events;
using Microsoft.AspNetCore.Http;

namespace Sample_AspNet5.Mvc6.Ntlm
{
Expand All @@ -21,6 +21,7 @@ public Startup(IHostingEnvironment env)
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
Expand All @@ -46,35 +47,35 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF

if (env.IsDevelopment())
{
app.UseBrowserLink();
// TODO: Fix this for RTM
//app.UseBrowserLink();
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}

app.UseIISPlatformHandler();

app.UseStaticFiles();



//ActiveDirectory: set up cookies for client-side session identitfication
app.UseCookieAuthentication(new ActiveDirectoryCookieOptions().ApplicationCookie);
//app.UseCookieAuthentication(new ActiveDirectoryCookieOptions().ApplicationCookie);

//EXAMPLE: using with a custom action URL
//app.UseCookieAuthentication(
// new ActiveDirectoryCookieOptions(
// new CookieAuthenticationOptions()
// {
// AuthenticationScheme = typeof(ActiveDirectoryCookieOptions).Namespace + ".Application",
// AutomaticAuthenticate = true,
// AutomaticChallenge = true,
// ReturnUrlParameter = "ReturnUrl",
// LoginPath = new PathString("/api/windowsauthentication/ntlm"),
// }).ApplicationCookie
//);
app.UseCookieAuthentication(
new ActiveDirectoryCookieOptions(
new CookieAuthenticationOptions()
{
AuthenticationScheme = typeof(ActiveDirectoryCookieOptions).Namespace + ".Application",
AutomaticAuthenticate = true,
AutomaticChallenge = true,
ReturnUrlParameter = "ReturnUrl",
LoginPath = new PathString("/windowsauthentication/ntlm"),
AccessDeniedPath = new PathString("/windowsauthentication/ntlm")
}).ApplicationCookie
);

//ActiveDirectory: add the NTLM middlware in the pipeline
app.UseNtlm(new ActiveDirectoryOptions
Expand All @@ -89,7 +90,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
{
OnAuthenticationSucceeded = succeededContext =>
{
var userName = succeededContext.AuthenticationTicket.Principal.Identity.Name;
var userName = succeededContext.Ticket.Principal.Identity.Name;

//do something on successful authentication

Expand Down Expand Up @@ -131,6 +132,16 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
}

// Entry point for the application.
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
public static void Main(string[] args)
{
var webHostBuilder = new WebHostBuilder()
.UseStartup<Startup>()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration();

var webHost = webHostBuilder.Build();
webHost.Run();
}
}
}
2 changes: 1 addition & 1 deletion samples/Sample-AspNet5.Mvc6.Ntlm/Views/_ViewImports.cshtml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@using Sample_AspNet5.Mvc6.Ntlm
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
70 changes: 42 additions & 28 deletions samples/Sample-AspNet5.Mvc6.Ntlm/project.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,57 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},

"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"Microsoft.AspNetCore.Authentication.ActiveDirectory": ""
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.FileProviders.Abstractions": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.AspNetCore.Authentication.ActiveDirectory": "1.1.0-*",
"Microsoft.AspNetCore.Authentication": "1.0.0",
"Microsoft.AspNetCore.Http.Abstractions": "1.0.0",
"Microsoft.AspNetCore.Authorization": "1.0.0"
},

"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final"
},

"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
"web": "Microsoft.AspNetCore.Server.Kestrel"
},

"frameworks": {
"dnx451": { },
"dnxcore50": { }
"net451": {}
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"compile": {
"exclude": [
"wwwroot",
"node_modules"
]
}
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"exclude": [
"**.user",
"**.vspscc"
]
},

"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
Expand Down
8 changes: 4 additions & 4 deletions samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/_references.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <autosync enabled="true" />
/// <reference path="../gulpfile.js" />
/// <reference path="lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js" />
/// <reference path="lib/jquery-validation/jquery.validate.js" />
/// <reference path="lib/jquery/dist/jquery.js" />
/// <reference path="lib/bootstrap/dist/js/bootstrap.js" />
/// <reference path="js/site.js" />
/// <reference path="lib/bootstrap/dist/js/bootstrap.js" />
/// <reference path="lib/jquery/dist/jquery.js" />
/// <reference path="lib/jquery-validation/dist/jquery.validate.js" />
/// <reference path="lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js" />
1 change: 0 additions & 1 deletion samples/Sample-AspNet5.Mvc6.Ntlm/wwwroot/css/site.min.css

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.AspNet.Authentication.Cookies;
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
Loading

0 comments on commit 817b198

Please sign in to comment.