private AuthenticationTicket CreateTicket(UserApplicationAuthentication user)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            var id = new ClaimsIdentity(user.AuthenticationType, user.NameType, user.RoleType);

            foreach (var claim in user.Claims)
            {
                id.AddClaim(new Claim(claim.Key, claim.Value ?? string.Empty));
            }

            var principal = new ClaimsPrincipal(id);
            var ticket    = new AuthenticationTicket(principal, new AuthenticationProperties(),
                                                     EnterpriseAuthenticationDefaults.AuthenticationScheme);

            Logger.LogInformation($"Authentication Success,Enterprise name is {user.Claims.FirstOrDefault(i => i.Key == ClaimTypes.NameIdentifier).Value}");
            return(ticket);
        }
        private void SetUserToCache(string accessKey, UserApplicationAuthentication model)
        {
            try
            {
                var memoryCacheEntryOptions =
                    new MemoryCacheEntryOptions {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300)
                };
                if (Options.AbsoluteExpirationRelativeToNow.HasValue)
                {
                    memoryCacheEntryOptions.AbsoluteExpirationRelativeToNow =
                        TimeSpan.FromSeconds(Options.AbsoluteExpirationRelativeToNow.Value);
                }

                var value = JsonConvert.SerializeObject(model);
                Cache.Set(GetLocalizedKey(accessKey), Encoding.UTF8.GetBytes(value), memoryCacheEntryOptions);
            }
            catch (Exception e)
            {
                Logger.LogError(899, e, "将企业用户信息写入缓存失败");
            }
        }