Skip to content
Permalink
Browse files

asp.net core RC2 migration

  • Loading branch information
rdefreitas committed May 18, 2016
1 parent 967c83e commit 47eaa797da37816a739b0b601d49bb94f4277be1
Showing with 1,357 additions and 1,033 deletions.
  1. +1 −4 global.json
  2. +5 −4 samples/AspNetMvcAuthDemo/AppTenantResolver.cs
  3. +1 −1 samples/AspNetMvcAuthDemo/AspNetMvcAuthSample.xproj
  4. +36 −36 samples/AspNetMvcAuthDemo/Controllers/AccountController.cs
  5. +2 −2 samples/AspNetMvcAuthDemo/Controllers/HomeController.cs
  6. +29 −0 samples/AspNetMvcAuthDemo/Program.cs
  7. +22 −27 samples/AspNetMvcAuthDemo/Startup.cs
  8. +1 −1 samples/AspNetMvcAuthDemo/Views/_ViewImports.cshtml
  9. +109 −57 samples/AspNetMvcAuthDemo/project.json
  10. +14 −0 samples/AspNetMvcAuthDemo/web.config
  11. +0 −2 samples/AspNetMvcAuthDemo/wwwroot/_references.js
  12. +0 −1 samples/AspNetMvcAuthDemo/wwwroot/css/site.min.css
  13. 0 samples/AspNetMvcAuthDemo/wwwroot/js/site.min.js
  14. +0 −9 samples/AspNetMvcAuthDemo/wwwroot/web.config
  15. +6 −4 samples/AspNetMvcSample/AppTenantResolver.cs
  16. +2 −2 samples/AspNetMvcSample/AspNetMvcSample.xproj
  17. +456 −454 samples/AspNetMvcSample/Controllers/AccountController.cs
  18. +1 −1 samples/AspNetMvcSample/Controllers/HomeController.cs
  19. +6 −6 samples/AspNetMvcSample/Controllers/ManageController.cs
  20. +4 −4 samples/AspNetMvcSample/Migrations/00000000000000_CreateIdentitySchema.Designer.cs
  21. +4 −3 samples/AspNetMvcSample/Migrations/00000000000000_CreateIdentitySchema.cs
  22. +4 −4 samples/AspNetMvcSample/Migrations/ApplicationDbContextModelSnapshot.cs
  23. +3 −2 samples/AspNetMvcSample/Models/ApplicationUser.cs
  24. +6 −3 samples/AspNetMvcSample/Models/SqlServerApplicationDbContext.cs
  25. +8 −6 samples/AspNetMvcSample/Models/SqliteApplicationDbContext.cs
  26. +24 −0 samples/AspNetMvcSample/Program.cs
  27. +16 −25 samples/AspNetMvcSample/Startup.cs
  28. +2 −2 samples/AspNetMvcSample/TenantViewLocationExpander.cs
  29. +3 −3 samples/AspNetMvcSample/Themes/_ViewImports.cshtml
  30. +1 −1 samples/AspNetMvcSample/ViewModels/Account/SendCodeViewModel.cs
  31. +1 −1 samples/AspNetMvcSample/ViewModels/Manage/ConfigureTwoFactorViewModel.cs
  32. +1 −1 samples/AspNetMvcSample/ViewModels/Manage/IndexViewModel.cs
  33. +2 −2 samples/AspNetMvcSample/ViewModels/Manage/ManageLoginsViewModel.cs
  34. +3 −3 samples/AspNetMvcSample/Views/Account/ExternalLoginConfirmation.cshtml
  35. +3 −3 samples/AspNetMvcSample/Views/Account/ForgotPassword.cshtml
  36. +10 −8 samples/AspNetMvcSample/Views/Account/Login.cshtml
  37. +2 −2 samples/AspNetMvcSample/Views/Account/Register.cshtml
  38. +2 −2 samples/AspNetMvcSample/Views/Account/ResetPassword.cshtml
  39. +1 −1 samples/AspNetMvcSample/Views/Account/SendCode.cshtml
  40. +2 −2 samples/AspNetMvcSample/Views/Account/VerifyCode.cshtml
  41. +19 −16 samples/AspNetMvcSample/Views/Shared/_LoginPartial.cshtml
  42. +3 −3 samples/AspNetMvcSample/Views/_ViewImports.cshtml
  43. +105 −49 samples/AspNetMvcSample/project.json
  44. +14 −0 samples/AspNetMvcSample/web.config
  45. +0 −1 samples/AspNetMvcSample/wwwroot/css/site.min.css
  46. +1 −1 samples/AspNetSample/AppTenantResolver.cs
  47. +2 −4 samples/AspNetSample/AspNetSample.xproj
  48. +4 −4 samples/AspNetSample/CachingAppTenantResolver.cs
  49. +24 −0 samples/AspNetSample/Program.cs
  50. +1 −1 samples/AspNetSample/Properties/launchSettings.json
  51. +6 −11 samples/AspNetSample/Startup.cs
  52. +52 −28 samples/AspNetSample/project.json
  53. +14 −0 samples/AspNetSample/web.config
  54. +0 −9 samples/AspNetSample/wwwroot/web.config
  55. +1 −1 samples/AspNetStructureMapSample/AppTenant.cs
  56. +4 −4 samples/AspNetStructureMapSample/AppTenantResolver.cs
  57. +1 −1 samples/AspNetStructureMapSample/AspNetStructureMapSample.xproj
  58. +22 −0 samples/AspNetStructureMapSample/Program.cs
  59. +12 −16 samples/AspNetStructureMapSample/Startup.cs
  60. +50 −29 samples/AspNetStructureMapSample/project.json
  61. +9 −9 samples/{AspNetMvcSample/wwwroot → AspNetStructureMapSample}/web.config
  62. +0 −9 samples/AspNetStructureMapSample/wwwroot/web.config
  63. +2 −2 src/SaasKit.Multitenancy.StructureMap/Internal/MultitenantContainerMiddleware.cs
  64. +1 −1 src/SaasKit.Multitenancy.StructureMap/SaasKit.Multitenancy.StructureMap.xproj
  65. +1 −1 src/SaasKit.Multitenancy.StructureMap/StructureMapApplicationBuilderExtensions.cs
  66. +38 −22 src/SaasKit.Multitenancy.StructureMap/project.json
  67. +1 −1 src/SaasKit.Multitenancy/ITenantResolver.cs
  68. +12 −10 src/SaasKit.Multitenancy/Internal/PrimaryHostnameRedirectMiddleware.cs
  69. +2 −2 src/SaasKit.Multitenancy/Internal/TenantPipelineMiddleware.cs
  70. +7 −7 src/SaasKit.Multitenancy/Internal/TenantResolutionMiddleware.cs
  71. +8 −8 src/SaasKit.Multitenancy/Internal/TenantUnresolvedRedirectMiddleware.cs
  72. +9 −9 src/SaasKit.Multitenancy/MemoryCacheTenantResolver.cs
  73. +4 −2 src/SaasKit.Multitenancy/MultitenancyApplicationBuilderExtensions.cs
  74. +6 −3 src/SaasKit.Multitenancy/MultitenancyHttpContextExtensions.cs
  75. +9 −3 src/SaasKit.Multitenancy/MultitenancyServiceCollectionExtensions.cs
  76. +1 −1 src/SaasKit.Multitenancy/SaasKit.Multitenancy.xproj
  77. +1 −1 src/SaasKit.Multitenancy/TenantPipelineBuilderContext.cs
  78. +4 −2 src/SaasKit.Multitenancy/UsePerTenantApplicationBuilderExtensions.cs
  79. +34 −18 src/SaasKit.Multitenancy/project.json
  80. +2 −2 tests/SaasKit.Multitenancy.Tests/MultitenancyHttpContextExtensionsTests.cs
  81. +1 −1 tests/SaasKit.Multitenancy.Tests/SaasKit.Multitenancy.Tests.xproj
  82. +30 −22 tests/SaasKit.Multitenancy.Tests/TenantPipelineMiddlewareTests.cs
  83. +47 −30 tests/SaasKit.Multitenancy.Tests/project.json
@@ -1,6 +1,3 @@
{
"projects": [ "src" ],
"sdk": {
"version": "1.0.0-rc1-final"
}
"projects": [ "src" ]
}
@@ -1,7 +1,7 @@
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.OptionsModel;
using Microsoft.Extensions.Options;
using SaasKit.Multitenancy;
using System;
using System.Collections.Generic;
@@ -10,15 +10,16 @@

namespace AspNetMvcAuthSample
{
public class CachingAppTenantResolver : MemoryCacheTenantResolver<AppTenant>

public class CachingAppTenantResolver : MemoryCacheTenantResolver<AppTenant>
{
private readonly IEnumerable<AppTenant> tenants;

public CachingAppTenantResolver(IMemoryCache cache, ILoggerFactory loggerFactory, IOptions<MultitenancyOptions> options)
: base(cache, loggerFactory)
{
this.tenants = options.Value.Tenants;
}
}

protected override string GetContextIdentifier(HttpContext context)
{
@@ -9,7 +9,7 @@
<ProjectGuid>fe7c68ec-5a31-4c31-a4ec-2e041c20483c</ProjectGuid>
<RootNamespace>AspNetMvcAuthSample</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
@@ -1,39 +1,39 @@
using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Mvc;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;

namespace AspNetMvcAuthSample.Controllers
{
public class AccountController : Controller
{
ILogger<AccountController> logger;

public AccountController(ILogger<AccountController> logger)
{
this.logger = logger;
}

public IActionResult LogIn()
{
return View();
}

public IActionResult Google()
{
var props = new AuthenticationProperties
{
RedirectUri = "/home/about"
};

return new ChallengeResult("Google", props);
using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;

namespace AspNetMvcAuthSample.Controllers
{
public class AccountController : Controller
{
ILogger<AccountController> logger;

public AccountController(ILogger<AccountController> logger)
{
this.logger = logger;
}

public IActionResult LogIn()
{
return View();
}

public async Task<IActionResult> LogOut()
{
await HttpContext.Authentication.SignOutAsync("Cookies");

return RedirectToAction("index", "home");
}
}
public IActionResult Google()
{
var props = new AuthenticationProperties
{
RedirectUri = "/home/about"
};

return new ChallengeResult("Google", props);
}

public async Task<IActionResult> LogOut()
{
await HttpContext.Authentication.SignOutAsync("Cookies");

return RedirectToAction("index", "home");
}
}
}
@@ -1,5 +1,5 @@
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace AspNetMvcAuthSample.Controllers
{
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AspNetMvcAuthSample
{
using System.IO;

using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.Extensions.Options;

public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseUrls("http://localhost:60000", "http://localhost:60001", "http://localhost:60002", "http://localhost:60003")
.Build();

host.Run();
}
}
}
@@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Authentication.Google;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Authentication.Google;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -18,7 +18,8 @@ public Startup(IHostingEnvironment env)
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();

builder.AddUserSecrets();
@@ -55,33 +56,30 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
}

app.UseDeveloperExceptionPage();

app.UseIISPlatformHandler();


app.UseStaticFiles();

app.UseMultitenancy<AppTenant>();

app.UsePerTenant<AppTenant>((ctx, builder) =>
{
builder.UseCookieAuthentication(options =>
builder.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "Cookies",
LoginPath = new PathString("/account/login"),
AccessDeniedPath = new PathString("/account/forbidden"),
AutomaticAuthenticate = true,
AutomaticChallenge = true,
CookieName = $"{ctx.Tenant.Id}.AspNet.Cookies"
});

builder.UseGoogleAuthentication(new GoogleOptions()
{
options.AuthenticationScheme = "Cookies";
options.LoginPath = new PathString("/account/login");
options.AccessDeniedPath = new PathString("/account/forbidden");
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
AuthenticationScheme = "Google",
SignInScheme = "Cookies",

options.CookieName = $"{ctx.Tenant.Id}.AspNet.Cookies";
});

builder.UseGoogleAuthentication(options =>
{
options.AuthenticationScheme = "Google";
options.SignInScheme = "Cookies";

options.ClientId = Configuration[$"{ctx.Tenant.Id}:GoogleClientId"];
options.ClientSecret = Configuration[$"{ctx.Tenant.Id}:GoogleClientSecret"];
ClientId = Configuration[$"{ctx.Tenant.Id}:GoogleClientId"],
ClientSecret = Configuration[$"{ctx.Tenant.Id}:GoogleClientSecret"]
});
});

@@ -92,8 +90,5 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
template: "{controller=Home}/{action=Index}/{id?}");
});
}

// Entry point for the application.
public static void Main(string[] args) => Microsoft.AspNet.Hosting.WebApplication.Run<Startup>(args);
}
}
@@ -2,6 +2,6 @@

@inject AppTenant Tenant;

@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"


0 comments on commit 47eaa79

Please sign in to comment.
You can’t perform that action at this time.