// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ContextBase>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddDefaultIdentity <ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores <ContextBase>(); services.AddControllersWithViews(); services.AddRazorPages(); HelpStartup.ConfigureSingleton(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ContextBase>(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection"))); services.AddDefaultIdentity <ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores <ContextBase>(); services.AddControllersWithViews(); services.AddRazorPages(); HelpStartup.ConfigureSingleton(services); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(option => { option.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = false, ValidateAudience = false, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = "Teste.Securiry.Bearer", ValidAudience = "Teste.Securiry.Bearer", IssuerSigningKey = JwtSecurityKey.Create("Secret_Key-12345678") }; option.Events = new JwtBearerEvents { OnAuthenticationFailed = context => { Console.WriteLine("OnAuthenticationFailed: " + context.Exception.Message); return(Task.CompletedTask); }, OnTokenValidated = context => { Console.WriteLine("OnTokenValidated: " + context.SecurityToken); return(Task.CompletedTask); } }; }); //services.AddAuthorization(options => //{ // options.AddPolicy("UsuarioAPI", // policy => policy.RequireClaim("UsuarioAPINumero")); //}); }