tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
SecurityConfiguration.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3
4using Swashbuckle.AspNetCore.SwaggerGen;
5
7
9{
13 public sealed class SecurityConfiguration
14 {
18 public const string Section = "Security";
19
24
28 const uint DefaultOAuthTokenExpiryMinutes = 60 * 24; // 1 day
29
34
39
43 public uint TokenExpiryMinutes { get; set; } = DefaultTokenExpiryMinutes;
44
49
54
59
63 public string? CustomTokenSigningKeyBase64 { get; set; }
64
68 public IDictionary<OAuthProvider, OAuthConfiguration>? OAuth
69 {
70 get => oAuth;
71 set
72 {
73 // Workaround for https://github.com/dotnet/runtime/issues/89547
74 var publicProperties = typeof(OAuthConfiguration)
75 .GetProperties()
76 .Where(property => property.CanWrite && property.SetMethod!.IsPublic)
77 .ToList();
78 oAuth = value
79 ?.Where(
80 kvp => !publicProperties.All(
81 prop => prop.GetValue(kvp.Value) == prop.PropertyType.GetDefaultValue()))
82 .ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
83 }
84 }
85
89 IDictionary<OAuthProvider, OAuthConfiguration>? oAuth;
90 }
91}
Configuration options pertaining to user security.
uint TokenSigningKeyByteCount
Amount of bytes to use in the Microsoft.IdentityModel.Tokens.TokenValidationParameters....
string? CustomTokenSigningKeyBase64
A custom token signing key. Overrides TokenSigningKeyByteCount.
uint TokenClockSkewMinutes
Amount of minutes to skew the clock for Api.Models.Response.TokenResponse validation.
const string Section
The key for the Microsoft.Extensions.Configuration.IConfigurationSection the SecurityConfiguration re...
const uint DefaultTokenSigningKeyByteAmount
Default value of TokenSigningKeyByteCount.
uint OAuthTokenExpiryMinutes
Amount of minutes until Api.Models.Response.TokenResponses generated from OAuth logins expire.
const uint DefaultOAuthTokenExpiryMinutes
Default value of OAuthTokenExpiryMinutes.
const uint DefaultTokenClockSkewMinutes
Default value of TokenClockSkewMinutes.
IDictionary< OAuthProvider, OAuthConfiguration >? oAuth
Backing field for OAuth.
uint TokenExpiryMinutes
Amount of minutes until Api.Models.Response.TokenResponses generated from passwords expire.
const uint DefaultTokenExpiryMinutes
Default value of TokenExpiryMinutes.
IDictionary< OAuthProvider, OAuthConfiguration >? OAuth
OAuth provider settings.