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;
101 IOptions<GeneralConfiguration> generalConfigurationOptions,
102 IOptionsSnapshot<SecurityConfiguration> securityConfigurationOptions,
103 ILogger<ApiRootController> logger,
108 authenticationContext,
118 generalConfiguration = generalConfigurationOptions?.Value ??
throw new ArgumentNullException(nameof(generalConfigurationOptions));
119 securityConfiguration = securityConfigurationOptions?.Value ??
throw new ArgumentNullException(nameof(securityConfigurationOptions));
149 failIfUnauthed = Request.Headers.Authorization.Count > 0;
152 failIfUnauthed = ApiHeaders.Token !=
null;
191 public ValueTask<IActionResult>
CreateToken(CancellationToken cancellationToken)
195 Response.Headers.Add(HeaderNames.WWWAuthenticate,
new StringValues($
"basic realm=\"Create TGS {ApiHeaders.BearerAuthenticationScheme} token\""));
210 [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.
Configuration options pertaining to user security.
IEnumerable< OidcProviderInfo > OidcProviderInfos()
Get the OidcProviderInfos from the SecurityConfiguration.
bool OidcStrictMode
If OIDC strict mode should be enabled. This mode enforces the existence of at least one OpenIDConnect...
Base Controller for API functions.
IActionResult HeadersIssue(HeadersException headersException)
Response for missing/Invalid headers.
Root ApiController for the Application.
ApiRootController(IDatabaseContext databaseContext, IAuthenticationContext authenticationContext, IAssemblyInformationProvider assemblyInformationProvider, IOAuthProviders oAuthProviders, IPlatformIdentifier platformIdentifier, ISwarmService swarmService, IServerControl serverControl, IOptions< GeneralConfiguration > generalConfigurationOptions, IOptionsSnapshot< SecurityConfiguration > securityConfigurationOptions, ILogger< ApiRootController > logger, IApiHeadersProvider apiHeadersProvider, IRestAuthorityInvoker< ILoginAuthority > loginAuthority)
Initializes a new instance of the ApiRootController class.
readonly SecurityConfiguration securityConfiguration
The SecurityConfiguration for the ApiRootController.
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.
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.