Skip to content

Commit

Permalink
Merge branch 'develop' into feature/mobile-main-button
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeySafronov authored Nov 22, 2021
2 parents 0e52607 + d94ea50 commit 2f21f22
Show file tree
Hide file tree
Showing 504 changed files with 6,215 additions and 3,776 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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.
4 changes: 3 additions & 1 deletion build/build.frontend.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PUSHD %~dp0..

REM call yarn wipe
call yarn install
call yarn install

POPD
1 change: 1 addition & 0 deletions build/buildAndDeploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ echo "##########################################################"

echo.

PUSHD %~dp0
setlocal EnableDelayedExpansion

call runasadmin.bat "%~dpnx0"
Expand Down
2 changes: 1 addition & 1 deletion build/install/common/systemd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion build/install/docker/Dockerfile.app
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions build/install/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

PARAMETERS=${PARAMETERS:-""}
# read parameters
if [ -n "$1" ]; then
DOTNET_RUN="${1}";
Expand All @@ -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"}
Expand Down
15 changes: 15 additions & 0 deletions build/install/docker/hooks/push
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions common/ASC.Core.Common/Billing/TariffService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public IEnumerable<PaymentInfo> GetPayments(int tenantId)
if (BillingClient.Configured)
{
try
{
{
var quotas = QuotaService.GetTenantQuotas();
var client = GetBillingClient();
foreach (var pi in client.GetPayments(GetPortalId(tenantId)))
Expand Down Expand Up @@ -483,7 +483,7 @@ private Tariff GetBillingInfo(int tenant)
var r = CoreDbContext.Tariffs
.Where(r => r.Tenant == tenant)
.OrderByDescending(r => r.Id)
.SingleOrDefault();
.FirstOrDefault();

if (r == null) return Tariff.CreateDefault();

Expand Down
17 changes: 15 additions & 2 deletions common/ASC.FederatedLogin/Helpers/OAuth20TokenHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public OAuth20TokenHelper(IHttpContextAccessor httpContextAccessor, ConsumerFact
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;
Expand All @@ -67,7 +67,20 @@ public OAuth20TokenHelper(IHttpContextAccessor httpContextAccessor, ConsumerFact
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)
Expand Down
63 changes: 22 additions & 41 deletions common/ASC.FederatedLogin/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading;
Expand Down Expand Up @@ -104,10 +105,22 @@ public async Task Invoke(HttpContext context)
{
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)
Expand All @@ -116,7 +129,7 @@ public async Task Invoke(HttpContext context)
}
catch (Exception ex)
{
await SendClientData(context, LoginProfile.FromError(Signature, InstanceCrypto, ex));
await SendJsCallback(context, LoginProfile.FromError(Signature, InstanceCrypto, ex));
}
}
else
Expand Down Expand Up @@ -179,48 +192,16 @@ public bool IsReusable
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())
);
}
}

Expand Down
8 changes: 4 additions & 4 deletions common/ASC.FederatedLogin/LoginProviders/BaseLoginProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ protected BaseLoginProvider(
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)
{
Expand All @@ -136,7 +136,7 @@ public virtual LoginProfile ProcessAuthoriztion(HttpContext context, IDictionary
}
}

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))
Expand All @@ -151,7 +151,7 @@ protected virtual OAuth20Token Auth(HttpContext context, string scopes, out bool
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public GosUslugiLoginProvider(
}


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
{
Expand Down Expand Up @@ -142,7 +142,7 @@ public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionar
}
}

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))
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.FederatedLogin/LoginProviders/ILoginProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public MailRuLoginProvider(
{
}

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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public OpenIdLoginProvider(Signature signature, InstanceCrypto instanceCrypto, C
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)
Expand Down
4 changes: 2 additions & 2 deletions common/ASC.FederatedLogin/LoginProviders/ProviderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public ILoginProvider GetLoginProvider(string providerType)
: 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)
Expand Down
4 changes: 2 additions & 2 deletions common/ASC.FederatedLogin/LoginProviders/VKLoginProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public VKLoginProvider(
}


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
{
Expand All @@ -111,7 +111,7 @@ public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionar
{
{ "revoke", "1" }
}
: null);
: null, additionalStateArgs);

if (redirect)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public YandexLoginProvider(
{
}

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
{
Expand All @@ -103,7 +103,7 @@ public override LoginProfile ProcessAuthoriztion(HttpContext context, IDictionar
{
{ "force_confirm", "true" }
}
: null);
: null, additionalStateArgs);
if (redirect)
{
return null;
Expand Down
15 changes: 10 additions & 5 deletions common/ASC.FederatedLogin/callback.htm
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Loading

0 comments on commit 2f21f22

Please sign in to comment.