// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var databaseOptionsSection = Configuration.GetSection("DatabaseOptions");

            services.Configure <DatabaseOptions>(databaseOptionsSection);
            var databaseOptions = databaseOptionsSection.Get <DatabaseOptions>();

            var oraConfig = new SQWOraConfig
            {
                host     = databaseOptions.dbServer,
                instance = databaseOptions.dbInstance,
                userName = databaseOptions.userName,
                password = databaseOptions.password
            };

            var sequenceGenerator = new SQWSequenceGenerator();

            SQWOraWorker worker = new SQWOraWorker(oraConfig, sequenceGenerator);

            services.AddSingleton <ISQWWorker>(worker);

            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;
            });


            services.AddDistributedMemoryCache();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddSingleton <NewsDatabaseRepository>();
            services.AddSingleton <SchedulerDatabaseRepository>();
            services.AddSingleton <EventDatabaseRepository>();
            services.AddSingleton <UserDatabaseRepository>();
            services.AddSingleton <PaymentsDatabaseRepository>();
            //προσθεσα αυτη για να βρισκω το current user id --svhseee
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();


            //προσθεσα αυτη για αυθεντικοποιηση
            services
            .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath        = "/User/Login";
                options.AccessDeniedPath = "/User/UnauthorizedView";
            });
            //προσθεσα για εξουσιοδότιση
            services.AddAuthorization(options =>
            {
                options.AddPolicy("admin", policy => policy.RequireRole("admin"));
                options.AddPolicy("user", policy => policy.RequireRole("user"));
            });
        }
        // This method gets called by the runtime. Use this method to
        // add services to the container.
        // For more information on how to configure your application,
        // visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            // Connect to oracle
            var databaseOptionsSection = Configuration.GetSection("DatabaseOptions");

            services.Configure <DatabaseOptions>(databaseOptionsSection);
            var databaseOptions = databaseOptionsSection.Get <DatabaseOptions>();

            var oraConfig = new SQWOraConfig
            {
                host     = databaseOptions.dbServer,
                instance = databaseOptions.dbInstance,
                userName = databaseOptions.userName,
                password = databaseOptions.password
            };

            var sequenceGenerator = new SQWSequenceGenerator();

            SQWOraWorker worker = new SQWOraWorker(oraConfig, sequenceGenerator);

            services.AddSingleton <ISQWWorker>(worker);

            // ******
            // BLAZOR COOKIE Auth Code (begin)
            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.AddAuthentication(
                CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie();
            // BLAZOR COOKIE Auth Code (end)
            // ******

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddSingleton <UserService>();
            services.AddSingleton <NoteService>();

            // ******
            // BLAZOR COOKIE Auth Code (begin)
            // From: https://github.com/aspnet/Blazor/issues/1554
            // HttpContextAccessor
            services.AddHttpContextAccessor();
            services.AddScoped <HttpContextAccessor>();
            services.AddHttpClient();
            services.AddScoped <HttpClient>();
            services.AddAuthorizationCore();
            // BLAZOR COOKIE Auth Code (end)
            // ******
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();

            var config = new SQWOraConfig
            {
                host     = "localhost",
                instance = "casino",
                userName = "******",
                password = "******"
            };

            services.AddSingleton <ISQWWorker>(new SQWOraWorker(config, new SQWSequenceGenerator()));

            services.AddSingleton <AreaRepository>();
            services.AddSingleton <PlayerRepository>();

            services.AddAutoMapper(typeof(Startup));
        }
Beispiel #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ///////////////////////////////////////////////////////////////////////////////////////////
            //συνδεση με βαση oracle (βιβλιοθηκη sqwWorker απο nuGet)

            var databaseOptionsSection = Configuration.GetSection("DatabaseOptions");

            services.Configure <DatabaseOptions>(databaseOptionsSection);
            var databaseOptions = databaseOptionsSection.Get <DatabaseOptions>();
            //πιο απλα :  var databaseOptions = new DatabaseOptions();
            //            Configuration.GetSection("DatabaseOptions").Bind(databaseOptions);

            var oraConfig = new SQWOraConfig
            {
                host     = databaseOptions.dbServer,
                instance = databaseOptions.dbInstance,
                userName = databaseOptions.userName,
                password = databaseOptions.password
            };

            var sequenceGenerator = new SQWSequenceGenerator();

            SQWOraWorker worker = new SQWOraWorker(oraConfig, sequenceGenerator);

            services.AddSingleton <ISQWWorker>(worker);

            //////////////////////////////////////////////////////////////////////////////////

            services.Configure <ProductOptions>(Configuration.GetSection("ProductOptions"));

            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;
            });

            //προσθεσα για τον φακελο του resx για την γλωσσα
            services.AddLocalization(options =>
            {
                options.ResourcesPath = "Resources";
            });

            services.AddDistributedMemoryCache();

            services.AddSession(options =>
            {
                options.Cookie.Name = ".ProductManagement.Session";
                // Set a short timeout for easy testing.
                options.IdleTimeout     = TimeSpan.FromMinutes(10);
                options.Cookie.HttpOnly = true;
                // Make the session cookie essential
                options.Cookie.IsEssential = true;
            });


            services.AddMvc()
            .AddViewLocalization(options => { options.ResourcesPath = "Resources"; })
            .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
            .AddDataAnnotationsLocalization()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.Configure <RequestLocalizationOptions>(options =>
            {
                var supportedCultures = new List <CultureInfo>
                {
                    new CultureInfo("en"),
                    new CultureInfo("el"),
                };

                options.DefaultRequestCulture = new RequestCulture("en"); //default language
                options.SupportedCultures     = supportedCultures;        //the supported are the ones i created above
                options.SupportedUICultures   = supportedCultures;
            });


            //προσθεσα για signalr
            services.AddSignalR();
            // services.AddSingleton<IProductRepository, ProductMemoryRepository>();
            services.AddSingleton <IProductRepository, ProductDatabaseRepository>();
            services.AddSingleton <UserRepository>();
            services.AddSingleton <OrderRepository>();

            //προσθεσα αυτη για αυθεντικοποιηση
            services
            .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath        = "/Account/Login";
                options.AccessDeniedPath = "/Account/UnauthorizedView";
            });
            //προσθεσα για εξουσιοδότιση
            services.AddAuthorization(options =>
            {
                options.AddPolicy("admin", policy => policy.RequireRole("admin"));
                options.AddPolicy("user", policy => policy.RequireRole("user"));
            });
        }