Added auth to StorageHandler

This commit is contained in:
pavelbannov 2019-07-09 13:29:53 +03:00
parent 9b3e9a3977
commit 1ad03ec6d8
10 changed files with 5085 additions and 43 deletions

5015
build/ASC.Web.log Normal file

File diff suppressed because one or more lines are too long

View File

@ -11,12 +11,12 @@ echo "ASC.Web.sln"
cd ../../../
call dotnet build ASC.Web.sln /fl1 /flp1:LogFile=build/ASC.Web.log;Verbosity=Normal
echo "ASC.People"
call dotnet publish products/ASC.People --self-contained -r win10-x64 -o build/deploy/products/people /fl1 /flp1:LogFile=build/ASC.People.log;Verbosity=Normal
rem echo "ASC.People"
rem call dotnet build products/ASC.People --self-contained -r win10-x64 -o build/deploy/products/people /fl1 /flp1:LogFile=build/ASC.People.log;Verbosity=Normal
echo "ASC.Web.Api"
call dotnet publish web/ASC.Web.Api --self-contained -r win10-x64 -o build/deploy/www/api /fl1 /flp1:LogFile=build/ASC.Web.Api.log;Verbosity=Normal
rem echo "ASC.Web.Api"
rem call dotnet publish web/ASC.Web.Api --self-contained -r win10-x64 -o build/deploy/www/api /fl1 /flp1:LogFile=build/ASC.Web.Api.log;Verbosity=Normal
xcopy config\*.* build\deploy\config\ /E /R /Y
rem xcopy config\*.* build\deploy\config\ /E /R /Y
pause

View File

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:63105/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ASC.Data.Storage": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:63106/"
}
}
}

View File

@ -35,6 +35,7 @@ using ASC.Core.Common.Configuration;
using ASC.Data.Storage.DiscStorage;
using ASC.Common.DependencyInjection;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
namespace ASC.Data.Storage
{
@ -141,8 +142,8 @@ namespace ASC.Data.Storage
//{
// throw new InvalidOperationException("Application not hosted.");
//}
var section = CommonServiceProvider.GetService<Configuration.Storage>();
var section = builder.ServiceProvider.GetService<Configuration.Storage>();
if (section != null)
{
//old scheme

View File

@ -57,13 +57,12 @@ namespace ASC.Data.Storage.DiscStorage
}
public async Task Invoke(HttpContext context)
{
//TODO
//if (_checkAuth && !SecurityContext.IsAuthenticated)
//{
// context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
// return;
//}
{
if (_checkAuth && !SecurityContext.IsAuthenticated)
{
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
return;
}
var storage = StorageFactory.GetStorage(CoreContext.TenantManager.GetCurrentTenant().TenantId.ToString(CultureInfo.InvariantCulture), _module);
var path = Path.Combine(_path, GetRouteValue("pathInfo").Replace('/', Path.DirectorySeparatorChar));

View File

@ -1,9 +1,16 @@
using System.Threading;
using ASC.Api.Core.Core;
using ASC.Api.Core.Middleware;
using ASC.Common.Logging;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Core;
using ASC.Data.Reassigns;
using ASC.Data.Storage.Configuration;
using ASC.MessagingSystem;
using ASC.Web.Api.Handlers;
using ASC.Web.Core;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
@ -15,12 +22,6 @@ using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ASC.Data.Storage.Configuration;
using ASC.Web.Core;
using ASC.Api.Core.Core;
using ASC.Common.Utils;
using ASC.Core;
using System.Threading;
namespace ASC.People
{

View File

@ -1,3 +1,16 @@
using System.Threading;
using ASC.Api.Core.Core;
using ASC.Api.Core.Middleware;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Core;
using ASC.Data.Reassigns;
using ASC.Data.Storage.Configuration;
using ASC.MessagingSystem;
using ASC.Web.Core;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
@ -9,19 +22,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ASC.Common.Logging;
using ASC.Web.Api.Handlers;
using ASC.Api.Core.Middleware;
using ASC.Common.Utils;
using ASC.Common.DependencyInjection;
using ASC.Web.Core;
using ASC.Data.Storage.Configuration;
using ASC.MessagingSystem;
using ASC.Data.Reassigns;
using ASC.Core;
using System.Threading;
using ASC.Api.Core.Core;
namespace ASC.Web.Api
{
public class Startup

View File

@ -3,13 +3,12 @@ using System.Security.Authentication;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using ASC.Core;
using ASC.Web.Core;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace ASC.Web.Api.Handlers
namespace ASC.Web.Core
{
public class CookieAuthHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{

View File

@ -28,6 +28,7 @@
<ItemGroup>
<ProjectReference Include="..\..\common\ASC.Data.Storage\ASC.Data.Storage.csproj" />
<ProjectReference Include="..\ASC.Web.Core\ASC.Web.Core.csproj" />
</ItemGroup>
<ItemGroup>

View File

@ -3,6 +3,8 @@ using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Data.Storage;
using ASC.Data.Storage.Configuration;
using ASC.Web.Core;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
@ -44,6 +46,8 @@ namespace ASC.Web.Studio
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
services.AddAuthentication("cookie").AddScheme<AuthenticationSchemeOptions, CookieAuthHandler>("cookie", a => { });
services.AddHttpContextAccessor()
.AddStorage()
.AddLogManager();
@ -72,12 +76,7 @@ namespace ASC.Web.Studio
app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseSession();
/*app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});*/
app.UseAuthentication();
app.UseCSP();
app.UseCm();