#pragma warning disable CA1506 public async Task <IActionResult> Home(CancellationToken cancellationToken) { if (controlPanelConfiguration.Enable) { Response.Headers.Add( HeaderNames.Vary, new StringValues( new[] { HeaderNames.UserAgent, ApiHeaders.ApiVersionHeader })); } // we only allow authorization header issues if (ApiHeaders == null) { // if we are using a browser and the control panel, redirect to the app page if (controlPanelConfiguration.Enable && browserResolver.Browser.Type != BrowserType.Generic) { Logger.LogDebug("Unauthorized browser request (User-Agent: \"{0}\"), redirecting to control panel...", browserResolver.UserAgent); return(Redirect(Core.Application.ControlPanelRoute)); } try { var headers = new ApiHeaders(Request.GetTypedHeaders(), true); if (!headers.Compatible()) { return(StatusCode( HttpStatusCode.UpgradeRequired, new ErrorMessage(ErrorCode.ApiMismatch))); } } catch (HeadersException) { return(HeadersIssue(true)); } } return(Json(new ServerInformation { Version = assemblyInformationProvider.Version, ApiVersion = ApiHeaders.Version, DMApiVersion = DMApiConstants.Version, MinimumPasswordLength = generalConfiguration.MinimumPasswordLength, InstanceLimit = generalConfiguration.InstanceLimit, UserLimit = generalConfiguration.UserLimit, UserGroupLimit = generalConfiguration.UserGroupLimit, ValidInstancePaths = generalConfiguration.ValidInstancePaths, WindowsHost = platformIdentifier.IsWindows, SwarmServers = swarmService.GetSwarmServers(), OAuthProviderInfos = await oAuthProviders.ProviderInfos(cancellationToken).ConfigureAwait(false), UpdateInProgress = serverControl.UpdateInProgress, })); }
#pragma warning disable CA1506 public async Task <IActionResult> Home(CancellationToken cancellationToken) { if (controlPanelConfiguration.Enable) { Response.Headers.Add( HeaderNames.Vary, new StringValues( new[] { ApiHeaders.ApiVersionHeader })); } if (ApiHeaders == null) { if (controlPanelConfiguration.Enable && !Request.Headers.TryGetValue(ApiHeaders.ApiVersionHeader, out _)) { Logger.LogDebug("No API headers on request, redirecting to control panel..."); return(Redirect(ControlPanelController.ControlPanelRoute)); } try { // we only allow authorization header issues var headers = new ApiHeaders(Request.GetTypedHeaders(), true); if (!headers.Compatible()) { return(StatusCode( HttpStatusCode.UpgradeRequired, new ErrorMessageResponse(ErrorCode.ApiMismatch))); } } catch (HeadersException) { return(HeadersIssue(true)); } } return(Json(new ServerInformationResponse { Version = assemblyInformationProvider.Version, ApiVersion = ApiHeaders.Version, DMApiVersion = DMApiConstants.InteropVersion, MinimumPasswordLength = generalConfiguration.MinimumPasswordLength, InstanceLimit = generalConfiguration.InstanceLimit, UserLimit = generalConfiguration.UserLimit, UserGroupLimit = generalConfiguration.UserGroupLimit, ValidInstancePaths = generalConfiguration.ValidInstancePaths, WindowsHost = platformIdentifier.IsWindows, SwarmServers = swarmService.GetSwarmServers(), OAuthProviderInfos = await oAuthProviders.ProviderInfos(cancellationToken).ConfigureAwait(false), UpdateInProgress = serverControl.UpdateInProgress, })); }