tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | Private Member Functions | Static Private Attributes | List of all members
Tgstation.Server.Api.ApiHeaders Class Referencesealed

Represents the header that must be present for every server request. More...

Collaboration diagram for Tgstation.Server.Api.ApiHeaders:
Collaboration graph
[legend]

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.
 
TokenResponseToken [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.
 
OAuthProviderOAuthProvider [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.
 

Detailed Description

Represents the header that must be present for every server request.

Definition at line 24 of file ApiHeaders.cs.

Constructor & Destructor Documentation

◆ ApiHeaders() [1/5]

Tgstation.Server.Api.ApiHeaders.ApiHeaders ( ProductHeaderValue  userAgent,
TokenResponse  token 
)

Initializes a new instance of the ApiHeaders class. Used for token authentication.

Parameters
userAgentThe value of UserAgent.
tokenThe value of Token.

Definition at line 143 of file ApiHeaders.cs.

144 : this(userAgent, token, null, null)
145 {
146 if (userAgent == null)
147 throw new ArgumentNullException(nameof(userAgent));
148 if (token == null)
149 throw new ArgumentNullException(nameof(token));
150 if (token.Bearer == null)
151 throw new InvalidOperationException("token.Bearer must be set!");
152 }

References Tgstation.Server.Api.Models.Response.TokenResponse.Bearer.

◆ ApiHeaders() [2/5]

Tgstation.Server.Api.ApiHeaders.ApiHeaders ( ProductHeaderValue  userAgent,
string  oAuthCode,
OAuthProvider  oAuthProvider 
)

Initializes a new instance of the ApiHeaders class. Used for token authentication.

Parameters
userAgentThe value of UserAgent.
oAuthCodeThe value of OAuthCode.
oAuthProviderThe value of OAuthProvider.

Definition at line 160 of file ApiHeaders.cs.

161 : this(userAgent, null, null, null)
162 {
163 if (userAgent == null)
164 throw new ArgumentNullException(nameof(userAgent));
165
166 OAuthCode = oAuthCode ?? throw new ArgumentNullException(nameof(oAuthCode));
167 OAuthProvider = oAuthProvider;
168 }
string? OAuthCode
The OAuth code in use.
OAuthProvider
List of OAuth providers supported by TGS.

References Tgstation.Server.Api.ApiHeaders.OAuthCode.

◆ ApiHeaders() [3/5]

Tgstation.Server.Api.ApiHeaders.ApiHeaders ( ProductHeaderValue  userAgent,
string  username,
string  password 
)

Initializes a new instance of the ApiHeaders class. Used for password authentication.

Parameters
userAgentThe value of UserAgent.
usernameThe value of Username.
passwordThe value of Password.

Definition at line 176 of file ApiHeaders.cs.

177 : this(userAgent, null, username, password)
178 {
179 if (userAgent == null)
180 throw new ArgumentNullException(nameof(userAgent));
181 if (username == null)
182 throw new ArgumentNullException(nameof(username));
183 if (password == null)
184 throw new ArgumentNullException(nameof(password));
185 }

◆ ApiHeaders() [4/5]

Tgstation.Server.Api.ApiHeaders.ApiHeaders ( RequestHeaders  requestHeaders,
bool  ignoreMissingAuth,
bool  allowEventStreamAccept 
)

Initializes a new instance of the ApiHeaders class.

Parameters
requestHeadersThe RequestHeaders containing the serialized ApiHeaders.
ignoreMissingAuthIf a missing HeaderNames.Authorization should be ignored.
allowEventStreamAcceptIf TextEventStreamMime is a valid accept.
Exceptions
HeadersExceptionThrown if the requestHeaders constitue invalid ApiHeaders.

Definition at line 195 of file ApiHeaders.cs.

196 {
197 if (requestHeaders == null)
198 throw new ArgumentNullException(nameof(requestHeaders));
199
200 var badHeaders = HeaderErrorTypes.None;
201 var errorBuilder = new StringBuilder();
202 var multipleErrors = false;
203 void AddError(HeaderErrorTypes headerType, string message)
204 {
205 if (badHeaders != HeaderErrorTypes.None)
206 {
207 multipleErrors = true;
208 errorBuilder.AppendLine();
209 }
210
211 badHeaders |= headerType;
212 errorBuilder.Append(message);
213 }
214
215 var jsonAccept = new Microsoft.Net.Http.Headers.MediaTypeHeaderValue(ApplicationJsonMime);
216 var eventStreamAccept = new Microsoft.Net.Http.Headers.MediaTypeHeaderValue(TextEventStreamMime);
217 if (!requestHeaders.Accept.Any(accept => accept.IsSubsetOf(jsonAccept)))
218 if (!allowEventStreamAccept)
219 AddError(HeaderErrorTypes.Accept, $"Client does not accept {ApplicationJsonMime}!");
220 else if (!requestHeaders.Accept.Any(eventStreamAccept.IsSubsetOf))
221 AddError(HeaderErrorTypes.Accept, $"Client does not accept {ApplicationJsonMime} or {TextEventStreamMime}!");
222
223 if (!requestHeaders.Headers.TryGetValue(HeaderNames.UserAgent, out var userAgentValues) || userAgentValues.Count == 0)
224 AddError(HeaderErrorTypes.UserAgent, $"Missing {HeaderNames.UserAgent} header!");
225 else
226 {
227 RawUserAgent = userAgentValues.First();
228 if (String.IsNullOrWhiteSpace(RawUserAgent))
229 AddError(HeaderErrorTypes.UserAgent, $"Malformed {HeaderNames.UserAgent} header!");
230 }
231
232 // make sure the api header matches ours
233 Version? apiVersion = null;
234 if (!requestHeaders.Headers.TryGetValue(ApiVersionHeader, out var apiUserAgentHeaderValues) || !ProductInfoHeaderValue.TryParse(apiUserAgentHeaderValues.FirstOrDefault(), out var apiUserAgent) || apiUserAgent.Product.Name != AssemblyName.Name)
235 AddError(HeaderErrorTypes.Api, $"Missing {ApiVersionHeader} header!");
236 else if (!Version.TryParse(apiUserAgent.Product.Version, out apiVersion))
237 AddError(HeaderErrorTypes.Api, $"Malformed {ApiVersionHeader} header!");
238
239 if (!requestHeaders.Headers.TryGetValue(HeaderNames.Authorization, out StringValues authorization))
240 {
241 if (!ignoreMissingAuth)
242 AddError(HeaderErrorTypes.AuthorizationMissing, $"Missing {HeaderNames.Authorization} header!");
243 }
244 else
245 {
246 var auth = authorization.First();
247 var splits = new List<string>(auth.Split(' '));
248 var scheme = splits.First();
249 if (String.IsNullOrWhiteSpace(scheme))
250 AddError(HeaderErrorTypes.AuthorizationInvalid, "Missing authentication scheme!");
251 else
252 {
253 splits.RemoveAt(0);
254 var parameter = String.Concat(splits);
255 if (String.IsNullOrEmpty(parameter))
256 AddError(HeaderErrorTypes.AuthorizationInvalid, "Missing authentication parameter!");
257 else
258 {
259 if (requestHeaders.Headers.TryGetValue(InstanceIdHeader, out var instanceIdValues))
260 {
261 var instanceIdString = instanceIdValues.FirstOrDefault();
262 if (instanceIdString != default && Int64.TryParse(instanceIdString, out var instanceId))
263 InstanceId = instanceId;
264 }
265
266 switch (scheme)
267 {
269 if (requestHeaders.Headers.TryGetValue(OAuthProviderHeader, out StringValues oauthProviderValues))
270 {
271 var oauthProviderString = oauthProviderValues.First();
272 if (Enum.TryParse<OAuthProvider>(oauthProviderString, true, out var oauthProvider))
273 OAuthProvider = oauthProvider;
274 else
275 AddError(HeaderErrorTypes.OAuthProvider, "Invalid OAuth provider!");
276 }
277 else
278 AddError(HeaderErrorTypes.OAuthProvider, $"Missing {OAuthProviderHeader} header!");
279
280 OAuthCode = parameter;
281 break;
283 Token = new TokenResponse
284 {
285 Bearer = parameter,
286 };
287
288 try
289 {
290 Token.ParseJwt();
291 }
292 catch (ArgumentException ex) when (ex is not ArgumentNullException)
293 {
294 AddError(HeaderErrorTypes.AuthorizationInvalid, $"Invalid JWT: {ex.Message}");
295 }
296
297 break;
299 string badBasicAuthHeaderMessage = $"Invalid basic {HeaderNames.Authorization} header!";
300 string joinedString;
301 try
302 {
303 var base64Bytes = Convert.FromBase64String(parameter);
304 joinedString = Encoding.UTF8.GetString(base64Bytes);
305 }
306 catch
307 {
308 AddError(HeaderErrorTypes.AuthorizationInvalid, badBasicAuthHeaderMessage);
309 break;
310 }
311
312 var basicAuthSplits = joinedString.Split(ColonSeparator, StringSplitOptions.RemoveEmptyEntries);
313 if (basicAuthSplits.Length < 2)
314 {
315 AddError(HeaderErrorTypes.AuthorizationInvalid, badBasicAuthHeaderMessage);
316 break;
317 }
318
319 Username = basicAuthSplits.First();
320 Password = String.Concat(basicAuthSplits.Skip(1));
321 break;
322 default:
323 AddError(HeaderErrorTypes.AuthorizationInvalid, "Invalid authentication scheme!");
324 break;
325 }
326 }
327 }
328 }
329
330 if (badHeaders != HeaderErrorTypes.None)
331 {
332 if (multipleErrors)
333 errorBuilder.Insert(0, $"Multiple header validation errors occurred:{Environment.NewLine}");
334
335 throw new HeadersException(badHeaders, errorBuilder.ToString());
336 }
337
338 ApiVersion = apiVersion!.Semver();
339 }
const string OAuthAuthenticationScheme
The JWT authentication header scheme.
Definition ApiHeaders.cs:54
string? RawUserAgent
The client's raw user agent.
Definition ApiHeaders.cs:94
const string InstanceIdHeader
The InstanceId header key.
Definition ApiHeaders.cs:34
string? Username
The client's username.
static readonly char[] ColonSeparator
A char Array containing the ':' char.
Definition ApiHeaders.cs:79
Version ApiVersion
The client's API version.
Definition ApiHeaders.cs:99
TokenResponse? Token
The client's TokenResponse.
long? InstanceId
The instance EntityId.Id being accessed.
Definition ApiHeaders.cs:84
static readonly Version Version
Get the version of the Api the caller is using.
Definition ApiHeaders.cs:69
const string BasicAuthenticationScheme
The JWT authentication header scheme.
Definition ApiHeaders.cs:49
const string TextEventStreamMime
Added to MediaTypeNames.Application in netstandard2.1. Can't use because of lack of ....
Definition ApiHeaders.cs:64
const string ApiVersionHeader
The ApiVersion header key.
Definition ApiHeaders.cs:29
const string ApplicationJsonMime
Added to MediaTypeNames.Application in netstandard2.1. Can't use because of lack of ....
Definition ApiHeaders.cs:59
const string BearerAuthenticationScheme
The JWT authentication header scheme.
Definition ApiHeaders.cs:44
static readonly AssemblyName AssemblyName
The current System.Reflection.AssemblyName.
Definition ApiHeaders.cs:74
const string OAuthProviderHeader
The OAuthProvider header key.
Definition ApiHeaders.cs:39
string? Password
The client's password.
Represents a JWT returned by the API.
JsonWebToken ParseJwt()
Parses the Bearer as a JsonWebToken.
HeaderErrorTypes
Types of individual ApiHeaders errors.

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.

Here is the call graph for this function:

◆ ApiHeaders() [5/5]

Tgstation.Server.Api.ApiHeaders.ApiHeaders ( ProductHeaderValue  userAgent,
TokenResponse token,
string?  username,
string?  password 
)
private

Initializes a new instance of the ApiHeaders class.

Parameters
userAgentThe value of UserAgent.
tokenThe value of Token.
usernameThe value of Username.
passwordThe value of Password.

Definition at line 349 of file ApiHeaders.cs.

350 {
351 RawUserAgent = userAgent?.ToString();
352 Token = token;
353 Username = username;
354 Password = password;
356 }

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.

Member Function Documentation

◆ CheckCompatibility()

static bool Tgstation.Server.Api.ApiHeaders.CheckCompatibility ( Version  otherVersion)
static

Checks if a given otherVersion is compatible with our own.

Parameters
otherVersionThe Version to test.
Returns
true if the given version is compatible with the API. false otherwise.

◆ Compatible()

bool Tgstation.Server.Api.ApiHeaders.Compatible ( Version alternateApiVersion = null)

Checks if the ApiVersion is compatible with Version.

Parameters
alternateApiVersionThe System.Version that can alternatively be used as the ApiVersion.
Returns
true if the API is compatible, false otherwise.

◆ CreateApiVersionHeader()

string Tgstation.Server.Api.ApiHeaders.CreateApiVersionHeader ( )
private

Create the stringified for of the ApiVersionHeader.

Returns
A string representing the ApiVersion.

Referenced by Tgstation.Server.Api.ApiHeaders.SetHubConnectionHeaders(), and Tgstation.Server.Api.ApiHeaders.SetRequestHeaders().

Here is the caller graph for this function:

◆ SetHubConnectionHeaders()

void Tgstation.Server.Api.ApiHeaders.SetHubConnectionHeaders ( IDictionary< string, string >  headers)

Adds the headers necessary for a SignalR hub connection.

Parameters
headersThe headers IDictionary<TKey, TValue> to write to.

Definition at line 402 of file ApiHeaders.cs.

403 {
404 if (headers == null)
405 throw new ArgumentNullException(nameof(headers));
406
407 headers.Add(HeaderNames.UserAgent, RawUserAgent ?? throw new InvalidOperationException("Missing UserAgent!"));
408 headers.Add(HeaderNames.Accept, ApplicationJsonMime);
410 }
string CreateApiVersionHeader()
Create the stringified for of the ApiVersionHeader.

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 >().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRequestHeaders()

void Tgstation.Server.Api.ApiHeaders.SetRequestHeaders ( HttpRequestHeaders  headers,
long?  instanceId = null 
)

Set HttpRequestHeaders using the ApiHeaders. This initially clears headers .

Parameters
headersThe HttpRequestHeaders to set.
instanceIdThe instance EntityId.Id for the request.

Definition at line 370 of file ApiHeaders.cs.

371 {
372 if (headers == null)
373 throw new ArgumentNullException(nameof(headers));
374 if (instanceId.HasValue && InstanceId.HasValue && instanceId != InstanceId)
375 throw new InvalidOperationException("Specified different instance IDs in constructor and SetRequestHeaders!");
376
377 headers.Clear();
378 headers.Accept.Add(new MediaTypeWithQualityHeaderValue(ApplicationJsonMime));
379 headers.UserAgent.Add(new ProductInfoHeaderValue(UserAgent));
381 if (OAuthProvider.HasValue)
382 {
383 headers.Authorization = new AuthenticationHeaderValue(OAuthAuthenticationScheme, OAuthCode!);
384 headers.Add(OAuthProviderHeader, OAuthProvider.ToString());
385 }
386 else if (!IsTokenAuthentication)
387 headers.Authorization = new AuthenticationHeaderValue(
389 Convert.ToBase64String(Encoding.UTF8.GetBytes($"{Username}:{Password}")));
390 else
391 headers.Authorization = new AuthenticationHeaderValue(BearerAuthenticationScheme, Token!.Bearer);
392
393 instanceId ??= InstanceId;
394 if (instanceId.HasValue)
395 headers.Add(InstanceIdHeader, instanceId.Value.ToString(CultureInfo.InvariantCulture));
396 }
ProductHeaderValue? UserAgent
The client's user agent as a ProductHeaderValue if valid.
Definition ApiHeaders.cs:89
bool IsTokenAuthentication
If the header uses OAuth or TGS JWT authentication.

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 >().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ApiVersionHeader

const string Tgstation.Server.Api.ApiHeaders.ApiVersionHeader = "Api"
static

◆ ApplicationJsonMime

const string Tgstation.Server.Api.ApiHeaders.ApplicationJsonMime = "application/json"
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().

◆ AssemblyName

readonly AssemblyName Tgstation.Server.Api.ApiHeaders.AssemblyName = Assembly.GetExecutingAssembly().GetName()
staticprivate

The current System.Reflection.AssemblyName.

Definition at line 74 of file ApiHeaders.cs.

Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders().

◆ BasicAuthenticationScheme

const string Tgstation.Server.Api.ApiHeaders.BasicAuthenticationScheme = "Basic"
static

◆ BearerAuthenticationScheme

const string Tgstation.Server.Api.ApiHeaders.BearerAuthenticationScheme = "Bearer"
static

◆ ColonSeparator

readonly char [] Tgstation.Server.Api.ApiHeaders.ColonSeparator = [':']
staticprivate

A char Array containing the ':' char.

Definition at line 79 of file ApiHeaders.cs.

Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders().

◆ InstanceIdHeader

const string Tgstation.Server.Api.ApiHeaders.InstanceIdHeader = "Instance"
static

◆ OAuthAuthenticationScheme

const string Tgstation.Server.Api.ApiHeaders.OAuthAuthenticationScheme = "OAuth"
static

◆ OAuthProviderHeader

const string Tgstation.Server.Api.ApiHeaders.OAuthProviderHeader = "OAuthProvider"
static

◆ TextEventStreamMime

const string Tgstation.Server.Api.ApiHeaders.TextEventStreamMime = "text/event-stream"
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().

◆ Version

readonly Version Tgstation.Server.Api.ApiHeaders.Version = Version.Parse(ApiVersionAttribute.Instance.RawApiVersion)
static

Property Documentation

◆ ApiVersion

Version Tgstation.Server.Api.ApiHeaders.ApiVersion
get

◆ InstanceId

long? Tgstation.Server.Api.ApiHeaders.InstanceId
getset

◆ IsTokenAuthentication

bool Tgstation.Server.Api.ApiHeaders.IsTokenAuthentication
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().

◆ OAuthCode

string? Tgstation.Server.Api.ApiHeaders.OAuthCode
get

◆ OAuthProvider

OAuthProvider? Tgstation.Server.Api.ApiHeaders.OAuthProvider
get

The Models.OAuthProvider the Token is for, if any.

Definition at line 124 of file ApiHeaders.cs.

124{ get; }

◆ Password

string? Tgstation.Server.Api.ApiHeaders.Password
get

The client's password.

Definition at line 114 of file ApiHeaders.cs.

114{ get; }

Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), and Tgstation.Server.Api.ApiHeaders.ApiHeaders().

◆ RawUserAgent

string? Tgstation.Server.Api.ApiHeaders.RawUserAgent
get

◆ Token

TokenResponse? Tgstation.Server.Api.ApiHeaders.Token
get

◆ UserAgent

ProductHeaderValue? Tgstation.Server.Api.ApiHeaders.UserAgent
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().

◆ Username

string? Tgstation.Server.Api.ApiHeaders.Username
get

The client's username.

Definition at line 109 of file ApiHeaders.cs.

109{ get; }

Referenced by Tgstation.Server.Api.ApiHeaders.ApiHeaders(), and Tgstation.Server.Api.ApiHeaders.ApiHeaders().


The documentation for this class was generated from the following file: