Skip to content

Instantly share code, notes, and snippets.

View RredCat's full-sized avatar

Taras Romanyk RredCat

View GitHub Profile
@RredCat
RredCat / TokenHandler.cs
Created July 22, 2019 15:33
TokenHandler for FA blog.
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)
@RredCat
RredCat / Startup.cs
Created July 22, 2019 16:15
Startup for FA
services.AddAuthentication(o => o.AddScheme("api", a => a.HandlerType = typeof(TokenHandler)));
@RredCat
RredCat / Example.cs
Created July 22, 2019 16:17
Example for FA
[Authorize(AuthenticationSchemes = "api")]