From bd082f2366ac4ec9c435726e82bf3340612abb20 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Wed, 3 Jan 2018 11:32:57 +0300 Subject: [PATCH] Facebook credentials added to appsettings. Adding Facebook authentication moved to abpDeskWebMvcModule class. --- src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs | 14 ++++++++++++++ src/AbpDesk/AbpDesk.Web.Mvc/Startup.cs | 11 ----------- src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json | 7 +++++++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs index e6f0c74ec2..eea4fead9b 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs @@ -66,6 +66,20 @@ namespace AbpDesk.Web.Mvc //services.Configure(configuration); //Needed when we use Volo.Abp.Identity.HttpApi.Client + //Adding Facebook authentication + if (bool.Parse(configuration["Authentication:Facebook:IsEnabled"])) + { + services.AddAuthentication().AddFacebook(options => + { + options.AppId = configuration["Authentication:Facebook:AppId"]; + options.AppSecret = configuration["Authentication:Facebook:AppSecret"]; + + options.Scope.Add("email"); + options.Scope.Add("public_profile"); + }); + } + + services.AddAssemblyOf(); services.Configure(options => diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/Startup.cs b/src/AbpDesk/AbpDesk.Web.Mvc/Startup.cs index 7e0d9ad95a..a166afafb9 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/Startup.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/Startup.cs @@ -1,12 +1,10 @@ using System; -using System.IO; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Serilog; using Volo.Abp; -using Volo.Abp.Modularity.PlugIns; namespace AbpDesk.Web.Mvc { @@ -37,15 +35,6 @@ namespace AbpDesk.Web.Mvc //); }); - - services.AddAuthentication().AddFacebook(facebookOptions => - { - facebookOptions.AppId = "911417875702990"; - facebookOptions.AppSecret = "adea0bff222ae340d8fb0ce3e6275d6b"; - }); - - - //TODO: This is needed because ASP.NET Core does not use IServiceProviderFactory! return services.BuildServiceProviderFromFactory(); } diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json index 927ad8e6c7..fe44ab1467 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json +++ b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json @@ -7,5 +7,12 @@ "AbpIdentity": { "BaseUrl": "http://localhost:63290/" } + }, + "Authentication": { + "Facebook": { + "IsEnabled": "true", + "AppId": "911417875702990", + "AppSecret": "adea0bff222ae340d8fb0ce3e6275d6b" + } } }