Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Services/auth/O2NextGen.Auth.Web/O2NextGen.Auth.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<DockerComposeProjectPath>../../../docker-compose.dcproj</DockerComposeProjectPath>
<UserSecretsId>adca6dac-ab6b-4a1a-b8c4-03f600c16f45</UserSecretsId>
Expand All @@ -14,7 +14,6 @@
<PackageReference Include="IdentityServer4" Version="2.3.2" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1">
</PackageReference>
Expand All @@ -27,6 +26,11 @@
<PackageReference Include="Serilog.Sinks.File" Version="2.2.0">
</PackageReference>
<PackageReference Include="SkiaSharp.QrCode" Version="0.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.30" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.30" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.30" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.30" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.30" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources\Pages\Account\Register.en.resx">
Expand Down Expand Up @@ -79,6 +83,12 @@
<None Remove="Resources\SharedResource.en" />
<None Remove="Resources\Resources.ru" />
<None Remove="Logs\**" />
<None Remove="Microsoft.AspNetCore.Identity" />
<None Remove="Microsoft.AspNetCore.Identity.UI" />
<None Remove="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<None Remove="Microsoft.EntityFrameworkCore" />
<None Remove="Microsoft.EntityFrameworkCore.SqlServer" />
<None Remove="Microsoft.EntityFrameworkCore.InMemory" />
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 20 additions & 1 deletion src/Services/auth/O2NextGen.Auth.Web/Services/ESenderService.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace O2NextGen.Auth.Web.Services
{
public static class HttpClientExtensions
{
public static Task<HttpResponseMessage> PostAsJsonAsync<T>(
this HttpClient httpClient, string url, T data, CancellationToken cancellationToken)
{
var dataAsString = JsonConvert.SerializeObject(data);
var content = new StringContent(dataAsString);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
return httpClient.PostAsync(url, content, cancellationToken);
}

public static async Task<T> ReadAsJsonAsync<T>(this HttpContent content, CancellationToken cancellationToken)
{
var dataAsString = await content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<T>(dataAsString);
}
}
public interface IESenderService
{
Task Send(string email, string subject, string htmlMessage);
Expand All @@ -30,7 +49,7 @@ public async Task Send(string email, string subject, string htmlMessage)
Body = htmlMessage
};
var response = await _httpClient.PostAsJsonAsync("api/emailsender",model,CancellationToken.None);
await response.Content.ReadAsAsync<MailRequestViewModel>(CancellationToken.None);
await response.Content.ReadAsJsonAsync<MailRequestViewModel>(CancellationToken.None);
}
}
}
6 changes: 3 additions & 3 deletions src/Services/auth/O2NextGen.Auth.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using O2NextGen.Auth.Web.Extensions;
using O2NextGen.Auth.Web.Helpers;
Expand All @@ -24,7 +25,7 @@ public Startup(IConfiguration configuration)
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddRazorPagesOptions(options =>
{
options.Conventions.AuthorizeFolder("/Account");
Expand Down Expand Up @@ -53,7 +54,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<IEmailSender, DummyEmailSender>();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

Expand All @@ -71,7 +72,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
app.UseRequestLocalization(v);
app.UseCookiePolicy();
app.UseAuthentication();

app.UseMvcWithDefaultRoute();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using System.Linq;
using System.Net;
using Microsoft.AspNetCore.Http.Features;
Expand All @@ -11,21 +12,31 @@ namespace O2NextGen.OnTracker.Api.Controllers
[ApiController]
public class GeoController : ControllerBase
{
#region Fields
private readonly IGeoIpAddressResolver _geoIpAddressResolver;
#endregion


#region Ctors
public GeoController(IGeoIpAddressResolver geoIpAddressResolver)
{
_geoIpAddressResolver = geoIpAddressResolver;
}
#endregion


#region Methods
// GET api/values
[HttpGet]
public ActionResult Get()
{
Debug.WriteLine("start");
Console.WriteLine("start");
// var ip = HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress;
//IPAddress remoteIpAddress = HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress;//Request.HttpContext.Connection.RemoteIpAddress;
//IPAddress remoteIpAddress = HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress;
//Request.HttpContext.Connection.RemoteIpAddress;
//IPAddress remoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress;//
IPAddress remoteIpAddress = HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress;
//IPAddress remoteIpAddress = HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress;
IPAddress remoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress;
string result = "";
if (remoteIpAddress != null)
{
Expand All @@ -38,13 +49,13 @@ public ActionResult Get()
}
result = remoteIpAddress.ToString();
}
Debug.WriteLine(remoteIpAddress.ToString());
Console.WriteLine(remoteIpAddress.ToString());
if (result.ToString() == "127.0.0.1")
return Ok("request with localhost");
return Ok(_geoIpAddressResolver.ResolveAddress(IPAddress.Parse(result.ToString())));
// return new string[] { "value1", "value2" };
}

#endregion
}

}

Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
using Microsoft.Extensions.Logging;

namespace O2NextGen.OnTracker.Api.Controllers
{
public class VersionController : Controller
[AllowAnonymous]
public class VersionController : ControllerBase
{
// GET: /<controller>/
public IActionResult Index()
#region Fields

private readonly IWebHostEnvironment _environment;
private readonly ILogger<VersionController> _logger;

#endregion


#region Ctors

public VersionController(IWebHostEnvironment environment, ILogger<VersionController> logger)
{
return View();
_environment = environment;
_logger = logger;
}

#endregion


#region Methods

[HttpGet("[controller]")]
public object Index()
{
var exVersion = Assembly.GetExecutingAssembly().GetName().Version;
_logger.LogInformation($"get version - {exVersion}");
return new
{
Environment = _environment.EnvironmentName,
Version = exVersion.ToString()
};
}

#endregion
}
}