/// <summary> /// Configure /// </summary> /// <param name="builder">Authentication builder</param> public void Configure(AuthenticationBuilder builder, IConfiguration configuration) { builder.AddFacebook(FacebookDefaults.AuthenticationScheme, options => { var settings = new FacebookExternalAuthSettings(); try { var fbSettings = new MongoDBRepository <Setting>(DataSettingsHelper.ConnectionString()).Table.Where(x => x.Name.StartsWith("facebookexternalauthsettings")); settings.ClientKeyIdentifier = fbSettings.FirstOrDefault(x => x.Name == "facebookexternalauthsettings.clientkeyidentifier")?.Value; settings.ClientSecret = fbSettings.FirstOrDefault(x => x.Name == "facebookexternalauthsettings.clientsecret")?.Value; } catch { }; //no empty values allowed. otherwise, an exception could be thrown on application startup options.AppId = !string.IsNullOrWhiteSpace(settings.ClientKeyIdentifier) ? settings.ClientKeyIdentifier : "000"; options.AppSecret = !string.IsNullOrWhiteSpace(settings.ClientSecret) ? settings.ClientSecret : "000"; options.SaveTokens = true; //handles exception thrown by external auth provider options.Events = new OAuthEvents() { OnRemoteFailure = ctx => { ctx.HandleResponse(); var errorCode = ctx.Request.Query["error_code"].FirstOrDefault(); var errorMessage = ctx.Request.Query["error_message"].FirstOrDefault(); var state = ctx.Request.Query["state"].FirstOrDefault(); errorCode = WebUtility.UrlEncode(errorCode); errorMessage = WebUtility.UrlEncode(errorMessage); ctx.Response.Redirect($"/fb-signin-failed?error_code={errorCode}&error_message={errorMessage}"); return(Task.FromResult(0)); } }; }); }
public FacebookAuthenticationSettingsController(FacebookExternalAuthSettings facebookExternalAuthSettings, ITranslationService translationService, IPermissionService permissionService, ISettingService settingService) { _facebookExternalAuthSettings = facebookExternalAuthSettings; _translationService = translationService; _permissionService = permissionService; _settingService = settingService; }
public ExternalAuthFacebookController(ISettingService settingService, FacebookExternalAuthSettings facebookExternalAuthSettings, IOAuthProviderFacebookAuthorizer oAuthProviderFacebookAuthorizer, IOpenAuthenticationService openAuthenticationService, ExternalAuthenticationSettings externalAuthenticationSettings) { this._settingService = settingService; this._facebookExternalAuthSettings = facebookExternalAuthSettings; this._oAuthProviderFacebookAuthorizer = oAuthProviderFacebookAuthorizer; this._openAuthenticationService = openAuthenticationService; this._externalAuthenticationSettings = externalAuthenticationSettings; }
public FacebookProviderAuthorizer(IExternalAuthorizer authorizer, IOpenAuthenticationService openAuthenticationService, ExternalAuthenticationSettings externalAuthenticationSettings, FacebookExternalAuthSettings facebookExternalAuthSettings, HttpContextBase httpContext) { this._authorizer = authorizer; this._openAuthenticationService = openAuthenticationService; this._externalAuthenticationSettings = externalAuthenticationSettings; this._facebookExternalAuthSettings = facebookExternalAuthSettings; this._httpContext = httpContext; }
public FacebookProviderAuthorizer(IExternalAuthorizer authorizer, ExternalAuthenticationSettings externalAuthenticationSettings, FacebookExternalAuthSettings facebookExternalAuthSettings, HttpContextBase httpContext, IWebHelper webHelper) { this._authorizer = authorizer; this._externalAuthenticationSettings = externalAuthenticationSettings; this._facebookExternalAuthSettings = facebookExternalAuthSettings; this._httpContext = httpContext; this._webHelper = webHelper; }
public FacebookAuthenticationController(FacebookExternalAuthSettings facebookExternalAuthSettings, IExternalAuthenticationService externalAuthenticationService, ILocalizationService localizationService, IPermissionService permissionService, ISettingService settingService) { _facebookExternalAuthSettings = facebookExternalAuthSettings; _externalAuthenticationService = externalAuthenticationService; _localizationService = localizationService; _permissionService = permissionService; _settingService = settingService; }
public ActionResult Configure(FacebookExternalAuthSettings settings) { var model = new ConfigurationModel(); MiniMapper.Map(settings, model); var host = Services.StoreContext.CurrentStore.GetHost(true); model.RedirectUrl = $"{host}Plugins/SmartStore.FacebookAuth/logincallback/"; return(View(model)); }
public FacebookAuthenticationController(FacebookExternalAuthSettings facebookExternalAuthSettings, IExternalAuthenticationService externalAuthenticationService, ILocalizationService localizationService, IOptionsMonitorCache <FacebookOptions> optionsCache, IPermissionService permissionService, ISettingService settingService) { this._facebookExternalAuthSettings = facebookExternalAuthSettings; this._externalAuthenticationService = externalAuthenticationService; this._localizationService = localizationService; this._optionsCache = optionsCache; this._permissionService = permissionService; this._settingService = settingService; }
public ActionResult Configure(FacebookExternalAuthSettings settings, ConfigurationModel model) { if (!ModelState.IsValid) { return(Configure(settings)); } MiniMapper.Map(model, settings); settings.ClientKeyIdentifier = model.ClientKeyIdentifier.TrimSafe(); settings.ClientSecret = model.ClientSecret.TrimSafe(); NotifySuccess(T("Admin.Common.DataSuccessfullySaved")); return(RedirectToConfiguration(FacebookExternalAuthMethod.SystemName, true)); }
public FacebookAuthenticationController(FacebookExternalAuthSettings facebookExternalAuthSettings, IExternalAuthenticationService externalAuthenticationService, ILocalizationService localizationService, IPermissionService permissionService, ISettingService settingService, IStoreService storeService, IWorkContext workContext) { this._facebookExternalAuthSettings = facebookExternalAuthSettings; this._externalAuthenticationService = externalAuthenticationService; this._localizationService = localizationService; this._permissionService = permissionService; this._settingService = settingService; this._storeService = storeService; this._workContext = workContext; }
public ExternalAuthFacebookController(ISettingService settingService, FacebookExternalAuthSettings facebookExternalAuthSettings, IOAuthProviderFacebookAuthorizer oAuthProviderFacebookAuthorizer, IOpenAuthenticationService openAuthenticationService, ExternalAuthenticationSettings externalAuthenticationSettings, IStoreContext storeContext, IPermissionService permissionService) { this._settingService = settingService; this._facebookExternalAuthSettings = facebookExternalAuthSettings; this._oAuthProviderFacebookAuthorizer = oAuthProviderFacebookAuthorizer; this._openAuthenticationService = openAuthenticationService; this._externalAuthenticationSettings = externalAuthenticationSettings; this._storeContext = storeContext; this._permissionService = permissionService; }
public ActionResult Configure(FacebookExternalAuthSettings settings) { if (!HasPermission(false)) { return(AccessDeniedPartialView()); } var model = new ConfigurationModel(); MiniMapper.Map(settings, model); var host = _services.StoreContext.CurrentStore.GetHost(true); model.RedirectUrl = $"{host}Plugins/SmartStore.FacebookAuth/logincallback/"; return(View(model)); }
/// <summary> /// Configure /// </summary> /// <param name="builder">Authentication builder</param> public void AddAuthentication(AuthenticationBuilder builder, IConfiguration configuration) { builder.AddFacebook(FacebookDefaults.AuthenticationScheme, options => { var connection = DataSettingsManager.LoadSettings(); var settings = new FacebookExternalAuthSettings(); try { var fbSettings = new MongoRepository <Setting>(connection.ConnectionString).Table.Where(x => x.Name.StartsWith("facebookexternalauthsettings")); if (fbSettings.Any()) { var metadata = fbSettings.FirstOrDefault().Metadata; settings = JsonSerializer.Deserialize <FacebookExternalAuthSettings>(metadata); } } catch (Exception ex) { Log.Error(ex, "AddFacebook"); }; //no empty values allowed. otherwise, an exception could be thrown on application startup options.AppId = !string.IsNullOrWhiteSpace(settings.ClientKeyIdentifier) ? settings.ClientKeyIdentifier : "000"; options.AppSecret = !string.IsNullOrWhiteSpace(settings.ClientSecret) ? settings.ClientSecret : "000"; options.SaveTokens = true; //handles exception thrown by external auth provider options.Events = new OAuthEvents() { OnRemoteFailure = ctx => { ctx.HandleResponse(); var errorCode = ctx.Request.Query["error_code"].FirstOrDefault(); var errorMessage = ctx.Request.Query["error_message"].FirstOrDefault(); var state = ctx.Request.Query["state"].FirstOrDefault(); errorCode = WebUtility.UrlEncode(errorCode); errorMessage = WebUtility.UrlEncode(errorMessage); ctx.Response.Redirect($"/fb-signin-failed?error_code={errorCode}&error_message={errorMessage}"); return(Task.FromResult(0)); } }; }); }
public FacebookAuthenticationController(FacebookExternalAuthSettings facebookExternalAuthSettings, IAuthenticationPluginManager authenticationPluginManager, IExternalAuthenticationService externalAuthenticationService, ILocalizationService localizationService, INotificationService notificationService, IOptionsMonitorCache <FacebookOptions> optionsCache, IPermissionService permissionService, ISettingService settingService, IStoreContext storeContext, IWorkContext workContext) { _facebookExternalAuthSettings = facebookExternalAuthSettings; _authenticationPluginManager = authenticationPluginManager; _externalAuthenticationService = externalAuthenticationService; _localizationService = localizationService; _notificationService = notificationService; _optionsCache = optionsCache; _permissionService = permissionService; _settingService = settingService; _storeContext = storeContext; _workContext = workContext; }
public FacebookAuthenticationController(FacebookExternalAuthSettings facebookExternalAuthSettings, IExternalAuthenticationService externalAuthenticationService) { _facebookExternalAuthSettings = facebookExternalAuthSettings; _externalAuthenticationService = externalAuthenticationService; }
public ActionResult Configure(FacebookExternalAuthSettings settings) { return(View(settings)); }