예제 #1
0
 public AzdoClients(
     IHttpContextAccessor httpContextAccessor,
     ActiveUsersCache activeUsers,
     AzdoConfig config
     )
 {
     this.httpContextAccessor = httpContextAccessor;
     this.activeUsers         = activeUsers;
     this.config = config;
 }
예제 #2
0
        public static AuthenticationBuilder AddAzdo(
            this AuthenticationBuilder builder,
            Action <AzdoConfig> configure,
            DatabaseProvider dbProvider,
            string connectionString
            )
        {
            IServiceCollection services = builder.Services;

            services.AddSingleton <AzdoAuthenticationService>();
            services.AddSingleton <AzdoClients>();
            services.AddSingleton <ActiveUsersCache>();
            var config = new AzdoConfig();

            configure(config);
            services.AddSingleton(config);
            builder.AddCookie(AzdoDefaults.CookieAuthenticationScheme);

            switch (dbProvider)
            {
            case DatabaseProvider.SqlServer:
                services.AddDbContext <SqlServerTokenDataContext>(options =>
                {
                    options.UseSqlServer(connectionString, options =>
                    {
                        options.MigrationsAssembly(typeof(TokenDataContext).Assembly.FullName);
                    });
                });
                services.AddScoped <ITokenDataContext, SqlServerTokenDataContext>();

                //services.AddDbContext<SqlServerConfigurationDataContext>(configureDb);
                //services.AddScoped<IConfigurationDataContext, SqlServerConfigurationDataContext>();

                break;

            default:
                throw new Exception("Unsupported Database Provider");
            }

            return(builder);
        }
 public AzdoAuthenticationService(AzdoConfig config, IHttpClientFactory clientFactory,
                                  ActiveUsersCache tokenCache)
 {
     this.config        = config;
     this.clientFactory = clientFactory;
 }