Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
demon near me

Taras Romanyk RredCat

:octocat:
demon near me
View GitHub Profile
@RredCat
RredCat / Example.cs
Created Jul 22, 2019
Example for FA
View Example.cs
[Authorize(AuthenticationSchemes = "api")]
@RredCat
RredCat / Startup.cs
Created Jul 22, 2019
Startup for FA
View Startup.cs
services.AddAuthentication(o => o.AddScheme("api", a => a.HandlerType = typeof(TokenHandler)));
@RredCat
RredCat / TokenHandler.cs
Created Jul 22, 2019
TokenHandler for FA blog.
View TokenHandler.cs
internal class TokenHandler : AuthenticationHandler
{
private const ulong _REQUEST_MAX_AGE_IN_SECONDS = 300; //5 mins
private const string _AUTHENTICATION_SCHEME = "amx";
private static readonly DateTime _1970 = new DateTime(1970, 01, 01, 0, 0, 0, 0, DateTimeKind.Utc);
private static readonly Dictionary _AllowedApps = new Dictionary();
private readonly IMemoryCache _cache;
public TokenHandler(IMemoryCache memoryCache, IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock)