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.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options => options.TokenValidationParameters =
                              TokenValidationParametersGenerator.GenerateTokenValidationParameters());

            services.AddTransient <ILoggingService, FileLoggingService>();
            services.AddScoped <IDbStudentService, MssqlDbStudentService>();
            services.AddScoped <IAuthenticationService, MssqlDbAuthenticationService>();
            services.AddSingleton <IEncryptionService, SaltedHashEncryptionService>();
            services.AddControllers();

            // Register the Swagger generator, defining Swagger documents
            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Students API",
                    Version     = "v1",
                    Description = "Students API prepared by Paweł Rutkowski (s18277) for purposes of APBD.",
                    Contact     = new OpenApiContact {
                        Name = "Paweł Rutkowski s18277"
                    }
                });
            });
        }
Exemplo n.º 2
0
 public Startup(IConfiguration configuration)
 {
     Configuration = configuration;
     TokenValidationParametersGenerator.AddConfiguration(configuration);
 }