// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddIdentityWithMongoStoresUsingCustomTypes <Usuario, UsuarioRole>(Configuration.GetSection("MongoConnectionStrings:ConnectionStringFull").Value) .AddDefaultTokenProviders(); services.AddAuthorization(opt => PolicyConfig.Configurar(opt)); AuthenticationConfig.Configurar(services, Configuration); NativeInjection.RegisterDependencys(services); services.AddOptions(); services.AddMvc(opt => { var policy = new AuthorizationPolicyBuilder() .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme) .RequireAuthenticatedUser() .Build(); opt.Filters.Add(new AuthorizeFilter(policy)); }); services.AddSwaggerGen(s => { s.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info { Title = "Delivery API", Version = "v1" }); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddDbContext <TemplateContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("TemplateDB")).EnableSensitiveDataLogging()); NativeInjection.RegisterServices(services); services.AddAutoMapper(typeof(AutoMapperSetup)); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(opt => { var policy = new AuthorizationPolicyBuilder() .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme) .RequireAuthenticatedUser() .Build(); opt.Filters.Add(new AuthorizeFilter(policy)); }).AddJsonOptions(opt => { opt.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); services.AddTransient <SeedConfiguration>(); IdentityConfiguration.Configure(services); AuthConfigurations.Configure(services, Configuration); NativeInjection.AddNativeInjection(services); }
private static void RegisterServices(IServiceCollection services) { NativeInjection.RegisterServices(services); }