-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStartup.cs
174 lines (150 loc) · 7.39 KB
/
Startup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// using System;
// using System.Text;
// using Bitar.Hubs;
// using Bitar.Models;
// using Bitar.Models.Settings;
// using Bitar.Repositories;
// using Bitar.Services;
// using Microsoft.AspNetCore.Authentication.JwtBearer;
// using Microsoft.AspNetCore.Builder;
// using Microsoft.AspNetCore.Hosting;
// using Microsoft.AspNetCore.Http;
// using Microsoft.AspNetCore.HttpOverrides;
// using Microsoft.AspNetCore.Identity;
// using Microsoft.EntityFrameworkCore;
// using Microsoft.Extensions.Configuration;
// using Microsoft.Extensions.DependencyInjection;
// using Microsoft.Extensions.Hosting;
// using Microsoft.IdentityModel.Tokens;
// namespace Bitar
// {
// public class Startup
// {
// public Startup(IConfiguration configuration)
// {
// Configuration = configuration;
// }
// public IConfiguration Configuration { get; }
// // This method gets called by the runtime. Use this method to add services to the container.
// public void ConfigureServices(IServiceCollection services)
// {
// services.AddDbContext<ApplicationDbContext>(options =>
// {
// options.EnableSensitiveDataLogging();
// options.UseNpgsql(
// Configuration.GetConnectionString("DefaultConnection"));
// }
// );
// services.AddDefaultIdentity<ApplicationUser>()
// .AddEntityFrameworkStores<ApplicationDbContext>()
// .AddDefaultTokenProviders();
// services.Configure<IdentityOptions>(options =>
// {
// // Password settings.
// options.Password.RequireNonAlphanumeric = false;
// options.Password.RequireUppercase = false;
// // Lockout settings.
// options.Lockout.MaxFailedAccessAttempts = 10;
// // User settings.
// options.User.AllowedUserNameCharacters = "aábcdðeéfghiíjklmnoópqrstuvwxyýzþæöAÁBCDÐEÉFGHIÍJKLMNOÓPQRSTUVWXYÝZÞÆÖ0123456789 -._@+";
// options.User.RequireUniqueEmail = true;
// });
// services
// .AddAuthentication(options =>
// {
// // Identity made Cookie authentication the default.
// // However, we want JWT Bearer Auth to be the default.
// options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
// options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
// options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
// })
// .AddJwtBearer(options =>
// {
// options.RequireHttpsMetadata = false;
// options.SaveToken = true;
// options.TokenValidationParameters = new TokenValidationParameters
// {
// ValidateIssuerSigningKey = true,
// ValidIssuer = "https://bitar.is",
// ValidAudience = "https://bitar.is",
// IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration.GetSection("JwtSettings:JwtKey").Value)),
// };
// });
// services.Configure<ForwardedHeadersOptions>(options => options.ForwardedHeaders = ForwardedHeaders.All);
// services.Configure<JwtSettings>(Configuration.GetSection("JwtSettings"));
// services.Configure<BitcoinSettings>(Configuration.GetSection("BitcoinSettings"));
// services.Configure<LandsbankinnSettings>(Configuration.GetSection("LandsbankinnSettings"));
// services.Configure<KrakenSettings>(Configuration.GetSection("KrakenSettings"));
// services.Configure<JaSettings>(Configuration.GetSection("JaSettings"));
// services.Configure<DilisenseSettings>(Configuration.GetSection("DilisenseSettings"));
// services.AddHttpClient<ArionService>();
// services.AddHttpClient<BlockchainService>();
// services.AddScoped<MarketRepository>();
// services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
// services.AddSingleton<BitcoinService>();
// services.AddSingleton<LandsbankinnService>();
// services.AddSingleton<AssetService>();
// services.AddSingleton<KrakenService>();
// services.AddSingleton<TickerService>();
// services.AddSingleton<OhlcService>();
// services.AddHostedService<MarketService>();
// services.AddControllers();
// services.AddSignalR();
// // services.AddOpenApiDocument(c =>
// // {
// // c.Title = "Bitar API";
// // c.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT"));
// // c.AddSecurity("JWT", new OpenApiSecurityScheme
// // {
// // Type = OpenApiSecuritySchemeType.ApiKey,
// // Name = "Authorization",
// // In = OpenApiSecurityApiKeyLocation.Header,
// // Description = "Copy this into the value field: Bearer {token}",
// // });
// // c.PostProcess = document =>
// // {
// // document.Info.Version = "v1";
// // document.Info.Title = "Bitar API";
// // document.Info.Description = "Endilega láttu okkur vita ef það vantar eitthvað eða þér finnst eitthvað mega bæta.";
// // };
// // });
// }
// // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
// public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
// {
// if (env.IsDevelopment())
// {
// app.UseDeveloperExceptionPage();
// }
// app.UseRouting();
// app.UseForwardedHeaders();
// app.UseAuthentication();
// app.UseAuthorization();
// // Enable middleware to serve generated Swagger as a JSON endpoint.
// // app.UseOpenApi(c =>
// // {
// // c.Path = "/{documentName}/swagger.json";
// // });
// // Enable middleware to serve ReDoc (HTML, JS, CSS, etc.).
// // app.UseReDoc(c =>
// // {
// // c.DocumentTitle = "Bitar API Documentation";
// // c.EnableUntrustedSpec();
// // c.ExpandResponses("200,201");
// // c.HideLoading();
// // c.DisableSearch();
// // c.RoutePrefix = string.Empty;
// // });
// app.UseCors(builder => builder
// .WithOrigins("https://bitar.is", "https://www.bitar.is", "http://localhost:4200", "https://innskraning.island.is")
// .AllowAnyHeader()
// .AllowAnyMethod()
// .AllowCredentials());
// app.UseEndpoints(endpoints =>
// {
// endpoints.MapHub<TickerHub>("/tickers");
// endpoints.MapControllers();
// });
// }
// }
// }