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
version: '3.3' | |
services: | |
elasticsearch: | |
image: docker.elastic.co/elasticsearch/elasticsearch:latest | |
ports: | |
- "9200:9200" | |
- "9300:9300" | |
configs: |
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
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
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
"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
@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
"JwtKey": "a-very-long-radonmly-generated-secret-key-that-cannot-be-guessed", | |
"JwtIssuer": "https://localhost:44394", //replace this with your application url | |
"JwtExpireDays": 30, |
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
install-package microsoft.identity.web | |
install-package microsoft.identity.web.ui |
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
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 => |