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"));
            }
        }
예제 #2
0
 public EmbeddedController()
 {
     _providerResolver = EmbedlurContext.Resolver;
 }
예제 #3
0
 public EmbeddedController(IProviderResolver providerResolver)
 {
     _providerResolver = providerResolver;
 }
 public AggregateReportRecordEnrichedFactory(IProviderResolver providerResolver)
 {
     _providerResolver = providerResolver;
 }
예제 #5
0
 public OEmbedController()
 {
     _providerResolver = EmbedlurContext.Resolver;
 }
예제 #6
0
 public OEmbedController(IProviderResolver providerResolver)
 {
     _providerResolver = providerResolver;
 }
 public void SetUp()
 {
     _providerResolver = A.Fake <IProviderResolver>();
     _aggregateReportRecordEnrichedFactory = new AggregateReportRecordEnrichedFactory(_providerResolver);
 }