4using System.Threading.Tasks;
6using Microsoft.AspNetCore.Authorization;
7using Microsoft.AspNetCore.Mvc;
8using Microsoft.Extensions.Logging;
9using Microsoft.Extensions.Options;
10using Microsoft.Extensions.Primitives;
11using Microsoft.Net.Http.Headers;
95 IOptions<GeneralConfiguration> generalConfigurationOptions,
96 ILogger<ApiRootController> logger,
101 authenticationContext,
111 generalConfiguration = generalConfigurationOptions?.Value ??
throw new ArgumentNullException(nameof(generalConfigurationOptions));
141 failIfUnauthed = Request.Headers.Authorization.Count > 0;
144 failIfUnauthed = ApiHeaders.Token !=
null;
181 public ValueTask<IActionResult>
CreateToken(CancellationToken cancellationToken)
185 Response.Headers.Add(HeaderNames.WWWAuthenticate,
new StringValues($
"basic realm=\"Create TGS {ApiHeaders.BearerAuthenticationScheme} token\""));
200 [HttpPost(
"oauth_gateway")]
Represents an error message returned by the server.
Success result for an OAuth gateway login attempt.
Represents a JWT returned by the API.
Routes to a server actions.
const string ApiRoot
The root of API methods.
Constants used for communication with the DMAPI.
static readonly Version InteropVersion
The DMAPI InteropVersion being used.
General configuration options.
Base Controller for API functions.
IActionResult HeadersIssue(HeadersException headersException)
Response for missing/Invalid headers.
Root ApiController for the Application.
ValueTask< IActionResult > CreateOAuthGatewayToken(CancellationToken cancellationToken)
Attempt to authenticate a User using ApiController.ApiHeaders.
ValueTask< IActionResult > CreateToken(CancellationToken cancellationToken)
Attempt to authenticate a User using ApiController.ApiHeaders.
readonly IServerControl serverControl
The IServerControl for the ApiRootController.
readonly IRestAuthorityInvoker< ILoginAuthority > loginAuthority
The IRestAuthorityInvoker<TAuthority> for the ILoginAuthority.
readonly IPlatformIdentifier platformIdentifier
The IPlatformIdentifier for the ApiRootController.
readonly GeneralConfiguration generalConfiguration
The GeneralConfiguration for the ApiRootController.
IActionResult ServerInfo()
Main page of the Application.
readonly IAssemblyInformationProvider assemblyInformationProvider
The IAssemblyInformationProvider for the ApiRootController.
ApiRootController(IDatabaseContext databaseContext, IAuthenticationContext authenticationContext, IAssemblyInformationProvider assemblyInformationProvider, IOAuthProviders oAuthProviders, IPlatformIdentifier platformIdentifier, ISwarmService swarmService, IServerControl serverControl, IOptions< GeneralConfiguration > generalConfigurationOptions, ILogger< ApiRootController > logger, IApiHeadersProvider apiHeadersProvider, IRestAuthorityInvoker< ILoginAuthority > loginAuthority)
Initializes a new instance of the ApiRootController class.
readonly IOAuthProviders oAuthProviders
The IOAuthProviders for the ApiRootController.
readonly ISwarmService swarmService
The ISwarmService for the ApiRootController.
Success response for a login attempt.
Success result for an OAuth gateway login attempt.
bool Valid
If the IAuthenticationContext is for a valid login.
Invokes TAuthority methods and generates IActionResult responses.
Represents a service that may take an updated Host assembly and run it, stopping the current assembly...
bool UpdateInProgress
Whether or not the server is currently updating.
For creating and accessing authentication contexts.
Contains IOAuthValidators.
Dictionary< OAuthProvider, OAuthProviderInfo > ProviderInfos()
Gets a Dictionary<TKey, TValue> of the provider client IDs.
Used for swarm operations. Functions may be no-op based on configuration.
List< SwarmServerInformation >? GetSwarmServers()
Gets the list of SwarmServerInformations in the swarm, including the current one.
@ UpdateInProgress
Another update is already in progress.
@ Unauthorized
The swarm private keys didn't match.