// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = "reporting", ValidAudience = "reporting", IssuerSigningKey = new SymmetricSecurityKey( Encoding.UTF8.GetBytes(Configuration.GetSection("Secret").Value)) }; }); services.AddMvc(options => { options.Filters.Add <CustomExceptionFilterAttribute>(); }); services.AddSingleton(new ConfigurationService(Configuration)); DalDependencies.Register(services); DataManagerDependencies.Register(services); services.AddDbContext <QueryDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("QueriesDb"))); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }); c.DescribeAllEnumsAsStrings(); c.OperationFilter <SwaggerAuthFilter>(); }); }
public static IKernel CreateDependencyGraph() { var kernel = new StandardKernel(); ServiceDependencies.Configure(kernel); DataManagerDependencies.Configure(kernel); return(kernel); }