protected override async Task <AuthenticateResult> HandleAuthenticateAsync() { if (!Request.Headers.ContainsKey("Authorization")) { return(AuthenticateResult.Fail("authorization header is absent")); } string tokenHeader = Request.Headers["Authorization"]; IProviderResolver resolver = ProviderResolverFactory.GetResolver(tokenHeader.Split(" ").First().ToLower(), tokenHeader.Split(" ").Last(), _serviceProvider); if (resolver == null) { return(AuthenticateResult.Fail("unknown auth center")); } try { var claims = await resolver.GetClaims(); if (claims.Count == 0) { return(AuthenticateResult.Fail("unauthorized")); } var identity = new ClaimsIdentity(claims, Scheme.Name); var principal = new System.Security.Principal.GenericPrincipal(identity, null); var ticket = new AuthenticationTicket(principal, Scheme.Name); return(AuthenticateResult.Success(ticket)); } catch (Exception e) { Console.WriteLine(e.Message); return(AuthenticateResult.Fail("unauthorized")); } }
public EmbeddedController() { _providerResolver = EmbedlurContext.Resolver; }
public EmbeddedController(IProviderResolver providerResolver) { _providerResolver = providerResolver; }
public AggregateReportRecordEnrichedFactory(IProviderResolver providerResolver) { _providerResolver = providerResolver; }
public OEmbedController() { _providerResolver = EmbedlurContext.Resolver; }
public OEmbedController(IProviderResolver providerResolver) { _providerResolver = providerResolver; }
public void SetUp() { _providerResolver = A.Fake <IProviderResolver>(); _aggregateReportRecordEnrichedFactory = new AggregateReportRecordEnrichedFactory(_providerResolver); }