Merge branch 'develop' into feature/new-context-menu

This commit is contained in:
Timofey Boyko 2021-12-02 15:03:00 +08:00
commit 168abcf288
749 changed files with 8294 additions and 6137 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30413.136
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Files.Tests", "products\ASC.Files\Tests\ASC.Files.Tests.csproj", "{EFB99A37-EF25-4A0F-8D7A-786402B1554C}"
EndProject
@ -73,7 +73,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Webhooks.Tests", "commo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Webhooks.Service", "common\services\ASC.Webhooks.Service\ASC.Webhooks.Service.csproj", "{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASC.Web.Api.Tests", "common\Tests\ASC.Web.Api.Tests\ASC.Web.Api.Tests.csproj", "{14823E93-C749-4069-9E0A-95E63DE0B254}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Web.Api.Tests", "common\Tests\ASC.Web.Api.Tests\ASC.Web.Api.Tests.csproj", "{14823E93-C749-4069-9E0A-95E63DE0B254}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Data.Backup.Core", "common\ASC.Data.Backup.Core\ASC.Data.Backup.Core.csproj", "{5E948877-52BD-42B9-95A9-0FF37931D0A5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Data.Encryption", "common\ASC.Data.Encryption\ASC.Data.Encryption.csproj", "{9E572FE2-8C3C-46B2-A314-532F7198B3EB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.AuditTrail", "common\services\ASC.AuditTrail\ASC.AuditTrail.csproj", "{B53587B7-58F6-48A9-B122-69BEA3E2572A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -209,10 +215,6 @@ Global
{8FAD3D1B-3ADC-470C-9933-CAE1B95A8599}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FAD3D1B-3ADC-470C-9933-CAE1B95A8599}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FAD3D1B-3ADC-470C-9933-CAE1B95A8599}.Release|Any CPU.Build.0 = Release|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Release|Any CPU.Build.0 = Release|Any CPU
{A0475D4F-29B7-490C-85C2-8AFD60118B35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0475D4F-29B7-490C-85C2-8AFD60118B35}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0475D4F-29B7-490C-85C2-8AFD60118B35}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -224,7 +226,23 @@ Global
{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23310CB9-1A14-4ED5-BF81-8BD38277FEFE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection
{14823E93-C749-4069-9E0A-95E63DE0B254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14823E93-C749-4069-9E0A-95E63DE0B254}.Release|Any CPU.Build.0 = Release|Any CPU
{5E948877-52BD-42B9-95A9-0FF37931D0A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E948877-52BD-42B9-95A9-0FF37931D0A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E948877-52BD-42B9-95A9-0FF37931D0A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E948877-52BD-42B9-95A9-0FF37931D0A5}.Release|Any CPU.Build.0 = Release|Any CPU
{9E572FE2-8C3C-46B2-A314-532F7198B3EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E572FE2-8C3C-46B2-A314-532F7198B3EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E572FE2-8C3C-46B2-A314-532F7198B3EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E572FE2-8C3C-46B2-A314-532F7198B3EB}.Release|Any CPU.Build.0 = Release|Any CPU
{B53587B7-58F6-48A9-B122-69BEA3E2572A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B53587B7-58F6-48A9-B122-69BEA3E2572A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B53587B7-58F6-48A9-B122-69BEA3E2572A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B53587B7-58F6-48A9-B122-69BEA3E2572A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection

View File

@ -2,7 +2,7 @@
Platform for building your own scalable online office with ONLYOFFICE modules
## Overview
App Server is a platform for building your own online office by connecting ONLYOFFICE modules packed as separate apps.
App Server is a platform for building your own online office by connecting ONLYOFFICE modules packaged as separate apps.
## How to install
[coming soon]
@ -35,4 +35,4 @@ Components source code - [https://github.com/ONLYOFFICE/AppComponents](https://g
## User feedback and support
If you have any problems or question about App Server, use the issues section here, in this repository.
If you have any problems or questions about App Server, use the issues section here, in this repository.

View File

@ -1,6 +1,7 @@
@echo off
PUSHD %~dp0..
dotnet build ASC.Web.slnf /fl1 /flp1:LogFile=build/ASC.Web.log;Verbosity=Normal
@echo off
echo.
echo Install nodejs projects dependencies...
echo.
@ -15,6 +16,8 @@ if %errorlevel% == 0 (
echo.
POPD
if "%1"=="nopause" goto start
pause
:start

View File

@ -1,18 +1,27 @@
@echo off
echo "##########################################################"
echo "######### Start build and deploy #######################"
echo "##########################################################"
echo.
PUSHD %~dp0
call runasadmin.bat "%~dpnx0"
if %errorlevel% == 0 (
call start\stop.bat
PUSHD %~dp0..
call start\stop.bat nopause
echo "FRONT-END (for start run command 'yarn start' inside the root folder)"
call build\build.frontend.bat
call build.frontend.bat nopause
echo "BACK-END"
call build\build.backend.bat
call build.backend.bat nopause
start /b call build\start\start.bat
call start\start.bat nopause
echo.
pause
)

View File

@ -1,4 +1,6 @@
PUSHD %~dp0..
REM call yarn wipe
call yarn install
call yarn install
POPD

View File

@ -48,15 +48,24 @@ powershell -Command "(gc build\deploy\nginx\sites-enabled\onlyoffice-studio.conf
REM restart nginx
echo service nginx stop
call sc stop nginx
call sc stop nginx > nul
REM sleep 5 seconds
call ping 127.0.0.1 -n 6 > nul
echo service nginx start
call sc start nginx
call sc start nginx > nul
if NOT %errorlevel% == 0 (
echo Couldn't restarte Onlyoffice%%~nf service
)
)
echo.
POPD
if "%1"=="nopause" goto start
pause
:start

View File

@ -1,3 +1,9 @@
echo "##########################################################"
echo "######### Start build and deploy Personal ##############"
echo "##########################################################"
echo.
PUSHD %~dp0
call runasadmin.bat "%~dpnx0"
if %errorlevel% == 0 (

View File

@ -1,4 +1,11 @@
@echo off
echo "##########################################################"
echo "######### Start build and deploy #######################"
echo "##########################################################"
echo.
PUSHD %~dp0
setlocal EnableDelayedExpansion
@ -8,15 +15,15 @@ if %errorlevel% == 0 (
call start\stop.bat nopause
PUSHD %~dp0..
echo "FRONT-END static"
call build\build.static.bat nopause
call build.static.bat nopause
echo "BACK-END"
call build\build.backend.bat nopause
call build.backend.bat nopause
call build\start\start.bat nopause
call start\start.bat nopause
echo.
pause
)

View File

@ -36,7 +36,7 @@ BASE_DIR="/var/www/${PRODUCT}"
PATH_TO_CONF="/etc/onlyoffice/${PRODUCT}"
STORAGE_ROOT="${PATH_TO_CONF}/data"
LOG_DIR="/var/log/onlyoffice/${PRODUCT}"
DOTNET_RUN="/usr/bin/dotnet"
DOTNET_RUN="/usr/share/dotnet/dotnet"
APP_URLS="http://0.0.0.0"
ENVIRONMENT=" --ENVIRONMENT=production"

View File

@ -201,7 +201,7 @@ WORKDIR ${BUILD_PATH}/products/ASC.Files/service/
COPY --chown=onlyoffice:onlyoffice docker-entrypoint.sh .
COPY --from=base --chown=onlyoffice:onlyoffice ${BUILD_PATH}/services/ASC.Files.Service/service/ .
CMD ["ASC.Files.Service.dll", "ASC.Files.Service", "core:products:folder=/var/www/products/", "core:products:subfolder=server"]
CMD ["ASC.Files.Service.dll", "ASC.Files.Service", "core:products:folder=/var/www/products/", "core:products:subfolder=server", "disable_elastic=true"]
## ASC.Mail ##
FROM builder AS mail

View File

@ -1,5 +1,5 @@
#!/bin/bash
PARAMETERS=${PARAMETERS:-""}
# read parameters
if [ -n "$1" ]; then
DOTNET_RUN="${1}";
@ -22,7 +22,6 @@ echo "#-------------------------------------#"
PRODUCT=${PRODUCT:-"onlyoffice"}
BASE_DIR="/app/${PRODUCT}"
PARAMETERS=""
PROXY_HOST=${PROXY_HOST:-"proxy"}
SHEME=${SHEME:-"http"}
SERVICE_PORT=${SERVICE_PORT:-"5050"}

View File

@ -1,3 +1,18 @@
#!/bin/bash
export DOCKER_TAG=$DOCKER_TAG
BASE_NAME="appserver"
BUILD_NUMBER="$(date "+%Y%m%d%H")"
docker-compose -f build.yml push
# Get docker images name to array
arrayImagesName=($(docker image ls | grep "$DOCKER_TAG" | grep "$STATUS" | grep "$BASE_NAME" | awk '{print $1}' ))
# Modify docker image tag
for i in ${!arrayImagesName[@]}; do
echo " Modify ${arrayImagesName[$i]}:$DOCKER_TAG "
docker image tag ${arrayImagesName[$i]}:$DOCKER_TAG ${arrayImagesName[$i]}:$DOCKER_TAG-$BUILD_NUMBER
done
# Push the same images with a new tag
DOCKER_TAG=$DOCKER_TAG-$BUILD_NUMBER
docker-compose -f build.yml push

View File

@ -23,6 +23,5 @@ if '%errorlevel%' NEQ '0' (
exit /B 1
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------

33
build/start/command.ps1 Normal file
View File

@ -0,0 +1,33 @@
$PSversionMajor = $PSVersionTable.PSVersion | sort-object major | ForEach-Object {$_.major}
$PSversionMinor = $PSVersionTable.PSVersion | sort-object minor | ForEach-Object {$_.minor}
if ($PSversionMajor -lt 7 -or $PSversionMinor -lt 2) {
Write-Error "Powershell version must be greater than or equal to 7.2. Press Enter to exit."
Pause
exit
}
$WorkDir = "$(Split-Path -Parent $PSScriptRoot)\run";
$CommandName = "$($args[0])";
#Write-Output "Starting $($CommandName) services at time: $(Get-Date -Format HH:mm:ss)"
#Write-Output ""
Get-ChildItem -Path $WorkDir | ForEach-Object -ThrottleLimit 20 -Parallel {
$ServiceName = "Onlyoffice$([System.IO.Path]::GetFileNameWithoutExtension($_))";
switch ( $Using:CommandName )
{
"start" { Start-Service -InputObject $(Get-Service -Name "$ServiceName") }
"stop" { Stop-Service -InputObject $(Get-Service -Name "$ServiceName") }
"restart" { Restart-Service -InputObject $(Get-Service -Name "$ServiceName") }
}
if( $? )
{
Write-Output "$ServiceName $($Using:CommandName) service has been done"
}
}
#Write-Output ""
#Write-Output "End $($CommandName) services at time: $(Get-Date -Format HH:mm:ss)"

View File

@ -3,11 +3,10 @@
PUSHD %~dp0..
call runasadmin.bat "%~dpnx0"
POPD
if %errorlevel% == 0 (
for /R "run\" %%f in (*.bat) do (
call sc stop "Onlyoffice%%~nf"
call sc start "Onlyoffice%%~nf"
)
pwsh %~dp0/command.ps1 "restart"
)
echo.

View File

@ -3,10 +3,10 @@
PUSHD %~dp0..
call runasadmin.bat "%~dpnx0"
POPD
if %errorlevel% == 0 (
for /R "run\" %%f in (*.bat) do (
call sc start "Onlyoffice%%~nf"
)
pwsh %~dp0/command.ps1 "start"
)
echo.

View File

@ -3,10 +3,10 @@
PUSHD %~dp0..
call runasadmin.bat "%~dpnx0"
POPD
if %errorlevel% == 0 (
for /R "run\" %%f in (*.bat) do (
call sc stop "Onlyoffice%%~nf"
)
pwsh %~dp0/command.ps1 "stop"
)
echo.

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
@ -17,7 +17,7 @@
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="5.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.13.0" />
</ItemGroup>

View File

@ -29,15 +29,15 @@ using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Hosting;
using NLog;
using NLog.Extensions.Logging;
namespace ASC.Api.Core
{
public abstract class BaseStartup
{
{
public abstract class BaseStartup
{
public IConfiguration Configuration { get; }
public IHostEnvironment HostEnvironment { get; }
public virtual JsonConverter[] Converters { get; }
@ -52,14 +52,14 @@ namespace ASC.Api.Core
{
Configuration = configuration;
HostEnvironment = hostEnvironment;
DIHelper = new DIHelper();
DIHelper = new DIHelper();
if (bool.TryParse(Configuration["core:products"], out var loadProducts))
{
LoadProducts = loadProducts;
}
}
}
public virtual void ConfigureServices(IServiceCollection services)
public virtual void ConfigureServices(IServiceCollection services)
{
services.AddCustomHealthCheck(Configuration);
services.AddHttpContextAccessor();
@ -69,20 +69,20 @@ namespace ASC.Api.Core
services.AddSession();
DIHelper.Configure(services);
Action<JsonOptions> jsonOptions = options =>
{
options.JsonSerializerOptions.WriteIndented = false;
options.JsonSerializerOptions.IgnoreNullValues = true;
options.JsonSerializerOptions.Converters.Add(new ApiDateTimeConverter());
{
options.JsonSerializerOptions.WriteIndented = false;
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.JsonSerializerOptions.Converters.Add(new ApiDateTimeConverter());
if (Converters != null)
{
foreach (var c in Converters)
{
options.JsonSerializerOptions.Converters.Add(c);
}
}
if (Converters != null)
{
foreach (var c in Converters)
{
options.JsonSerializerOptions.Converters.Add(c);
}
}
};
services.AddControllers()
@ -110,19 +110,19 @@ namespace ASC.Api.Core
}
var builder = services.AddMvcCore(config =>
{
{
config.Conventions.Add(new ControllerNameAttributeConvention());
var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
config.Filters.Add(new AuthorizeFilter(policy));
config.Filters.Add(new TypeFilterAttribute(typeof(TenantStatusFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(PaymentFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(IpSecurityFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(ProductSecurityFilter)));
config.Filters.Add(new AuthorizeFilter(policy));
config.Filters.Add(new TypeFilterAttribute(typeof(TenantStatusFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(PaymentFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(IpSecurityFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(ProductSecurityFilter)));
config.Filters.Add(new CustomResponseFilterAttribute());
config.Filters.Add(new CustomExceptionFilterAttribute());
config.Filters.Add(new TypeFilterAttribute(typeof(FormatFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(FormatFilter)));
config.Filters.Add(new TypeFilterAttribute(typeof(WebhooksGlobalFilterAttribute)));
config.OutputFormatters.RemoveType<XmlSerializerOutputFormatter>();
@ -149,7 +149,7 @@ namespace ASC.Api.Core
});
app.UseRouting();
if (AddAndUseSession)
app.UseSession();
@ -182,7 +182,7 @@ namespace ASC.Api.Core
{
builder.Register(Configuration, LoadProducts, LoadConsumers);
}
}
}
public static class LogNLogConfigureExtenstion
{

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<FileUpgradeFlags />
<UpgradeBackupLocation />
<AssemblyTitle>ASC.Common</AssemblyTitle>
@ -39,13 +39,12 @@
</PackageReference>
<PackageReference Include="JWT" Version="6.1.4" />
<PackageReference Include="log4net" Version="2.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<!-- <PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -56,7 +55,6 @@
</PackageReference> -->
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NVelocity" Version="1.2.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="protos\AscCacheItem.proto" />

View File

@ -50,12 +50,14 @@ namespace ASC.Security.Cryptography
public byte[] Encrypt(byte[] data)
{
var hasher = Rijndael.Create();
var hasher = Aes.Create();
hasher.Key = EKey();
hasher.IV = new byte[hasher.BlockSize >> 3];
using var ms = new MemoryStream();
using var ss = new CryptoStream(ms, hasher.CreateEncryptor(), CryptoStreamMode.Write);
ss.Write(data, 0, data.Length);
using var plainTextStream = new MemoryStream(data);
plainTextStream.CopyTo(ss);
ss.FlushFinalBlock();
hasher.Clear();
return ms.ToArray();
@ -63,23 +65,24 @@ namespace ASC.Security.Cryptography
public string Decrypt(string data)
{
return Encoding.UTF8.GetString(Decrypt(Convert.FromBase64String(data)));
return Decrypt(Convert.FromBase64String(data));
}
public byte[] Decrypt(byte[] data)
public string Decrypt(byte[] data)
{
var hasher = Rijndael.Create();
var hasher = Aes.Create();
hasher.Key = EKey();
hasher.IV = new byte[hasher.BlockSize >> 3];
using var ms = new MemoryStream(data);
using var ss = new CryptoStream(ms, hasher.CreateDecryptor(), CryptoStreamMode.Read);
var buffer = new byte[data.Length];
var size = ss.Read(buffer, 0, buffer.Length);
hasher.Clear();
var newBuffer = new byte[size];
Array.Copy(buffer, newBuffer, size);
return newBuffer;
using (MemoryStream msDecrypt = new MemoryStream(data))
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, hasher.CreateDecryptor(), CryptoStreamMode.Read))
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
{
// Read the decrypted bytes from the decrypting stream
// and place them in a string.
return srDecrypt.ReadToEnd();
}
}
private byte[] EKey()

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<ProjectGuid>{A51D0454-4AFA-46DE-89D4-B03D37E1816C}</ProjectGuid>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<FileUpgradeFlags />
<UpgradeBackupLocation />
<AssemblyTitle>ASC.Core.Common</AssemblyTitle>
@ -51,14 +51,13 @@
<ItemGroup>
<PackageReference Include="AWSSDK.Core" Version="3.5.1.25" />
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.5.0.27" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="Grpc.Tools" Version="2.32.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MailKit" Version="2.5.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0" />
<PackageReference Include="Telegram.Bot" Version="15.7.1" />
</ItemGroup>
<ItemGroup>

View File

@ -28,7 +28,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.ServiceModel;
@ -218,16 +218,17 @@ namespace ASC.Core.Billing
{
var url = _billingDomain + method;
var request = WebRequest.Create(url);
request.Method = "POST";
request.Timeout = 60000;
request.ContentType = "application/json";
var request = new HttpRequestMessage();
request.RequestUri = new Uri(url);
request.Method = HttpMethod.Post;
if (!string.IsNullOrEmpty(_billingKey))
{
request.Headers.Add("Authorization", CreateAuthToken(_billingKey, _billingSecret));
}
using var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMilliseconds(60000);
var data = new Dictionary<string, List<string>>();
if (!string.IsNullOrEmpty(portalId))
{
@ -244,35 +245,22 @@ namespace ASC.Core.Billing
data[parameter.Item1].Add(parameter.Item2);
}
}
var body = JsonSerializer.Serialize(data);
var bytes = Encoding.UTF8.GetBytes(body ?? "");
request.ContentLength = bytes.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(bytes, 0, bytes.Length);
}
var body = JsonSerializer.Serialize(data);
request.Content = new StringContent(body, Encoding.UTF8, "application/json");
string result;
try
using (var response = httpClient.Send(request))
using (var stream = response.Content.ReadAsStream())
{
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
if (stream == null)
{
if (stream == null)
{
throw new BillingNotConfiguredException("Billing response is null");
}
using (var readStream = new StreamReader(stream))
{
result = readStream.ReadToEnd();
}
throw new BillingNotConfiguredException("Billing response is null");
}
using (var readStream = new StreamReader(stream))
{
result = readStream.ReadToEnd();
}
}
catch (WebException)
{
request.Abort();
throw;
}
if (string.IsNullOrEmpty(result))

View File

@ -155,7 +155,7 @@ namespace ASC.Core.Common.Billing
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
const string applicationJson = "application/json";
var httpClient = new HttpClient { BaseAddress = BaseAddress, Timeout = TimeSpan.FromMinutes(3) };
using var httpClient = new HttpClient { BaseAddress = BaseAddress, Timeout = TimeSpan.FromMinutes(3) };
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", applicationJson);
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", applicationJson);
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Avangate-Authentication", CreateAuthHeader());

View File

@ -330,7 +330,7 @@ namespace ASC.Core.Billing
if (BillingClient.Configured)
{
try
{
{
var quotas = QuotaService.GetTenantQuotas();
var client = GetBillingClient();
foreach (var pi in client.GetPayments(GetPortalId(tenantId)))
@ -483,7 +483,7 @@ namespace ASC.Core.Billing
var r = CoreDbContext.Tariffs
.Where(r => r.Tenant == tenant)
.OrderByDescending(r => r.Id)
.SingleOrDefault();
.FirstOrDefault();
if (r == null) return Tariff.CreateDefault();

View File

@ -28,6 +28,7 @@ using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using ASC.Common.Module;
@ -77,17 +78,22 @@ namespace ASC.Core.Configuration
private static string GetAmiPublicDnsName()
{
try
{
var request = WebRequest.Create("http://169.254.169.254/latest/meta-data/public-hostname");
request.Timeout = 5000;
using var responce = request.GetResponse();
using var stream = responce.GetResponseStream();
{
var request = new HttpRequestMessage();
request.RequestUri = new Uri("http://169.254.169.254/latest/meta-data/public-hostname");
request.Method = HttpMethod.Get;
using var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMilliseconds(5000);
using var responce = httpClient.Send(request);
using var stream = responce.Content.ReadAsStream();
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
}
catch (WebException ex)
catch (HttpRequestException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
if (ex.StatusCode == HttpStatusCode.NotFound || ex.StatusCode == HttpStatusCode.Conflict)
{
throw;
}

View File

@ -27,8 +27,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
@ -40,8 +39,6 @@ using ASC.Core.Billing;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
namespace ASC.Core
{
@ -110,21 +107,15 @@ namespace ASC.Core
var now = DateTime.UtcNow;
var actionUrl = "/partnerapi/ActivateKey?code=" + HttpUtility.UrlEncode(key) + "&portal=" + HttpUtility.UrlEncode(TenantManager.GetCurrentTenant().TenantAlias);
using var webClient = new WebClient();
webClient.Headers.Add("Authorization", GetPartnerAuthHeader(actionUrl));
try
{
webClient.DownloadData(partnerUrl + actionUrl);
}
catch (WebException we)
{
var error = GetException(we);
if (error != null)
{
throw error;
}
throw;
}
var request = new HttpRequestMessage();
request.Headers.Add("Authorization", GetPartnerAuthHeader(actionUrl));
request.RequestUri = new Uri(partnerUrl + actionUrl);
using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
tariffService.ClearCache(TenantManager.GetCurrentTenant().TenantId);
var timeout = DateTime.UtcNow - now - TimeSpan.FromSeconds(5);
@ -145,27 +136,5 @@ namespace ASC.Core
return string.Format("ASC :{0}:{1}", now, hash);
}
private static Exception GetException(WebException we)
{
var response = (HttpWebResponse)we.Response;
if (response.StatusCode == HttpStatusCode.InternalServerError)
{
using var stream = response.GetResponseStream();
using var reader = new StreamReader(stream, Encoding.UTF8);
var result = reader.ReadToEnd();
var excInfo = JsonConvert.DeserializeObject<ExceptionJson>(result);
return (Exception)Activator.CreateInstance(Type.GetType(excInfo.exceptionType, true), excInfo.exceptionMessage);
}
return null;
}
private class ExceptionJson
{
public string message = null;
public string exceptionMessage = null;
public string exceptionType = null;
public string stackTrace = null;
}
}
}

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model.Mail

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model.Resource

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model

View File

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF.Model

View File

@ -1,8 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using ASC.Core.Common.EF.Model;
using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Common.EF
{

View File

@ -142,11 +142,8 @@ namespace ASC.Core.Encryption
var array = new byte[length];
var array2 = new char[length];
var num = 0;
using (var rng = new RNGCryptoServiceProvider())
{
rng.GetBytes(array);
}
array = RandomNumberGenerator.GetBytes(length);
for (var i = 0; i < length; i++)
{

View File

@ -26,8 +26,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.ServiceModel;
using System.Text;
@ -362,14 +363,24 @@ namespace ASC.Core.Notify.Signalr
private string MakeRequest(string method, object data)
{
if (!IsAvailable()) return "";
using var webClient = new WebClient();
var request = new HttpRequestMessage();
request.Headers.Add("Authorization", CreateAuthToken());
request.Method = HttpMethod.Post;
request.RequestUri = new Uri(GetMethod(method));
var jsonData = JsonConvert.SerializeObject(data);
Log.DebugFormat("Method:{0}, Data:{1}", method, jsonData);
webClient.Encoding = Encoding.UTF8;
webClient.Headers.Add("Authorization", CreateAuthToken());
webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
return webClient.UploadString(GetMethod(method), jsonData);
Log.DebugFormat("Method:{0}, Data:{1}", method, jsonData);
request.Content = new StringContent(jsonData, Encoding.UTF8, "application/json");
using (var httpClient = new HttpClient())
using (var response = httpClient.Send(request))
using (var stream = response.Content.ReadAsStream())
using (var streamReader = new StreamReader(stream))
{
return streamReader.ReadToEnd();
}
}
private T MakeRequest<T>(string method, object data)

View File

@ -138,7 +138,7 @@ namespace ASC.Core.Common.Notify
var buf = id.Concat(d).ToArray();
using var sha = new SHA256CryptoServiceProvider();
using var sha = SHA256.Create();
return Convert.ToBase64String(sha.ComputeHash(buf))
.Replace('+', '-').Replace('/', '_').Replace("=", ""); // make base64 url safe
}

View File

@ -58,68 +58,56 @@ namespace ASC.Core
public static string GetV(string data, int keyno, bool reverse)
{
var hasher = Rijndael.Create();
var hasher = Aes.Create();
hasher.Key = keyno == 1 ? GetSK1(false) : GetSK2(false);
hasher.IV = new byte[hasher.BlockSize >> 3];
string result;
if (reverse)
{
{
using var ms = new MemoryStream();
using var ss = new CryptoStream(ms, hasher.CreateEncryptor(), CryptoStreamMode.Write);
var buffer = Encoding.Unicode.GetBytes(data);
ss.Write(buffer, 0, buffer.Length);
using var plainTextStream = new MemoryStream(Convert.FromBase64String(data));
plainTextStream.CopyTo(ss);
ss.FlushFinalBlock();
hasher.Clear();
result = Convert.ToBase64String(ms.ToArray());
return Convert.ToBase64String(ms.ToArray());
}
else
{
var bytes = Convert.FromBase64String(data);
using var ms = new MemoryStream(bytes);
using var ms = new MemoryStream(Convert.FromBase64String(data));
using var ss = new CryptoStream(ms, hasher.CreateDecryptor(), CryptoStreamMode.Read);
var buffer = new byte[bytes.Length];
var size = ss.Read(buffer, 0, buffer.Length);
using var plainTextStream = new MemoryStream();
ss.CopyTo(plainTextStream);
hasher.Clear();
var newBuffer = new byte[size];
Array.Copy(buffer, newBuffer, size);
result = Encoding.Unicode.GetString(newBuffer);
return Encoding.Unicode.GetString(plainTextStream.ToArray());
}
return result;
}
internal static byte[] GetV(byte[] data, int keyno, bool reverse)
{
var hasher = Rijndael.Create();
var hasher = Aes.Create();
hasher.Key = keyno == 1 ? GetSK1(false) : GetSK2(false);
hasher.IV = new byte[hasher.BlockSize >> 3];
byte[] result;
if (reverse)
{
using var ms = new MemoryStream();
using var ss = new CryptoStream(ms, hasher.CreateEncryptor(), CryptoStreamMode.Write);
var buffer = data;
ss.Write(buffer, 0, buffer.Length);
using var plainTextStream = new MemoryStream(data);
plainTextStream.CopyTo(ss);
ss.FlushFinalBlock();
hasher.Clear();
result = ms.ToArray();
return ms.ToArray();
}
else
{
var bytes = data;
using var ms = new MemoryStream(bytes);
using var ms = new MemoryStream(data);
using var ss = new CryptoStream(ms, hasher.CreateDecryptor(), CryptoStreamMode.Read);
var buffer = new byte[bytes.Length];
var size = ss.Read(buffer, 0, buffer.Length);
using var plainTextStream = new MemoryStream();
ss.CopyTo(plainTextStream);
hasher.Clear();
var newBuffer = new byte[size];
Array.Copy(buffer, newBuffer, size);
result = newBuffer;
return plainTextStream.ToArray();
}
return result;
}
}
}

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>
@ -13,8 +13,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Google.Protobuf" Version="3.14.0" />
<PackageReference Include="Grpc" Version="2.32.0">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
@ -22,10 +20,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="MySql.Data" Version="8.0.23" />
<PackageReference Include="SharpZipLib" Version="1.3.2" />
</ItemGroup>
<ItemGroup>

View File

@ -24,8 +24,6 @@
*/
using System.IO;
using ASC.Common.Utils;
using ASC.Data.Backup.Tasks.Modules;

View File

@ -24,8 +24,8 @@
*/
using System.Configuration;
using System.Configuration;
namespace ASC.Data.Backup.Utils
{
internal static class ConfigurationProvider

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>

View File

@ -186,16 +186,15 @@ namespace ASC.Data.Encryption
}
public SymmetricAlgorithm GetCryptographyAlgorithm()
{
return new RijndaelManaged
{
KeySize = keySize,
BlockSize = blockSize,
Key = Key,
IV = IV,
Padding = PaddingMode.PKCS7,
Mode = CipherMode.CBC
};
{
var aes = Aes.Create();
aes.KeySize = keySize;
aes.BlockSize = blockSize;
aes.Key = Key;
aes.IV = IV;
aes.Padding = PaddingMode.PKCS7;
aes.Mode = CipherMode.CBC;
return aes;
}
public void ComputeAndWriteHmacHash(Stream stream)
@ -245,10 +244,7 @@ namespace ASC.Data.Encryption
{
var random = new byte[length];
using (var rng = new RNGCryptoServiceProvider())
{
rng.GetBytes(random);
}
random = RandomNumberGenerator.GetBytes(length);
return random;
}
@ -269,7 +265,7 @@ namespace ASC.Data.Encryption
{
var hmacKey = new byte[hmacKeyLength];
using (var sha512 = new SHA512Managed())
using (var sha512 = SHA512.Create())
{
hmacKey = sha512.ComputeHash(Key);
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@ -10,10 +10,6 @@
<NoWarn>1701;1702;NU1701;</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="UAParser" Version="3.1.44" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\web\ASC.Web.Core\ASC.Web.Core.csproj" />
<ProjectReference Include="..\ASC.Data.Storage\ASC.Data.Storage.csproj" />

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
@ -42,9 +42,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.5" />
<PackageReference Include="openstack.net" Version="1.7.9" />
<PackageReference Include="openstack.net" Version="1.8.0" />
</ItemGroup>
<ItemGroup>

View File

@ -83,7 +83,6 @@ namespace ASC.Data.Storage.DiscStorage
{
await context.Response.SendFileAsync(path);
}
context.Response.ContentType = MimeMapping.GetMimeMapping(path);
//TODO
//context.Response.Cache.SetVaryByCustom("*");

View File

@ -25,7 +25,6 @@
using System.Collections.Generic;
using System.IO;
using ASC.Common.Utils;

View File

@ -31,7 +31,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
@ -71,7 +70,7 @@ namespace ASC.Data.Storage.GoogleCloud
private Uri _bucketSSlRoot;
private bool _lowerCasing = true;
public GoogleCloudStorage(
TempStream tempStream,
TenantManager tenantManager,
@ -760,32 +759,17 @@ namespace ASC.Data.Storage.GoogleCloud
var totalBytes = "*";
var BufferSize = 2 * 4096;
if (chunkLength != defaultChunkSize)
totalBytes = Convert.ToString((chunkNumber - 1) * defaultChunkSize + chunkLength);
var contentRangeHeader = string.Format("bytes {0}-{1}/{2}", bytesRangeStart, bytesRangeEnd, totalBytes);
var request = HttpWebRequest.CreateHttp(uploadUri);
request.Method = HttpMethod.Put.ToString();
request.ContentLength = chunkLength;
var request = new HttpRequestMessage();
request.RequestUri = new Uri(uploadUri);
request.Method = HttpMethod.Put;
request.Headers.Add("Content-Range", contentRangeHeader);
request.Content = new StreamContent(stream);
using (var rs = request.GetRequestStream())
{
var buffer = new byte[BufferSize];
int readed;
while ((readed = stream.Read(buffer, 0, BufferSize)) != 0)
{
rs.Write(buffer, 0, readed);
}
stream.Close();
}
long MAX_RETRIES = 100;
int millisecondsTimeout;
@ -798,16 +782,15 @@ namespace ASC.Data.Storage.GoogleCloud
try
{
var response = request.GetResponse();
var status = ((HttpWebResponse)response).StatusCode;
using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
var status = response.StatusCode;
break;
}
catch (WebException ex)
catch (HttpRequestException ex)
{
var response = (HttpWebResponse)ex.Response;
var status = (int)response.StatusCode;
var status = (int)ex.StatusCode;
if (status == 408 || status == 500 || status == 502 || status == 503 || status == 504)
{

View File

@ -30,6 +30,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using ASC.Common;
using ASC.Common.Logging;
@ -237,10 +238,13 @@ namespace ASC.Data.Storage
{
try
{
var request = (HttpWebRequest)WebRequest.Create(path);
request.Method = "HEAD";
using var resp = (HttpWebResponse)request.GetResponse();
return resp.StatusCode == HttpStatusCode.OK;
var request = new HttpRequestMessage();
request.RequestUri = new Uri(path);
request.Method = HttpMethod.Head;
using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
return response.StatusCode == HttpStatusCode.OK;
}
catch (Exception)
{

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>

View File

@ -49,7 +49,7 @@ namespace ASC.FederatedLogin.Helpers
ConsumerFactory = consumerFactory;
}
public string RequestCode<T>(string scope = null, Dictionary<string, string> additionalArgs = null) where T : Consumer, IOAuthProvider, new()
public string RequestCode<T>(string scope = null, IDictionary<string, string> additionalArgs = null, IDictionary<string, string> additionalStateArgs = null) where T : Consumer, IOAuthProvider, new()
{
var loginProvider = ConsumerFactory.Get<T>();
var requestUrl = loginProvider.CodeUrl;
@ -67,7 +67,20 @@ namespace ASC.FederatedLogin.Helpers
if (!string.IsNullOrEmpty(scope)) query += $"&scope={HttpUtility.UrlEncode(scope)}";
var u = HttpContextAccessor.HttpContext.Request.GetUrlRewriter();
var state = HttpUtility.UrlEncode(new UriBuilder(u.Scheme, u.Host, u.Port, $"thirdparty/{loginProvider.Name.ToLower()}/code").Uri.AbsoluteUri);
var stateUriBuilder = new UriBuilder(u.Scheme, u.Host, u.Port, $"thirdparty/{loginProvider.Name.ToLower()}/code");
if (additionalStateArgs != null && additionalStateArgs.Any())
{
var stateQuery = "";
stateQuery = additionalStateArgs.Keys
.Where(a => a != null)
.Aggregate(stateQuery, (current, a) => a != null ? $"{current}&{a.Trim()}={additionalStateArgs[a] ?? "".Trim()}" : null);
stateUriBuilder.Query = stateQuery.Substring(1);
}
var state = HttpUtility.UrlEncode(stateUriBuilder.Uri.AbsoluteUri);
query += $"&state={state}";
if (additionalArgs != null)

View File

@ -27,7 +27,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
namespace ASC.FederatedLogin.Helpers
@ -38,9 +38,13 @@ namespace ASC.FederatedLogin.Helpers
{
if (string.IsNullOrEmpty(uri)) throw new ArgumentNullException("uri");
var request = WebRequest.Create(uri);
request.Method = method;
request.Timeout = timeout;
var request = new HttpRequestMessage();
request.RequestUri = new Uri(uri);
request.Method = new HttpMethod(method);
using var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMilliseconds(timeout);
if (headers != null)
{
foreach (var key in headers.Keys)
@ -49,33 +53,22 @@ namespace ASC.FederatedLogin.Helpers
}
}
if (!string.IsNullOrEmpty(contentType))
{
request.ContentType = contentType;
}
var bytes = Encoding.UTF8.GetBytes(body ?? "");
if (request.Method != "GET" && bytes.Length > 0)
if (request.Method != HttpMethod.Get && bytes.Length > 0)
{
request.ContentLength = bytes.Length;
using var stream = request.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
request.Content = new ByteArrayContent(bytes, 0, bytes.Length);
if (!string.IsNullOrEmpty(contentType))
{
request.Headers.Add("Content-Type", contentType);
}
}
try
{
using var response = request.GetResponse();
using var stream = response.GetResponseStream();
if (stream == null) return null;
using var readStream = new StreamReader(stream);
return readStream.ReadToEnd();
}
catch (WebException)
{
request.Abort();
throw;
}
using var response = httpClient.Send(request);
using var stream = response.Content.ReadAsStream();
if (stream == null) return null;
using var readStream = new StreamReader(stream);
return readStream.ReadToEnd();
}
}
}

View File

@ -26,6 +26,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading;
@ -104,10 +105,22 @@ namespace ASC.FederatedLogin
{
try
{
var profile = ProviderManager.Process(Auth, context, _params);
var desktop = _params.ContainsKey("desktop") && _params["desktop"] == "true";
IDictionary<string, string> additionalStateArgs = null;
if (desktop)
{
additionalStateArgs = context.Request.Query.ToDictionary(r => r.Key, r => r.Value.FirstOrDefault());
if (!additionalStateArgs.ContainsKey("desktop"))
{
additionalStateArgs.Add("desktop", "true");
}
}
var profile = ProviderManager.Process(Auth, context, null, additionalStateArgs);
if (profile != null)
{
await SendClientData(context, profile);
await SendJsCallback(context, profile);
}
}
catch (ThreadAbortException)
@ -116,7 +129,7 @@ namespace ASC.FederatedLogin
}
catch (Exception ex)
{
await SendClientData(context, LoginProfile.FromError(Signature, InstanceCrypto, ex));
await SendJsCallback(context, LoginProfile.FromError(Signature, InstanceCrypto, ex));
}
}
else
@ -179,48 +192,16 @@ namespace ASC.FederatedLogin
get { return false; }
}
private async Task SendClientData(HttpContext context, LoginProfile profile)
{
switch (Mode)
{
case LoginMode.Redirect:
await RedirectToReturnUrl(context, profile);
break;
case LoginMode.Popup:
await SendJsCallback(context, profile);
break;
}
}
private async Task SendJsCallback(HttpContext context, LoginProfile profile)
{
//Render a page
context.Response.ContentType = "text/html";
await context.Response.WriteAsync(JsCallbackHelper.GetCallbackPage().Replace("%PROFILE%", profile.ToJson()).Replace("%CALLBACK%", Callback));
}
private async Task RedirectToReturnUrl(HttpContext context, LoginProfile profile)
{
var useMinimalProfile = Minimal;
if (useMinimalProfile)
profile = profile.GetMinimalProfile(); //Only id and provider
if (context.Session != null && !useMinimalProfile)
{
//Store in session
context.Response.Redirect(new Uri(ReturnUrl, UriKind.Absolute).AddProfileSession(profile, context).ToString(), true);
}
else if (MemoryCache != null && !useMinimalProfile)
{
context.Response.Redirect(new Uri(ReturnUrl, UriKind.Absolute).AddProfileCache(profile, MemoryCache).ToString(), true);
}
else
{
context.Response.Redirect(new Uri(ReturnUrl, UriKind.Absolute).AddProfile(profile).ToString(), true);
}
await context.Response.CompleteAsync();
return;
await context.Response.WriteAsync(
JsCallbackHelper.GetCallbackPage()
.Replace("%PROFILE%", $"\"{profile.Serialized}\"")
.Replace("%CALLBACK%", Callback)
.Replace("%DESKTOP%", (Mode == LoginMode.Redirect).ToString().ToLowerInvariant())
);
}
}

View File

@ -113,11 +113,11 @@ namespace ASC.FederatedLogin.LoginProviders
InstanceCrypto = instanceCrypto;
}
public virtual LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
public virtual LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params, IDictionary<string, string> additionalStateArgs = null)
{
try
{
var token = Auth(context, Scopes, out var redirect);
var token = Auth(context, Scopes, out var redirect, @params, additionalStateArgs);
if (redirect)
{
@ -136,7 +136,7 @@ namespace ASC.FederatedLogin.LoginProviders
}
}
protected virtual OAuth20Token Auth(HttpContext context, string scopes, out bool redirect, Dictionary<string, string> additionalArgs = null)
protected virtual OAuth20Token Auth(HttpContext context, string scopes, out bool redirect, IDictionary<string, string> additionalArgs = null, IDictionary<string, string> additionalStateArgs = null)
{
var error = context.Request.Query["error"];
if (!string.IsNullOrEmpty(error))
@ -151,7 +151,7 @@ namespace ASC.FederatedLogin.LoginProviders
var code = context.Request.Query["code"];
if (string.IsNullOrEmpty(code))
{
context.Response.Redirect(OAuth20TokenHelper.RequestCode<T>(scopes, additionalArgs));
context.Response.Redirect(OAuth20TokenHelper.RequestCode<T>(scopes, additionalArgs, additionalStateArgs));
redirect = true;
return null;
}

View File

@ -114,7 +114,7 @@ namespace ASC.FederatedLogin.LoginProviders
}
public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params, IDictionary<string, string> additionalStateArgs = null)
{
try
{
@ -142,7 +142,7 @@ namespace ASC.FederatedLogin.LoginProviders
}
}
protected override OAuth20Token Auth(HttpContext context, string scopes, out bool redirect, Dictionary<string, string> additionalArgs = null)
protected override OAuth20Token Auth(HttpContext context, string scopes, out bool redirect, IDictionary<string, string> additionalArgs = null, IDictionary<string, string> additionalStateArgs = null)
{
var error = context.Request.Query["error"];
if (!string.IsNullOrEmpty(error))

View File

@ -34,7 +34,7 @@ namespace ASC.FederatedLogin.LoginProviders
{
public interface ILoginProvider : IOAuthProvider
{
LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params);
LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params, IDictionary<string, string> additionalStateArgs);
LoginProfile GetLoginProfile(string accessToken);
}

View File

@ -97,7 +97,7 @@ namespace ASC.FederatedLogin.LoginProviders
{
}
public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params, IDictionary<string, string> additionalStateArgs = null)
{
try
{

View File

@ -53,7 +53,7 @@ namespace ASC.FederatedLogin.LoginProviders
ConsumerFactory = consumerFactory;
}
public LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
public LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params, IDictionary<string, string> additionalStateArgs = null)
{
var response = Openid.GetResponse();
if (response == null)

View File

@ -71,9 +71,9 @@ namespace ASC.FederatedLogin.LoginProviders
: ConsumerFactory.GetByKey(providerType) as ILoginProvider;
}
public LoginProfile Process(string providerType, HttpContext context, IDictionary<string, string> @params)
public LoginProfile Process(string providerType, HttpContext context, IDictionary<string, string> @params, IDictionary<string, string> additionalStateArgs = null)
{
return GetLoginProvider(providerType).ProcessAuthoriztion(context, @params);
return GetLoginProvider(providerType).ProcessAuthoriztion(context, @params, additionalStateArgs);
}
public LoginProfile GetLoginProfile(string providerType, string accessToken)

View File

@ -102,7 +102,7 @@ namespace ASC.FederatedLogin.LoginProviders
}
public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params, IDictionary<string, string> additionalStateArgs = null)
{
try
{
@ -111,7 +111,7 @@ namespace ASC.FederatedLogin.LoginProviders
{
{ "revoke", "1" }
}
: null);
: null, additionalStateArgs);
if (redirect)
{

View File

@ -94,7 +94,7 @@ namespace ASC.FederatedLogin.LoginProviders
{
}
public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params)
public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary<string, string> @params, IDictionary<string, string> additionalStateArgs = null)
{
try
{
@ -103,7 +103,7 @@ namespace ASC.FederatedLogin.LoginProviders
{
{ "force_confirm", "true" }
}
: null);
: null, additionalStateArgs);
if (redirect)
{
return null;

View File

@ -373,7 +373,7 @@ namespace ASC.FederatedLogin.Profile
internal void FromTransport(string transportstring)
{
var serialized = Encoding.UTF8.GetString(InstanceCrypto.Decrypt(WebEncoders.Base64UrlDecode(transportstring)));
var serialized = InstanceCrypto.Decrypt(WebEncoders.Base64UrlDecode(transportstring));
FromSerializedString(serialized);
}

View File

@ -2,12 +2,17 @@
<html>
<head>
<script language="javascript" type="text/javascript">
try {
window.opener.%CALLBACK%(%PROFILE%);
if (%DESKTOP%) {
localStorage.setItem("profile", %PROFILE%);
window.location.href = "/";
} else {
try {
window.opener.%CALLBACK%(%PROFILE%);
}
catch (ex) {
}
window.close();
}
catch (ex) {
}
window.close();
</script>
</head>
<body></body>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyTitle>ASC.Notify.Textile</AssemblyTitle>
<Company>Ascensio System SIA</Company>
<Product>ASC.Notify.Textile</Product>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />

View File

@ -77,7 +77,7 @@ namespace ASC.VoipService.Twilio
{
if (!string.IsNullOrEmpty(settings.GreetingAudio))
{
response.Play(Uri.EscapeUriString(settings.GreetingAudio));
response.Play(Uri.EscapeDataString(settings.GreetingAudio));
}
response.Enqueue(settings.Queue.Name, GetEcho("Enqueue", agent != null), "POST",
@ -129,7 +129,7 @@ namespace ASC.VoipService.Twilio
if (!string.IsNullOrEmpty(queue.WaitUrl))
{
var gather = new Gather(method: "POST", action: GetEcho("gatherQueue"));
gather.Play(Uri.EscapeUriString(queue.WaitUrl));
gather.Play(Uri.EscapeDataString(queue.WaitUrl));
response.Gather(gather);
}
else
@ -156,7 +156,7 @@ namespace ASC.VoipService.Twilio
{
if (to == "hold")
{
return new VoiceResponse().Play(Uri.EscapeUriString(settings.HoldAudio), 0);
return new VoiceResponse().Play(Uri.EscapeDataString(settings.HoldAudio), 0);
}
@ -199,7 +199,7 @@ namespace ASC.VoipService.Twilio
{
return string.IsNullOrEmpty(settings.VoiceMail)
? response.Say("")
: response.Play(Uri.EscapeUriString(settings.VoiceMail)).Record(method: "POST", action: GetEcho("voiceMail"), maxLength: 30);
: response.Play(Uri.EscapeDataString(settings.VoiceMail)).Record(method: "POST", action: GetEcho("voiceMail"), maxLength: 30);
}
public string GetEcho(string action, bool user = true)

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<DefaultItemExcludes>$(DefaultItemExcludes);</DefaultItemExcludes>
<RazorCompileOnBuild>false</RazorCompileOnBuild>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.8" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0" />
<PackageReference Include="Moq" Version="4.14.7" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
</ItemGroup>
<ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@ -428,8 +428,9 @@ namespace Frontend.Translations.Tests
.Select(item => item.Key);
var allJsTranslationKeys = JavaScriptFiles
.Where(f => !f.Path.Contains("Banner.js")) // skip Banner.js (translations from firebase)
.SelectMany(j => j.TranslationKeys)
.Select(k => k.Replace("Common:", "").Replace("Translations:", ""))
.Select(k => k.Replace("Common:", "").Replace("Translations:", "").Replace("Home:", ""))
.Distinct();
var notFoundJsKeys = allJsTranslationKeys.Except(allEnKeys);
@ -811,6 +812,83 @@ namespace Frontend.Translations.Tests
Assert.AreEqual(0, NotTranslatedToasts.Count, message);
}
[Test]
public void WrongTranslationVariablesTest()
{
var message = $"Next keys have wrong variables:\r\n\r\n";
var regVariables = new Regex("\\{\\{([^\\{].?[^\\}]+)\\}\\}", RegexOptions.Compiled | RegexOptions.Multiline);
var groupedByLng = TranslationFiles
.GroupBy(t => t.Language)
.Select(g => new
{
Language = g.Key,
TranslationsWithVariables = g.ToList()
.SelectMany(t => t.Translations)
.Where(k => k.Value.IndexOf("{{") != -1)
.Select(t => new
{
t.Key,
t.Value,
Variables = regVariables.Matches(t.Value)
.Select(m => m.Groups[1]?.Value?.Trim().Replace(", lowercase", ""))
.ToList()
})
.ToList()
})
.ToList();
var enWithVariables = groupedByLng
.Where(t => t.Language == "en")
.SelectMany(t => t.TranslationsWithVariables)
.ToList();
var otherLanguagesWithVariables = groupedByLng
.Where(t => t.Language != "en")
.ToList();
var i = 0;
var errorsCount = 0;
foreach (var lng in otherLanguagesWithVariables)
{
foreach (var t in lng.TranslationsWithVariables)
{
var enKey = enWithVariables
.Where(en => en.Key == t.Key)
.FirstOrDefault();
if (enKey == null)
{
// wrong
message += $"{++i}. lng='{lng.Language}' key='{t.Key}' has no 'en' language variant (!!!useless key!!!)\r\n\r\n";
errorsCount++;
continue;
}
if (enKey.Variables.Count != t.Variables.Count)
{
// wrong
message += $"{++i}. lng='{lng.Language}' key='{t.Key}' has less variables then 'en' language have " +
$"(en={enKey.Variables.Count}|{lng.Language}={t.Variables.Count})\r\n" +
$"'en': '{enKey.Value}'\r\n'{lng.Language}': '{t.Value}'\r\n\r\n";
errorsCount++;
}
if (!t.Variables.All(v => enKey.Variables.Contains(v)))
{
// wrong
errorsCount++;
message += $"{++i}. lng='{lng.Language}' key='{t.Key}' has not equals variables of 'en' language have\r\n\r\n" +
$"Have to be:\r\n'{enKey.Value}'\r\n\r\n{string.Join("\r\n", enKey.Variables)}\r\n\r\n" +
$"But in real:\r\n'{t.Value}'\r\n\r\n{string.Join("\r\n", t.Variables)} \r\n\r\n";
}
}
}
Assert.AreEqual(0, errorsCount, message);
}
/*[Test]
public void TempTest()
{

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<StartupObject>AutoMigrationCreator.Program</StartupObject>
</PropertyGroup>
@ -13,11 +13,11 @@
<ItemGroup>
<ProjectReference Include="..\..\..\products\ASC.Files\Core\ASC.Files.Core.csproj" />
<ProjectReference Include="..\..\ASC.Core.Common\ASC.Core.Common.csproj" />
<PackageReference Include="Microsoft.Build" Version="16.11.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.10">
<PrivateAssets>all</PrivateAssets>
<PackageReference Include="Microsoft.Build" Version="17.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
</ItemGroup>
</Project>

View File

@ -1,6 +1,9 @@
using ASC.Core.Common.EF;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
namespace AutoMigrationCreator
@ -12,6 +15,10 @@ namespace AutoMigrationCreator
var serviceCollection = new ServiceCollection();
serviceCollection.AddEntityFrameworkDesignTimeServices();
serviceCollection.AddDbContextDesignTimeServices(context);
serviceCollection.AddSingleton<MigrationsCodeGeneratorDependencies>();
serviceCollection.AddSingleton<AnnotationCodeGeneratorDependencies>();
serviceCollection.AddSingleton<IAnnotationCodeGenerator, AnnotationCodeGenerator>();
serviceCollection.AddSingleton(context.GetService<ITypeMappingSource>());
var designTimeServices = serviceCollection.BuildServiceProvider();

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyTitle>ASC.ApiSystem</AssemblyTitle>
<Company>Ascensio System SIA</Company>
<Product>ASC.ApiSystem</Product>
@ -17,10 +17,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -28,7 +28,8 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.RegularExpressions;
@ -168,18 +169,16 @@ namespace ASC.ApiSystem.Controllers
Log.DebugFormat("congratulations skiped");
return false;
}
var webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = WebRequestMethods.Http.Post;
webRequest.Accept = "application/x-www-form-urlencoded";
webRequest.ContentLength = 0;
var request = new HttpRequestMessage();
request.Method = HttpMethod.Post;
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/x-www-form-urlencoded"));
try
{
using var response = webRequest.GetResponse();
using var stream = response.GetResponseStream();
{
using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
using var stream = response.Content.ReadAsStream();
using var reader = new StreamReader(stream, Encoding.UTF8);
var result = reader.ReadToEnd();
@ -305,18 +304,17 @@ namespace ASC.ApiSystem.Controllers
{
var data = string.Format("secret={0}&remoteip={1}&response={2}", Configuration["recaptcha:private-key"], ip, response);
var url = Configuration["recaptcha:verify-url"] ?? "https://www.recaptcha.net/recaptcha/api/siteverify";
var request = new HttpRequestMessage();
request.RequestUri = new Uri(url);
request.Method = HttpMethod.Post;
request.Content = new StringContent(data, Encoding.UTF8, "application/x-www-form-urlencoded");
using var httpClient = new HttpClient();
using var httpClientResponse = httpClient.Send(request);
using var stream = httpClientResponse.Content.ReadAsStream();
using var reader = new StreamReader(stream);
var webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = WebRequestMethods.Http.Post;
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = data.Length;
using (var writer = new StreamWriter(webRequest.GetRequestStream()))
{
writer.Write(data);
}
using var webResponse = webRequest.GetResponse();
using var reader = new StreamReader(webResponse.GetResponseStream());
var resp = reader.ReadToEnd();
var resObj = JObject.Parse(resp);

View File

@ -26,9 +26,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Web;
using ASC.ApiSystem.Classes;
@ -336,25 +338,20 @@ namespace ASC.ApiSystem.Controllers
string.IsNullOrEmpty(query) ? "" : "?" + query);
Log.Info(string.Format("CalDav: SendToApi: {0}", url));
var request = new HttpRequestMessage();
request.RequestUri = new Uri(url);
request.Method = new HttpMethod(httpMethod);
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json"));
var webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = httpMethod;
webRequest.Accept = "application/json";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = 0;
using var httpClient = new HttpClient();
if (data != null)
{
webRequest.ContentLength = data.Length;
using var writer = new StreamWriter(webRequest.GetRequestStream());
writer.Write(data);
request.Content = new StringContent(data, Encoding.UTF8, "application/x-www-form-urlencoded");
}
using (webRequest.GetResponse())
{
}
httpClient.Send(request);
}
#endregion

View File

@ -46,7 +46,6 @@ namespace ASC.ApiSystem
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}

View File

@ -24,6 +24,8 @@
*/
using System.Text.Json.Serialization;
using ASC.Api.Core;
using ASC.ApiSystem.Classes;
using ASC.ApiSystem.Controllers;
@ -66,7 +68,7 @@ namespace ASC.ApiSystem
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.WriteIndented = false;
options.JsonSerializerOptions.IgnoreNullValues = true;
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});
services.AddMemoryCache();

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
@ -33,10 +33,9 @@
<ProjectReference Include="..\..\ASC.Common\ASC.Common.csproj" />
<ProjectReference Include="..\..\ASC.Core.Common\ASC.Core.Common.csproj" />
<ProjectReference Include="..\..\ASC.Data.Encryption\ASC.Data.Encryption.csproj" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
@ -21,6 +21,10 @@
</ItemGroup>
</Target>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ASC.Data.Backup.Core\ASC.Data.Backup.Core.csproj" />
</ItemGroup>

Some files were not shown because too many files have changed in this diff Show More