src/fursvp.api/Startup.cs
/// <summary>
/// This method gets called by the runtime. Use this method to add services to the container.
/// </summary>
/// <param name="services">The container in which components are registered.</param>
This method gets called by the runtime. Use this method to add services to the container.
This method gets called by the runtime . Use this method to add services to the container .
public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors();
            services.AddControllers();
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });
            services.AddDomainServices();
            services.Configure<FirestoreOptions>(Configuration.GetSection(FirestoreOptions.SectionName));
            services.AddFursvpDataWithFirestore();
            if (Environment.IsDevelopment() || string.IsNullOrEmpty(Configuration["SendGrid:ApiKey"]))
            {
                services.AddSingleton<IEmailer, SuppressAndLogEmailer>();
            }
            else
            {
                services.AddSingleton<IEmailer, SendGridEmailer>();
                services.Configure<SendGridOptions>(Configuration.GetSection(SendGridOptions.SectionName));
            }
            services.AddLogging(lc =>
            {
                lc.ClearProviders();
                lc.AddConsole();
            });
            services.AddSingleton<PrivateContentFilter>();
            services.AddSingleton<DebugModeOnlyFilter>();
            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(ApiExceptionFilter));
                options.Filters.AddService<PrivateContentFilter>();
            });
            services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
            services.AddScoped<IUrlHelper>(x => x.GetRequiredService<IUrlHelperFactory>().GetUrlHelper(x.GetService<IActionContextAccessor>().ActionContext));
            services.AddHttpContextAccessor(); 
            services.AddSingleton<IUserAccessor, ClaimsPrincipalUserAccessor>();
            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(x =>
            {
                var key = Encoding.ASCII.GetBytes(Configuration["AuthorizationIssuerSigningKey"]);
                x.SaveToken = true;
                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey = new SymmetricSecurityKey(key),
                    ValidateIssuer = false,
                    ValidateAudience = false,
                };
            });
            services.AddSingleton<IReadAuthorize<EventResponse>, ReadAuthorizeEvent<EventResponse, MemberResponse>>();
            services.AddSingleton<IReadAuthorize<MemberResponse>, ReadAuthorizeMember<MemberResponse>>();
            ConfigureAutoMapper(services);
        }
public void ConfigureServices ( IServiceCollection services ) { services . AddCors ( ) ; services . AddControllers ( ) ; services . AddSpaStaticFiles ( configuration => { configuration . RootPath = " " ; } ) ; services . AddDomainServices ( ) ; services . Configure < FirestoreOptions > ( Configuration . GetSection ( FirestoreOptions . SectionName ) ) ; services . AddFursvpDataWithFirestore ( ) ; if ( Environment . IsDevelopment ( ) || string . IsNullOrEmpty ( Configuration [ " " ] ) ) { services . AddSingleton < IEmailer , SuppressAndLogEmailer > ( ) ; } else { services . AddSingleton < IEmailer , SendGridEmailer > ( ) ; services . Configure < SendGridOptions > ( Configuration . GetSection ( SendGridOptions . SectionName ) ) ; } services . AddLogging ( lc => { lc . ClearProviders ( ) ; lc . AddConsole ( ) ; } ) ; services . AddSingleton < PrivateContentFilter > ( ) ; services . AddSingleton < DebugModeOnlyFilter > ( ) ; services . AddMvc ( options => { options . Filters . Add ( typeof ( ApiExceptionFilter ) ) ; options . Filters . AddService < PrivateContentFilter > ( ) ; } ) ; services . AddSingleton < IActionContextAccessor , ActionContextAccessor > ( ) ; services . AddScoped < IUrlHelper > ( x => x . GetRequiredService < IUrlHelperFactory > ( ) . GetUrlHelper ( x . GetService < IActionContextAccessor > ( ) . ActionContext ) ) ; services . AddHttpContextAccessor ( ) ; services . AddSingleton < IUserAccessor , ClaimsPrincipalUserAccessor > ( ) ; services . AddAuthentication ( x => { x . DefaultAuthenticateScheme = JwtBearerDefaults . AuthenticationScheme ; x . DefaultChallengeScheme = JwtBearerDefaults . AuthenticationScheme ; } ) . AddJwtBearer ( x => { var key = Encoding . ASCII . GetBytes ( Configuration [ " " ] ) ; x . SaveToken = true ; x . TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true , IssuerSigningKey = new SymmetricSecurityKey ( key ) , ValidateIssuer = false , ValidateAudience = false , } ; } ) ; services . AddSingleton < IReadAuthorize < EventResponse > , ReadAuthorizeEvent < EventResponse , MemberResponse > > ( ) ; services . AddSingleton < IReadAuthorize < MemberResponse > , ReadAuthorizeMember < MemberResponse > > ( ) ; ConfigureAutoMapper ( services ) ; }
This method gets called by the runtime.
This method gets called by the runtime .
// In production, the React files will be served from this directory // For authorization / access to user info.
services
IServiceCollection
The container in which components are registered.
The container in which components are registered .