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
@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 / 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:
public class AccountController : Controller
{
private readonly IConfiguration _configuration;
public AccountController(IConfiguration configuration)
{
_configuration = configuration;
}
[HttpPost]
[Route("Login")]
@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 =>
{
@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));
});
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"ClientId": "your-client-id",
"TenantId": "your-tenant-id"
},
@if(User.Identity.IsAuthenticated)
{
<p>
@User.Identity.Name
</p>
}
"JwtKey": "a-very-long-radonmly-generated-secret-key-that-cannot-be-guessed",
"JwtIssuer": "https://localhost:44394", //replace this with your application url
"JwtExpireDays": 30,
@FacileTechnolab
FacileTechnolab / NugetPackageManager
Created December 22, 2023 07:07
BlazorAppPart2-NugetPackages
install-package microsoft.identity.web
install-package microsoft.identity.web.ui
@FacileTechnolab
FacileTechnolab / Program.cs
Last active December 22, 2023 11:40
BlazorAppPart2/Program.cs
using BlazorAppPart2.Components;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration);
builder.Services.AddHttpContextAccessor();
builder.Services.AddControllersWithViews(options =>