un positionnement de paramètre workflow des pros
This commit is contained in:
parent
fbd352e788
commit
96746fcc0b
322 changed files with 25893 additions and 3844 deletions
|
|
@ -7,7 +7,6 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
|
||||
namespace Yavsc
|
||||
{
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
public void ConfigureProtectionServices(IServiceCollection services)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
using System.IO;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.StaticFiles;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
public static string UserFilesDirName { get; private set; }
|
||||
|
|
@ -15,7 +17,7 @@ namespace Yavsc
|
|||
|
||||
public static FileServerOptions AvatarsOptions { get; set; }
|
||||
public void ConfigureFileServerApp(IApplicationBuilder app,
|
||||
SiteSettings siteSettings, IHostingEnvironment env)
|
||||
SiteSettings siteSettings, IHostingEnvironment env, IAuthorizationService authorizationService)
|
||||
{
|
||||
var userFilesDirInfo = new DirectoryInfo( siteSettings.UserFiles.Blog );
|
||||
UserFilesDirName = userFilesDirInfo.FullName;
|
||||
|
|
@ -28,6 +30,14 @@ namespace Yavsc
|
|||
RequestPath = new PathString(Constants.UserFilesPath),
|
||||
EnableDirectoryBrowsing = env.IsDevelopment()
|
||||
};
|
||||
|
||||
UserFilesOptions.StaticFileOptions.OnPrepareResponse += async context =>
|
||||
{
|
||||
var uname = context.Context.User.GetUserName();
|
||||
var path = context.Context.Request.Path;
|
||||
var result = await authorizationService.AuthorizeAsync(context.Context.User, new ViewFileContext
|
||||
{ UserName = uname, File = context.File, Path = path } , new ViewRequirement());
|
||||
};
|
||||
var avatarsDirInfo = new DirectoryInfo(Startup.SiteSetup.UserFiles.Avatars);
|
||||
if (!avatarsDirInfo.Exists) avatarsDirInfo.Create();
|
||||
AvatarsDirName = avatarsDirInfo.FullName;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ using Yavsc.Models;
|
|||
|
||||
namespace Yavsc
|
||||
{
|
||||
|
||||
public partial class Startup
|
||||
{
|
||||
public static CookieAuthenticationOptions ExternalCookieAppOptions { get; private set; }
|
||||
|
|
@ -151,8 +150,8 @@ namespace Yavsc
|
|||
branch.UseFacebookAuthentication(options =>
|
||||
{
|
||||
FacebookAppOptions = options;
|
||||
options.AppId = Configuration["Authentication:Facebook:AppId"];
|
||||
options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
|
||||
options.AppId = Configuration["Authentication:Facebook:ClientId"];
|
||||
options.AppSecret = Configuration["Authentication:Facebook:ClientSecret"];
|
||||
options.Scope.Add("email");
|
||||
options.UserInformationEndpoint = "https://graph.facebook.com/v2.5/me?fields=id,name,email,first_name,last_name";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Net.WebSockets;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
|
||||
|
|
@ -15,7 +11,7 @@ namespace Yavsc
|
|||
app.UseWebSockets();
|
||||
|
||||
app.UseSignalR("/api/signalr");
|
||||
|
||||
/*
|
||||
var _sockets = new ConcurrentBag<WebSocket>();
|
||||
|
||||
app.Use(
|
||||
|
|
@ -56,7 +52,7 @@ namespace Yavsc
|
|||
await next();
|
||||
}
|
||||
}
|
||||
);
|
||||
); */
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Yavsc/Startup/Startup.Workflow.cs
Normal file
33
Yavsc/Startup/Startup.Workflow.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Builder;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
public partial class Startup
|
||||
{
|
||||
/// <summary>
|
||||
/// Lists Available user profile classes.
|
||||
/// </summary>
|
||||
public static Dictionary<string,Type> ProfileTypes = new Dictionary<string,Type>() ;
|
||||
private void ConfigureWorkflow(IApplicationBuilder app, SiteSettings settings)
|
||||
{
|
||||
System.AppDomain.CurrentDomain.ResourceResolve += OnYavscResourceResolve;
|
||||
|
||||
foreach (var a in System.AppDomain.CurrentDomain.GetAssemblies()) {
|
||||
foreach (var c in a.GetTypes()) {
|
||||
if (c.IsClass && !c.IsAbstract &&
|
||||
c.GetInterface("ISpecializationSettings")!=null) {
|
||||
ProfileTypes.Add(c.FullName,c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static System.Reflection.Assembly OnYavscResourceResolve (object sender, ResolveEventArgs ev)
|
||||
{
|
||||
return AppDomain.CurrentDomain.GetAssemblies()[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ using Microsoft.Net.Http.Headers;
|
|||
using Yavsc.Formatters;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
|
|
@ -36,6 +37,7 @@ namespace Yavsc
|
|||
public static string AvatarsDirName { private set; get; }
|
||||
public static string Authority { get; private set; }
|
||||
public static string Audience { get; private set; }
|
||||
public static string Temp { get; set; }
|
||||
public static SiteSettings SiteSetup { get; private set; }
|
||||
|
||||
private static ILogger logger;
|
||||
|
|
@ -93,8 +95,8 @@ namespace Yavsc
|
|||
};
|
||||
var supportedUICultures = new[]
|
||||
{
|
||||
new CultureInfo("en"),
|
||||
new CultureInfo("fr")
|
||||
new CultureInfo("fr"),
|
||||
new CultureInfo("en")
|
||||
};
|
||||
|
||||
// You must explicitly state which cultures your application supports.
|
||||
|
|
@ -180,6 +182,8 @@ namespace Yavsc
|
|||
services.AddSingleton<IAuthorizationHandler, CommandEditHandler>();
|
||||
services.AddSingleton<IAuthorizationHandler, CommandViewHandler>();
|
||||
services.AddSingleton<IAuthorizationHandler, PostUserFileHandler>();
|
||||
services.AddSingleton<IAuthorizationHandler, EstimateViewHandler>();
|
||||
services.AddSingleton<IAuthorizationHandler, ViewFileHandler>();
|
||||
|
||||
services.AddMvc(config =>
|
||||
{
|
||||
|
|
@ -227,11 +231,15 @@ namespace Yavsc
|
|||
IOptions<RequestLocalizationOptions> localizationOptions,
|
||||
IOptions<OAuth2AppSettings> oauth2SettingsContainer,
|
||||
RoleManager<IdentityRole> roleManager,
|
||||
IAuthorizationService authorizationService,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
SiteSetup = siteSettings.Value;
|
||||
Authority = siteSettings.Value.Authority;
|
||||
Audience = siteSettings.Value.Audience;
|
||||
Startup.UserFilesDirName = new DirectoryInfo(siteSettings.Value.UserFiles.Blog).FullName;
|
||||
Startup.UserBillsDirName = new DirectoryInfo(siteSettings.Value.UserFiles.Bills).FullName;
|
||||
Startup.Temp = siteSettings.Value.TempDir;
|
||||
|
||||
// TODO implement an installation & upgrade procedure
|
||||
// Create required directories
|
||||
|
|
@ -283,7 +291,7 @@ namespace Yavsc
|
|||
if (ex.InnerException is InvalidOperationException)
|
||||
// nothing to do ?
|
||||
{
|
||||
// TODO Send an email to the Admin
|
||||
// TODO (or not) Hit the developper
|
||||
}
|
||||
else throw ex;
|
||||
}
|
||||
|
|
@ -322,14 +330,13 @@ namespace Yavsc
|
|||
options.AutomaticAuthentication = false;
|
||||
});
|
||||
|
||||
Authority = siteSettings.Value.Authority;
|
||||
Audience = siteSettings.Value.Audience;
|
||||
|
||||
ConfigureOAuthApp(app, siteSettings.Value);
|
||||
ConfigureFileServerApp(app, siteSettings.Value, env);
|
||||
ConfigureWebSocketsApp(app, siteSettings.Value, env);
|
||||
|
||||
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture)new RequestCulture((string)"en"));
|
||||
ConfigureOAuthApp(app, SiteSetup);
|
||||
ConfigureFileServerApp(app, SiteSetup, env, authorizationService);
|
||||
ConfigureWebSocketsApp(app, SiteSetup, env);
|
||||
ConfigureWorkflow(app, SiteSetup);
|
||||
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture) new RequestCulture((string)"en"));
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
|
|
@ -344,4 +351,4 @@ namespace Yavsc
|
|||
}
|
||||
|
||||
}
|
||||
//
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue