Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy("AllowAll",
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader();
                });
            });


            services.AddControllers();

            Configdependecyinjection.Setup(services, Configuration);
            DataDiConfig.Setup(services, Configuration);
            ConfigureDi.Setup(services);
            services.AddAutoMapper(typeof(AutoMapperProfile));
            //Auth
            JwtAuthConfig.Setup(services, Configuration);

            //services.AddDirectoryBrowser();
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseWebSockets();
            app.UseHttpsRedirection();
            app.UseMvc();

            // JWT
            JwtAuthConfig.AddRegistration(app, this._configuration);

            // Cors
            CorsConfig.AddRegistration(app);

            //GraphQL
            GraphQLConfig.AddRegistration(app);
        }
Exemplo n.º 3
0
 public LoginModel(IJwtProvider jwtProvider,
                   IOptions <JwtAuthConfig> jwtAuthConfig,
                   ICacheProvider _cacheService,
                   IUserService _userService,
                   IEventPublisher _eventPublisher)
 {
     this._jwtProvider    = jwtProvider;
     this._jwtAuthConfig  = jwtAuthConfig.Value;
     this._cacheService   = _cacheService;
     this._userService    = _userService;
     this._eventPublisher = _eventPublisher;
 }
Exemplo n.º 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            // Inject Dependecies
            IoCRegister.AddRegistration(services);

            // JWT
            JwtAuthConfig.AddRegistration(services, this._configuration);

            // Cors
            CorsConfig.AddRegistration(services);

            //GraphQL
            GraphQLConfig.AddRegistration(services);
        }
Exemplo n.º 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // Swagger
            SwaggerConfig.AddRegistration(services);

            // AutoMapper
            AutoMapperConfig.AddRegistration(services);

            // Inject Dependecies
            IoCRegister.AddRegistration(services);

            // JWT
            JwtAuthConfig.AddRegistration(services, _configuration);

            // Cors
            CorsConfig.AddRegistration(services);
        }
Exemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(o => o.AddPolicy("LoginCors", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            services.AddControllers();
            JwtAuthConfig.Setup(services, Configuration);
            var mapperConfig = new MapperConfiguration(t => {
                t.AddProfile(new AutoMapperProfile());
            });
            IMapper mapper = mapperConfig.CreateMapper();

            services.AddSingleton(mapper);
            services.UserShopService();
            services.AddDbContext <ShopDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), b => b.MigrationsAssembly("Domain")));
        }
Exemplo n.º 7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(o => o.AddPolicy("TestCors", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));


            services.AddControllers();

            Configdependecyinjection.Setup(services, Configuration);
            DataDiConfig.Setup(services, Configuration);
            ConfigureDi.Setup(services);

            //Auth
            JwtAuthConfig.Setup(services, Configuration);

            //services.AddDirectoryBrowser();
        }
Exemplo n.º 8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            // Swagger
            SwaggerConfig.AddRegistration(app);

            // JWT
            JwtAuthConfig.AddRegistration(app, this._configuration);

            // Cors
            CorsConfig.AddRegistration(app);

            app.UseHttpsRedirection();
            app.UseAuthentication();
            app.UseHttpsRedirection();
            app.UseMvc();
        }
Exemplo n.º 9
0
        public static void AddJwtAuth(this IServiceCollection services, JwtAuthConfig configuration)
        {
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

            services
            .AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultScheme             = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(cfg =>
            {
                cfg.RequireHttpsMetadata      = false;
                cfg.SaveToken                 = true;
                cfg.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidIssuer      = configuration.Issuer,
                    ValidAudience    = configuration.Issuer,
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration.Key)),
                    ClockSkew        = TimeSpan.Zero,
                };
            });
        }
Exemplo n.º 10
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
     services.UserGiantStoreServices();
     JwtAuthConfig.Setup(services, Configuration);
 }
Exemplo n.º 11
0
 public IdentityLoginService(SignInManager <IdentityUser> signInManager, UserManager <IdentityUser> userManager, IOptionsMonitor <JwtAuthConfig> configuration)
 {
     _signInManager = signInManager;
     _userManager   = userManager;
     _configuration = configuration.CurrentValue;
 }
Exemplo n.º 12
0
 public TokenRepository(IOptions <JwtAuthConfig> jwtAuthConfig, TokenDbContext context)
 {
     _jwtAuthConfig = jwtAuthConfig.Value;
     _context       = context;
 }
Exemplo n.º 13
0
 protected void Application_Start()
 {
     UnityConfig.RegisterComponents();
     JwtAuthConfig.Configure(ConfigurationManager.AppSettings);
     GlobalConfiguration.Configure(WebApiConfig.Register);
 }