This file contains hidden or 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
| const crypto = require('crypto') | |
| # header | |
| const header = { "alg": "HS256", "typ": "JWT" } | |
| const encodedHeader = Buffer.from(JSON.stringify(header)).toString('base64') | |
| # payload | |
| const payload = { username: 'Flavio' } | |
| const encodedPayload = Buffer.from(JSON.stringify(payload)).toString('base64') | |
| # signature | |
| const jwtSecret = 'secretKey' | |
| const signature = crypto.createHmac('sha256', jwtSecret).update(encodedHeader + '.' + encodedPayload).digest('base64') |
This file contains hidden or 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 -Version 0.4.0-preview | |
| Install-Package Microsoft.Identity.Web.UI -Version 0.4.4-preview |
This file contains hidden or 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
| { | |
| "Logging": { | |
| "LogLevel": { | |
| "Default": "Information", | |
| "Microsoft": "Warning", | |
| "Microsoft.Hosting.Lifetime": "Information" | |
| } | |
| }, | |
| "AllowedHosts": "*", | |
| "AzureAd": { |
This file contains hidden or 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 System.Security.Principal | |
| <ul class="navbar-nav"> | |
| @if (User.Identity.IsAuthenticated) | |
| { | |
| <li class="nav-item"> | |
| <span class="navbar-text text-dark">Hello @User.Identity.Name</span> | |
| </li> | |
| <li class="nav-item"> | |
| <a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign Out</a> |
This file contains hidden or 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 BenchmarkDotNet.Attributes; | |
| using BenchmarkDotNet.Jobs; | |
| using BenchmarkDotNet.Running; | |
| using System; | |
| namespace FastRangeBenchmark | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) |
This file contains hidden or 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 void ConfigureService(IServiceCollection services) | |
| { | |
| service.AddSingleton<MyService>(sp => { | |
| ILoggerFactory loggerFactory = sp.GetService<ILoggerFactory>(); | |
| MyService service = new MyServcie(loggerFactory); | |
| return service; | |
| } | |
| } |
This file contains hidden or 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 Logger<T> : ILogger<T> | |
| { | |
| private readonly ILogger _logger; | |
| public Logger(ILoggerFactory factory) | |
| { | |
| if (factory == null) | |
| { | |
| throw new ArgumentNullException(nameof(factory)); | |
| } |
OlderNewer