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
<rewrite> | |
<globalRules> | |
<rule name="ReverseProxyRule1" enabled="false"> | |
<match url="^About" /> | |
<action type="Rewrite" url="http://localhost:8021/Home/About" /> | |
<conditions> | |
<add input="{SERVER_PORT}" pattern="88" /> | |
</conditions> | |
</rule> | |
<rule name="ReverseProxyRule2" enabled="true" stopProcessing="true"> |
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
<rewrite> | |
<outboundRules> | |
<rule name="AnchorFixer" preCondition="IsHTML" | |
enabled="true" stopProcessing="true"> | |
<match filterByTags="A" pattern="^/Home/(.*)" /> | |
<action type="Rewrite" value="/{R:1}" /> | |
</rule> | |
<rule name="LinkNScriptFixer" preCondition="IsHTML" | |
enabled="true" stopProcessing="true"> | |
<match filterByTags="Link, Script" pattern="^/(css|js)/(.*)" |
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
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
// ...other middleware | |
app.UseAuthentication(); | |
app.UseMvc(routes => | |
{ | |
routes.MapRoute( | |
name: "default", |
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
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddAuthentication(options => | |
{ | |
// these must be set other ASP.NET Core will throw exception that no | |
// default authentication scheme or default challenge scheme is set. | |
options.DefaultAuthenticateScheme = | |
CookieAuthenticationDefaults.AuthenticationScheme; | |
options.DefaultChallengeScheme = | |
CookieAuthenticationDefaults.AuthenticationScheme; |
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
public class HomeController : Controller | |
{ | |
[Authorize] | |
public IActionResult About() | |
{ | |
ViewData["Message"] = "Your application description page."; | |
return View(); | |
} | |
} |
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
[AllowAnonymous] | |
[HttpPost] | |
[ValidateAntiForgeryToken] | |
public async Task Login(UserCredentials userCredentials, | |
string returnUrl = null) | |
{ | |
// I will fill this in a bit... | |
} |
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
public interface IJwtTokenGenerator | |
{ | |
TokenWithClaimsPrincipal GenerateAccessTokenWithClaimsPrincipal(string userName, | |
IEnumerable userClaims); | |
string GenerateAccessToken(string userName, | |
IEnumerable userClaims); | |
} |
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
public class TokenWithClaimsPrincipal | |
{ | |
public string AccessToken { get; internal set; } | |
public ClaimsPrincipal ClaimsPrincipal { get; internal set; } | |
public AuthenticationProperties AuthProperties { get; internal set; } | |
} |
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
public IHostingEnvironment Environment {get; set;} | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
var signingKey = new SymmetricSecurityKey( | |
Encoding.ASCII.GetBytes( | |
Configuration["Token:SigningKey"]); | |
var validationParams = new TokenValidationParameters() | |
{ |
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
[HttpPost] | |
[AllowAnonymous] | |
[ValidateAntiForgeryToken] | |
public async Task Login(UserCredentials userCredentials, | |
string returnUrl = null) | |
{ | |
ViewBag.returnUrl = returnUrl; | |
var returnTo = "/Account/Login"; | |
// Replace this with your custom authentication logic |