-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to use aspnet core 2.2 runtime (#108)
* Update everything to netcoreapp2.2 Tests pass and generation works for both KO and Vue * Remove deps on obsolete logging setup. Fix some netcoreapp2.1 refs. Upgraded vue-cli to fix build issues. * Updated some Vue npm bits * Update Sourcelink to latest to remove dep on GitSharpLib * Changed to use 'webpack-env' instead of node in tsconfig per microsoft/nodejstools#2085 * Don't serve the /public/index.html, serve the one out of wwwroot * Make UseTimeZone cross-platform until https://github.com/dotnet/corefx/issues/11897 is fixed. * Fix VS trying to be "helpful" * Not hardcode the wwwroot convention
- Loading branch information
Showing
28 changed files
with
2,862 additions
and
19,090 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Security.Claims; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Coalesce.Web.Vue | ||
{ | ||
public class DemoMiddleware | ||
{ | ||
public const string AuthenticationScheme = "DemoMiddleware"; | ||
|
||
RequestDelegate _next; | ||
|
||
public DemoMiddleware(RequestDelegate next) | ||
{ | ||
_next = next; | ||
} | ||
|
||
public async Task Invoke(HttpContext context) | ||
{ | ||
var validRoles = new List<string> { "Admin", "User", "None" }; | ||
var wasLoggedIn = context.User.Identity.IsAuthenticated; | ||
|
||
var cookie = context.Request.Cookies.FirstOrDefault(c => c.Key == "SecurityTestRole"); | ||
if (!cookie.Equals(default(KeyValuePair<string, string>)) | ||
&& validRoles.Contains(cookie.Value) | ||
&& context.Request.Host.Value.ToLower().Contains("localhost")) | ||
{ | ||
if (cookie.Value != "None") | ||
{ | ||
await SignInUser(context, "SecurityTestUser", cookie.Value); | ||
if (!wasLoggedIn) context.Response.Redirect(context.Request.Path); | ||
} | ||
} | ||
else | ||
{ | ||
cookie = context.Request.Cookies.FirstOrDefault(c => c.Key == "DemoUserRole"); | ||
if (!cookie.Equals(default(KeyValuePair<string, string>)) | ||
&& validRoles.Contains(cookie.Value) | ||
&& context.Request.Host.Value.ToLower().Contains("localhost")) | ||
{ | ||
await SignInUser(context, "DemoUser", cookie.Value); | ||
} | ||
else | ||
{ | ||
await SignInUser(context, "DemoUser", "Admin"); | ||
} | ||
} | ||
|
||
var isLoggedIn = context.User.Identity.IsAuthenticated; | ||
if (!wasLoggedIn && isLoggedIn) context.Response.Redirect("/"); | ||
else await _next(context); | ||
} | ||
|
||
private async Task SignInUser(HttpContext context, string name, string role) | ||
{ | ||
Claim[] claims; | ||
if (string.IsNullOrEmpty(role)) claims = new[] { new Claim(ClaimTypes.Name, name) }; | ||
else claims = new[] { | ||
new Claim(ClaimTypes.Name, name), | ||
new Claim(ClaimTypes.Role, role) | ||
}; | ||
|
||
var identity = new ClaimsIdentity(claims, "AutoSignIn"); | ||
await context.SignInAsync(AuthenticationScheme, new ClaimsPrincipal(identity)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
@using VuePlayground | ||
@using Coalesce.Web.Vue | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | ||
@addTagHelper *, Microsoft.AspNetCore.SpaServices |
Oops, something went wrong.