Пример #1
0
 public ExamService(HttpClient httpClient, ClientAppSettings appSettings, AppState appState)
 {
     _httpClient  = httpClient;
     _appSettings = appSettings;
     _appState    = appState;
     Current      = this;
 }
Пример #2
0
        internal void InitializeContainer(IApplicationBuilder app, ClientAppSettings clientAppSettings, ConnectionstringSettings connectionstringSettings)
        {
            var executingAssembly = Assembly.GetExecutingAssembly();
            var allAssemblies     = new[] { executingAssembly };

            // Add application presentation components:
            _container.RegisterMvcControllers(app);

            // Register settings as singleton
            _container.RegisterInstance(clientAppSettings);
            _container.RegisterInstance(connectionstringSettings);

            // Add application services. For instance:
            _container.Register(typeof(IQueryHandler <,>), allAssemblies);
            _container.Register(typeof(ICommandHandler <>), allAssemblies);
            _container.Register <HistoricContext>(Lifestyle.Scoped);

            // Add crosswiring services.

            // Allow Simple Injector to resolve services from ASP.NET Core.
            _container.AutoCrossWireAspNetComponents(app);

            using (AsyncScopedLifestyle.BeginScope(_container)) {
                var context = _container.GetInstance <HistoricContext>();
                context.Database.Migrate();
            }

            _container.Verify();
        }
Пример #3
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            _clientAppSettings        = configuration.GetSection("ClientApp").Get <ClientAppSettings>();
            _connectionstringSettings = configuration.GetSection("ConnectionStrings").Get <ConnectionstringSettings>();
        }
Пример #4
0
 public IdentityService(UserManager <ApplicationUser> userManager, IEmailService emailService, IOptions <ClientAppSettings> client, IOptions <JwtSecurityTokenSettings> jwt, RoleManager <IdentityRole> roleManager)
 {
     _userManager  = userManager;
     _roleManager  = roleManager;
     _emailService = emailService;
     _client       = client.Value;
     _jwt          = jwt.Value;
 }
Пример #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.Configure <ClientAppSettings>(Configuration);
            var config = new ClientAppSettings();

            Configuration.Bind("ClientAppSettings", config);      //  <--- This
            services.AddSingleton(config);

            Config.ApiUrl         = Configuration["ApiAppConfig:Url"];
            Config.APIKeyValue    = Configuration["ApiAppConfig:KeyValue"];
            Config.SessionTimeout = int.Parse(Configuration["SessionTimeOut"]);
            Config.debugMode      = bool.Parse(Configuration["debugMode"]);
            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });
            services.AddHttpClient();
            services.AddTransient <ApiProxyMiddleware>();
            //services.AddHttpClient<IAccountService, AccountService>();
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath          = "/";
                options.LogoutPath         = "/";
                options.Cookie.Name        = CookieAuthenticationDefaults.AuthenticationScheme;
                options.Cookie.SameSite    = SameSiteMode.None;
                options.LoginPath          = new Microsoft.AspNetCore.Http.PathString("/");
                options.AccessDeniedPath   = "/";
                options.ReturnUrlParameter = "/";
                options.AccessDeniedPath   = "/";
                options.LogoutPath         = "/";
                options.ExpireTimeSpan     = TimeSpan.FromMinutes(Config.SessionTimeout); //set it less for testing purpose
                                                                                          // options.Events.OnRedirectToLogin
            });
            services.AddDistributedMemoryCache();
            services.AddSession(options => {
                options.Cookie.Name     = CookieAuthenticationDefaults.AuthenticationScheme;
                options.IdleTimeout     = TimeSpan.FromMinutes(Config.SessionTimeout);
                options.Cookie.HttpOnly = true;
            });
            services.AddSingleton <IApiConfiguration, DevelopmentApiConfiguration>();
            // If using Kestrel:
            services.Configure <KestrelServerOptions>(options =>
            {
                options.AllowSynchronousIO = true;
            });

            // If using IIS:
            services.Configure <IISServerOptions>(options =>
            {
                options.AllowSynchronousIO = true;
            });
            //In-Memory
        }
Пример #6
0
        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            ClientAppSettings.Enable(pipelines);
            Elmahlogging.Enable(pipelines, "elmah");
            CustomErrors.Enable(pipelines, new ErrorHandlingConfiguration());
            FormsAuthentication.Enable(pipelines, new FormsAuthenticationConfiguration
            {
                RedirectUrl = "~/login",
                UserMapper  = container.Resolve <IUserMapper>()
            });
        }
Пример #7
0
 public ManageController(
     UserManager <User> userManager,
     UrlEncoder urlEncoder,
     IEmailService emailService,
     IOptions <ClientAppSettings> client,
     IOptions <QRCodeSettings> qr
     )
 {
     _userManager  = userManager;
     _urlEncoder   = urlEncoder;
     _emailService = emailService;
     _client       = client.Value;
     _qr           = qr.Value;
 }
Пример #8
0
 public AuthController(
     UserManager <IdentityUser> userManager,
     RoleManager <IdentityRole> roleManager,
     IConfiguration configuration,
     IEmailService emailService,
     IOptions <ClientAppSettings> client,
     IOptions <JwtSecurityTokenSettings> jwt
     )
 {
     this._userManager   = userManager;
     this._roleManager   = roleManager;
     this._configuration = configuration;
     this._emailService  = emailService;
     this._client        = client.Value;
     this._jwt           = jwt.Value;
 }
Пример #9
0
 public AuthService(UserManager <User> userManager,
                    RoleManager <IdentityRole> roleManager,
                    SecurityContext securityContext,
                    IEmailService emailService,
                    TokenValidationParameters tokenValidationParameters,
                    IOptions <ClientAppSettings> client,
                    IOptions <JwtSecurityTokenSettings> jwtSettings)
 {
     _userManager               = userManager;
     _roleManager               = roleManager;
     _securityContext           = securityContext;
     _emailService              = emailService;
     _tokenValidationParameters = tokenValidationParameters;
     _client      = client.Value;
     _jwtSettings = jwtSettings.Value;
 }
Пример #10
0
 public ManageController(
     UserManager <IdentityUser> userManager,
     RoleManager <IdentityRole> roleManager,
     UrlEncoder urlEncoder,
     IEmailService emailService,
     IOptions <ClientAppSettings> client,
     IOptions <QRCodeSettings> qr
     )
 {
     this._userManager  = userManager;
     this._roleManager  = roleManager;
     this._urlEncoder   = urlEncoder;
     this._emailService = emailService;
     this._client       = client.Value;
     this._qr           = qr.Value;
 }
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            if (!IsLoaded)
            {
                var appSettings = await HttpClient.GetJsonAsync <ClientAppSettings>("api/clientappsettings");

                ClientAppSettings =
                    new ClientAppSettings
                {
                    ClientId     = appSettings.ClientId,
                    ClientSecret = appSettings.ClientSecret
                };

                IsLoaded = true;
            }
        }
Пример #12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.Configure <ClientAppSettings>(Configuration);
            var config = new ClientAppSettings();

            Configuration.Bind("ClientAppSettings", config);      //  <--- This
            services.AddSingleton(config);

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });
            //services.AddHttpClient<IAccountService, AccountService>();
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath          = "/";
                options.LogoutPath         = "/";
                options.Cookie.Name        = CookieAuthenticationDefaults.AuthenticationScheme;
                options.Cookie.SameSite    = SameSiteMode.None;
                options.LoginPath          = new Microsoft.AspNetCore.Http.PathString("/");
                options.AccessDeniedPath   = "/";
                options.ReturnUrlParameter = "/";
                options.AccessDeniedPath   = "/";
                options.LogoutPath         = "/";
                options.ExpireTimeSpan     = TimeSpan.FromMinutes(Config.SessionTimeout); //set it less for testing purpose
                                                                                          // options.Events.OnRedirectToLogin
            });
            services.AddDistributedMemoryCache();
            services.AddSession(options => {
                options.Cookie.Name     = CookieAuthenticationDefaults.AuthenticationScheme;
                options.IdleTimeout     = TimeSpan.FromMinutes(Config.SessionTimeout);
                options.Cookie.HttpOnly = true;
            });
            //In-Memory
        }
 public ClientAppSettingsController(IOptions <ClientAppSettings> clientAppSettings)
 {
     _clientAppSettings = clientAppSettings.Value;
 }
Пример #14
0
 public ClientAppSettingsController(ClientAppSettings clientAppSettings)
 {
     _clientAppSettings = clientAppSettings;
 }