/// <summary>
        /// Configures the services.
        /// </summary>
        /// <param name="services">The services.</param>
        public void ConfigureServices(IServiceCollection services)
        {
            var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                .AddConsole();
            });

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            var config = new SaaSApiClientConfiguration()
            {
                AdAuthenticationEndPoint = this.Configuration["SaaSApiConfiguration:AdAuthenticationEndPoint"],
                ClientId              = this.Configuration["SaaSApiConfiguration:ClientId"],
                ClientSecret          = this.Configuration["SaaSApiConfiguration:ClientSecret"],
                FulFillmentAPIBaseURL = this.Configuration["SaaSApiConfiguration:FulFillmentAPIBaseURL"],
                FulFillmentAPIVersion = this.Configuration["SaaSApiConfiguration:FulFillmentAPIVersion"],
                GrantType             = this.Configuration["SaaSApiConfiguration:GrantType"],
                Resource              = this.Configuration["SaaSApiConfiguration:Resource"],
                SaaSAppUrl            = this.Configuration["SaaSApiConfiguration:SaaSAppUrl"],
                SignedOutRedirectUri  = this.Configuration["SaaSApiConfiguration:SignedOutRedirectUri"],
                TenantId              = this.Configuration["SaaSApiConfiguration:TenantId"],
            };
            var knownUsers = new KnownUsersModel()
            {
                KnownUsers = this.Configuration["KnownUsers"],
            };

            services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = OpenIdConnectDefaults.AuthenticationScheme;
                options.DefaultSignInScheme       = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = CookieAuthenticationDefaults.AuthenticationScheme;
            })

            .AddOpenIdConnect(options =>
            {
                options.Authority            = $"{config.AdAuthenticationEndPoint}/common";
                options.ClientId             = config.ClientId;
                options.ResponseType         = OpenIdConnectResponseType.IdToken;
                options.CallbackPath         = "/Home/Index";
                options.SignedOutRedirectUri = config.SignedOutRedirectUri;
                options.TokenValidationParameters.NameClaimType  = "name";
                options.TokenValidationParameters.ValidateIssuer = false;
            })
            .AddCookie();

            services.AddSingleton <IFulfillmentApiClient>(new FulfillmentApiClient(config, new FulfillmentApiClientLogger()));
            services.AddSingleton <IMeteredBillingApiClient>(new MeteredBillingApiClient(config, new MeteringApiClientLogger()));
            services.AddSingleton <SaaSApiClientConfiguration>(config);
            services.AddSingleton <KnownUsersModel>(knownUsers);
            services.AddDbContext <SaasKitContext>(options =>
                                                   options.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection")));

            InitializeRepositoryServices(services);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
            services.AddMvc(option => option.EnableEndpointRouting = false);
            services.AddControllersWithViews();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="KnownUserAttribute" /> class.
 /// </summary>
 /// <param name="knownUsersRepository">The known users repository.</param>
 /// <param name="knownUsers">The known users.</param>
 public KnownUserAttribute(IKnownUsersRepository knownUsersRepository, KnownUsersModel knownUsers)
 {
     this.knownUsersRepository = knownUsersRepository;
     this.knownUsers           = knownUsers;
 }