aboutsummaryrefslogtreecommitdiff
path: root/Timeline
diff options
context:
space:
mode:
Diffstat (limited to 'Timeline')
-rw-r--r--Timeline/Controllers/UserAvatarController.cs3
-rw-r--r--Timeline/Program.cs3
-rw-r--r--Timeline/Services/UserAvatarService.cs4
-rw-r--r--Timeline/Startup.cs29
-rw-r--r--Timeline/Timeline.csproj8
5 files changed, 22 insertions, 25 deletions
diff --git a/Timeline/Controllers/UserAvatarController.cs b/Timeline/Controllers/UserAvatarController.cs
index e7e12d0b..e77076ca 100644
--- a/Timeline/Controllers/UserAvatarController.cs
+++ b/Timeline/Controllers/UserAvatarController.cs
@@ -122,7 +122,8 @@ namespace Timeline.Controllers
return BadRequest(new CommonResponse(ErrorCodes.Put_Content_UnmatchedLength_Less,
$"Content length in header is {contentLength} but actual length is {bytesRead}."));
- if (Request.Body.ReadByte() != -1)
+ var extraByte = new byte[1];
+ if (await Request.Body.ReadAsync(extraByte) != 0)
return BadRequest(new CommonResponse(ErrorCodes.Put_Content_UnmatchedLength_Bigger,
$"Content length in header is {contentLength} but actual length is bigger than that."));
diff --git a/Timeline/Program.cs b/Timeline/Program.cs
index f343de44..dfc93b9e 100644
--- a/Timeline/Program.cs
+++ b/Timeline/Program.cs
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.FileProviders;
+using Microsoft.Extensions.Hosting;
namespace Timeline
{
@@ -10,7 +11,7 @@ namespace Timeline
public static void Main(string[] args)
{
CreateWebHostBuilder(args)
- .ConfigureAppConfiguration((context, config) =>
+ .ConfigureAppConfiguration((context, config) =>
{
if (context.HostingEnvironment.IsProduction())
config.AddJsonFile(new PhysicalFileProvider("/etc/webapp/timeline/"), "config.json", true, true);
diff --git a/Timeline/Services/UserAvatarService.cs b/Timeline/Services/UserAvatarService.cs
index 5c380dd8..ecec5a31 100644
--- a/Timeline/Services/UserAvatarService.cs
+++ b/Timeline/Services/UserAvatarService.cs
@@ -121,7 +121,7 @@ namespace Timeline.Services
public class DefaultUserAvatarProvider : IDefaultUserAvatarProvider
{
- private readonly IHostingEnvironment _environment;
+ private readonly IWebHostEnvironment _environment;
private readonly IETagGenerator _eTagGenerator;
@@ -129,7 +129,7 @@ namespace Timeline.Services
private DateTime _cacheLastModified;
private string _cacheETag;
- public DefaultUserAvatarProvider(IHostingEnvironment environment, IETagGenerator eTagGenerator)
+ public DefaultUserAvatarProvider(IWebHostEnvironment environment, IETagGenerator eTagGenerator)
{
_environment = environment;
_eTagGenerator = eTagGenerator;
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index b5a5106b..7552df2e 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -1,9 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
-using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Timeline.Authenticate;
@@ -16,23 +14,23 @@ namespace Timeline
{
public class Startup
{
- public Startup(IConfiguration configuration, IHostingEnvironment environment)
+ public Startup(IConfiguration configuration, IWebHostEnvironment environment)
{
Environment = environment;
Configuration = configuration;
}
- public IHostingEnvironment Environment { get; }
+ public IWebHostEnvironment Environment { get; }
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.AddMvc()
- .ConfigureApiBehaviorOptions(options =>{
+ .ConfigureApiBehaviorOptions(options =>
+ {
options.InvalidModelStateResponseFactory = InvalidModelResponseFactory.Factory;
- })
- .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
+ });
services.Configure<JwtConfig>(Configuration.GetSection(nameof(JwtConfig)));
var jwtConfig = Configuration.GetSection(nameof(JwtConfig)).Get<JwtConfig>();
@@ -52,14 +50,7 @@ namespace Timeline
services.AddDbContext<DatabaseContext>(options =>
{
- options.UseMySql(databaseConfig.ConnectionString)
- .ConfigureWarnings(warnings =>
- {
- if (Environment.IsProduction())
- warnings.Log(RelationalEventId.QueryClientEvaluationWarning);
- else
- warnings.Throw(RelationalEventId.QueryClientEvaluationWarning);
- });
+ options.UseMySql(databaseConfig.ConnectionString);
});
services.AddHttpClient();
@@ -75,9 +66,15 @@ namespace Timeline
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
+ app.UseRouting();
+
app.UseAuthentication();
+ app.UseAuthorization();
- app.UseMvc();
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllers();
+ });
}
}
}
diff --git a/Timeline/Timeline.csproj b/Timeline/Timeline.csproj
index d414ab2f..f01b8e31 100644
--- a/Timeline/Timeline.csproj
+++ b/Timeline/Timeline.csproj
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
- <TargetFramework>netcoreapp2.2</TargetFramework>
+ <TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
<UserSecretsId>1f6fb74d-4277-4bc0-aeea-b1fc5ffb0b43</UserSecretsId>
<Authors>crupest</Authors>
@@ -13,11 +13,9 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.App" />
- <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
- <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
- <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
+ <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.0.0-rc1.final" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-dev002868" />
+ <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.5.0" />
</ItemGroup>
</Project>