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
"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 / docker-compose.yml
Created February 27, 2020 06:58
Setting up docker instance of Elastichsearch, Kibana and Logstash on your local machine
version: '3.3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:latest
ports:
- "9200:9200"
- "9300:9300"
configs:
@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;
}
}
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;
//AppHost.cs, Configure method
AuthFeature authFeature = new AuthFeature(() => new UserSession(), new IAuthProvider[] {
container.Resolve<IAuthProvider>(),
new JwtAuthProvider(AppSettings) //=> use DI to register
{
AuthKeyBase64 = ConfigurationManager.AppSettings["jwt.AuthKeyBase64"],
RequireSecureConnection = false, //dev configuration
EncryptPayload = false, //dev configuration
HashAlgorithm = "HS256"
}