tgstation-server 6.12.0
The /tg/station 13 server suite
|
Represents the header that must be present for every server request. More...
Public Member Functions | |
ApiHeaders (ProductHeaderValue userAgent, TokenResponse token) | |
Initializes a new instance of the ApiHeaders class. Used for token authentication. | |
ApiHeaders (ProductHeaderValue userAgent, string oAuthCode, OAuthProvider oAuthProvider) | |
Initializes a new instance of the ApiHeaders class. Used for token authentication. | |
ApiHeaders (ProductHeaderValue userAgent, string username, string password) | |
Initializes a new instance of the ApiHeaders class. Used for password authentication. | |
ApiHeaders (RequestHeaders requestHeaders, bool ignoreMissingAuth, bool allowEventStreamAccept) | |
Initializes a new instance of the ApiHeaders class. | |
bool | Compatible (Version? alternateApiVersion=null) |
Checks if the ApiVersion is compatible with Version. | |
void | SetRequestHeaders (HttpRequestHeaders headers, long? instanceId=null) |
Set HttpRequestHeaders using the ApiHeaders. This initially clears headers . | |
void | SetHubConnectionHeaders (IDictionary< string, string > headers) |
Adds the headers necessary for a SignalR hub connection. | |
Static Public Member Functions | |
static bool | CheckCompatibility (Version otherVersion) |
Checks if a given otherVersion is compatible with our own. | |
Static Public Attributes | |
const string | ApiVersionHeader = "Api" |
The ApiVersion header key. | |
const string | InstanceIdHeader = "Instance" |
The InstanceId header key. | |
const string | OAuthProviderHeader = "OAuthProvider" |
The OAuthProvider header key. | |
const string | BearerAuthenticationScheme = "Bearer" |
The JWT authentication header scheme. | |
const string | BasicAuthenticationScheme = "Basic" |
The JWT authentication header scheme. | |
const string | OAuthAuthenticationScheme = "OAuth" |
The JWT authentication header scheme. | |
const string | ApplicationJsonMime = "application/json" |
Added to MediaTypeNames.Application in netstandard2.1. Can't use because of lack of .NET Framework support. | |
static readonly Version | Version = Version.Parse(ApiVersionAttribute.Instance.RawApiVersion) |
Get the version of the Api the caller is using. | |
Properties | |
long? | InstanceId [get, set] |
The instance EntityId.Id being accessed. | |
ProductHeaderValue? | UserAgent [get] |
The client's user agent as a ProductHeaderValue if valid. | |
string? | RawUserAgent [get] |
The client's raw user agent. | |
Version | ApiVersion [get] |
The client's API version. | |
TokenResponse? | Token [get] |
The client's TokenResponse. | |
string? | Username [get] |
The client's username. | |
string? | Password [get] |
The client's password. | |
string? | OAuthCode [get] |
The OAuth code in use. | |
OAuthProvider? | OAuthProvider [get] |
The Models.OAuthProvider the Token is for, if any. | |
bool | IsTokenAuthentication [get] |
If the header uses OAuth or TGS JWT authentication. | |
Private Member Functions | |
ApiHeaders (ProductHeaderValue userAgent, TokenResponse? token, string? username, string? password) | |
Initializes a new instance of the ApiHeaders class. | |
string | CreateApiVersionHeader () |
Create the stringified for of the ApiVersionHeader. | |
Static Private Attributes | |
const string | TextEventStreamMime = "text/event-stream" |
Added to MediaTypeNames.Application in netstandard2.1. Can't use because of lack of .NET Framework support. | |
static readonly AssemblyName | AssemblyName = Assembly.GetExecutingAssembly().GetName() |
The current System.Reflection.AssemblyName. | |
static readonly char[] | ColonSeparator = [':'] |
A char Array containing the ':' char. | |
Represents the header that must be present for every server request.
Definition at line 24 of file ApiHeaders.cs.
Tgstation.Server.Api.ApiHeaders.ApiHeaders | ( | ProductHeaderValue | userAgent, |
TokenResponse | token | ||
) |
Initializes a new instance of the ApiHeaders class. Used for token authentication.
userAgent | The value of UserAgent. |
token | The value of Token. |
Definition at line 143 of file ApiHeaders.cs.
References Tgstation.Server.Api.Models.Response.TokenResponse.Bearer.
Tgstation.Server.Api.ApiHeaders.ApiHeaders | ( | ProductHeaderValue | userAgent, |
string | oAuthCode, | ||
OAuthProvider | oAuthProvider | ||
) |
Initializes a new instance of the ApiHeaders class. Used for token authentication.
userAgent | The value of UserAgent. |
oAuthCode | The value of OAuthCode. |
oAuthProvider | The value of OAuthProvider. |
Definition at line 160 of file ApiHeaders.cs.
References Tgstation.Server.Api.ApiHeaders.OAuthCode.
Tgstation.Server.Api.ApiHeaders.ApiHeaders | ( | ProductHeaderValue | userAgent, |
string | username, | ||
string | password | ||
) |
Initializes a new instance of the ApiHeaders class. Used for password authentication.
userAgent | The value of UserAgent. |
username | The value of Username. |
password | The value of Password. |
Definition at line 176 of file ApiHeaders.cs.
Tgstation.Server.Api.ApiHeaders.ApiHeaders | ( | RequestHeaders | requestHeaders, |
bool | ignoreMissingAuth, | ||
bool | allowEventStreamAccept | ||
) |
Initializes a new instance of the ApiHeaders class.
requestHeaders | The RequestHeaders containing the serialized ApiHeaders. |
ignoreMissingAuth | If a missing HeaderNames.Authorization should be ignored. |
allowEventStreamAccept | If TextEventStreamMime is a valid accept. |
HeadersException | Thrown if the requestHeaders constitue invalid ApiHeaders. |
Definition at line 195 of file ApiHeaders.cs.
References Tgstation.Server.Api.ApiHeaders.ApiVersion, Tgstation.Server.Api.ApiHeaders.ApiVersionHeader, Tgstation.Server.Api.ApiHeaders.ApplicationJsonMime, Tgstation.Server.Api.ApiHeaders.AssemblyName, Tgstation.Server.Api.ApiHeaders.BasicAuthenticationScheme, Tgstation.Server.Api.ApiHeaders.BearerAuthenticationScheme, Tgstation.Server.Api.ApiHeaders.ColonSeparator, Tgstation.Server.Api.ApiHeaders.InstanceId, Tgstation.Server.Api.ApiHeaders.InstanceIdHeader, Tgstation.Server.Api.ApiHeaders.OAuthAuthenticationScheme, Tgstation.Server.Api.ApiHeaders.OAuthCode, Tgstation.Server.Api.ApiHeaders.OAuthProviderHeader, Tgstation.Server.Api.Models.Response.TokenResponse.ParseJwt(), Tgstation.Server.Api.ApiHeaders.Password, Tgstation.Server.Api.ApiHeaders.RawUserAgent, Tgstation.Server.Api.ApiHeaders.TextEventStreamMime, Tgstation.Server.Api.ApiHeaders.Token, Tgstation.Server.Api.ApiHeaders.Username, and Tgstation.Server.Api.ApiHeaders.Version.
|
private |
Initializes a new instance of the ApiHeaders class.
userAgent | The value of UserAgent. |
token | The value of Token. |
username | The value of Username. |
password | The value of Password. |
Definition at line 349 of file ApiHeaders.cs.
References Tgstation.Server.Api.ApiHeaders.ApiVersion, Tgstation.Server.Api.ApiHeaders.Password, Tgstation.Server.Api.ApiHeaders.RawUserAgent, Tgstation.Server.Api.ApiHeaders.Token, Tgstation.Server.Api.ApiHeaders.Username, and Tgstation.Server.Api.ApiHeaders.Version.
|
static |
Checks if a given otherVersion is compatible with our own.
otherVersion | The Version to test. |
true
if the given version is compatible with the API. false
otherwise.bool Tgstation.Server.Api.ApiHeaders.Compatible | ( | Version? | alternateApiVersion = null | ) |
Checks if the ApiVersion is compatible with Version.
alternateApiVersion | The System.Version that can alternatively be used as the ApiVersion. |
true
if the API is compatible, false
otherwise.
|
private |
Create the stringified for of the ApiVersionHeader.
Referenced by Tgstation.Server.Api.ApiHeaders.SetHubConnectionHeaders(), and Tgstation.Server.Api.ApiHeaders.SetRequestHeaders().
void Tgstation.Server.Api.ApiHeaders.SetHubConnectionHeaders | ( | IDictionary< string, string > | headers | ) |
Adds the headers necessary for a SignalR hub connection.
headers | The headers IDictionary<TKey, TValue> to write to. |
Definition at line 402 of file ApiHeaders.cs.
References Tgstation.Server.Api.ApiHeaders.ApiVersionHeader, Tgstation.Server.Api.ApiHeaders.ApplicationJsonMime, Tgstation.Server.Api.ApiHeaders.CreateApiVersionHeader(), and Tgstation.Server.Api.ApiHeaders.RawUserAgent.
Referenced by Tgstation.Server.Client.ApiClient.CreateHubConnection< THubImplementation >().
void Tgstation.Server.Api.ApiHeaders.SetRequestHeaders | ( | HttpRequestHeaders | headers, |
long? | instanceId = null |
||
) |
Set HttpRequestHeaders using the ApiHeaders. This initially clears headers .
headers | The HttpRequestHeaders to set. |
instanceId | The instance EntityId.Id for the request. |
Definition at line 370 of file ApiHeaders.cs.
References Tgstation.Server.Api.ApiHeaders.ApiVersionHeader, Tgstation.Server.Api.ApiHeaders.ApplicationJsonMime, Tgstation.Server.Api.ApiHeaders.BasicAuthenticationScheme, Tgstation.Server.Api.ApiHeaders.BearerAuthenticationScheme, Tgstation.Server.Api.ApiHeaders.CreateApiVersionHeader(), Tgstation.Server.Api.ApiHeaders.InstanceId, Tgstation.Server.Api.ApiHeaders.InstanceIdHeader, Tgstation.Server.Api.ApiHeaders.IsTokenAuthentication, Tgstation.Server.Api.ApiHeaders.OAuthAuthenticationScheme, Tgstation.Server.Api.ApiHeaders.OAuthCode, Tgstation.Server.Api.ApiHeaders.OAuthProviderHeader, Tgstation.Server.Api.ApiHeaders.Token, and Tgstation.Server.Api.ApiHeaders.UserAgent.
Referenced by Tgstation.Server.Client.ApiClient.RunRequest< TResult >().
|
static |
The ApiVersion header key.
Definition at line 29 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Api.ApiHeaders.SetHubConnectionHeaders(), Tgstation.Server.Api.ApiHeaders.SetRequestHeaders(), and Tgstation.Server.Client.GraphQL.GraphQLServerClientFactory.SetupServiceProvider().
|
static |
Added to MediaTypeNames.Application in netstandard2.1. Can't use because of lack of .NET Framework support.
Definition at line 59 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Client.ApiClient.RunRequest< TBody, TResult >(), Tgstation.Server.Api.ApiHeaders.SetHubConnectionHeaders(), and Tgstation.Server.Api.ApiHeaders.SetRequestHeaders().
|
staticprivate |
The current System.Reflection.AssemblyName.
Definition at line 74 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders().
|
static |
The JWT authentication header scheme.
Definition at line 49 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Host.Utils.SwaggerConfiguration.Configure(), Tgstation.Server.Client.GraphQL.GraphQLServerClientFactory.CreateFromLogin(), and Tgstation.Server.Api.ApiHeaders.SetRequestHeaders().
|
static |
The JWT authentication header scheme.
Definition at line 44 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Host.Utils.SwaggerConfiguration.Configure(), Tgstation.Server.Client.GraphQL.GraphQLServerClientFactory.CreateFromToken(), Tgstation.Server.Host.IO.FileDownloader.DownloadFile(), Tgstation.Server.Api.ApiHeaders.SetRequestHeaders(), and Tgstation.Server.Host.Security.OAuth.GenericOAuthValidator.ValidateResponseCode().
|
staticprivate |
A char Array containing the ':' char.
Definition at line 79 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders().
|
static |
The InstanceId header key.
Definition at line 34 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Host.Utils.SwaggerConfiguration.Apply(), Tgstation.Server.Host.Utils.SwaggerConfiguration.Apply(), and Tgstation.Server.Api.ApiHeaders.SetRequestHeaders().
|
static |
The JWT authentication header scheme.
Definition at line 54 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Host.Utils.SwaggerConfiguration.Configure(), Tgstation.Server.Client.GraphQL.GraphQLServerClientFactory.CreateFromOAuth(), and Tgstation.Server.Api.ApiHeaders.SetRequestHeaders().
|
static |
The OAuthProvider header key.
Definition at line 39 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Host.Utils.SwaggerConfiguration.Apply(), Tgstation.Server.Api.ApiHeaders.SetRequestHeaders(), and Tgstation.Server.Client.GraphQL.GraphQLServerClientFactory.SetupServiceProvider().
|
staticprivate |
Added to MediaTypeNames.Application in netstandard2.1. Can't use because of lack of .NET Framework support.
Definition at line 64 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders().
|
static |
Get the version of the Api the caller is using.
Definition at line 69 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Host.Utils.SwaggerConfiguration.Configure(), Tgstation.Server.Api.Models.Response.ErrorMessageResponse.ErrorMessageResponse(), Tgstation.Server.Host.Controllers.ControlPanelController.GetChannelJson(), and Tgstation.Server.Host.Controllers.ApiRootController.ServerInfo().
|
get |
The client's API version.
Definition at line 99 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Api.ApiHeaders.ApiHeaders(), and Tgstation.Server.Host.Controllers.ApiController.HookExecuteAction().
|
getset |
The instance EntityId.Id being accessed.
Definition at line 84 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Host.Controllers.ApiController.HookExecuteAction(), Tgstation.Server.Api.ApiHeaders.SetRequestHeaders(), and Tgstation.Server.Host.Security.AuthenticationContextFactory.ValidateToken().
|
get |
If the header uses OAuth or TGS JWT authentication.
Definition at line 129 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.SetRequestHeaders().
|
get |
The OAuth code in use.
Definition at line 119 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Api.ApiHeaders.SetRequestHeaders(), and Tgstation.Server.Host.Authority.LoginAuthority.TryOAuthenticate< TResult >().
|
get |
The Models.OAuthProvider the Token is for, if any.
Definition at line 124 of file ApiHeaders.cs.
|
get |
The client's password.
Definition at line 114 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), and Tgstation.Server.Api.ApiHeaders.ApiHeaders().
|
get |
The client's raw user agent.
Definition at line 94 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Host.Controllers.ApiController.HookExecuteAction(), and Tgstation.Server.Api.ApiHeaders.SetHubConnectionHeaders().
|
get |
The client's TokenResponse.
Definition at line 104 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Api.ApiHeaders.ApiHeaders(), Tgstation.Server.Client.ApiClient.RefreshToken(), and Tgstation.Server.Api.ApiHeaders.SetRequestHeaders().
|
get |
The client's user agent as a ProductHeaderValue if valid.
Definition at line 89 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Client.ApiClient.RefreshToken(), and Tgstation.Server.Api.ApiHeaders.SetRequestHeaders().
|
get |
The client's username.
Definition at line 109 of file ApiHeaders.cs.
Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), and Tgstation.Server.Api.ApiHeaders.ApiHeaders().