View Token-Auth-Appsettings.json
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, |
View Azure-AD-Auth-Index.cshtml
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> | |
} |
View Azure-AD-Auth-appsettings.json
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" | |
}, |
View Azure-AD-Auth-Startup.cs
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)); | |
}); |
View Startup.cs
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 => | |
{ |
View AccountController.cs
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")] |
View docker-compose.yml
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: |
View web.config
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" /> |
View gist:49ffc4e929b30c43d223b6d5649561a0
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 | |
} |
View Apphost.cs
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; | |
} | |
} |
NewerOlder