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
@if(User.Identity.IsAuthenticated) | |
{ | |
<p> | |
@User.Identity.Name | |
</p> | |
} |
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
"AzureAd": { | |
"Instance": "https://login.microsoftonline.com/", | |
"ClientId": "your-client-id", | |
"TenantId": "your-tenant-id" | |
}, |
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
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) | |
.AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd")); | |
services.AddControllersWithViews(options => | |
{ | |
var policy = new AuthorizationPolicyBuilder() | |
.RequireAuthenticatedUser() | |
.Build(); | |
options.Filters.Add(new AuthorizeFilter(policy)); | |
}); |
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
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); // => remove default claims | |
services | |
.AddAuthentication(options => | |
{ | |
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; | |
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; | |
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; | |
}) | |
.AddJwtBearer(cfg => | |
{ |
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 AccountController : Controller | |
{ | |
private readonly IConfiguration _configuration; | |
public AccountController(IConfiguration configuration) | |
{ | |
_configuration = configuration; | |
} | |
[HttpPost] | |
[Route("Login")] |
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
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<rule name="Angular Routes" stopProcessing="true"> | |
<match url=".*" /> | |
<conditions logicalGrouping="MatchAll"> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> | |
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="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
Plugins.Add(new AutoQueryFeature() | |
{ | |
MaxLimit = 100 | |
} |
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.GlobalRequestFilters.Add((req, res, requestDto) => | |
{ | |
if (requestDto != null && requestDto is QueryBase) | |
{ | |
var dto = requestDto as QueryBase; | |
if (dto.Take == null) | |
{ | |
dto.Take = 100; | |
} | |
} |
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
<nlog throwExceptions="true" throwConfigExceptions="true" internalLogLevel="Trace" autoReload="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<targets async="true"> | |
<target name="file" xsi:type="File" fileName="${basedir}/Logs/Logs.log" layout="${date}: ${message}" /> | |
</targets> | |
<rules> | |
<logger name="*" minlevel="Info" writeTo="file" archiveFileName="${basedir}/archives/log.{#####}.txt" archiveAboveSize="1024" archiveNumbering="Sequence" concurrentWrites="true" keepFileOpen="false" encoding="iso-8859-2" /> | |
</rules> | |
</nlog> |
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
JsConfig.AssumeUtc = true; | |
JsConfig<DateTime>.SerializeFn = time => new DateTime(time.Ticks, DateTimeKind.Local).ToString("o"); | |
JsConfig<DateTime?>.SerializeFn = time => time != null ? new DateTime(time.Value.Ticks, DateTimeKind.Local).ToString("o") : null; | |
JsConfig.DateHandler = DateHandler.ISO8601; |