public HttpResponseMessage UpdateGeneralSettings(AzureADB2CProviderSettings settings) { try { var config = new AzureConfig(AzureConfig.ServiceName, PortalId); if (!UserInfo.IsSuperUser) { if (config.UseGlobalSettings || config.UseGlobalSettings != settings.UseGlobalSettings) { return(Request.CreateResponse(HttpStatusCode.Forbidden, "Only super users can change this setting")); } } AzureADB2CProviderSettings.SaveGeneralSettings(AzureConfig.ServiceName, PortalId, settings); AddUserProfilePage(PortalId, settings.Enabled && !string.IsNullOrEmpty(settings.ProfilePolicy)); // If UseGlobalSettigns was set to false, we have to create mappings if there're no mappings for the current portal if (config.UseGlobalSettings != settings.UseGlobalSettings && settings.UseGlobalSettings == false) { PrepareUserMappingsForCurrentPortal(); } return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true })); } catch (Exception ex) { Logger.Error(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public HttpResponseMessage GetSettings() { try { var settings = AzureADB2CProviderSettings.LoadSettings(AzureConfig.ServiceName, PortalId); return(Request.CreateResponse(HttpStatusCode.OK, settings)); } catch (Exception ex) { Logger.Error(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public HttpResponseMessage UpdateAdvancedSettings(AzureADB2CProviderSettings settings) { try { AzureADB2CProviderSettings.SaveAdvancedSettings("AzureB2C", PortalId, settings); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { Logger.Error(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public HttpResponseMessage UpdateGeneralSettings(AzureADB2CProviderSettings settings) { try { AzureADB2CProviderSettings.SaveGeneralSettings("AzureB2C", PortalId, settings); AddUserProfilePage(PortalId, settings.Enabled && !string.IsNullOrEmpty(settings.ProfilePolicy)); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { Logger.Error(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public static void SaveAdvancedSettings(string service, int portalId, AzureADB2CProviderSettings settings) { var config = new AzureConfig(service, portalId) { AADApplicationId = settings.AadAppClientId, AADApplicationKey = settings.AadAppSecret, JwtAudiences = settings.JwtAudiences, RoleSyncEnabled = settings.RoleSyncEnabled, ProfileSyncEnabled = settings.ProfileSyncEnabled, JwtAuthEnabled = settings.JwtAuthEnabled, APIResource = settings.ApiResource + (!string.IsNullOrEmpty(settings.ApiResource.Trim()) && !settings.ApiResource.EndsWith("/") ? "/" : ""), Scopes = settings.Scopes }; AzureConfig.UpdateConfig(config); }
public static void SaveGeneralSettings(string service, int portalId, AzureADB2CProviderSettings settings) { var config = new AzureConfig(service, portalId) { TenantName = settings.TenantName.ToLowerInvariant().Trim().Replace(".onmicrosoft.com", ""), TenantId = settings.TenantId, APIKey = settings.ApiKey, APISecret = settings.ApiSecret, AutoRedirect = settings.AutoRedirect, SignUpPolicy = settings.SignUpPolicy, ProfilePolicy = settings.ProfilePolicy, PasswordResetPolicy = settings.PasswordResetPolicy, Enabled = settings.Enabled, }; AzureConfig.UpdateConfig(config); }
public HttpResponseMessage UpdateAdvancedSettings(AzureADB2CProviderSettings settings) { try { if (!UserInfo.IsSuperUser) { var config = new AzureConfig(AzureConfig.ServiceName, PortalId); if (config.UseGlobalSettings || config.UseGlobalSettings != settings.UseGlobalSettings) { return(Request.CreateResponse(HttpStatusCode.Forbidden, "Only super users can change this setting")); } } AzureADB2CProviderSettings.SaveAdvancedSettings(AzureConfig.ServiceName, PortalId, settings); return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true })); } catch (Exception ex) { Logger.Error(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }