Skip to content

Instantly share code, notes, and snippets.

View FacileTechnolab's full-sized avatar
:octocat:
happy to help

FacileTechnolab FacileTechnolab

:octocat:
happy to help
View GitHub Profile
@if(User.Identity.IsAuthenticated)
{
<p>
@User.Identity.Name
</p>
}
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"ClientId": "your-client-id",
"TenantId": "your-tenant-id"
},
@FacileTechnolab
FacileTechnolab / Azure-AD-Auth-Startup.cs
Created April 5, 2021 05:44
Configure Startup.cs for Azure AD Authentication
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"));
services.AddControllersWithViews(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
});
@FacileTechnolab
FacileTechnolab / Startup.cs
Created April 4, 2021 06:35
Setting up jwt authentication as default authentication and add token validation options
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); // => remove default claims
services
.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(cfg =>
{
public class AccountController : Controller
{
private readonly IConfiguration _configuration;
public AccountController(IConfiguration configuration)
{
_configuration = configuration;
}
[HttpPost]
[Route("Login")]
@FacileTechnolab
FacileTechnolab / web.config
Last active August 29, 2018 06:27
Publishing and hosting angular6 apps in iis
<?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" />
@FacileTechnolab
FacileTechnolab / gist:49ffc4e929b30c43d223b6d5649561a0
Last active June 15, 2018 11:58
Apphost AutoQuery Configure
Plugins.Add(new AutoQueryFeature()
{
MaxLimit = 100
}
@FacileTechnolab
FacileTechnolab / Apphost.cs
Created June 15, 2018 10:10
Faciltechnolab/AppHost-AutoQueryGlobalPageSizeFilter
this.GlobalRequestFilters.Add((req, res, requestDto) =>
{
if (requestDto != null && requestDto is QueryBase)
{
var dto = requestDto as QueryBase;
if (dto.Take == null)
{
dto.Take = 100;
}
}
<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>
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;